Catch pawns that are pregnant but not with BasePregnancy (e.g. vanilla animal pregnancy)

This commit is contained in:
lutepickle 2022-08-17 06:37:30 -07:00
parent 177f941d93
commit d98a102d44
3 changed files with 8 additions and 3 deletions

View File

@ -306,6 +306,8 @@ namespace RJW_Menstruation
else
newNippleProgress = 0f;
if (newNippleProgress < 0) newNippleProgress = 0;
if (newNippleProgress == nippleProgress) return; // Nothing to change
else if (newNippleProgress > nippleProgress)
{

View File

@ -57,8 +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;
Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.loadID);
if (newestPregnancy == null) return;
IEnumerable<Hediff_BasePregnancy> pregnancies = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>();
if (!pregnancies.Any()) return;
Hediff_BasePregnancy newestPregnancy = pregnancies.MaxBy(hediff => hediff.loadID);
if (pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
else __state.Pregnancy = newestPregnancy;

View File

@ -138,7 +138,9 @@ namespace RJW_Menstruation
public static float GetFarthestPregnancyProgress(this Pawn pawn)
{
return pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.GestationProgress)?.GestationProgress ?? -1;
IEnumerable<Hediff_BasePregnancy> pregnancies = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>();
if (!pregnancies.Any()) return -1;
else return pregnancies.MaxBy(hediff => hediff.GestationProgress)?.GestationProgress ?? -1;
}
public static float GetPregnancyProgress(this HediffComp_Menstruation comp)