Status component that grants a player passive health regeneration. It sets title and icon, applies an additive HealthRegen modifier based on the status level, and provides description and upgrade text showing the regen amount.
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
[Status(7, 0, 1f, 0, false )]
public class HealthRegenStatus : Status
{
public HealthRegenStatus()
{
Title = "Self-Heal";
IconPath = "textures/icons/health_regen.png";
}
public override void Init(Player player)
{
base.Init(player);
}
public override void Refresh()
{
Description = GetDescription(Level);
Player.Modify(this, PlayerStat.HealthRegen, GetAmountForLevel(Level), ModifierType.Add);
}
public override string GetDescription(int newLevel)
{
return string.Format("Increase health regen by {0}/s", GetPrintAmountForLevel(Level));
}
public override string GetUpgradeDescription(int newLevel)
{
return newLevel > 1 ? string.Format("Increase health regen by {0}/s→{1}/s", GetPrintAmountForLevel(newLevel - 1), GetPrintAmountForLevel(newLevel)) : GetDescription(newLevel);
}
public float GetAmountForLevel(int level)
{
return 0.45f * level + (level == 7 ? 0.3f : 0f);
}
public string GetPrintAmountForLevel(int level)
{
return string.Format("{0:0.00}", GetAmountForLevel(level));
}
}