Fields spawn on a grid
This commit is contained in:
@@ -19,7 +19,7 @@ _showLabel = false
|
|||||||
shape = SubResource("SphereShape3D_u7egi")
|
shape = SubResource("SphereShape3D_u7egi")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
transform = Transform3D(0.5, 0, 0, 0, -2.18557e-08, -0.5, 0, 0.5, -2.18557e-08, 0, 0, 0)
|
transform = Transform3D(0.4, 0, 0, 0, -1.74846e-08, -0.4, 0, 0.4, -1.74846e-08, 0, 0, 0)
|
||||||
pixel_size = 0.004
|
pixel_size = 0.004
|
||||||
texture = ExtResource("1_2cisk")
|
texture = ExtResource("1_2cisk")
|
||||||
script = ExtResource("2_u7egi")
|
script = ExtResource("2_u7egi")
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||||
@@ -12,6 +13,7 @@ public partial class FarmingControls : Node3D
|
|||||||
public Node FieldParent;
|
public Node FieldParent;
|
||||||
|
|
||||||
private bool _hoeInHand = false;
|
private bool _hoeInHand = false;
|
||||||
|
private Dictionary<KeyValuePair<int, int>, bool> _spawnedFields = new Dictionary<KeyValuePair<int, int>, bool>();
|
||||||
public void ActivateHoe(bool activate)
|
public void ActivateHoe(bool activate)
|
||||||
{
|
{
|
||||||
_hoeSprite.Visible = !activate;
|
_hoeSprite.Visible = !activate;
|
||||||
@@ -35,11 +37,16 @@ public partial class FarmingControls : Node3D
|
|||||||
|
|
||||||
if (fieldInstance is Node3D field3d)
|
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);
|
FieldParent.AddChild(fieldInstance);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float AdjustValue(float value)
|
||||||
|
{
|
||||||
|
return Mathf.Floor(value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user