public static HediffDef GetRandomPhotosensitiveHediffDef()
        {
            if (AnyPSHediffsExist.IsUndefined())
            {
                var query =
                    from entry in Settings.Store.HediffLightMods
                    where Classifier.ClassifyModifier(entry.Value[0], true) == VisionType.NVPhotosensitivity &&
                    entry.Value.AffectsEye &&
                    !ManuallyDisallowedHediffs.Contains(entry.Key.defName)
                    select entry.Value;
                PSHediffLightMods = query.ToList();

                if (PSHediffLightMods.Count == 0)
                {
                    AnyPSHediffsExist.MakeFalse();
                }
                else
                {
                    AnyPSHediffsExist.MakeTrue();
                }
            }

            if (AnyPSHediffsExist.IsFalse())
            {
                return(null);
            }
            return(PSHediffLightMods.RandomElementByWeight(lm => Math.Max(lm[0] * 20, 1)).ParentDef as HediffDef);
        }
Exemple #2
0
        public static void BuildGiveNVApparelLookup()
        {
            var nvApparel = Settings.Store.NVApparel;
            var list      = nvApparel.Where(appset => appset.Value.GrantsNV && appset.Key.IsApparel)
                            .SelectMany(appset => appset.Key.apparel.tags.Select(tag => new { tag, thingDef = appset.Key }))
                            .ToLookup(anonT => anonT.tag, anonT => anonT.thingDef) as Lookup <string, ThingDef>;

            if (list == null || list.Count == 0)
            {
                AnyGiveNVApparelExists.MakeFalse();
            }
            else
            {
                AnyGiveNVApparelExists.MakeTrue();
                GiveNVApparelDefsByTag = list;
            }
        }