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 RHealth { get; set; } public float CurrentHealth { get; set; } public override void _Ready() { CurrentHealth = RHealth.StartingHealth; } public void ReduceHealth(IDamageable source, DamageRecord damageRecord) { GD.Print(CurrentHealth); CurrentHealth -= damageRecord.Damage.DamageDealt; HealthChanged?.Invoke(this, CurrentHealth); if (CurrentHealth <= 0) { CurrentHealth = 0; HealthDepleted?.Invoke(this); } } }