This commit is contained in:
2026-06-17 09:45:25 +02:00
commit cca539dc32
40 changed files with 831 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using Godot;
namespace Slimepire.Gameplay;
[SceneTree]
public partial class BuildGhost : Node2D
{
public event Action<Vector2>? OnBuild;
private Tube? _tube;
public override void _Ready()
{
_tube = Instantiator.Instantiate<Tube>();
_tube.Position = Position / 2; // TODO WHYYY????
GetParent()?.AddChild(_tube);
}
public override void _Process(double delta)
{
GlobalPosition = GetGlobalMousePosition();
_tube?.SetTarget(GlobalPosition);
}
public override void _UnhandledInput(InputEvent @event)
{
using (@event)
{
if (@event is InputEventMouseButton { Pressed: false, ButtonIndex: MouseButton.Left })
{
OnBuild?.Invoke(GlobalPosition);
_tube?.QueueFree();
QueueFree();
GetViewport().SetInputAsHandled();
}
}
}
}