🚧 reworked farming system to work with indices instead of positions

This commit is contained in:
2025-11-11 14:02:03 +01:00
parent 97dcadf07a
commit 55f0d2a77e
11 changed files with 98 additions and 84 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=486 format=3 uid="uid://c25udixd5m6l0"]
[gd_scene load_steps=487 format=3 uid="uid://c25udixd5m6l0"]
[ext_resource type="Script" uid="uid://b05uyj001ehwi" path="res://scripts/CSharp/Common/Farming/VesnaBehaviour2D.cs" id="1_yd5ep"]
[ext_resource type="Script" uid="uid://cjbclkxesh3hc" path="res://scripts/CSharp/Common/CharacterControls/PlayerMovement.cs" id="2_1vqmv"]
@@ -286,6 +286,7 @@
[ext_resource type="Texture2D" uid="uid://blh0t2ofqj2uq" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0016.png" id="472_wdxsr"]
[ext_resource type="AudioStream" uid="uid://dymoalptxmge" path="res://audio/sfx/Footsteps/Single/Gravel/Reverb/SFX_Footstep_Gravel_04_R.wav" id="473_8hbu5"]
[ext_resource type="Texture2D" uid="uid://l5ym7gi82l1b" path="res://art/ui/UI/Watercan-ui/Tropfen-ui-6.png" id="473_g32y8"]
[ext_resource type="Resource" uid="uid://fnb0n0w2ktuc" path="res://resources/low code/farming/var_cursorOnField.tres" id="474_ogmln"]
[ext_resource type="AudioStream" uid="uid://4555a4w30tda" path="res://audio/sfx/Footsteps/Single/Gravel/Reverb/SFX_Footstep_Gravel_05_R.wav" id="474_t1d6r"]
[ext_resource type="Texture2D" uid="uid://3t1m2xi4ks75" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0018.png" id="474_tu801"]
[ext_resource type="AudioStream" uid="uid://dpqvnogggvgea" path="res://audio/sfx/Footsteps/Single/Gravel/Reverb/SFX_Footstep_Gravel_06_R.wav" id="475_83c4i"]
@@ -2163,6 +2164,7 @@ _movingPlayer = NodePath("../CharacterBody2D")
_wateringParticles = NodePath("../pouring water vfx")
_wateringCanParticlesVerticalOffset = -100.0
_fieldOffsetVector = Vector2i(735, 600)
_cursorOnField = ExtResource("474_ogmln")
[node name="pouring water vfx" type="CPUParticles2D" parent="."]
position = Vector2(-652, -599)
+28 -2
View File
@@ -1,5 +1,6 @@
[gd_scene load_steps=19 format=3 uid="uid://b1d2e7ely6hyw"]
[gd_scene load_steps=23 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"]
[ext_resource type="Texture2D" uid="uid://cgmu3qlovdr22" path="res://art/masks/field_outline_1.png" id="2_w8caw"]
[ext_resource type="Texture2D" uid="uid://50qn027e5lvh" path="res://art/masks/field_outline_2_outline.png" id="3_2eegd"]
@@ -18,10 +19,17 @@
[ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="15_i4qwg"]
[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="Script" uid="uid://dfpyjxivcuidr" path="res://scripts/CSharp/Low Code/Variables/VariableSetter.cs" id="19_lgya6"]
[ext_resource type="Resource" uid="uid://fnb0n0w2ktuc" path="res://resources/low code/farming/var_cursorOnField.tres" id="20_lgya6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_57jmp"]
size = Vector2(600, 400)
[node name="BaseField" type="Node2D"]
script = ExtResource("1_4mg73")
Payload = 0
[node name="FieldBehaviour" type="Sprite2D" parent="." node_paths=PackedStringArray("_fieldSprite", "_maskSprite", "_outlineSprite", "PlantingInteraction", "PlantingPlaceholder", "FieldInteractionArea")]
[node name="FieldBehaviour" type="Sprite2D" parent="." node_paths=PackedStringArray("_fieldSprite", "_maskSprite", "_outlineSprite", "PlantingInteraction", "PlantingPlaceholder", "FieldInteractionArea", "_fieldIndex")]
z_index = -1
scale = Vector2(0.9, 1)
script = ExtResource("1_qa01x")
@@ -37,6 +45,7 @@ PlantingPlaceholder = NodePath("PlantPlaceholder")
ItemRepository = ExtResource("7_w8caw")
FieldInteractionArea = NodePath("../InteractionArea")
_sceneKeyProvider = ExtResource("11_cjahb")
_fieldIndex = NodePath("..")
[node name="MaskedField" type="Sprite2D" parent="FieldBehaviour"]
clip_children = 1
@@ -71,7 +80,24 @@ _itemResourcesToListenFor = Array[Object]([ExtResource("15_i4qwg"), ExtResource(
script = ExtResource("14_w08sx")
_itemResourcesToListenFor = Array[Object]([ExtResource("17_1mi0u")])
[node name="FieldCreationBlocker" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="FieldCreationBlocker"]
shape = SubResource("RectangleShape2D_57jmp")
[node name="CursorOnFieldSetter" type="Node" parent="FieldCreationBlocker"]
script = ExtResource("19_lgya6")
_variableResource = ExtResource("20_lgya6")
_payloadToSet = true
[node name="CursorNotOnFieldSetter" type="Node" parent="FieldCreationBlocker"]
script = ExtResource("19_lgya6")
_variableResource = ExtResource("20_lgya6")
_payloadToSet = false
[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="mouse_entered" from="FieldCreationBlocker" to="FieldCreationBlocker/CursorOnFieldSetter" method="Set"]
[connection signal="mouse_exited" from="FieldCreationBlocker" to="FieldCreationBlocker/CursorNotOnFieldSetter" method="Set"]