New hooks: OnDecayTickHeal & OnDecayTickDamageSolved

I'm sorry if it isn't the good category to post Hooks suggestion but because OxidePatcher doesn't supports creating new hook inside a method (I mean it only allow to create hook at start of a method) so I can't create a PR and because I don't want to ping administrator on Discord each time I would like a new hook so I prefer to post it there hoping someone can add them.


Assembly-CSharp > Global > DecayEntity > DecayTick():
public virtual void DecayTick()
{
    if (this.decay == null)
    {
        return;
    }
    float single = UnityEngine.Time.time - this.lastDecayTick;
    if (single < ConVar.Decay.tick)
    {
        return;
    }
    this.lastDecayTick = UnityEngine.Time.time;
    if (!this.decay.ShouldDecay(this))
    {
        return;
    }
    float single1 = single * ConVar.Decay.scale;
    if (ConVar.Decay.upkeep)
    {
        this.upkeepTimer += single1;
        if (this.upkeepTimer > 0f)
        {
            BuildingPrivlidge buildingPrivilege = this.GetBuildingPrivilege();
            if (buildingPrivilege != null)
            {
                this.upkeepTimer -= buildingPrivilege.PurchaseUpkeepTime(this, Mathf.Max(this.upkeepTimer, 600f));
            }
        }
        if (this.upkeepTimer < 1f)
        {
            if (base.healthFraction < 1f && ConVar.Decay.upkeep_heal_scale > 0f && base.SecondsSinceAttacked > 600f)
            {
                if (Interface.CallHook("OnDecayTickHeal", this) != null)
                {
                    return;
                }
                float decayDuration = single / this.decay.GetDecayDuration(this) * ConVar.Decay.upkeep_heal_scale;
                this.Heal(this.MaxHealth() * decayDuration);
            }
            return;
        }
        this.upkeepTimer = 1f;
    }
    this.decayTimer += single1;
    if (this.decayTimer < this.decay.GetDecayDelay(this))
    {
        return;
    }
    using (TimeWarning timeWarning = TimeWarning.New("DecayTick", 0))
    {
        float upkeepInsideDecayScale = 1f;
        if (!ConVar.Decay.upkeep)
        {
            for (int i = 0; i < (int)this.decayPoints.Length; i++)
            {
                DecayPoint decayPoint = this.decayPoints[i];
                if (decayPoint.IsOccupied(this))
                {
                    upkeepInsideDecayScale -= decayPoint.protection;
                }
            }
        }
        else if (!this.IsOutside())
        {
            upkeepInsideDecayScale *= ConVar.Decay.upkeep_inside_decay_scale;
        }
        if (upkeepInsideDecayScale > 0f)
        {
            if (Interface.CallHook("OnDecayTickDamage", this) != null)
            {
                return;
            }
            float decayDuration1 = single1 / this.decay.GetDecayDuration(this) * this.MaxHealth();
            base.Hurt(decayDuration1 * upkeepInsideDecayScale * this.decayVariance, DamageType.Decay, null, true);
        }
    }
}​
 

The preferred category for hook requests is Rust.

The Oxide Patcher allows you to move a hook to anywhere in the method using injection index. You can also place multiple hooks in a method by clicking the clone button from the first hook. It works that way because the subsequent hooks need to know about the others to ensure they are injected in the correct spot.

Thank you for your answer! I'll try to move these hook and PR them 😊

Locked automatically