diff --git a/scenes/Babushka_scene_farm_outside_2d.tscn b/scenes/Babushka_scene_farm_outside_2d.tscn index 88ad312..050f772 100644 --- a/scenes/Babushka_scene_farm_outside_2d.tscn +++ b/scenes/Babushka_scene_farm_outside_2d.tscn @@ -1047,6 +1047,8 @@ script = ExtResource("40_w3jkj") [connection signal="FilledWateringCan" from="YSorted/Vesna" to="Audio/SFX/FillWater SFX2" method="PlayOneShot"] [connection signal="WateringField" from="YSorted/Vesna/FarmingControls" to="Audio/SFX/Watering SFX" method="PlayOneShot"] [connection signal="InteractedTool" from="YSorted/BrĂ¼nnen/InteractionArea" to="YSorted/Vesna" method="TryFillWateringCan"] +[connection signal="SuccessfulPickUp" from="YSorted/CanGenericPickup" to="YSorted/Vesna" method="HandlePickUp"] +[connection signal="SuccessfulPickUp" from="YSorted/RakeGenericPickup" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="Interacted" from="YSorted/Farm visuals/Static/EnterHouseInteraction" to="." method="LoadScene"] [connection signal="FieldCreated" from="YSorted/Farm visuals/FieldParent" to="Audio/SFX/Farming SFX" method="PlayOneShot"] [connection signal="mouse_entered" from="YSorted/Farm visuals/FieldParent/Area2D" to="YSorted/Farm visuals/FieldParent" method="MouseEnteredAllowedArea"] diff --git a/scripts/CSharp/Common/Farming/VesnaBehaviour2D.cs b/scripts/CSharp/Common/Farming/VesnaBehaviour2D.cs index 118ede5..1fc8435 100644 --- a/scripts/CSharp/Common/Farming/VesnaBehaviour2D.cs +++ b/scripts/CSharp/Common/Farming/VesnaBehaviour2D.cs @@ -26,8 +26,18 @@ public partial class VesnaBehaviour2D : Node _inventoryInstance = _inventoryManager.playerInventory; _inventoryManager.SlotIndexChanged += HandleInventorySelectedSlotIndexChanged; } + + /// + /// Called when picking up an item. + /// Makes sure that item animations are also updated when they are occupying a currently empty spot. + /// + public void HandlePickUp() + { + //Calls the same event handler as the inventory to ensure the currently selected item is updated in the animation. + HandleInventorySelectedSlotIndexChanged(0); + } - private void HandleInventorySelectedSlotIndexChanged(int newIndex) + private void HandleInventorySelectedSlotIndexChanged(int newIndex = 0) { InventorySlot currentSlot = InventoryManager.Instance.GetCurrentSelectedSlot(); ItemInstance? currentItem = currentSlot.itemInstance; diff --git a/scripts/CSharp/Common/Inventory/ItemOnGround2D.cs b/scripts/CSharp/Common/Inventory/ItemOnGround2D.cs index 52842d8..bba4bb7 100644 --- a/scripts/CSharp/Common/Inventory/ItemOnGround2D.cs +++ b/scripts/CSharp/Common/Inventory/ItemOnGround2D.cs @@ -11,6 +11,8 @@ public partial class ItemOnGround2D : Node [Export] public bool IsActive = true; private int pickUpCounter = 0; + + [Signal] public delegate void SuccessfulPickUpEventHandler(); private Label _itemLabel => GetNode