Fields spawn on a grid
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
@@ -12,6 +13,7 @@ public partial class FarmingControls : Node3D
|
||||
public Node FieldParent;
|
||||
|
||||
private bool _hoeInHand = false;
|
||||
private Dictionary<KeyValuePair<int, int>, bool> _spawnedFields = new Dictionary<KeyValuePair<int, int>, bool>();
|
||||
public void ActivateHoe(bool activate)
|
||||
{
|
||||
_hoeSprite.Visible = !activate;
|
||||
@@ -35,11 +37,16 @@ public partial class FarmingControls : Node3D
|
||||
|
||||
if (fieldInstance is Node3D field3d)
|
||||
{
|
||||
field3d.Position = _movingPlayer.GlobalPosition;
|
||||
Vector3 playerPos = _movingPlayer.GlobalPosition;
|
||||
field3d.Position = new Vector3(AdjustValue(playerPos.X), 0.1f, AdjustValue(playerPos.Z));
|
||||
}
|
||||
|
||||
FieldParent.AddChild(fieldInstance);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private float AdjustValue(float value)
|
||||
{
|
||||
return Mathf.Floor(value);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user