Fix passive absorption not making absorbers dirty. Add absorbed amount to detailed description. Move passive absorption rate to XML

This commit is contained in:
lutepickle 2023-12-26 16:02:49 -08:00
parent 0dd3507010
commit 1a8189d9af
7 changed files with 41 additions and 10 deletions

Binary file not shown.

View File

@ -68,6 +68,7 @@
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.2</passiveAbsorptionPerHour>
<leakAfterDirty>false</leakAfterDirty> <leakAfterDirty>false</leakAfterDirty>
<effectsAfterDirty>true</effectsAfterDirty> <effectsAfterDirty>true</effectsAfterDirty>
<minHourstoDirtyEffect>10</minHourstoDirtyEffect> <minHourstoDirtyEffect>10</minHourstoDirtyEffect>
@ -122,6 +123,7 @@
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.2</passiveAbsorptionPerHour>
<leakAfterDirty>false</leakAfterDirty> <leakAfterDirty>false</leakAfterDirty>
<effectsAfterDirty>true</effectsAfterDirty> <effectsAfterDirty>true</effectsAfterDirty>
<minHourstoDirtyEffect>8</minHourstoDirtyEffect> <minHourstoDirtyEffect>8</minHourstoDirtyEffect>
@ -204,6 +206,7 @@
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.04</passiveAbsorptionPerHour>
<leakAfterDirty>true</leakAfterDirty> <leakAfterDirty>true</leakAfterDirty>
<effectsAfterDirty>false</effectsAfterDirty> <effectsAfterDirty>false</effectsAfterDirty>
<dirtyDef>Absorber_Pad_Dirty</dirtyDef> <dirtyDef>Absorber_Pad_Dirty</dirtyDef>
@ -265,6 +268,7 @@
</apparel> </apparel>
<modExtensions> <modExtensions>
<li Class="RJW_Menstruation.AbsorberModExtension"> <li Class="RJW_Menstruation.AbsorberModExtension">
<passiveAbsorptionPerHour>0.04</passiveAbsorptionPerHour>
<leakAfterDirty>true</leakAfterDirty> <leakAfterDirty>true</leakAfterDirty>
<effectsAfterDirty>false</effectsAfterDirty> <effectsAfterDirty>false</effectsAfterDirty>
<dirtyDef>Absorber_Pad_Dirty</dirtyDef> <dirtyDef>Absorber_Pad_Dirty</dirtyDef>

View File

@ -37,7 +37,7 @@
<Dialog_WombInfo08></Dialog_WombInfo08> <Dialog_WombInfo08></Dialog_WombInfo08>
<Dialog_WombInfo09></Dialog_WombInfo09> <Dialog_WombInfo09></Dialog_WombInfo09>
<Dialog_FatherUnknown>Unknown</Dialog_FatherUnknown> <Dialog_FatherUnknown>Unknown</Dialog_FatherUnknown>
<Description_Absorbed>Absorbed</Description_Absorbed>
<Option1_Label_1>Enable womb icon</Option1_Label_1> <Option1_Label_1>Enable womb icon</Option1_Label_1>

View File

@ -367,7 +367,7 @@ namespace RJW_Menstruation
{ {
if (cums.NullOrEmpty()) yield return Translations.Info_noCum; if (cums.NullOrEmpty()) yield return Translations.Info_noCum;
else foreach (Cum cum in cums) else foreach (Cum cum in cums)
yield return string.Format("{0}: {1:0.##}ml", cum.notcum ? cum.notcumLabel : cum.pawn?.Label, cum.Volume); yield return string.Format("{0}: {1:0.##}ml", cum.notcum ? cum.notcumLabel : cum.pawn?.Label, cum.Volume);
} }
} }
public Color GetCumMixtureColor public Color GetCumMixtureColor
@ -1570,12 +1570,7 @@ namespace RJW_Menstruation
return amount; return amount;
} }
absorber.absorbedfluids += amount; absorber.absorbedfluids += amount;
if (absorber.absorbedfluids > absorbable && !Pawn.apparel.IsLocked(absorber)) absorber.CheckDirty();
{
absorber.def = absorber.DirtyDef;
//absorber.fluidColor = GetCumMixtureColor;
absorber.dirty = true;
}
return 0; return 0;
} }

View File

