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

@@ -0,0 +1,42 @@
using Godot;
using NodeWar.Scripts;
namespace NodeWar.scripts.components;
public partial class SpawnerComponent : Node
{
[Export]
public PackedScene Spawnee;
[Export]
public Faction Faction;
[Export]
public float BuildSpeed = 28;
[Export]
public float BuildProgress = 0;
[Export]
public float MaxBuildProgress = 100;
public Vector2 Target { get; set; }
public override void _Ready() { }
public override void _Process(double delta)
{
BuildProgress += BuildSpeed * delta.ToFloat();
if (BuildProgress >= MaxBuildProgress)
{
BuildProgress = 0;
var pip = Spawnee.Instantiate<Pip>();
pip.Faction = Faction;
pip.Target = Target;
GetParent().AddChild(pip);
pip.GlobalPosition = GetParent<Node2D>().GlobalPosition;
}
}
}