diff --git a/1.4/Assemblies/RJW_Menstruation.dll b/1.4/Assemblies/RJW_Menstruation.dll index e6dba69..d7f14ce 100644 Binary files a/1.4/Assemblies/RJW_Menstruation.dll and b/1.4/Assemblies/RJW_Menstruation.dll differ diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index 9e3851b..05a4dba 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -319,7 +319,6 @@ namespace RJW_Menstruation fertilityByAge.TransformValue(StatRequest.For(Pawn), ref factor); 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; try diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs index 4697141..6950552 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs @@ -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))] //public class GreedyConsume_Patch //{ diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs index 31a3688..5176542 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs @@ -374,26 +374,13 @@ namespace RJW_Menstruation } } - [HarmonyPatch(typeof(PawnCapacityWorker_Fertility), nameof(PawnCapacityWorker_Fertility.CalculateCapacityLevel))] - public static class PawnCapacityWorker_Fertility_Patch + [HarmonyPatch(typeof(PawnCapacityWorker_Fertility), "CalculateAgeImpact")] + 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)) - return 1.0f; - 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 Transpiler(IEnumerable 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; - } + __result = 1f; } } } diff --git a/changelogs.txt b/changelogs.txt index d7aaa6b..c4babf8 100644 --- a/changelogs.txt +++ b/changelogs.txt @@ -1,6 +1,7 @@ Version 1.0.9.2 - Updated Traditional Chinese translation by Hydrogen. - 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. - Handle errors more gracefully when starting a pregnancy. - Fix implanting multiple eggs in an animal when configured to use Biotech pregnancies.