using Godot; using System; using Movementtests.interfaces; [GlobalClass] public partial class CHealth : Node, IHealthable { public event Action HealthChanged; public event Action HealthDepleted; [Export] public RHealth HealthResource; public float CurrentHealth { get; set; } public override void _Ready() { CurrentHealth = HealthResource.StartingHealth; } public void ReduceHealth(IDamageable source, float amount) { CurrentHealth -= amount; HealthChanged?.Invoke(this, CurrentHealth); if (CurrentHealth <= 0) { CurrentHealth = 0; HealthDepleted?.Invoke(this); } } }