diff --git a/1.4/Assemblies/RJW_Menstruation.dll b/1.4/Assemblies/RJW_Menstruation.dll index 9314e1a..4d7a51b 100644 Binary files a/1.4/Assemblies/RJW_Menstruation.dll and b/1.4/Assemblies/RJW_Menstruation.dll differ diff --git a/1.4/Patches/Hediffs_PrivateParts_Animal.xml b/1.4/Patches/Hediffs_PrivateParts_Animal.xml index 723eafc..fc60760 100644 --- a/1.4/Patches/Hediffs_PrivateParts_Animal.xml +++ b/1.4/Patches/Hediffs_PrivateParts_Animal.xml @@ -30,6 +30,28 @@ + + /Defs/rjw.HediffDef_PartBase[defName="CatVagina"] 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 a7f17c9..32219a6 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 @@ -639,7 +639,7 @@ namespace RJW_Menstruation curStage = Stage.Pregnant; } - CumOut(); + BeforeSimulator(); if (pregnancy == null && (Pawn.health.capacities.GetLevel(xxx.reproduction) <= 0 || EggHealth <= 0 || Pawn.SterileGenes())) curStage = Stage.Infertile; switch (curStage) @@ -1053,6 +1053,7 @@ namespace RJW_Menstruation else if (currentIntervalHours < curStageHrs) curStageHrs = currentIntervalHours; } if (crampPain < 0) crampPain = PainRandomizer(); + InitializeExtraValues(); if (cums == null) cums = new List(); if (eggs == null) eggs = new List(); @@ -1065,6 +1066,10 @@ namespace RJW_Menstruation initError = false; } + protected virtual void InitializeExtraValues() + { + } + protected virtual float RaceCyclesPerYear() { int breedingSeasons = 0; @@ -1130,8 +1135,12 @@ namespace RJW_Menstruation ovarypower = Math.Max(0, (int)(ovarypower * multiply)); } + protected virtual void BeforeSimulator() + { + CumOut(); + } - protected void AfterSimulator() + protected virtual void AfterSimulator() { if (EggHealth < 1f) { @@ -1796,7 +1805,7 @@ namespace RJW_Menstruation GoNextStage(Stage.Pregnant); } - public void CopyCycleProperties(HediffComp_Menstruation original) + public virtual void CopyCycleProperties(HediffComp_Menstruation original) { cycleSpeed = original.cycleSpeed; cycleVariability = original.cycleVariability; diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PeriodicOvulator.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PeriodicOvulator.cs new file mode 100644 index 0000000..0026e89 --- /dev/null +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_PeriodicOvulator.cs @@ -0,0 +1,103 @@ +using RimWorld; +using Verse; + +namespace RJW_Menstruation +{ + public class CompProperties_PeriodicOvulator : CompProperties_Menstruation + { + public FloatRange cycleIntervalDays; // From the start of one cycle to the start of the next + + public CompProperties_PeriodicOvulator() + { + compClass = typeof(HediffComp_PeriodicOvulator); + } + } + + public class HediffComp_PeriodicOvulator : HediffComp_Menstruation + { + public int hoursToNextCycle = -100000; + public int averageCycleIntervalHours = -1; + + public new CompProperties_PeriodicOvulator Props; + + protected override void InitializeExtraValues() + { + base.InitializeExtraValues(); + Props = (CompProperties_PeriodicOvulator)props; + if (averageCycleIntervalHours < 0) + { + averageCycleIntervalHours = (int)(24f * Props.cycleIntervalDays.RandomInRange / cycleSpeed); + if (hoursToNextCycle < -50000) + hoursToNextCycle = Rand.Range(0, averageCycleIntervalHours); + // Make the cutoff halfway into cycle, just to be sure there isn't a double-cycle the first time + if ((curStage == Stage.Follicular || curStage == Stage.Luteal || curStage == Stage.Bleeding) + && (averageCycleIntervalHours - hoursToNextCycle) / 2 >= 24 * (Props.follicularIntervalDays + Props.lutealIntervalDays) / cycleSpeed) + curStage = Stage.Anestrus; + } + } + + protected override float RaceCyclesPerYear() + { + // Don't bother trying to work seasonal breeding into the math + // Due to the enormous variation in possible cycle gaps, cheat and base it off the individual + return averageCycleIntervalHours * cycleSpeed / (24 * 360); // cancel out their cycleSpeed from initialization to get their "normal" speed + } + + protected override void BeforeSimulator() + { + base.BeforeSimulator(); + if (hoursToNextCycle > 0) hoursToNextCycle -= Configurations.CycleAcceleration; + } + + public override void CompExposeData() + { + base.CompExposeData(); + Scribe_Values.Look(ref hoursToNextCycle, "hoursToNextCycle", hoursToNextCycle, true); + Scribe_Values.Look(ref averageCycleIntervalHours, "averageCycleIntervalHours", averageCycleIntervalHours, true); + } + + protected override void BleedingAction() + { + if (curStageHrs >= currentIntervalHours) + { + Hediff hediff = Pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.Hediff_MenstrualCramp); + if (hediff != null) Pawn.health.RemoveHediff(hediff); + estrusflag = false; + GoNextStage(Stage.Anestrus); + return; + } + else + { + if (curStageHrs < currentIntervalHours / 4) for (int i = 0; i < Configurations.CycleAcceleration; i++) BleedOut(); + curStageHrs += Configurations.CycleAcceleration; + StayCurrentStage(); + } + } + + protected override void PregnantAction() + { + base.PregnantAction(); + if (curStage != Stage.Pregnant) + // Go halfway into the cycle + hoursToNextCycle = (int)(averageCycleIntervalHours * Rand.Range(-cycleVariability, cycleVariability)) / 2; + } + + protected override void AnestrusAction() + { + if (hoursToNextCycle <= 0) + { + hoursToNextCycle = (int)(averageCycleIntervalHours * Rand.Range(-cycleVariability, cycleVariability)); + if (IsBreedingSeason()) GoNextStage(Stage.Follicular); + return; + } + StayCurrentStage(); + } + + public override void CopyCycleProperties(HediffComp_Menstruation original) + { + base.CopyCycleProperties(original); + if (original is HediffComp_PeriodicOvulator comp) + averageCycleIntervalHours = comp.averageCycleIntervalHours; + } + } +} diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj index 1a8b5e3..5dd5cdc 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj @@ -68,6 +68,7 @@ +