mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Refactor breast CalculateLastBirth
This commit is contained in:
parent
034bf4d75a
commit
96109e7607
1 changed files with 10 additions and 19 deletions
|
@ -210,25 +210,16 @@ namespace RJW_Menstruation
|
|||
protected long CalculateLastBirth()
|
||||
{
|
||||
long youngestAge = (long)(BabyHalfAge * GenDate.TicksPerYear) * -2; // So a newborn isn't considered a new mother, either
|
||||
if ((Pawn.relations?.ChildrenCount ?? 0) > 0)
|
||||
{
|
||||
foreach (Pawn child in Pawn.relations.Children)
|
||||
{
|
||||
bool isFetus = false;
|
||||
if (Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Any(preg => preg.babies.Contains(child)))
|
||||
{
|
||||
isFetus = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
Pawn.ageTracker.BirthAbsTicks - child.ageTracker.BirthAbsTicks > ageOfLastBirth &&
|
||||
!isFetus &&
|
||||
child.GetMother() == Pawn // Don't do Dad's boobs
|
||||
)
|
||||
youngestAge = Pawn.ageTracker.BirthAbsTicks - child.ageTracker.BirthAbsTicks;
|
||||
}
|
||||
}
|
||||
if ((Pawn.relations == null)) return youngestAge;
|
||||
|
||||
bool hasChild = Pawn.relations.Children.
|
||||
Where(child => !Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Any(preg => preg.babies.Contains(child))). // no fetuses
|
||||
Where(child => child.GetMother() == Pawn). // not Dad
|
||||
TryMinBy(child => child.ageTracker.AgeBiologicalTicks, out Pawn youngest);
|
||||
|
||||
if (hasChild) youngestAge = Pawn.ageTracker.AgeBiologicalTicks - youngest.ageTracker.AgeBiologicalTicks;
|
||||
|
||||
return youngestAge;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue