Rework infertile decision, let the last egg ovulated potentially implant. Guarantee full drug ovulation even if eggs aren't available.

This commit is contained in:
lutepickle 2023-03-16 12:24:47 -07:00
parent b81a07c172
commit 93855c5ee7

View file

@ -700,6 +700,16 @@ namespace RJW_Menstruation
return false;
}
public bool ShouldBeInfertile()
{
if (pregnancy != null) return false;
if (ImplantChance <= 0.0f) return true;
// Give the last egg ovulated a chance to implant
if (curStage == Stage.Luteal || curStage == Stage.Bleeding || curStage == Stage.Recover) return false;
if (EggHealth <= 0.0f) return true;
return false;
}
public override void CompPostTick(ref float severityAdjustment)
{
base.CompPostTick(ref severityAdjustment);
@ -727,7 +737,7 @@ namespace RJW_Menstruation
BeforeSimulator();
if (pregnancy == null && (ImplantChance <= 0.0f || EggHealth <= 0)) GoNextStage(Stage.Infertile);
if (ShouldBeInfertile()) GoNextStage(Stage.Infertile);
switch (curStage)
{
case Stage.Follicular:
@ -1165,7 +1175,7 @@ namespace RJW_Menstruation
if (currentIntervalHours < 0)
{
if (ImplantChance <= 0.0f || EggHealth <= 0) curStage = Stage.Infertile;
if (ShouldBeInfertile()) curStage = Stage.Infertile;
else if (!IsBreedingSeason()) curStage = Stage.Anestrus;
else curStage = RandomStage();
if (curStage == Stage.Follicular)
@ -1619,21 +1629,14 @@ namespace RJW_Menstruation
eggs.Add(new Egg((int)(EggLifespanHours / CycleFactor)));
++ovulated;
}
if(ovulated < ovarypower) ovulated = Math.Max(ovarypower, eggstack);
ovarypower -= ovulated;
eggstack = 0;
if (Configurations.Debug && ovulated != toOvulate)
Log.Message($"{Pawn} ovulated {ovulated}/{toOvulate} eggs ({ovulationChance.ToStringPercent()} chance)");
eggstack = 0;
if (EggHealth <= 0)
{
eggs.Clear();
ovarypower = 0;
GoNextStage(Stage.Infertile);
}
else
{
GoNextStage(Stage.Luteal);
}
GoNextStage(Stage.Luteal);
}
protected virtual void LutealAction()
@ -1720,7 +1723,7 @@ namespace RJW_Menstruation
{
if (curStageHrs >= currentIntervalHours)
{
if (ImplantChance <= 0.0f || EggHealth <= 0)
if (ShouldBeInfertile())
{
GoNextStage(Stage.Infertile);
}
@ -1742,7 +1745,7 @@ namespace RJW_Menstruation
protected virtual void InfertileAction()
{
if (ImplantChance <= 0 || EggHealth <= 0)
if (ShouldBeInfertile())
{
StayCurrentStageConst(Stage.Infertile);
}