a bit more stuff
This commit is contained in:
28
EnergyProducer.cs
Normal file
28
EnergyProducer.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user