Compare commits

...

4 Commits

11 changed files with 124 additions and 5 deletions
@@ -0,0 +1,20 @@
[gd_scene load_steps=5 format=3 uid="uid://bs4t0t7o4jmam"]
[ext_resource type="Script" uid="uid://doxr432r22dd0" path="res://scripts/CSharp/Common/Items/InventoryDependentInteractable.cs" id="1_cu47d"]
[ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/wateringcan.tres" id="2_s5peo"]
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="3_wsetd"]
[ext_resource type="Texture2D" uid="uid://bleimj6jr1jka" path="res://art/general/rectangle.png" id="4_1dub8"]
[node name="InventoryDependentInteractableTest" type="Node2D" node_paths=PackedStringArray("_interactionArea")]
script = ExtResource("1_cu47d")
_interactionArea = NodePath("InteractionArea")
_itemsToReactTo = Array[Object]([ExtResource("2_s5peo")])
_activateOnItem = true
[node name="InteractionArea" parent="." node_paths=PackedStringArray("_spriteToOutline") instance=ExtResource("3_wsetd")]
_active = false
_spriteToOutline = NodePath("../Sprite2D")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.5, 0.5)
texture = ExtResource("4_1dub8")
+4 -1
View File
@@ -1,7 +1,8 @@
[gd_scene load_steps=15 format=3 uid="uid://sbf12hin4kes"] [gd_scene load_steps=16 format=3 uid="uid://sbf12hin4kes"]
[ext_resource type="Texture2D" uid="uid://bylgmr0skwtrs" path="res://art/farm/farming/farmobjekte/broken tools atlas.png" id="1_k4ca3"] [ext_resource type="Texture2D" uid="uid://bylgmr0skwtrs" path="res://art/farm/farming/farmobjekte/broken tools atlas.png" id="1_k4ca3"]
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="2_gcgfd"] [ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="2_gcgfd"]
[ext_resource type="Script" uid="uid://dkk1vjijvgrd7" path="res://scripts/CSharp/Common/Items/NonInventoryPickup.cs" id="2_ic616"]
[ext_resource type="AudioStream" uid="uid://be6g8b3v3u1ai" path="res://audio/sfx/Kitchen/SFX_Cooking_Knife_PickUp_01.wav" id="3_ktmp7"] [ext_resource type="AudioStream" uid="uid://be6g8b3v3u1ai" path="res://audio/sfx/Kitchen/SFX_Cooking_Knife_PickUp_01.wav" id="3_ktmp7"]
[ext_resource type="AudioStream" uid="uid://cgjsajsdrrn0j" path="res://audio/sfx/Kitchen/SFX_Cooking_Knife_PutDown_01.wav" id="4_ic616"] [ext_resource type="AudioStream" uid="uid://cgjsajsdrrn0j" path="res://audio/sfx/Kitchen/SFX_Cooking_Knife_PutDown_01.wav" id="4_ic616"]
[ext_resource type="AudioStream" uid="uid://br4drgupled6c" path="res://audio/sfx/Kitchen/SFX_Cooking_Pot_01.wav" id="5_dx175"] [ext_resource type="AudioStream" uid="uid://br4drgupled6c" path="res://audio/sfx/Kitchen/SFX_Cooking_Pot_01.wav" id="5_dx175"]
@@ -34,6 +35,7 @@ texture = ExtResource("1_k4ca3")
offset = Vector2(1, -215) offset = Vector2(1, -215)
region_enabled = true region_enabled = true
region_rect = Rect2(44, 479, 356, 503) region_rect = Rect2(44, 479, 356, 503)
script = ExtResource("2_ic616")
[node name="InteractionArea" parent="." node_paths=PackedStringArray("_spriteToOutline") instance=ExtResource("2_gcgfd")] [node name="InteractionArea" parent="." node_paths=PackedStringArray("_spriteToOutline") instance=ExtResource("2_gcgfd")]
position = Vector2(0, -172) position = Vector2(0, -172)
@@ -46,4 +48,5 @@ playback_type = 2
script = ExtResource("13_wswkg") script = ExtResource("13_wswkg")
[connection signal="Interacted" from="InteractionArea" to="." method="queue_free"] [connection signal="Interacted" from="InteractionArea" to="." method="queue_free"]
[connection signal="Interacted" from="InteractionArea" to="." method="PlayPickupAnimation"]
[connection signal="Interacted" from="InteractionArea" to="AudioStreamPlayer2D" method="PlayOneShot"] [connection signal="Interacted" from="InteractionArea" to="AudioStreamPlayer2D" method="PlayOneShot"]
+20 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://cgjc4wurbgimy"] [gd_scene load_steps=12 format=3 uid="uid://cgjc4wurbgimy"]
[ext_resource type="Script" uid="uid://hg7jay2kt441" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"] [ext_resource type="Script" uid="uid://hg7jay2kt441" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"]
[ext_resource type="Script" uid="uid://cvkw4qd2hxksi" path="res://scripts/GdScript/dialogic_toggle.gd" id="1_l3npx"] [ext_resource type="Script" uid="uid://cvkw4qd2hxksi" path="res://scripts/GdScript/dialogic_toggle.gd" id="1_l3npx"]
@@ -11,6 +11,9 @@
[ext_resource type="PackedScene" uid="uid://2q1n6g2kj5er" path="res://prefabs/UI/Quest/QuestLog.tscn" id="7_vvo7l"] [ext_resource type="PackedScene" uid="uid://2q1n6g2kj5er" path="res://prefabs/UI/Quest/QuestLog.tscn" id="7_vvo7l"]
[ext_resource type="Texture2D" uid="uid://qwia360i1ir1" path="res://art/ui/UI/inventory_active.png" id="8_df8i8"] [ext_resource type="Texture2D" uid="uid://qwia360i1ir1" path="res://art/ui/UI/inventory_active.png" id="8_df8i8"]
[sub_resource type="LabelSettings" id="LabelSettings_l3npx"]
font_size = 50
[node name="CanvasLayer" type="CanvasLayer"] [node name="CanvasLayer" type="CanvasLayer"]
layer = 90 layer = 90
@@ -455,6 +458,22 @@ offset_bottom = 100.0
texture = ExtResource("8_df8i8") texture = ExtResource("8_df8i8")
expand_mode = 1 expand_mode = 1
[node name="Label" type="Label" parent="Inventory/SlotsContainer/SlotsMover"]
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = 14.4142
offset_top = 184.286
offset_right = 54.4142
offset_bottom = 207.286
grow_horizontal = 0
grow_vertical = 2
text = "[I]"
label_settings = SubResource("LabelSettings_l3npx")
[node name="QuestLogRoot" parent="." instance=ExtResource("7_vvo7l")] [node name="QuestLogRoot" parent="." instance=ExtResource("7_vvo7l")]
[node name="Control" type="Control" parent="."] [node name="Control" type="Control" parent="."]
+2 -2
View File
@@ -2077,7 +2077,7 @@ _vesnaAnimations = NodePath("CharacterBody2D/visuals")
_hoe = ExtResource("2_dnm27") _hoe = ExtResource("2_dnm27")
_wateringCan = ExtResource("3_e04c3") _wateringCan = ExtResource("3_e04c3")
[node name="CharacterBody2D" type="CharacterBody2D" parent="." groups=["PlantGrowing"]] [node name="CharacterBody2D" type="CharacterBody2D" parent="."]
position = Vector2(0, 374) position = Vector2(0, 374)
collision_layer = 4 collision_layer = 4
collision_mask = 3 collision_mask = 3
@@ -2091,7 +2091,7 @@ position = Vector2(-24, -13)
shape = SubResource("CircleShape2D_ssqtd") shape = SubResource("CircleShape2D_ssqtd")
debug_color = Color(0.923708, 0.202722, 0.475262, 0.42) debug_color = Color(0.923708, 0.202722, 0.475262, 0.42)
[node name="visuals" type="Node2D" parent="CharacterBody2D" node_paths=PackedStringArray("_sprite", "_wateringParticles")] [node name="visuals" type="Node2D" parent="CharacterBody2D" node_paths=PackedStringArray("_sprite", "_wateringParticles") groups=["Pickup", "PlantGrowing"]]
position = Vector2(0, -374) position = Vector2(0, -374)
script = ExtResource("3_f6xmn") script = ExtResource("3_f6xmn")
_sprite = NodePath("Animated Sprites") _sprite = NodePath("Animated Sprites")
+1
View File
@@ -207,6 +207,7 @@ folder_colors={
[global_group] [global_group]
PlantGrowing="" PlantGrowing=""
Pickup=""
[input] [input]
+5 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=114 format=3 uid="uid://gigb28qk8t12"] [gd_scene load_steps=115 format=3 uid="uid://gigb28qk8t12"]
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="1_7wfwe"] [ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="1_7wfwe"]
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"] [ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
@@ -64,6 +64,7 @@
[ext_resource type="Script" uid="uid://dnipeibppjirs" path="res://scripts/CSharp/Common/NPC/DialogicOverlayStarter.cs" id="51_uxa2m"] [ext_resource type="Script" uid="uid://dnipeibppjirs" path="res://scripts/CSharp/Common/NPC/DialogicOverlayStarter.cs" id="51_uxa2m"]
[ext_resource type="Script" uid="uid://d2486x6upmwqq" path="res://scripts/GdScript/dialogic_starter.gd" id="52_lwk6t"] [ext_resource type="Script" uid="uid://d2486x6upmwqq" path="res://scripts/GdScript/dialogic_starter.gd" id="52_lwk6t"]
[ext_resource type="PackedScene" uid="uid://sbf12hin4kes" path="res://prefabs/Interactables/trash_object.tscn" id="53_ycj14"] [ext_resource type="PackedScene" uid="uid://sbf12hin4kes" path="res://prefabs/Interactables/trash_object.tscn" id="53_ycj14"]
[ext_resource type="PackedScene" uid="uid://bs4t0t7o4jmam" path="res://prefabs/Interactables/inventory_dependent_interactable_test.tscn" id="54_fv1t2"]
[ext_resource type="PackedScene" uid="uid://muuxxgvx33fp" path="res://prefabs/farm/duck.tscn" id="62_i36hd"] [ext_resource type="PackedScene" uid="uid://muuxxgvx33fp" path="res://prefabs/farm/duck.tscn" id="62_i36hd"]
[ext_resource type="Script" uid="uid://cldtt4atgymm5" path="res://scripts/CSharp/Common/Quest/QuestTrigger.cs" id="66_2065p"] [ext_resource type="Script" uid="uid://cldtt4atgymm5" path="res://scripts/CSharp/Common/Quest/QuestTrigger.cs" id="66_2065p"]
[ext_resource type="Resource" uid="uid://cm8kftow8br00" path="res://resources/quests/demo/1_talk_yeli_1.tres" id="67_tm0yg"] [ext_resource type="Resource" uid="uid://cm8kftow8br00" path="res://resources/quests/demo/1_talk_yeli_1.tres" id="67_tm0yg"]
@@ -2275,6 +2276,9 @@ rotation = 1.77025
offset = Vector2(0, 0) offset = Vector2(0, 0)
region_rect = Rect2(1048, 1092, 348, 106) region_rect = Rect2(1048, 1092, 348, 106)
[node name="InventoryDependentInteractableTest" parent="YSorted" instance=ExtResource("54_fv1t2")]
position = Vector2(10868, 3000)
[node name="CanvasLayer" parent="." instance=ExtResource("32_2nee2")] [node name="CanvasLayer" parent="." instance=ExtResource("32_2nee2")]
[node name="Inventory" parent="CanvasLayer" index="1"] [node name="Inventory" parent="CanvasLayer" index="1"]
@@ -37,6 +37,7 @@ public partial class PlantBehaviour2D : Node2D
public override void _Ready() public override void _Ready()
{ {
GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation);
_state = PlantState.Planted; _state = PlantState.Planted;
_currentPlantSprite = GetRandomSprite(_seeds); _currentPlantSprite = GetRandomSprite(_seeds);
_currentPlantSprite.Visible = true; _currentPlantSprite.Visible = true;
@@ -0,0 +1,57 @@
using Babushka.scripts.CSharp.Common.CharacterControls;
using Babushka.scripts.CSharp.Common.Inventory;
using Godot;
using Godot.Collections;
namespace Babushka.scripts.CSharp.Common.Items;
public partial class InventoryDependentInteractable : Node2D
{
[Export] private InteractionArea2D _interactionArea;
[Export] private Array<ItemResource> _itemsToReactTo;
[Export] private bool _activateOnItem = true;
private InventoryManager _inventoryManager;
private InventoryInstance _inventoryInstance;
public override void _Ready()
{
_inventoryManager = InventoryManager.Instance;
_inventoryInstance = _inventoryManager.playerInventory;
_inventoryManager.SlotIndexChanged += HandleInventorySelectedSlotIndexChanged;
}
private void HandleInventorySelectedSlotIndexChanged(int newIndex)
{
int currentSlotIndex = InventoryManager.Instance.CurrentSelectedSlotIndex;
ItemInstance? item = InventoryManager.Instance.playerInventory.Slots[currentSlotIndex].itemInstance;
if (item != null)
{
if (_activateOnItem)
{
_interactionArea.IsActive = Match(item.blueprint);
}
else
{
_interactionArea.IsActive = !Match(item.blueprint);
}
}
}
private bool Match(ItemResource inventoryItem)
{
bool matched = false;
foreach (ItemResource item in _itemsToReactTo)
{
if (inventoryItem == item)
{
matched = true;
}
}
return matched;
}
}
@@ -0,0 +1 @@
uid://doxr432r22dd0
@@ -0,0 +1,12 @@
using Babushka.scripts.CSharp.Common.Animation;
using Godot;
namespace Babushka.scripts.CSharp.Common.Items;
public partial class NonInventoryPickup : Node2D
{
public void PlayPickupAnimation()
{
GetTree().CallGroup("Pickup", VesnaAnimations.MethodName.PlayPickUpAnimation);
}
}
@@ -0,0 +1 @@
uid://dkk1vjijvgrd7