A game item class for an emerald gem that grants health regeneration. It defines an item id, computes regen based on gem level, provides description strings, and applies an additive health regen modifier to the player when the gem effect starts.
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 );
}
}