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); }
public static ThingDef GetGiveNVApparelDefByTag(List <string> tagsList) { if (AnyGiveNVApparelExists.IsUndefined()) { BuildGiveNVApparelLookup(); } if (AnyGiveNVApparelExists.IsFalse()) { return(null); } //because better stuff is normally at the end tagsList.Reverse(); foreach (string tag in tagsList) { if (GiveNVApparelDefsByTag[tag].Any()) { return(GiveNVApparelDefsByTag[tag].RandomElement()); } } return(null); }