mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Add HediffComp_PeriodicOvulator
This commit is contained in:
parent
b3ffe9afed
commit
f235c32af1
5 changed files with 138 additions and 3 deletions
Binary file not shown.
|
@ -31,6 +31,28 @@
|
|||
</value>
|
||||
</Operation>
|
||||
|
||||
<!--<Operation Class="PatchOperationAdd">
|
||||
<xpath>/Defs/rjw.HediffDef_PartBase[defName="DogVagina"]</xpath>
|
||||
<value>
|
||||
<comps>
|
||||
<li Class="RJW_Menstruation.CompProperties_PeriodicOvulator">
|
||||
<maxCumCapacity>8</maxCumCapacity>
|
||||
<baseImplantationChanceFactor>1.0</baseImplantationChanceFactor>
|
||||
<basefertilizationChanceFactor>1.0</basefertilizationChanceFactor>
|
||||
<follicularIntervalDays>14</follicularIntervalDays>
|
||||
<lutealIntervalDays>36</lutealIntervalDays>
|
||||
<bleedingIntervalDays>8</bleedingIntervalDays>
|
||||
<recoveryIntervalDays>15</recoveryIntervalDays>
|
||||
<eggLifespanDays>4</eggLifespanDays>
|
||||
<wombTex>Womb/Womb</wombTex>
|
||||
<vagTex>Genitals/Vagina</vagTex>
|
||||
<estrusDaysBeforeOvulation>9</estrusDaysBeforeOvulation>
|
||||
<cycleIntervalDays>180~360</cycleIntervalDays>
|
||||
</li>
|
||||
</comps>
|
||||
</value>
|
||||
</Operation>-->
|
||||
|
||||
<Operation Class="PatchOperationAdd">
|
||||
<xpath>/Defs/rjw.HediffDef_PartBase[defName="CatVagina"]</xpath>
|
||||
<value>
|
||||
|
|
|
@ -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<Cum>();
|
||||
if (eggs == null) eggs = new List<Egg>();
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,6 +68,7 @@
|
|||
<Compile Include="DrugOutcomeDoers.cs" />
|
||||
<Compile Include="EstrusPartKindUsageRule.cs" />
|
||||
<Compile Include="HediffComps\HediffComp_InducedOvulator.cs" />
|
||||
<Compile Include="HediffComps\HediffComp_PeriodicOvulator.cs" />
|
||||
<Compile Include="HediffComps\MenstruationUtility.cs" />
|
||||
<Compile Include="Hediff_Estrus.cs" />
|
||||
<Compile Include="IngestionOutcomeDoers.cs" />
|
||||
|
|
Loading…
Reference in a new issue