This commit is contained in:
2026-05-14 13:17:23 +02:00
parent 37f4ea3b4e
commit 70bba45b8a
18 changed files with 293 additions and 71 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using Godot;
@@ -5,11 +6,25 @@ namespace NodeWar.scripts.components;
public partial class HealthComponent : ProgressBar
{
private float _health = 100;
[Export]
public Sprite2D Gfx { get; set; }
[Export]
public float Health { get; set; } = 100;
public float Health
{
get => _health;
set
{
if (value >= MaxHealth)
{
_health = MaxHealth;
}
_health = value;
}
}
[Export]
public float MaxHealth { get; set; } = 100;
@@ -55,6 +70,8 @@ public partial class HealthComponent : ProgressBar
public override void _Process(double delta)
{
Visible = Math.Abs(Health - MaxHealth) > 0.001f;
Value = Health;
}
}