rjw-genes/Source/Genes/Damage/Gene_Unbreakable.cs
2023-01-15 21:14:26 +01:00

40 lines
1.1 KiB
C#

using rjw;
using Verse;
namespace RJW_Genes
{
/// <summary>
/// This Gene regularly removes the broken hediff of a pawn.
/// Blocking / Removing thoughts are done in an XML Patch.
/// </summary>
public class Gene_Unbreakable : Gene
{
/// DevNote: I first tried to Harmony-Postfix the AfterSexUtility and never add it - but that failed?
private const int RESET_INTERVAL = 30000; // 30k should be 0.5 day
public override void PostAdd()
{
base.PostAdd();
RemoveBrokenHediff();
}
public override void Tick()
{
base.Tick();
if (pawn.IsHashIntervalTick(RESET_INTERVAL))
RemoveBrokenHediff();
}
private void RemoveBrokenHediff()
{
// Clean-Up of existing feeling brokens
var maybeBrokenHediff = pawn.health.hediffSet.GetFirstHediffOfDef(xxx.feelingBroken);
if (maybeBrokenHediff != null)
{
pawn.health.RemoveHediff(maybeBrokenHediff);
}
}
}
}