From cca7676bc0079d5e38c3d066afda365b4d48f390 Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Wed, 13 Mar 2024 08:09:54 -0700 Subject: [PATCH] Have ovulation and implant chance cache be nullable --- .../HediffComps/HediffComp_Menstruation.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 f952929..3518b5c 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 @@ -123,8 +123,8 @@ namespace RJW_Menstruation protected string customwombtex = null; protected string customvagtex = null; protected bool estrusflag = false; - protected float ovulationChanceCache = -1.0f; // Dirtied every simulation - protected float implantationChanceCache = -1.0f; + protected float? ovulationChanceCache = null; // Dirtied every simulation + protected float? implantationChanceCache = null; protected int opcache = -1; protected float antisperm = 0.0f; // RJW pregnancy, or Biotech pregnancy/labor/laborpushing @@ -289,7 +289,7 @@ namespace RJW_Menstruation private bool calculatingOvulationChance = false; public bool CalculatingOvulationChance { get => calculatingOvulationChance; } - protected float CalculatedOvulationChance() + private float CalculatedOvulationChance() { float ovulationChance = 1.0f; if (EggHealth <= 0.0f) return 0.0f; @@ -315,7 +315,7 @@ namespace RJW_Menstruation return ovulationChance; } - protected float CalculatedImplantChance() + private float CalculatedImplantChance() { if (ModsConfig.BiotechActive && xxx.is_human(Pawn)) { @@ -336,8 +336,8 @@ namespace RJW_Menstruation { get { - if (ovulationChanceCache < 0.0f) ovulationChanceCache = CalculatedOvulationChance(); - return ovulationChanceCache; + if (ovulationChanceCache == null) ovulationChanceCache = CalculatedOvulationChance(); + return ovulationChanceCache.Value; } } @@ -346,8 +346,8 @@ namespace RJW_Menstruation { get { - if (implantationChanceCache < 0.0f) implantationChanceCache = CalculatedImplantChance(); - return implantationChanceCache; + if (implantationChanceCache == null) implantationChanceCache = CalculatedImplantChance(); + return implantationChanceCache.Value; } } @@ -1266,8 +1266,8 @@ namespace RJW_Menstruation protected virtual void BeforeSimulator() { - ovulationChanceCache = -1.0f; - implantationChanceCache = -1.0f; + ovulationChanceCache = null; + implantationChanceCache = null; CumOut(); }