@ -1,6 +1,7 @@
using RimWorld; using RimWorld;
using rjw; using rjw;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Xml; using System.Xml;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@ -186,6 +187,7 @@ namespace RJW_Menstruation
} }
public class AbsorberModExtension : DefModExtension public class AbsorberModExtension : DefModExtension
{ {
public float passiveAbsorptionPerHour = 0.1f;
public bool leakAfterDirty = false; public bool leakAfterDirty = false;
public bool effectsAfterDirty = false; public bool effectsAfterDirty = false;
public ThingDef dirtyDef = null; public ThingDef dirtyDef = null;
@ -198,7 +200,7 @@ namespace RJW_Menstruation
public float absorbedfluids = 0; public float absorbedfluids = 0;
public bool dirty = false; public bool dirty = false;
public int wearTicks = 0; public int wearTicks = 0;
protected virtual float PassiveAbsorptionPerHour => 0.1f; public virtual float PassiveAbsorptionPerHour => def.GetModExtension<AbsorberModExtension>().passiveAbsorptionPerHour;
public virtual bool LeakAfterDirty => def.GetModExtension<AbsorberModExtension>().leakAfterDirty; public virtual bool LeakAfterDirty => def.GetModExtension<AbsorberModExtension>().leakAfterDirty;
public virtual bool EffectAfterDirty => def.GetModExtension<AbsorberModExtension>().effectsAfterDirty; public virtual bool EffectAfterDirty => def.GetModExtension<AbsorberModExtension>().effectsAfterDirty;
public virtual ThingDef DirtyDef => def.GetModExtension<AbsorberModExtension>().dirtyDef; public virtual ThingDef DirtyDef => def.GetModExtension<AbsorberModExtension>().dirtyDef;
@ -211,9 +213,20 @@ namespace RJW_Menstruation
public virtual void WearEffect(int tickInterval) public virtual void WearEffect(int tickInterval)
{ {
absorbedfluids += PassiveAbsorptionPerHour * tickInterval / GenDate.TicksPerHour; absorbedfluids += PassiveAbsorptionPerHour * tickInterval / GenDate.TicksPerHour;
CheckDirty();
if (dirty) wearTicks += tickInterval; if (dirty) wearTicks += tickInterval;
} }
public void CheckDirty()
{
if (absorbedfluids > this.GetStatValue(VariousDefOf.MaxAbsorbable) && (Wearer?.apparel.IsLocked(this) ?? false))
{
def = DirtyDef;
//absorber.fluidColor = GetCumMixtureColor;
dirty = true;
}
}
public override Color DrawColorTwo => fluidColor; public override Color DrawColorTwo => fluidColor;
public override void ExposeData() public override void ExposeData()
@ -231,11 +244,26 @@ namespace RJW_Menstruation
Scribe_Values.Look(ref fluidColor, "fluidColor", Color.white); Scribe_Values.Look(ref fluidColor, "fluidColor", Color.white);
} }
public override string DescriptionDetailed
{
get
{
StringBuilder text = new StringBuilder(base.DescriptionDetailed);
text.AppendLine();
text.Append(Translations.Description_Absorbed);
text.Append(": ");
text.Append(absorbedfluids.ToStringDecimalIfSmall());
text.Append("/");
text.Append(this.GetStatValue(VariousDefOf.MaxAbsorbable).ToStringDecimalIfSmall());
text.Append("ml");
return text.ToString();
}
}
} }
public class Absorber_Tampon : Absorber public class Absorber_Tampon : Absorber
{ {
protected override float PassiveAbsorptionPerHour => 0.5f;
public override void DirtyEffect(int tickInterval) public override void DirtyEffect(int tickInterval)
{ {

View File

@ -44,6 +44,7 @@ namespace RJW_Menstruation
public static readonly string Dialog_WombInfo08 = "Dialog_WombInfo08".Translate(); public static readonly string Dialog_WombInfo08 = "Dialog_WombInfo08".Translate();
public static readonly string Dialog_WombInfo09 = "Dialog_WombInfo09".Translate(); public static readonly string Dialog_WombInfo09 = "Dialog_WombInfo09".Translate();
public static readonly string Dialog_WombInfo10 = "Dialog_WombInfo10".Translate(); public static readonly string Dialog_WombInfo10 = "Dialog_WombInfo10".Translate();
public static readonly string Description_Absorbed = "Description_Absorbed".Translate();
public static readonly string Option1_Label_1 = "Option1_Label_1".Translate(); public static readonly string Option1_Label_1 = "Option1_Label_1".Translate();

View File

@ -5,6 +5,9 @@ Version 1.0.9.2
- Better handle wombs that are not in the genitals body part. - Better handle wombs that are not in the genitals body part.
- Handle errors more gracefully when starting a pregnancy. - Handle errors more gracefully when starting a pregnancy.
- Fix implanting multiple eggs in an animal when configured to use Biotech pregnancies. - Fix implanting multiple eggs in an animal when configured to use Biotech pregnancies.
- An equipped tampon or pad will now show how much fluid it has absorbed in its tooltip.
- Passive absorption will now make a tampon or pad dirty after enough time, even if no fluid was added.
- It will take a cloth tampon about 2 days to become dirty passively. A cloth pad will take about 10 days.
- Egglaying races no longer have a menstrual cycle, regardless of vagina type. - Egglaying races no longer have a menstrual cycle, regardless of vagina type.
- Pawns with the egglaying genes from Alpha Genes, VE Saurids, or Phytokin no longer have a menstrual cycle. - Pawns with the egglaying genes from Alpha Genes, VE Saurids, or Phytokin no longer have a menstrual cycle.
- The womb status button will now appear in a pawn's health tab when using Compact Hediffs, with thanks to Fern. - The womb status button will now appear in a pawn's health tab when using Compact Hediffs, with thanks to Fern.