limited field creation to specified shape

This commit is contained in:
2025-05-17 17:40:15 +02:00
parent 8af825bc18
commit 222c10fe0a
3 changed files with 44 additions and 4 deletions
@@ -66,7 +66,7 @@ public partial class FarmingControls2D : Node2D
public override void _Input(InputEvent @event)
{
Vector2 mousePosition = GetViewport().GetMousePosition();
Vector2 mousePosition = _camera.GetGlobalMousePosition();
Vector2I adjustedPosition = new Vector2I(AdjustValue(mousePosition.X), AdjustValue(mousePosition.Y));
@@ -94,6 +94,14 @@ public partial class FarmingControls2D : Node2D
{
if(FieldParent == null || _fieldPrefab == null)
return;
bool fieldAllowed = FieldParent.FieldAllowed();
GD.Print($"Field allowed at {fieldPosition}: {fieldAllowed}");
// only try to instantiate a field if you're in the allowed area
if (!fieldAllowed)
return;
// only instantiate a field if there isn't one already.
if(FieldParent.Get(fieldPosition) == null)