decisions decisions decisions

This commit is contained in:
2026-06-22 23:15:09 +02:00
parent f2fd147c19
commit 9a6566a178
14 changed files with 174 additions and 156 deletions

View File

@@ -0,0 +1,57 @@
using Godot;
using Slimepire.Core;
namespace Slimepire.Gameplay.Nodules.Components;
[SceneTree]
public partial class GrowArea : Area2D
{
private bool _mouseInsideClickArea;
private bool _clickedInside;
public override void _Ready()
{
MouseEntered += ClickAreaOnMouseEntered;
MouseExited += ClickAreaOnMouseExited;
}
private void ClickAreaOnMouseEntered()
{
_mouseInsideClickArea = true;
}
private void ClickAreaOnMouseExited()
{
_mouseInsideClickArea = false;
// ghost == null check probably unnecessary
if (_clickedInside && !NoduleManager.Instance.Building)
{
NoduleManager.Instance.Building = true;
_clickedInside = false;
var ghost = Instantiator.Instantiate<BuildGhost>();
ghost.Position = Position;
// TODO: Make it better... EntityRoot oder vllt. NoduleRoot
// Oder einfach den Baum auch als Baum in der Scene darstellen?
GetTree().Root.AddChild(ghost);
}
}
public override void _UnhandledInput(InputEvent @event)
{
using (@event)
{
if (
@event is InputEventMouseButton { ButtonIndex: MouseButton.Left }
&& @event.IsPressed()
&& _mouseInsideClickArea
)
{
_clickedInside = true;
GetViewport().SetInputAsHandled();
}
}
}
}