using System; using Astra; [ComponentId("docs.player-health")] public sealed class PlayerHealth : Behavior { public const int Capacity = 3; public int Current { get; private set; } public bool IsDead => Current == 0; public override void Awake() => Current = Capacity; public void TakeDamage(int amount) { Current = Math.Max(0, Current - Math.Clamp(amount, 0, Capacity)); } public void Heal(int amount) { Current = Math.Min(Capacity, Current + Math.Clamp(amount, 0, Capacity)); } }