2022-11-26 20:32:32 +00:00
|
|
|
|
using LicentiaLabs;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace RJW_Genes
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This Gene adds Licentia-Labs Elasticised Hediff to a Pawn.
|
2022-11-26 20:56:44 +00:00
|
|
|
|
/// Note: I had a HarmonyPatch first, similar to skipping cumflation, but the Stretching Logic is called quite a lot and for both pawns actually.
|
2022-11-26 20:32:32 +00:00
|
|
|
|
/// Hence, I think choosing the Elasticiced Hediff was good as then everything is covered by "Licentia-Logic".
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Gene_Elasticity : Gene
|
|
|
|
|
{
|
2022-11-26 20:56:44 +00:00
|
|
|
|
private const int RESET_INTERVAL = 60000; // 60k should be 1 day
|
2022-11-26 20:32:32 +00:00
|
|
|
|
|
|
|
|
|
public override void PostAdd()
|
|
|
|
|
{
|
|
|
|
|
base.PostAdd();
|
2022-11-26 20:56:44 +00:00
|
|
|
|
// 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();
|
2023-01-06 15:23:13 +00:00
|
|
|
|
if (pawn.IsHashIntervalTick(RESET_INTERVAL))
|
|
|
|
|
ResetSeverity();
|
2022-11-26 20:32:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostRemove()
|
|
|
|
|
{
|
|
|
|
|
Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised);
|
|
|
|
|
if (candidate != null)
|
|
|
|
|
{
|
|
|
|
|
pawn.health.RemoveHediff(candidate);
|
|
|
|
|
}
|
|
|
|
|
base.PostRemove();
|
|
|
|
|
}
|
2022-11-26 20:56:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ResetSeverity(float severity = 0.7f)
|
|
|
|
|
{
|
|
|
|
|
Hediff candidate = pawn.health.hediffSet.GetFirstHediffOfDef(Licentia.HediffDefs.Elasticised);
|
|
|
|
|
if (candidate != null)
|
|
|
|
|
{
|
|
|
|
|
candidate.Severity = severity;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-26 20:32:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|