mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
GetMenstruationComps is used in enough places it's worth a little caching
This commit is contained in:
parent
6383823e34
commit
ef115b03fd
5 changed files with 13 additions and 1 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -18,7 +18,7 @@ namespace RJW_Menstruation
|
|||
|
||||
public static IEnumerable<HediffComp_Menstruation> GetMenstruationComps(this Pawn pawn)
|
||||
{
|
||||
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("vagina"));
|
||||
List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll(h => VariousDefOf.AllVaginas.Contains(h.def));
|
||||
if (hedifflist == null) yield break;
|
||||
foreach (Hediff hediff in hedifflist)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace RJW_Menstruation
|
|||
|
||||
private static List<ThingDef> allraces = null;
|
||||
private static List<PawnKindDef> allkinds = null;
|
||||
private static HashSet<HediffDef> allvaginas = null;
|
||||
|
||||
public static List<ThingDef> AllRaces
|
||||
{
|
||||
|
@ -73,6 +74,17 @@ namespace RJW_Menstruation
|
|||
return allkinds;
|
||||
}
|
||||
}
|
||||
public static HashSet<HediffDef> AllVaginas
|
||||
{
|
||||
get
|
||||
{
|
||||
if (allvaginas != null) return allvaginas;
|
||||
|
||||
List<HediffDef> allVaginas = DefDatabase<HediffDef>.AllDefsListForReading;
|
||||
allvaginas = new HashSet<HediffDef>(allVaginas.FindAll(vagina => vagina.HasComp(typeof(HediffComp_Menstruation)) || vagina.HasComp(typeof(HediffComp_InducedOvulator))));
|
||||
return allvaginas;
|
||||
}
|
||||
}
|
||||
|
||||
// Defs from Milkable Colonists
|
||||
public static readonly HediffDef Hediff_Lactating_Drug = DefDatabase<HediffDef>.GetNamedSilentFail("Lactating_Drug");
|
||||
|
|
Loading…
Reference in a new issue