using Godot; using System; using Movementtests.interfaces; [GlobalClass] public partial class CHealthbar : Node3D { private Sprite3D _currentHealth; private float _initialXScale; public override void _Ready() { Visible = false; _currentHealth = GetNode("Health"); _initialXScale = _currentHealth.Scale.X; } public void OnHealthChanged(HealthChangedRecord healthChanged) { if (healthChanged.MaxHealth == 0) return; Visible = true; var healthPercentage = healthChanged.CurrentHealth / healthChanged.MaxHealth; _currentHealth.Scale = new Vector3(_initialXScale * healthPercentage, _currentHealth.Scale.Y, _currentHealth.Scale.Z); } }