Compare commits

...

2 commits

Author SHA1 Message Date
lutepickle
96109e7607 Refactor breast CalculateLastBirth 2022-10-05 08:53:24 -07:00
lutepickle
034bf4d75a Keep the breasts full size for a while after a birth again 2022-10-05 07:49:01 -07:00
3 changed files with 16 additions and 19 deletions

Binary file not shown.

View file

@ -210,25 +210,16 @@ namespace RJW_Menstruation
protected long CalculateLastBirth() protected long CalculateLastBirth()
{ {
long youngestAge = (long)(BabyHalfAge * GenDate.TicksPerYear) * -2; // So a newborn isn't considered a new mother, either long youngestAge = (long)(BabyHalfAge * GenDate.TicksPerYear) * -2; // So a newborn isn't considered a new mother, either
if ((Pawn.relations?.ChildrenCount ?? 0) > 0)
{ if ((Pawn.relations == null)) return youngestAge;
foreach (Pawn child in Pawn.relations.Children)
{ bool hasChild = Pawn.relations.Children.
bool isFetus = false; Where(child => !Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Any(preg => preg.babies.Contains(child))). // no fetuses
if (Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Any(preg => preg.babies.Contains(child))) Where(child => child.GetMother() == Pawn). // not Dad
{ TryMinBy(child => child.ageTracker.AgeBiologicalTicks, out Pawn youngest);
isFetus = true;
break; if (hasChild) youngestAge = Pawn.ageTracker.AgeBiologicalTicks - youngest.ageTracker.AgeBiologicalTicks;
}
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;
}
}
return youngestAge; return youngestAge;
} }
@ -337,6 +328,11 @@ namespace RJW_Menstruation
} }
} }
public void GaveBirth()
{
ageOfLastBirth = Pawn.ageTracker.AgeBiologicalTicks;
}
public void AdjustNippleProgress(float amount) public void AdjustNippleProgress(float amount)
{ {
nippleProgress = Mathf.Clamp01(nippleProgress + amount); nippleProgress = Mathf.Clamp01(nippleProgress + amount);

View file

@ -72,6 +72,7 @@ namespace RJW_Menstruation
pawn.health.RemoveHediff(this); pawn.health.RemoveHediff(this);
HediffComp_Menstruation comp = this.GetMenstruationComp(); HediffComp_Menstruation comp = this.GetMenstruationComp();
if(comp != null) comp.Pregnancy = null; if(comp != null) comp.Pregnancy = null;
pawn.GetBreastComp()?.GaveBirth();
} }
public string GetBabyInfo() public string GetBabyInfo()