fixed errors when runtimeGC removed pawns in cum list

added menstrual cramp
This commit is contained in:
moreoreganostodump 2021-02-03 17:20:10 +09:00
parent fd2ded7091
commit bbe60f1dab
6 changed files with 67 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>RJW Menstruation</identifier>
<version>1.0.0.3</version>
<version>1.0.0.4</version>
<dependencies>
</dependencies>
<incompatibleWith />

Binary file not shown.

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<HediffDef Name="Hediff_MenstrualCramp">
<hediffClass>HediffWithComps</hediffClass>
<defName>Hediff_MenstrualCramp</defName>
<label>In period</label>
<labelNoun>in period</labelNoun>
<description>in period</description>
<labelNounPretty>{1} in period</labelNounPretty>
<defaultLabelColor>(0.70,0.00,0.00)</defaultLabelColor>
<isBad>true</isBad>
<tendable>false</tendable>
<makesSickThought>true</makesSickThought>
<makesAlert>false</makesAlert>
<maxSeverity>1</maxSeverity>
<initialSeverity>0.1</initialSeverity>
<injuryProps>
<canMerge>true</canMerge>
</injuryProps>
<stages>
<li>
<label>unpleasant</label>
<painOffset>0.05</painOffset>
</li>
<li>
<minSeverity>0.2</minSeverity>
<label>annoy</label>
<painOffset>0.1</painOffset>
</li>
<li>
<minSeverity>0.4</minSeverity>
<label>ache</label>
<painOffset>0.2</painOffset>
</li>
<li>
<minSeverity>0.6</minSeverity>
<label>painful</label>
<painOffset>0.4</painOffset>
</li>
</stages>
<comps>
<li Class="HediffCompProperties_SeverityPerDay">
<severityPerDay>-0.1</severityPerDay>
</li>
</comps>
</HediffDef>
</Defs>

View file

@ -42,7 +42,7 @@ namespace RJW_Menstruation
{
if (DNAcache == null)
{
DNAcache = DefDatabase<DNADef>.GetNamedSilentFail(pawn.def.defName);
DNAcache = DefDatabase<DNADef>.GetNamedSilentFail(pawn?.def.defName ?? "Human");
if (DNAcache == null)
{
DNAcache = VariousDefOf.defaultDNA;
@ -121,6 +121,7 @@ namespace RJW_Menstruation
public void ExposeData()
{
Scribe_References.Look(ref pawn, "pawn", true);
Scribe_Defs.Look(ref DNAcache, "DNAcache");
Scribe_Values.Look(ref volume, "volume", volume, true);
Scribe_Values.Look(ref fertvolume, "fertvolume", fertvolume, true);
Scribe_Values.Look(ref notcumthickness, "notcumthickness", notcumthickness, true);

View file

@ -79,6 +79,7 @@ namespace RJW_Menstruation
private int lutealIntervalhours = -1;
private int bleedingIntervalhours = -1;
private int recoveryIntervalhours = -1;
private float crampPain= -1;
public float TotalCum
{
@ -165,7 +166,7 @@ namespace RJW_Menstruation
{
if (!cums.NullOrEmpty()) foreach (Cum cum in cums)
{
if (!cum.notcum) yield return String.Format(cum.pawn.Label + ": {0:0.##}ml", cum.volume);
if (!cum.notcum) yield return String.Format(cum.pawn?.Label + ": {0:0.##}ml", cum.volume);
else yield return String.Format(cum.notcumLabel + ": {0:0.##}ml", cum.volume);
}
else yield return Translations.Info_noCum;
@ -264,6 +265,7 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref lutealIntervalhours, "lutealIntervalhours", lutealIntervalhours, true);
Scribe_Values.Look(ref bleedingIntervalhours, "bleedingIntervalhours", bleedingIntervalhours, true);
Scribe_Values.Look(ref recoveryIntervalhours, "recoveryIntervalhours", recoveryIntervalhours, true);
Scribe_Values.Look(ref crampPain, "crampPain", crampPain, true);
}
@ -316,7 +318,6 @@ namespace RJW_Menstruation
}
public void CumIn(Pawn pawn, float injectedvolume, float fertility = 1.0f, ThingDef filthdef = null)
{
float volume = injectedvolume * CumInFactor;
@ -500,6 +501,7 @@ namespace RJW_Menstruation
if (lutealIntervalhours < 0) lutealIntervalhours = PeriodRandomizer(Props.lutealIntervalDays * 24, Props.deviationFactor);
if (bleedingIntervalhours < 0) bleedingIntervalhours = PeriodRandomizer(Props.bleedingIntervalDays * 24, Props.deviationFactor);
if (recoveryIntervalhours < 0) recoveryIntervalhours = PeriodRandomizer(Props.recoveryIntervalDays * 24, Props.deviationFactor);
if (crampPain < 0) crampPain = PainRandomizer();
if (cums == null) cums = new List<Cum>();
if (eggs == null) eggs = new List<Egg>();
if (parent.pawn.IsPregnant()) curStage = Stage.Pregnant;
@ -662,6 +664,9 @@ namespace RJW_Menstruation
else
{
bleedingIntervalhours = PeriodRandomizer(bleedingIntervalhours, Props.deviationFactor);
Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_MenstrualCramp, parent.pawn);
hediff.Severity = crampPain * Rand.Range(0.9f,1.1f);
parent.pawn.health.AddHediff(hediff,Genital_Helper.get_genitalsBPR(parent.pawn));
GoNextStage(Stage.Bleeding);
}
}
@ -787,6 +792,15 @@ namespace RJW_Menstruation
else return RJWPregnancySettings.interspecies_impregnation_modifier;
}
private float PainRandomizer()
{
float rand = Rand.Range(0.0f, 1.0f);
if (rand < 0.2f) return Rand.Range(0.1f, 0.2f);
else if (rand < 0.8f) return Rand.Range(0.2f, 0.4f);
else if (rand < 0.95f) return Rand.Range(0.4f, 0.6f);
else return Rand.Range(0.6f, 1.0f);
}
private Stage RandomStage()
{
int rand = Rand.Range(0,2);

View file

@ -20,6 +20,7 @@ namespace RJW_Menstruation
public static readonly ThingDef CumFilth = DefDatabase<ThingDef>.GetNamed("FilthCum");
public static readonly HediffDef RJW_IUD = DefDatabase<HediffDef>.GetNamed("RJW_IUD");
public static readonly HediffDef Hediff_MenstrualCramp = DefDatabase<HediffDef>.GetNamed("Hediff_MenstrualCramp");
}
}