A gem item class that increases player max HP. It defines an ItemId, computes max HP by level, provides description strings, and on run start adds the HP modifier and sets the player's current health to the new max.
using Sandbox;
public class GemBloodstone : Gem
{
public const string ItemId = "gem_bloodstone";
private static float GetMaxHp( int level ) => 5 * level;
public static string Description( int level ) => $"+{GetMaxHp( level ).ToString( "0.#" )} max hp";
public static string UpgradeDescription( int level ) => $"+{GetMaxHp( level - 1 ).ToString( "0.#" )}→+{GetMaxHp( level ).ToString( "0.#" )} max hp";
public override void OnRunStart()
{
Player.Modify( this, PlayerStat.MaxHp, GetMaxHp( Level ), ModifierType.Add );
Player.Health = Player.Stats[PlayerStat.MaxHp];
}
}