State after inventory clip (farming mechanic still WIP)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
@@ -7,12 +8,44 @@ public partial class VesnaBehaviour2D : Node
|
||||
[ExportGroup("Farming")]
|
||||
[Export] private FieldService2D _fieldParent;
|
||||
[Export] private FarmingControls2D _farmingControls;
|
||||
[Export] private ItemResource _hoe;
|
||||
[Export] private ItemResource _wateringCan;
|
||||
|
||||
[Signal] public delegate void PickedUpToolEventHandler(bool success, int toolId);
|
||||
|
||||
private InventoryManager _inventoryManager;
|
||||
private InventoryInstance _inventoryInstance;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_farmingControls.FieldService = _fieldParent;
|
||||
_inventoryManager = InventoryManager.Instance;
|
||||
_inventoryInstance = _inventoryManager.playerInventory;
|
||||
_inventoryManager.SlotIndexChanged += HandleInventorySelectedSlotIndexChanged;
|
||||
}
|
||||
|
||||
private void HandleInventorySelectedSlotIndexChanged(int newIndex)
|
||||
{
|
||||
InventorySlot currentSlot = InventoryManager.Instance.GetCurrentSelectedSlot();
|
||||
ItemInstance? currentItem = currentSlot.itemInstance;
|
||||
|
||||
if (currentItem == null)
|
||||
return;
|
||||
|
||||
if (currentItem.blueprint == _hoe)
|
||||
{
|
||||
ActivateTool(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentItem.blueprint == _wateringCan)
|
||||
{
|
||||
ActivateTool(1);
|
||||
return;
|
||||
}
|
||||
|
||||
ActivateTool(-1);
|
||||
|
||||
}
|
||||
|
||||
#region Farming
|
||||
|
||||
Reference in New Issue
Block a user