Merge branch 'main' into bugfixes

This commit is contained in:
amevarashi 2022-03-31 18:04:51 +05:00
commit 6e022789a2
3 changed files with 40 additions and 25 deletions

Binary file not shown.

View file

@ -52,6 +52,12 @@ namespace RJW_Menstruation
{ {
p.GetMenstruationComp().eggstack++; 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 #pragma warning restore IDE0051 // Remove unused private members

View file

@ -878,7 +878,8 @@ namespace RJW_Menstruation
if (follicularIntervalhours < 0) if (follicularIntervalhours < 0)
{ {
follicularIntervalhours = PeriodRandomizer(Props.folicularIntervalDays * 24, Props.deviationFactor); follicularIntervalhours = PeriodRandomizer(Props.folicularIntervalDays * 24, Props.deviationFactor);
curStage = RandomStage(); if (parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) curStage = Stage.Young;
else curStage = RandomStage();
} }
if (lutealIntervalhours < 0) lutealIntervalhours = PeriodRandomizer(Props.lutealIntervalDays * 24, Props.deviationFactor); if (lutealIntervalhours < 0) lutealIntervalhours = PeriodRandomizer(Props.lutealIntervalDays * 24, Props.deviationFactor);
@ -928,21 +929,13 @@ namespace RJW_Menstruation
loaded = true; loaded = true;
} }
protected void InitOvary() public int GetOvaryPowerByAge(Pawn pawn)
{
if (!Configurations.EnableMenopause)
{
RemoveClimactericEffect();
}
else if (ovarypower < -50000)
{
if (Props.ovaryPower > 10000000) ovarypower = Props.ovaryPower;
else
{ {
int power;
float avglittersize; float avglittersize;
try try
{ {
avglittersize = Rand.ByCurveAverage(parent.pawn.def.race.litterSizeCurve); avglittersize = Rand.ByCurveAverage(pawn.def.race.litterSizeCurve);
} }
catch (NullReferenceException) catch (NullReferenceException)
{ {
@ -956,13 +949,28 @@ namespace RJW_Menstruation
//New one. //New one.
float fertendage, lifenormalized; float fertendage, lifenormalized;
if (parent.pawn.IsAnimal()) fertendage = RJWPregnancySettings.fertility_endage_female_animal * 100f; if (pawn.IsAnimal()) fertendage = RJWPregnancySettings.fertility_endage_female_animal * 100f;
else fertendage = RJWPregnancySettings.fertility_endage_female_humanlike * 80f; else fertendage = RJWPregnancySettings.fertility_endage_female_humanlike * 80f;
lifenormalized = parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy; lifenormalized = pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy;
fertendage *= lifenormalized; fertendage *= lifenormalized;
ovarypower = (int)((fertendage - parent.pawn.ageTracker.AgeBiologicalYearsFloat) * (60f / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration) * avglittersize); power = (int)((fertendage - 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)); 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)
{
RemoveClimactericEffect();
}
else if (ovarypower < -50000)
{
if (Props.ovaryPower > 10000000) ovarypower = Props.ovaryPower;
else
{
ovarypower = GetOvaryPowerByAge(parent.pawn);
if (ovarypower < 1) if (ovarypower < 1)
{ {
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Menopause, parent.pawn); Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Menopause, parent.pawn);
@ -976,6 +984,7 @@ namespace RJW_Menstruation
hediff.Severity = 0.008f * (OvaryPowerThreshold - ovarypower); hediff.Severity = 0.008f * (OvaryPowerThreshold - ovarypower);
parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn)); parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn));
} }
} }
} }
} }