WIP reworking the field behaviour to implement watering. Broken state.
This commit is contained in:
@@ -7,18 +7,38 @@ namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
public partial class FarmingControls : Node3D
|
||||
{
|
||||
[Export] private Sprite3D _hoeSprite;
|
||||
[Export] private Sprite3D _wateringCanSprite;
|
||||
[Export] private PackedScene _fieldPrefab;
|
||||
[Export] private Node3D _movingPlayer;
|
||||
|
||||
public Node FieldParent;
|
||||
public FieldService FieldParent;
|
||||
|
||||
private bool _hoeInHand = false;
|
||||
private Dictionary<KeyValuePair<int, int>, bool> _spawnedFields = new Dictionary<KeyValuePair<int, int>, bool>();
|
||||
public void ActivateHoe(bool activate)
|
||||
private bool _waterCanInHand = false;
|
||||
|
||||
#region Tools
|
||||
|
||||
public bool ActivateHoe(bool activate)
|
||||
{
|
||||
_hoeSprite.Visible = !activate;
|
||||
_hoeInHand = !activate;
|
||||
bool success = ActivateTool(activate, _hoeSprite);
|
||||
_hoeInHand = success;
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool ActivateWateringCan(bool activate)
|
||||
{
|
||||
bool success = ActivateTool(activate, _wateringCanSprite);
|
||||
_waterCanInHand = success;
|
||||
return success;
|
||||
}
|
||||
|
||||
private bool ActivateTool(bool activate, Sprite3D tool)
|
||||
{
|
||||
tool.Visible = !activate;
|
||||
return !activate;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
@@ -26,6 +46,16 @@ public partial class FarmingControls : Node3D
|
||||
{
|
||||
MakeField();
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed("click") && _waterCanInHand)
|
||||
{
|
||||
WaterTheField();
|
||||
}
|
||||
}
|
||||
|
||||
private void WaterTheField()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MakeField()
|
||||
@@ -38,9 +68,13 @@ public partial class FarmingControls : Node3D
|
||||
if (fieldInstance is Node3D field3d)
|
||||
{
|
||||
Vector3 playerPos = _movingPlayer.GlobalPosition;
|
||||
field3d.Position = new Vector3(AdjustValue(playerPos.X), 0.1f, AdjustValue(playerPos.Z));
|
||||
playerPos = new Vector3(AdjustValue(playerPos.X), 0.1f, AdjustValue(playerPos.Z));
|
||||
field3d.Position = playerPos;
|
||||
Vector2I intPosition = new Vector2I((int) playerPos.X, (int) playerPos.Z);
|
||||
FieldParent.AddEntry(intPosition, FieldState.Tilled);
|
||||
}
|
||||
|
||||
|
||||
FieldParent.AddChild(fieldInstance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user