diff --git a/Common/Assemblies/Rjw-Genes.dll b/Common/Assemblies/Rjw-Genes.dll index cb0815e..352f035 100644 Binary files a/Common/Assemblies/Rjw-Genes.dll and b/Common/Assemblies/Rjw-Genes.dll differ diff --git a/Source/Genes/Damage/Gene_Elasticity.cs b/Source/Genes/Damage/Gene_Elasticity.cs index b9d3033..603a18d 100644 --- a/Source/Genes/Damage/Gene_Elasticity.cs +++ b/Source/Genes/Damage/Gene_Elasticity.cs @@ -1,25 +1,36 @@ using LicentiaLabs; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Verse; namespace RJW_Genes { /// /// This Gene adds Licentia-Labs Elasticised Hediff to a Pawn. - /// Important: I had a HarmonyPatch first, similar to skipping cumflation, but the Stretching Logic is called quite a lot and for both pawns actually. + /// Note: I had a HarmonyPatch first, similar to skipping cumflation, but the Stretching Logic is called quite a lot and for both pawns actually. /// Hence, I think choosing the Elasticiced Hediff was good as then everything is covered by "Licentia-Logic". /// public class Gene_Elasticity : Gene { + + private int ticksToReset = RESET_INTERVAL; + private const int RESET_INTERVAL = 60000; // 60k should be 1 day public override void PostAdd() { base.PostAdd(); - this.pawn.health.AddHediff(Licentia.HediffDefs.Elasticised); + // Doing it like this will add the hediff with a severity of ~0.5, but it will decay. + // Hence we check with the Ticks to update. + this.pawn.health.AddHediff(Licentia.HediffDefs.Elasticised); + ResetSeverity(); + } + + public override void Tick() + { + base.Tick(); + --this.ticksToReset; + if (this.ticksToReset > 0) + return; + this.ticksToReset = RESET_INTERVAL; + ResetSeverity(); } public override void PostRemove() @@ -31,5 +42,15 @@ namespace RJW_Genes } base.PostRemove(); } + + + private void ResetSeverity(float severity = 0.7f) + { + Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised); + if (candidate != null) + { + candidate.Severity = severity; + } + } } }