Null check in GetMenstruationComps, probably unnecessary. Also simplify HasMenstruationComp

This commit is contained in:
lutepickle 2022-07-16 07:30:34 -07:00
parent 5a64a081c2
commit 6383823e34
2 changed files with 2 additions and 9 deletions

View File

@ -19,6 +19,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"));
if (hedifflist == null) yield break;
foreach (Hediff hediff in hedifflist)
{
HediffComp_Menstruation result = hediff.TryGetComp<HediffComp_Menstruation>();

View File

@ -120,15 +120,7 @@ namespace RJW_Menstruation
public static bool HasMenstruationComp(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"));
HediffComp_Menstruation result;
if (hedifflist.NullOrEmpty()) return false;
foreach (Hediff h in hedifflist)
{
result = h.TryGetComp<HediffComp_Menstruation>();
if (result != null) return true;
}
return false;
return pawn.GetMenstruationComps().Any();
}
public static bool HasMenstruationComp(this Hediff hediff)