A GemEmerald class representing an emerald gem item. It defines item id, computes health regeneration per level, provides descriptions, and on run start applies a health regen modifier to the player.
using Sandbox;
public class GemEmerald : Gem
{
public const string ItemId = "gem_emerald";
private static float GetRegen( int level ) => 0.1f + level * 0.1f;
public static string Description( int level ) => $"+{GetRegen( level ):0.#} hp/s regen";
public static string UpgradeDescription( int level ) => $"+{GetRegen( level - 1 ):0.#}→+{GetRegen( level ):0.#} hp/s regen";
public override void OnRunStart()
{
Player.Modify( this, PlayerStat.HealthRegen, GetRegen( Level ), ModifierType.Add );
}
}