Implement random tick timing

This commit is contained in:
lutepickle 2022-06-05 08:32:52 -07:00
parent d039dca628
commit 56691171b4
3 changed files with 27 additions and 13 deletions

Binary file not shown.

View file

@ -969,20 +969,20 @@ namespace RJW_Menstruation
{ {
if (Configurations.EnableAnimalCycle) if (Configurations.EnableAnimalCycle)
{ {
HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), tickInterval, parent.pawn, false); HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false);
} }
} }
else else
{ {
if (pregnancy == null && parent.pawn.health.capacities.GetLevel(xxx.reproduction) <= 0) HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Young), 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), tickInterval, parent.pawn, false); else HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curStage), GetNextUpdate(), parent.pawn, false);
} }
} }
else else
{ {
if (cums == null) cums = new List<Cum>(); if (cums == null) cums = new List<Cum>();
curStage = Stage.None; 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"); //Log.Message(parent.pawn.Label + " - Initialized menstruation comp");
loaded = true; loaded = true;
@ -1738,7 +1738,7 @@ namespace RJW_Menstruation
curStage = Stage.Follicular; curStage = Stage.Follicular;
curStageHrs = 0; curStageHrs = 0;
if (follicularIntervalhours < 0) follicularIntervalhours = PeriodRandomizer(Props.folicularIntervalDays * 24, Props.deviationFactor); 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; break;
} }
action += delegate 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; curStageHrs = 0;
curStage = nextstage; 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; curStageHrs = hour;
curStage = nextstage; 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 //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 //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() protected void GoFollicularOrBleeding()

View file

@ -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 Version 1.0.6.5
- Handle climacteric induced ovulators a bit better. - Handle climacteric induced ovulators a bit better.
- Compatibility update for Sexperience 1.0.4.2 - Compatibility update for Sexperience 1.0.4.2