From dc33024d42903dcbbaae674e2a3f31c90268f840 Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Mon, 4 Dec 2023 11:44:45 -0800 Subject: [PATCH] Move the hash interval to the start of CompPostTick, since ShouldSimulate is getting heavy --- .../HediffComps/HediffComp_Menstruation.cs | 8 ++++---- .../RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs | 4 ---- 2 files changed, 4 insertions(+), 8 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 803ff77..9e3851b 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 @@ -739,6 +739,9 @@ namespace RJW_Menstruation // If an exception makes it out, RW will remove the hediff, so catch it here try { + if (Pawn.IsHashIntervalTick(recalculateTickInterval)) TickInterval = -1; // Every so often, force TickInterval to be recalculated in case the pawn's status changed. + if (!Pawn.IsHashIntervalTick(TickInterval)) return; + if (!ShouldSimulate()) return; // Initialize immediately if needed, but if there's an error, then don't spam it every tick @@ -747,10 +750,7 @@ namespace RJW_Menstruation Log.Warning($"{Pawn}'s womb is ticking, but was not initialized first"); Initialize(); } - - if (Pawn.IsHashIntervalTick(recalculateTickInterval)) TickInterval = -1; // Every so often, force TickInterval to be recalculated in case the pawn's status changed. - if (!Pawn.IsHashIntervalTick(TickInterval)) return; - + if (initError) Log.Warning($"Attempting to process {Pawn}'s womb uninitialized"); if (Pregnancy != null && curStage != Stage.Pregnant) diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs index 991f84a..ddebe41 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs @@ -37,10 +37,6 @@ namespace RJW_Menstruation if (t.Pawn == pawn && pawn.HasMenstruationComp()) opts.AddDistinct(MakeSelfMenu(pawn, t)); break; } - - - - } public static FloatMenuOption MakeSelfMenu(Pawn pawn, LocalTargetInfo target)