Do the age adjustment for ovulation in FertilityByGenderAge instead of trying to patch RJW's StatWorker
This commit is contained in:
parent
02a96b957a
commit
c254ce039a
Binary file not shown.
|
@ -319,7 +319,6 @@ namespace RJW_Menstruation
|
||||||
fertilityByAge.TransformValue(StatRequest.For(Pawn), ref factor);
|
fertilityByAge.TransformValue(StatRequest.For(Pawn), ref factor);
|
||||||
if (factor <= 0.0f) return 0.0f; // Too young or too old
|
if (factor <= 0.0f) return 0.0f; // Too young or too old
|
||||||
}
|
}
|
||||||
else part.TransformValue(StatRequest.For(Pawn), ref ovulationChance);
|
|
||||||
}
|
}
|
||||||
if (Pawn.HasQuirk(QuirkUtility.Quirks.Breeder)) ovulationChance *= 10.0f;
|
if (Pawn.HasQuirk(QuirkUtility.Quirks.Breeder)) ovulationChance *= 10.0f;
|
||||||
try
|
try
|
||||||
|
|
|
@ -219,6 +219,16 @@ namespace RJW_Menstruation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(StatPart_FertilityByGenderAge), "AgeFactor")]
|
||||||
|
public class AgeFactor_Patch
|
||||||
|
{
|
||||||
|
public static void Postfix(ref float __result, Pawn pawn)
|
||||||
|
{
|
||||||
|
if (pawn.GetMenstruationComps().Any(comp => comp.CalculatingOvulationChance))
|
||||||
|
__result = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//[HarmonyPatch(typeof(ChildcareUtility), nameof(ChildcareUtility.SuckleFromLactatingPawn))]
|
//[HarmonyPatch(typeof(ChildcareUtility), nameof(ChildcareUtility.SuckleFromLactatingPawn))]
|
||||||
//public class GreedyConsume_Patch
|
//public class GreedyConsume_Patch
|
||||||
//{
|
//{
|
||||||
|
|
|
@ -374,26 +374,13 @@ namespace RJW_Menstruation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(PawnCapacityWorker_Fertility), nameof(PawnCapacityWorker_Fertility.CalculateCapacityLevel))]
|
[HarmonyPatch(typeof(PawnCapacityWorker_Fertility), "CalculateAgeImpact")]
|
||||||
public static class PawnCapacityWorker_Fertility_Patch
|
public static class PawnCapacityWorker_Fertility_Age_Patch
|
||||||
{
|
{
|
||||||
private static float GetFertilityStatOrOne(Thing thing, StatDef stat, bool applyPostProcess, int cacheStaleAfterTicks)
|
public static void Postfix(ref float __result, Pawn pawn)
|
||||||
{
|
{
|
||||||
Pawn pawn = (Pawn)thing;
|
|
||||||
if (pawn.GetMenstruationComps().Any(comp => comp.CalculatingOvulationChance))
|
if (pawn.GetMenstruationComps().Any(comp => comp.CalculatingOvulationChance))
|
||||||
return 1.0f;
|
__result = 1f;
|
||||||
else return thing.GetStatValue(stat, applyPostProcess, cacheStaleAfterTicks);
|
|
||||||
}
|
|
||||||
private static readonly MethodInfo GetStatValue = AccessTools.Method(typeof(StatExtension), "GetStatValue", new System.Type[] { typeof(Thing), typeof(StatDef), typeof(bool), typeof(int) });
|
|
||||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
||||||
{
|
|
||||||
if (GetStatValue?.ReturnType != typeof(float)) throw new System.InvalidOperationException("GetStatValue not found");
|
|
||||||
foreach (CodeInstruction instruction in instructions)
|
|
||||||
{
|
|
||||||
if (instruction.Calls(GetStatValue))
|
|
||||||
yield return CodeInstruction.Call(typeof(PawnCapacityWorker_Fertility_Patch), nameof(GetFertilityStatOrOne));
|
|
||||||
else yield return instruction;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Version 1.0.9.2
|
Version 1.0.9.2
|
||||||
- Updated Traditional Chinese translation by Hydrogen.
|
- Updated Traditional Chinese translation by Hydrogen.
|
||||||
- Fixed the no bleeding gene having positive metabolic efficiency instead of negative.
|
- Fixed the no bleeding gene having positive metabolic efficiency instead of negative.
|
||||||
|
- Fixed ovulation chance not accounting for genes or precepts.
|
||||||
- Better handle wombs that are not in the genitals body part.
|
- Better handle wombs that are not in the genitals body part.
|
||||||
- Handle errors more gracefully when starting a pregnancy.
|
- Handle errors more gracefully when starting a pregnancy.
|
||||||
- Fix implanting multiple eggs in an animal when configured to use Biotech pregnancies.
|
- Fix implanting multiple eggs in an animal when configured to use Biotech pregnancies.
|
||||||
|
|
Loading…
Reference in New Issue