energy manager noch nicht fertig...
This commit is contained in:
32
src/Gameplay/Nodules/Components/EnergyProducer.cs
Normal file
32
src/Gameplay/Nodules/Components/EnergyProducer.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Godot;
|
||||
using Slimepire.Core;
|
||||
|
||||
namespace Slimepire.Gameplay.Nodules.Components;
|
||||
|
||||
public partial class EnergyProducer : Node
|
||||
{
|
||||
[Export]
|
||||
public float ProductionRate = 1;
|
||||
|
||||
private float _energy;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
EnergyManager.Instance.RegisterEnergyProducer(this);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_energy += ProductionRate * (float)delta;
|
||||
if (_energy > 1)
|
||||
{
|
||||
EnergyManager.Instance.TransferEnergy(_energy);
|
||||
_energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
EnergyManager.Instance.RemoveEnergyProducer(this);
|
||||
}
|
||||
}
|
||||
1
src/Gameplay/Nodules/Components/EnergyProducer.cs.uid
Normal file
1
src/Gameplay/Nodules/Components/EnergyProducer.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bku1vey63ew65
|
||||
6
src/Gameplay/Nodules/Components/EnergyProducer.tscn
Normal file
6
src/Gameplay/Nodules/Components/EnergyProducer.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://t0gdf172f65v"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bku1vey63ew65" path="res://src/Gameplay/Nodules/Components/EnergyProducer.cs" id="1_4q7h4"]
|
||||
|
||||
[node name="EnergyProducer" type="Node" unique_id=1184182162]
|
||||
script = ExtResource("1_4q7h4")
|
||||
28
src/Gameplay/Nodules/Components/EnergyStorage.cs
Normal file
28
src/Gameplay/Nodules/Components/EnergyStorage.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Godot;
|
||||
using Slimepire.Core;
|
||||
|
||||
namespace Slimepire.Gameplay.Nodules.Components;
|
||||
|
||||
public partial class EnergyStorage : Node
|
||||
{
|
||||
[Export]
|
||||
public float MaxEnergy = 100;
|
||||
|
||||
public float Energy { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
EnergyManager.Instance.RegisterEnergyStorage(this);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
EnergyManager.Instance.RemoveEnergyStorage(this);
|
||||
}
|
||||
|
||||
public float AcceptEnergy(float energy)
|
||||
{
|
||||
Energy += energy;
|
||||
return Energy;
|
||||
}
|
||||
}
|
||||
1
src/Gameplay/Nodules/Components/EnergyStorage.cs.uid
Normal file
1
src/Gameplay/Nodules/Components/EnergyStorage.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgkeo1wsicv13
|
||||
6
src/Gameplay/Nodules/Components/EnergyStorage.tscn
Normal file
6
src/Gameplay/Nodules/Components/EnergyStorage.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://by6iw05ovnhq8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dgkeo1wsicv13" path="res://src/Gameplay/Nodules/Components/EnergyStorage.cs" id="1_vetx7"]
|
||||
|
||||
[node name="EnergyStorage" type="Node" unique_id=1765924301]
|
||||
script = ExtResource("1_vetx7")
|
||||
Reference in New Issue
Block a user