diff --git a/1.3/Assemblies/RJW_Menstruation.dll b/1.3/Assemblies/RJW_Menstruation.dll index 50512b5..f2c1607 100644 Binary files a/1.3/Assemblies/RJW_Menstruation.dll and b/1.3/Assemblies/RJW_Menstruation.dll differ diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs index 1a78f20..d49b8b4 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs @@ -1,5 +1,4 @@ -using HugsLib; -using RimWorld; +using RimWorld; using rjw; using System; using System.Collections.Generic; @@ -63,8 +62,6 @@ namespace RJW_Menstruation protected Color cachedColor; protected bool loaded = false; - public Action action; - protected float BabyHalfAge { get @@ -160,7 +157,30 @@ namespace RJW_Menstruation Scribe_Values.Look(ref baseNipple, "baseNipple", baseNipple, true); } - public override void CompPostTick(ref float severityAdjustment) { } + public override void CompPostTick(ref float severityAdjustment) + { + base.CompPostTick(ref severityAdjustment); + // If an exception makes it out, RW will remove the hediff, so catch it here + try + { + if ( + !parent.pawn.IsHashIntervalTick(tickInterval) || + !parent.pawn.Spawned || // TODO: Add option to simulate off-map pawns + parent.pawn.health.Dead + ) + { + return; + } + CalculateBreastSize(); + CalculateNipples(); + UpdateNipples(); + } + catch (Exception ex) + { + Log.Error($"Error processing breasts of {parent.pawn}: {ex}"); + } + + } public override void CompPostPostAdd(DamageInfo? dinfo) { @@ -175,8 +195,6 @@ namespace RJW_Menstruation Log.Warning($"Attempted to remove breast comp from wrong pawn ({parent.pawn})."); return; } - HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(action); - if (Configurations.Debug) Log.Message(parent.pawn.Label + " breast tick scheduler removed"); base.CompPostPostRemoved(); } @@ -208,7 +226,6 @@ namespace RJW_Menstruation public void Initialize() { Props = (CompProperties_Breast)props; - action = Update; if (maxBreastIncrement <= 0f) { @@ -232,15 +249,6 @@ namespace RJW_Menstruation } UpdateNipples(); loaded = true; - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, GetNextUpdate(), parent.pawn); - } - - public void Update() - { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(action, GetNextUpdate(), parent.pawn); - CalculateBreastSize(); - CalculateNipples(); - UpdateNipples(); } protected void CalculateBreastSize() @@ -344,15 +352,6 @@ namespace RJW_Menstruation cachedColor = Colors.CMYKLerp(parent.pawn.story?.SkinColor ?? Color.white, Props.BlackNippleColor, Alpha); } - protected int GetNextUpdate() - { - // Just like the menstruation code - int currentOffset = Find.TickManager.TicksGame % tickInterval; - int nextOffset = (parent.pawn.HashOffset() % tickInterval + tickInterval) % tickInterval; - - return ((nextOffset - currentOffset + tickInterval - 1) % tickInterval) + 1; - } - public void CopyBreastProperties(HediffComp_Breast original) { maxBreastIncrement = original.maxBreastIncrement; diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index a60d36f..35c609b 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -1,5 +1,4 @@ -using HugsLib; -using RimWorld; +using RimWorld; using rjw; using System; using System.Collections.Generic; @@ -70,7 +69,6 @@ namespace RJW_Menstruation public CompProperties_Menstruation Props; public Stage curStage = Stage.Follicular; public int curStageHrs = 0; - public Action actionref; public bool loaded = false; public int ovarypower = -100000; public int eggstack = 0; @@ -530,11 +528,68 @@ namespace RJW_Menstruation public override void CompPostTick(ref float severityAdjustment) { - //initializer moved to SpawnSetup - //if (!loaded) - //{ - // Initialize(); - //} + base.CompPostTick(ref severityAdjustment); + // If an exception makes it out, RW will remove the hediff, so catch it here + try + { + if ( + !parent.pawn.IsHashIntervalTick(tickInterval) || + !parent.pawn.Spawned || // TODO: Add option to simulate off-map pawns + parent.pawn.health.Dead || + (parent.pawn.IsAnimal() && !Configurations.EnableAnimalCycle) + ) + { + return; + } + + CumOut(); + switch (curStage) + { + case Stage.Follicular: + FollicularAction(false); + break; + case Stage.Ovulatory: + OvulatoryAction(); + break; + case Stage.Luteal: + LutealAction(false); + break; + case Stage.Bleeding: + BleedingAction(false); + break; + case Stage.Pregnant: + PregnantAction(); + break; + case Stage.Recover: + RecoverAction(); + break; + case Stage.None: + break; + case Stage.Young: + YoungAction(); + break; + case Stage.ClimactericFollicular: + FollicularAction(true); + break; + case Stage.ClimactericLuteal: + LutealAction(true); + break; + case Stage.ClimactericBleeding: + BleedingAction(true); + break; + case Stage.Anestrus: + AnestrusAction(); + break; + default: + GoNextStage(Stage.Follicular); + break; + } + if (pregnancy == null && parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) curStage = Stage.Young; + } + catch (Exception ex) + { + Log.Error($"Error processing womb of {parent.pawn}: {ex}"); + } } public override void CompPostPostRemoved() @@ -546,8 +601,6 @@ namespace RJW_Menstruation Log.Warning($"Attempted to remove menstruation comp from wrong pawn ({parent.pawn})."); return; } - HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(actionref); - if (Configurations.Debug) Log.Message(parent.pawn.Label + " menstruation tick scheduler removed"); pregnancy?.Miscarry(); base.CompPostPostRemoved(); } @@ -871,7 +924,6 @@ namespace RJW_Menstruation { if (cums == null) cums = new List(); curStage = Stage.None; - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); loaded = true; return; } @@ -912,18 +964,6 @@ namespace RJW_Menstruation } } - if (parent.pawn.IsAnimal()) - { - if (Configurations.EnableAnimalCycle) - { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); - } - } - else - { - if (pregnancy == null && parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Young), GetNextUpdate(), parent.pawn, false); - else HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); - } //Log.Message(parent.pawn.Label + " - Initialized menstruation comp"); loaded = true; } @@ -1576,108 +1616,12 @@ namespace RJW_Menstruation TaleRecorder.RecordTale(VariousDefOf.TaleCameInside, new object[] { cummer, parent.pawn }); } - private Action PeriodSimulator(Stage targetstage) - { - Action action = null; - switch (targetstage) - { - case Stage.Follicular: - action = delegate - { - FollicularAction(false); - }; - break; - case Stage.Ovulatory: - action = OvulatoryAction; - break; - case Stage.Luteal: - action = delegate - { - LutealAction(false); - }; - break; - case Stage.Bleeding: - action = delegate - { - BleedingAction(false); - }; - break; - case Stage.Pregnant: - action = PregnantAction; - break; - case Stage.Recover: - action = RecoverAction; - break; - case Stage.None: - action = delegate - { - StayCurrentStageConst(Stage.None); - }; - break; - case Stage.Young: - action = YoungAction; - break; - case Stage.ClimactericFollicular: - action = delegate - { - FollicularAction(true); - }; - break; - case Stage.ClimactericLuteal: - action = delegate - { - LutealAction(true); - }; - break; - case Stage.ClimactericBleeding: - action = delegate - { - BleedingAction(true); - }; - break; - case Stage.Anestrus: - action = AnestrusAction; - break; - default: - curStage = Stage.Follicular; - curStageHrs = 0; - if (currentIntervalHours < 0) currentIntervalHours = PeriodRandomizer(curStage); - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Follicular), GetNextUpdate(), parent.pawn, false); - break; - } - action += delegate - { - if (parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) curStage = Stage.Young; - //CumOut(); - AfterSimulator(); - }; - action = CumOut + action; - - actionref = action; - return actionref; - - - - - } - - protected int GetNextUpdate() - { - // Ticks past the hour. Will be equal except for game start or load - int currentOffset = Find.TickManager.TicksGame % tickInterval; - int nextOffset = (parent.pawn.HashOffset() % tickInterval + tickInterval) % tickInterval; // Messy, but HashOffset is negative a lot - - // The -1/+1 to ensure that equality works out to 1 hour and not 0 ticks - return ((nextOffset - currentOffset + tickInterval - 1) % tickInterval) + 1; - } - protected void GoNextStage(Stage nextstage, bool calculateHours = true) { curStageHrs = 0; float variabilityFactor = nextstage == Stage.ClimactericFollicular || nextstage == Stage.ClimactericLuteal || nextstage == Stage.ClimactericBleeding ? 6.0f : 1.0f; if (calculateHours) currentIntervalHours = PeriodRandomizer(nextstage, variabilityFactor); curStage = nextstage; - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(nextstage), GetNextUpdate(), parent.pawn, false); } protected virtual void GoOvulatoryStage(bool climacteric) @@ -1688,13 +1632,11 @@ namespace RJW_Menstruation //stage can be interrupted in other reasons protected void StayCurrentStage() { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); } //stage never changes protected void StayCurrentStageConst(Stage curstage) { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curstage), GetNextUpdate(), parent.pawn, false); } protected void GoFollicularOrBleeding() diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs index 2265058..f26ca4c 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs @@ -1,5 +1,4 @@ using HarmonyLib; -using HugsLib; using RimWorld; using System.Collections.Generic; using UnityEngine; @@ -16,14 +15,12 @@ namespace RJW_Menstruation //Log.Message("Initialize on spawnsetup"); foreach (HediffComp_Menstruation comp in __instance.GetMenstruationComps()) { - HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(comp.actionref); comp.Initialize(); } HediffComp_Breast bcomp = __instance.GetBreastComp(); if (bcomp != null) { - HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(bcomp.action); bcomp.Initialize(); } } diff --git a/1.3/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/1.3/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj index 198c10f..2cab59f 100644 --- a/1.3/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj +++ b/1.3/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj @@ -93,10 +93,6 @@ ..\..\..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll False - - ..\..\..\..\..\..\..\..\workshop\content\294100\818773962\v1.3\Assemblies\HugsLib.dll - False - ..\..\..\..\..\rjw\1.3\Assemblies\RJW.dll False diff --git a/About/About.xml b/About/About.xml index 273bef9..426bf26 100644 --- a/About/About.xml +++ b/About/About.xml @@ -13,12 +13,6 @@ steam://url/CommunityFilePage/2009463077 https://github.com/pardeike/HarmonyRimWorld/releases/latest -
  • - UnlimitedHugs.HugsLib - HugsLib - https://github.com/UnlimitedHugs/RimworldHugsLib/releases/latest - steam://url/CommunityFilePage/818773962 -
  • rim.job.world RimJobWorld @@ -26,7 +20,6 @@
  • -
  • UnlimitedHugs.HugsLib
  • brrainz.harmony
  • rim.job.world
  • Abraxas.RJW.RaceSupport