Refactor the impregnation patch postfix to use MaxByWithFallback, too

This commit is contained in:
lutepickle 2022-08-21 20:57:52 -07:00
parent e023938a41
commit 4fc1d6b4ab
1 changed files with 2 additions and 4 deletions

View File

@ -57,11 +57,9 @@ namespace RJW_Menstruation
if (__state == null || __state.Pregnancy != null) return;
// It was pregnant, but not anymore. This probably means the pregnancy was destroyed by e.g. a mech implant
Pawn pawn = props.partner;
IEnumerable<Hediff_BasePregnancy> pregnancies = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>();
if (!pregnancies.Any()) return;
Hediff_BasePregnancy newestPregnancy = pregnancies.MaxBy(hediff => hediff.loadID);
Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxByWithFallback(hediff => hediff.loadID);
if (pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
if (newestPregnancy == null || pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
else __state.Pregnancy = newestPregnancy;
}