Simplify Energy Stuff

This commit is contained in:
2026-06-24 14:39:02 +02:00
parent bfee5f4025
commit 390ac95638
14 changed files with 78 additions and 136 deletions

View File

@@ -0,0 +1,47 @@
using Godot;
namespace Slimepire.Gameplay.Components;
[GlobalClass]
public partial class EnergyStorage : Node
{
[Export]
public Label EnergyLabel = null!;
[Export]
public float MaxEnergy = 100;
public float Energy
{
get;
set
{
if (field + value > MaxEnergy)
{
field = MaxEnergy;
}
else
{
field += value;
}
field = value;
UpdateLabel();
}
}
public override void _Ready()
{
UpdateLabel();
}
public override void _ExitTree()
{
// EnergyManager.Instance.RemoveEnergyStorage(this);
}
private void UpdateLabel()
{
EnergyLabel.Text = $"{Energy:0}/{MaxEnergy}";
}
}