using Godot; using Godot.Collections; namespace Newlon.Components.Zombies; public partial class DegradingSprite : Sprite2D { [Export] private Armor armor; [Export] private Array degradationStages; [Export] private Array thresholdPercentage; public override void _Ready() { armor.ArmorDamaged += OnZombieHPChanged; } private void OnZombieHPChanged(float hp) { float percent = hp / armor.MaxHP; for (int i = 0; i < degradationStages.Count; i++) { if (percent <= thresholdPercentage[i]) { Texture = degradationStages[i]; } else { break; } } } }