mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Added an Unbreakable Gene
This commit is contained in:
parent
75891ca0b3
commit
8e63e69385
6 changed files with 136 additions and 7 deletions
41
Source/Genes/Damage/Gene_Unbreakable.cs
Normal file
41
Source/Genes/Damage/Gene_Unbreakable.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using LicentiaLabs;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue