Tools get deactivated from animation when switching to an empty slot in the inventory. Also fixed layering (AGAIN)

pull/16/head
kziolkowski 5 months ago
parent 378bf45c49
commit 871e1856f1

@ -2170,7 +2170,6 @@ script = ExtResource("475_nxglm")
[connection signal="FilledWateringCan" from="." to="CharacterBody2D/WateringCanUI" method="Refill"] [connection signal="FilledWateringCan" from="." to="CharacterBody2D/WateringCanUI" method="Refill"]
[connection signal="InventorySelectionChanged" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"] [connection signal="InventorySelectionChanged" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"]
[connection signal="PickedUpTool" from="." to="CharacterBody2D" method="ActivateTool"]
[connection signal="PickedUpTool" from="." to="CharacterBody2D/visuals" method="ActivateTool"] [connection signal="PickedUpTool" from="." to="CharacterBody2D/visuals" method="ActivateTool"]
[connection signal="PickedUpTool" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"] [connection signal="PickedUpTool" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"]
[connection signal="WateringField" from="FarmingControls" to="CharacterBody2D/visuals" method="PlayWateringAnimation"] [connection signal="WateringField" from="FarmingControls" to="CharacterBody2D/visuals" method="PlayWateringAnimation"]

@ -1160,6 +1160,7 @@ region_rect = Rect2(130, 0, 201, 278)
[node name="bush6" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/left side"] [node name="bush6" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/left side"]
modulate = Color(0.8428, 0.8771, 0.98, 1) modulate = Color(0.8428, 0.8771, 0.98, 1)
z_index = 2
material = SubResource("ShaderMaterial_bcdgk") material = SubResource("ShaderMaterial_bcdgk")
position = Vector2(2612, 4022) position = Vector2(2612, 4022)
scale = Vector2(2, 2) scale = Vector2(2, 2)
@ -1255,6 +1256,7 @@ region_enabled = true
region_rect = Rect2(1699, 76, 280, 230) region_rect = Rect2(1699, 76, 280, 230)
[node name="bush14" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/left side"] [node name="bush14" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/left side"]
z_index = 2
material = SubResource("ShaderMaterial_bcdgk") material = SubResource("ShaderMaterial_bcdgk")
position = Vector2(8925, 4194) position = Vector2(8925, 4194)
scale = Vector2(-5.54387, 3.80466) scale = Vector2(-5.54387, 3.80466)
@ -1515,6 +1517,7 @@ region_enabled = true
region_rect = Rect2(1699, 76, 280, 230) region_rect = Rect2(1699, 76, 280, 230)
[node name="bush13" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/right side"] [node name="bush13" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/right side"]
z_index = 2
material = SubResource("ShaderMaterial_bcdgk") material = SubResource("ShaderMaterial_bcdgk")
position = Vector2(8145, 4141) position = Vector2(8145, 4141)
scale = Vector2(-2.82886, 2.51195) scale = Vector2(-2.82886, 2.51195)
@ -1524,6 +1527,7 @@ region_enabled = true
region_rect = Rect2(1699, 76, 280, 230) region_rect = Rect2(1699, 76, 280, 230)
[node name="bush14" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/right side"] [node name="bush14" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/right side"]
z_index = 2
material = SubResource("ShaderMaterial_bcdgk") material = SubResource("ShaderMaterial_bcdgk")
position = Vector2(8925, 4194) position = Vector2(8925, 4194)
scale = Vector2(-5.54387, 3.80466) scale = Vector2(-5.54387, 3.80466)
@ -1534,6 +1538,7 @@ region_rect = Rect2(130, 0, 201, 278)
[node name="bush15" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/right side"] [node name="bush15" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/right side"]
modulate = Color(0.8428, 0.8771, 0.98, 1) modulate = Color(0.8428, 0.8771, 0.98, 1)
z_index = 2
material = SubResource("ShaderMaterial_bcdgk") material = SubResource("ShaderMaterial_bcdgk")
position = Vector2(7763, 4164) position = Vector2(7763, 4164)
scale = Vector2(3.21806, 3.18583) scale = Vector2(3.21806, 3.18583)
@ -1800,7 +1805,7 @@ region_enabled = true
region_rect = Rect2(29, 204, 219, 159) region_rect = Rect2(29, 204, 219, 159)
[node name="grass27" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/grass"] [node name="grass27" type="Sprite2D" parent="YSorted/Farm visuals/Static/greenery/grass"]
z_index = -5 z_index = 2
position = Vector2(7757, 3423) position = Vector2(7757, 3423)
rotation = 1.57079 rotation = 1.57079
scale = Vector2(7.28513, 6.16997) scale = Vector2(7.28513, 6.16997)

@ -1,4 +1,3 @@
using System.Threading.Tasks;
using Babushka.scripts.CSharp.Common.Inventory; using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Common.Services; using Babushka.scripts.CSharp.Common.Services;
using Godot; using Godot;

@ -46,23 +46,21 @@ public partial class VesnaBehaviour2D : Node
{ {
InventorySlot currentSlot = InventoryManager.Instance.GetCurrentSelectedSlot(); InventorySlot currentSlot = InventoryManager.Instance.GetCurrentSelectedSlot();
ItemInstance? currentItem = currentSlot.itemInstance; ItemInstance? currentItem = currentSlot.itemInstance;
if (currentItem == null)
return;
int toolId = -1; int toolId = -1;
if (currentItem.blueprint == _hoe) if (currentItem != null && currentItem.blueprint == _hoe)
{ {
toolId = 0; toolId = 0;
} }
if (currentItem.blueprint == _wateringCan) if (currentItem != null && currentItem.blueprint == _wateringCan)
{ {
toolId = 1; toolId = 1;
} }
ActivateTool(toolId); ActivateTool(toolId);
_vesnaAnimations.ActivateTool(toolId >= 0, toolId);
EmitSignal(SignalName.InventorySelectionChanged, toolId); EmitSignal(SignalName.InventorySelectionChanged, toolId);
} }

@ -1,4 +1,5 @@
using Godot; using Godot;
namespace Babushka.scripts.CSharp.Common.Inventory; namespace Babushka.scripts.CSharp.Common.Inventory;
[GlobalClass] [GlobalClass]
@ -18,7 +19,7 @@ public partial class ItemResource : Resource
[Export] [Export]
public PackedScene? itemPrefab; public PackedScene? itemPrefab;
public ItemResource() public ItemResource()
{ {
name = ""; name = "";
@ -27,3 +28,4 @@ public partial class ItemResource : Resource
itemPrefab = null; itemPrefab = null;
} }
} }

Loading…
Cancel
Save