29 lines
533 B
C#
29 lines
533 B
C#
using Godot;
|
|
using NodeWar.scripts;
|
|
using NodeWar.Scripts;
|
|
|
|
namespace NodeWar;
|
|
|
|
public partial class EnergyProducer : Node
|
|
{
|
|
[Export]
|
|
public float EnergyCapacity = 100;
|
|
|
|
[Export]
|
|
public float EnergyStored = 0;
|
|
|
|
[Export]
|
|
public float EnergyGenerationRate = 1.0f;
|
|
|
|
public override void _Ready()
|
|
{
|
|
EnergyManager.Instance.EnergyProducers.Add(this);
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
EnergyStored += EnergyGenerationRate * delta.ToFloat();
|
|
EnergyStored = Mathf.Clamp(EnergyStored, 0, EnergyCapacity);
|
|
}
|
|
}
|