Make AllVaginas less hardcoded

This commit is contained in:
lutepickle 2022-07-20 07:23:36 -07:00
parent 57998a3895
commit 1125930869
2 changed files with 16 additions and 2 deletions

Binary file not shown.

View file

@ -1,5 +1,6 @@
using RimWorld; using RimWorld;
using rjw; using rjw;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Verse; using Verse;
@ -81,9 +82,22 @@ namespace RJW_Menstruation
get get
{ {
if (allvaginas != null) return allvaginas; if (allvaginas != null) return allvaginas;
allvaginas = new HashSet<HediffDef>();
List<HediffDef> allHediffs = DefDatabase<HediffDef>.AllDefsListForReading;
foreach(HediffDef hediffDef in allHediffs)
{
if (hediffDef.comps.NullOrEmpty()) continue;
foreach (HediffCompProperties comp in hediffDef.comps)
{
if (comp.compClass == typeof(HediffComp_Menstruation) || comp.compClass.IsSubclassOf(typeof(HediffComp_Menstruation)))
{
allvaginas.Add(hediffDef);
break;
}
}
}
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; return allvaginas;
} }
} }