Add debug action to recalculate ovary power

This commit is contained in:
lutepickle 2022-03-19 16:32:17 -07:00
parent 38b16c75c3
commit 23b09b0fa9
3 changed files with 38 additions and 24 deletions

Binary file not shown.

View File

@ -52,6 +52,12 @@ namespace RJW_Menstruation
{
p.GetMenstruationComp().eggstack++;
}
[DebugAction("RJW Menstruation", "Recalculate pawn's ovary power", false, false, actionType = DebugActionType.ToolMapForPawns, allowedGameStates = AllowedGameStates.Playing)]
private static void RecalculateOvaryPower(Pawn p)
{
p.GetMenstruationComp().ovarypower = p.GetMenstruationComp().GetOvaryPowerByAge(p);
}
}
}
#pragma warning restore IDE0051 // Remove unused private members

View File

@ -914,6 +914,36 @@ namespace RJW_Menstruation
loaded = true;
}
public int GetOvaryPowerByAge(Pawn pawn)
{
int power;
float avglittersize;
try
{
avglittersize = Rand.ByCurveAverage(pawn.def.race.litterSizeCurve);
}
catch (NullReferenceException)
{
avglittersize = 1;
}
//Old one. Sex minimum age based.
//ovarypower = (int)(((Props.ovaryPower * Utility.RandGaussianLike(0.70f, 1.30f) * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy)
// - (Math.Max(0, ageYear - RJWSettings.sex_minimum_age * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy))
// * (60 / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration)) * avglittersize);
//New one.
float fertendage, lifenormalized;
if (pawn.IsAnimal()) fertendage = RJWPregnancySettings.fertility_endage_female_animal * 100f;
else fertendage = RJWPregnancySettings.fertility_endage_female_humanlike * 80f;
lifenormalized = pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy;
fertendage *= lifenormalized;
power = (int)((fertendage - pawn.ageTracker.AgeBiologicalYearsFloat) * (60f / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration) * avglittersize);
power = (int)Mathf.Max(0, Mathf.Min(Props.ovaryPower * Utility.RandGaussianLike(0.70f, 1.30f, 5) * lifenormalized, power));
return power;
}
protected void InitOvary()
{
if (!Configurations.EnableMenopause)
@ -925,30 +955,7 @@ namespace RJW_Menstruation
if (Props.ovaryPower > 10000000) ovarypower = Props.ovaryPower;
else
{
float avglittersize;
try
{
avglittersize = Rand.ByCurveAverage(parent.pawn.def.race.litterSizeCurve);
}
catch (NullReferenceException)
{
avglittersize = 1;
}
//Old one. Sex minimum age based.
//ovarypower = (int)(((Props.ovaryPower * Utility.RandGaussianLike(0.70f, 1.30f) * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy)
// - (Math.Max(0, ageYear - RJWSettings.sex_minimum_age * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy))
// * (60 / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration)) * avglittersize);
//New one.
float fertendage, lifenormalized;
if (parent.pawn.IsAnimal()) fertendage = RJWPregnancySettings.fertility_endage_female_animal * 100f;
else fertendage = RJWPregnancySettings.fertility_endage_female_humanlike * 80f;
lifenormalized = parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy;
fertendage *= lifenormalized;
ovarypower = (int)((fertendage - parent.pawn.ageTracker.AgeBiologicalYearsFloat) * (60f / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration) * avglittersize);
ovarypower = (int)Mathf.Max(0, Mathf.Min(Props.ovaryPower * Utility.RandGaussianLike(0.70f,1.30f,5) * lifenormalized,ovarypower));
ovarypower = GetOvaryPowerByAge(parent.pawn);
if (ovarypower < 1)
{
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Menopause, parent.pawn);
@ -962,6 +969,7 @@ namespace RJW_Menstruation
hediff.Severity = 0.008f * (OvaryPowerThreshold - ovarypower);
parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn));
}
}
}
}