From 554a319428e2cd463cc53c68ba5ff966ca953704 Mon Sep 17 00:00:00 2001 From: kziolkowski Date: Tue, 11 Nov 2025 16:39:47 +0100 Subject: [PATCH] :construction: farming rework part 2: you can now kinda "create" fields --- prefabs/farm/base_field.tscn | 28 +++++- scenes/Babushka_scene_outside_beets.tscn | 93 ++++++++++++++++++- .../CSharp/Common/Farming/FieldActivator.cs | 27 ++++++ .../Common/Farming/FieldActivator.cs.uid | 1 + 4 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 scripts/CSharp/Common/Farming/FieldActivator.cs create mode 100644 scripts/CSharp/Common/Farming/FieldActivator.cs.uid diff --git a/prefabs/farm/base_field.tscn b/prefabs/farm/base_field.tscn index 3221f16..43016c8 100644 --- a/prefabs/farm/base_field.tscn +++ b/prefabs/farm/base_field.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://b1d2e7ely6hyw"] +[gd_scene load_steps=25 format=3 uid="uid://b1d2e7ely6hyw"] [ext_resource type="Script" uid="uid://j2mhvb45egej" path="res://scripts/CSharp/Low Code/Variables/VariableNode.cs" id="1_4mg73"] [ext_resource type="Script" uid="uid://bdffon388rkty" path="res://scripts/CSharp/Common/Farming/FieldBehaviour2D.cs" id="1_qa01x"] @@ -21,6 +21,12 @@ [ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="16_i4qwg"] [ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/wateringcan.tres" id="17_1mi0u"] [ext_resource type="Texture2D" uid="uid://l5ym7gi82l1b" path="res://art/ui/UI/Watercan-ui/Tropfen-ui-6.png" id="21_4mg73"] +[ext_resource type="Resource" uid="uid://dlcmqfjvgphqu" path="res://resources/items/rake.tres" id="21_68xcd"] +[ext_resource type="Script" uid="uid://dlbjjgbs0n4b0" path="res://scripts/CSharp/Common/Farming/FieldActivator.cs" id="22_57jmp"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_57jmp"] +resource_local_to_scene = true +radius = 325.2599 [node name="BaseField" type="Node2D"] script = ExtResource("1_4mg73") @@ -66,6 +72,7 @@ texture = ExtResource("9_wx561") position = Vector2(-26, -57) _active = false _spritesToOutline = [NodePath("../FieldBehaviour/OutlineSprite")] +_showLabel = false [node name="PlantCreationEventRaiser" type="Node" parent="."] script = ExtResource("9_teirr") @@ -79,6 +86,10 @@ _itemResourcesToListenFor = Array[Object]([ExtResource("15_i4qwg"), ExtResource( script = ExtResource("14_w08sx") _itemResourcesToListenFor = Array[Object]([ExtResource("17_1mi0u")]) +[node name="InventoryListener rake" type="Node" parent="."] +script = ExtResource("14_w08sx") +_itemResourcesToListenFor = Array[Object]([ExtResource("21_68xcd")]) + [node name="pouring water vfx" type="CPUParticles2D" parent="."] position = Vector2(0, -300) emitting = false @@ -98,7 +109,22 @@ scale_amount_max = 0.8 color = Color(0.400601, 0.62444, 0.791217, 1) hue_variation_max = 0.4 +[node name="FieldActivator" type="Node2D" parent="." node_paths=PackedStringArray("_field")] +script = ExtResource("22_57jmp") +_field = NodePath("../FieldBehaviour") + +[node name="InteractionArea" parent="FieldActivator" instance=ExtResource("7_2eegd")] +_useOutline = false + +[node name="CollisionShape3D" parent="FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_57jmp") + [connection signal="Planted" from="FieldBehaviour" to="PlantCreationEventRaiser" method="RaiseEvents"] [connection signal="Interacted" from="InteractionArea" to="FieldBehaviour" method="Farm"] [connection signal="ItemInstanceActivated" from="InventoryListener Seeds" to="FieldBehaviour" method="ActivatedSeedInInventory"] [connection signal="ItemInstanceActivated" from="InventoryListener watering can" to="FieldBehaviour" method="ActivateWateringCanInInventory"] +[connection signal="ItemInstanceActivated" from="InventoryListener rake" to="FieldActivator" method="RakeActivated"] +[connection signal="Interacted" from="FieldActivator/InteractionArea" to="FieldActivator/InteractionArea" method="ToggleActive"] +[connection signal="Interacted" from="FieldActivator/InteractionArea" to="FieldActivator" method="ActivateField"] + +[editable path="FieldActivator/InteractionArea"] diff --git a/scenes/Babushka_scene_outside_beets.tscn b/scenes/Babushka_scene_outside_beets.tscn index 18d6654..79d6c14 100644 --- a/scenes/Babushka_scene_outside_beets.tscn +++ b/scenes/Babushka_scene_outside_beets.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=86 format=3 uid="uid://b3ibx4resa1f3"] +[gd_scene load_steps=96 format=3 uid="uid://b3ibx4resa1f3"] [ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="1_6krrk"] [ext_resource type="Script" uid="uid://bqomwxclsbhd3" path="res://scripts/CSharp/Common/Camera/CameraController.cs" id="2_4ktoi"] @@ -170,6 +170,42 @@ shader_parameter/offset = 0.0 shader = ExtResource("24_anpd4") shader_parameter/tiling_scale = Vector2(1, 20) +[sub_resource type="CircleShape2D" id="CircleShape2D_qavgq"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_njxly"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_54ty3"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_gbxtf"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_6krrk"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_4ktoi"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_aaup4"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_v10dc"] +resource_local_to_scene = true +radius = 325.2599 + +[sub_resource type="CircleShape2D" id="CircleShape2D_4pibb"] +resource_local_to_scene = true +radius = 325.2599 + [sub_resource type="CircleShape2D" id="CircleShape2D_dr6bm"] resource_local_to_scene = true radius = 335.72162 @@ -185,6 +221,10 @@ shader_parameter/contrast_mult = 1.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_ycj14"] size = Vector2(707.116, 604.111) +[sub_resource type="CircleShape2D" id="CircleShape2D_hpgl7"] +resource_local_to_scene = true +radius = 294.02722 + [sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_ceriq"] loop = false stream_count = 1 @@ -1714,6 +1754,9 @@ scale = Vector2(1, 1.00622) _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_qavgq") + [node name="BaseField2" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(1226, 3098.15) scale = Vector2(1, 1.00622) @@ -1723,6 +1766,9 @@ Payload = 1 _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField2/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_njxly") + [node name="BaseField3" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(1782, 2606.11) scale = Vector2(1, 1.00622) @@ -1732,6 +1778,9 @@ Payload = 2 _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField3/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_54ty3") + [node name="BaseField4" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(2559, 2624.22) scale = Vector2(1, 1.00622) @@ -1744,6 +1793,9 @@ FieldState = 3 _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField4/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_gbxtf") + [node name="BaseField5" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(3305, 2624.22) scale = Vector2(1, 1.00622) @@ -1756,6 +1808,9 @@ FieldState = 3 _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField5/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_6krrk") + [node name="BaseField6" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(4033, 2618.18) scale = Vector2(1, 1.00622) @@ -1768,6 +1823,9 @@ FieldState = 3 _state = 1 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField6/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_4ktoi") + [node name="BaseField7" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(4755, 2630.26) scale = Vector2(1, 1.00622) @@ -1780,6 +1838,9 @@ FieldState = 3 _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField7/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_aaup4") + [node name="BaseField8" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(4418, 3226.95) scale = Vector2(1, 1.00622) @@ -1792,18 +1853,25 @@ FieldState = 3 _state = 2 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField8/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_v10dc") + [node name="BaseField9" parent="YSorted/Farm visuals/FieldParent" instance=ExtResource("40_efblm")] position = Vector2(5317, 3208.83) scale = Vector2(1, 1.00622) Payload = 8 [node name="FieldBehaviour" parent="YSorted/Farm visuals/FieldParent/BaseField9" index="0"] +visible = false FieldState = 3 [node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField9/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")] _state = 1 _field = NodePath("../..") +[node name="CollisionShape3D" parent="YSorted/Farm visuals/FieldParent/BaseField9/FieldActivator/InteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_4pibb") + [node name="Blocker" type="Node2D" parent="YSorted"] [node name="BackToFarm" parent="YSorted/Blocker" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("31_xcb8u")] @@ -1847,6 +1915,18 @@ position = Vector2(14423, 5123) scale = Vector2(1.89667, 1) texture = ExtResource("23_s4721") +[node name="RakeGenericPickup" parent="YSorted" instance=ExtResource("43_dr6bm")] +position = Vector2(6401, 2602) + +[node name="SpawnWithItem" parent="YSorted/RakeGenericPickup" index="0"] +_blueprint = ExtResource("28_le48k") + +[node name="PickupInteractionArea" parent="YSorted/RakeGenericPickup" index="3"] +_id = 0 + +[node name="CollisionShape3D" parent="YSorted/RakeGenericPickup/PickupInteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_hpgl7") + [node name="CanvasLayer" parent="." instance=ExtResource("52_gwhnv")] [node name="Inventory" parent="CanvasLayer" index="1"] @@ -1925,13 +2005,24 @@ _payloadToSet = "beetRootScene" [editable path="YSorted/Vesna/GenericItemOnGround/PickupInteractionArea"] [editable path="YSorted/BrĂ¼nnen/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField2"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField2/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField3"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField3/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField4"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField4/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField5"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField5/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField6"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField6/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField7"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField7/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField8"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField8/FieldActivator/InteractionArea"] [editable path="YSorted/Farm visuals/FieldParent/BaseField9"] +[editable path="YSorted/Farm visuals/FieldParent/BaseField9/FieldActivator/InteractionArea"] [editable path="YSorted/Blocker/BackToFarm"] +[editable path="YSorted/RakeGenericPickup"] +[editable path="YSorted/RakeGenericPickup/PickupInteractionArea"] [editable path="CanvasLayer"] diff --git a/scripts/CSharp/Common/Farming/FieldActivator.cs b/scripts/CSharp/Common/Farming/FieldActivator.cs new file mode 100644 index 0000000..a2e2ca5 --- /dev/null +++ b/scripts/CSharp/Common/Farming/FieldActivator.cs @@ -0,0 +1,27 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Common.Farming; + +public partial class FieldActivator : Node +{ + [Export] private Node2D _field; + + private bool _activated = false; + private bool _rakeInHand; + + public void ActivateField() + { + if (!_activated && _rakeInHand) + { + GD.Print("Tryina activate this field right here...."); + _field.Visible = true; + _activated = true; + } + } + + public void RakeActivated(bool activated) + { + _rakeInHand = activated; + } + +} \ No newline at end of file diff --git a/scripts/CSharp/Common/Farming/FieldActivator.cs.uid b/scripts/CSharp/Common/Farming/FieldActivator.cs.uid new file mode 100644 index 0000000..d98ca61 --- /dev/null +++ b/scripts/CSharp/Common/Farming/FieldActivator.cs.uid @@ -0,0 +1 @@ +uid://dlbjjgbs0n4b0