diff --git a/1.3/Assemblies/RJW_Menstruation.dll b/1.3/Assemblies/RJW_Menstruation.dll index d8abcdd..01ffd39 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_Menstruation.cs b/1.3/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index 2ae40fa..26c2898 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 @@ -969,20 +969,20 @@ namespace RJW_Menstruation { if (Configurations.EnableAnimalCycle) { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false); + 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), tickInterval, parent.pawn, false); - else HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false); + 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); } } else { if (cums == null) cums = new List(); curStage = Stage.None; - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false); + HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); } //Log.Message(parent.pawn.Label + " - Initialized menstruation comp"); loaded = true; @@ -1738,7 +1738,7 @@ namespace RJW_Menstruation curStage = Stage.Follicular; curStageHrs = 0; if (follicularIntervalhours < 0) follicularIntervalhours = PeriodRandomizer(Props.folicularIntervalDays * 24, Props.deviationFactor); - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Follicular), tickInterval, parent.pawn, false); + HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Follicular), GetNextUpdate(), parent.pawn, false); break; } action += delegate @@ -1757,31 +1757,41 @@ namespace RJW_Menstruation } - protected void GoNextStage(Stage nextstage, float factor = 1.0f) + 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) { curStageHrs = 0; curStage = nextstage; - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(nextstage), (int)(tickInterval * factor), parent.pawn, false); + HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(nextstage), GetNextUpdate(), parent.pawn, false); } - protected void GoNextStageSetHour(Stage nextstage, int hour, float factor = 1.0f) + protected void GoNextStageSetHour(Stage nextstage, int hour) { curStageHrs = hour; curStage = nextstage; - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(nextstage), (int)(tickInterval * factor), parent.pawn, false); + HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(nextstage), GetNextUpdate(), parent.pawn, false); } //stage can be interrupted in other reasons - protected void StayCurrentStage(float factor = 1.0f) + protected void StayCurrentStage() { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), (int)(tickInterval * factor), parent.pawn, false); + HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false); } //stage never changes - protected void StayCurrentStageConst(Stage curstage, float factor = 1.0f) + protected void StayCurrentStageConst(Stage curstage) { - HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curstage), (int)(tickInterval * factor), parent.pawn, false); + HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curstage), GetNextUpdate(), parent.pawn, false); } protected void GoFollicularOrBleeding() diff --git a/changelogs.txt b/changelogs.txt index 2663dbc..a9bac38 100644 --- a/changelogs.txt +++ b/changelogs.txt @@ -1,3 +1,7 @@ +Version 1.0.6.6 + - The menstruation cycle used to start ticking exactly one game hour after loading the save. Now the hour timing is consistent across a save/load. + - Every womb will tick at a different (but consistent) time after the hour per pawn. + Version 1.0.6.5 - Handle climacteric induced ovulators a bit better. - Compatibility update for Sexperience 1.0.4.2