diff --git a/prefabs/characters/Player2D.tscn b/prefabs/characters/Player2D.tscn index 4e36931..5ce1757 100644 --- a/prefabs/characters/Player2D.tscn +++ b/prefabs/characters/Player2D.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=482 format=3 uid="uid://c25udixd5m6l0"] +[gd_scene load_steps=484 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"] @@ -272,8 +272,10 @@ [ext_resource type="Texture2D" uid="uid://vahac0df0dhj" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0008.png" id="464_pbc3r"] [ext_resource type="PackedScene" uid="uid://pflu0uaig7vv" path="res://prefabs/interactions/detection_cross.tscn" id="466_e04c3"] [ext_resource type="Texture2D" uid="uid://b37lpqrsjjuc0" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0010.png" id="466_pw1ip"] +[ext_resource type="Script" uid="uid://bc6uaaxsx5k5p" path="res://scripts/CSharp/Low Code/Events/EventListener.cs" id="467_8hbu5"] [ext_resource type="Script" uid="uid://er03dkj8axlr" path="res://scripts/CSharp/Common/UI/WateringCanUi.cs" id="467_j4m0f"] [ext_resource type="Texture2D" uid="uid://oi11ax6tml6j" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0012.png" id="468_08021"] +[ext_resource type="Resource" uid="uid://b4hawvsc7cmkn" path="res://resources/low code/farming/event_newPlantCreated.tres" id="468_t1d6r"] [ext_resource type="Texture2D" uid="uid://dsjj23763pej5" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0014.png" id="470_bmmei"] [ext_resource type="AudioStream" uid="uid://ce5mxs2yrwgrh" path="res://audio/sfx/Footsteps/Single/Gravel/Reverb/SFX_Footstep_Gravel_01_R.wav" id="470_dnm27"] [ext_resource type="Script" uid="uid://dx25g14a7xi4w" path="res://scripts/CSharp/Common/Audio/AudioPlayer.cs" id="471_2f15g"] @@ -2103,7 +2105,7 @@ position = Vector2(-24, -13) shape = SubResource("CircleShape2D_ssqtd") debug_color = Color(0.923708, 0.202722, 0.475262, 0.42) -[node name="visuals" type="Node2D" parent="CharacterBody2D" node_paths=PackedStringArray("_sprite", "_wateringParticles") groups=["Pickup", "PlantGrowing"]] +[node name="visuals" type="Node2D" parent="CharacterBody2D" node_paths=PackedStringArray("_sprite", "_wateringParticles") groups=["Pickup"]] position = Vector2(0, -374) script = ExtResource("3_f6xmn") _sprite = NodePath("Animated Sprites") @@ -2142,6 +2144,10 @@ scrollable = false [node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")] position = Vector2(0, -200) +[node name="PlantCreatedEventListener" type="Node" parent="CharacterBody2D"] +script = ExtResource("467_8hbu5") +_eventResources = Array[Object]([ExtResource("468_t1d6r")]) + [node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer", "_wateringParticles")] script = ExtResource("817_6nrw3") _fieldPrefab = ExtResource("818_16w6h") @@ -2192,6 +2198,7 @@ wait_time = 0.5 [connection signal="PickedUpTool" from="." to="CharacterBody2D/visuals" method="ActivateTool"] [connection signal="PickedUpTool" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"] [connection signal="LookDirection" from="CharacterBody2D/visuals" to="CharacterBody2D/DetectionCross" method="SetDirection"] +[connection signal="EventRaised" from="CharacterBody2D/PlantCreatedEventListener" to="CharacterBody2D/visuals" method="PlayFarmingAnimation"] [connection signal="WateringField" from="FarmingControls" to="CharacterBody2D/visuals" method="PlayWateringAnimation"] [connection signal="WateringField" from="FarmingControls" to="CharacterBody2D/WateringCanUI" method="Water"] [connection signal="timelineEnded" from="dialogic toggle" to="." method="EnableMovement"] diff --git a/prefabs/farm/base_field.tscn b/prefabs/farm/base_field.tscn index ab21577..43b27a3 100644 --- a/prefabs/farm/base_field.tscn +++ b/prefabs/farm/base_field.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://b1d2e7ely6hyw"] +[gd_scene load_steps=11 format=3 uid="uid://b1d2e7ely6hyw"] [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"] @@ -8,6 +8,8 @@ [ext_resource type="Texture2D" uid="uid://ctvdxwgmfaj5c" path="res://art/farm/tilable grounds/böden/nasse farming erde.png" id="6_7m4xq"] [ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="7_2eegd"] [ext_resource type="Resource" uid="uid://d284vxftxhym0" path="res://resources/itemRepository.tres" id="7_w8caw"] +[ext_resource type="Script" uid="uid://b5dotkx17gvxg" path="res://scripts/CSharp/Low Code/Events/EventRaiser.cs" id="9_teirr"] +[ext_resource type="Resource" uid="uid://b4hawvsc7cmkn" path="res://resources/low code/farming/event_newPlantCreated.tres" id="10_wx561"] [node name="BaseField" type="Node2D"] @@ -39,4 +41,9 @@ position = Vector2(-16, -54) _active = false _spriteToOutline = NodePath("../FieldBehaviour/MaskedField/FieldTexture") +[node name="PlantCreationEventRaiser" type="Node" parent="."] +script = ExtResource("9_teirr") +_eventResources = Array[Object]([ExtResource("10_wx561")]) + +[connection signal="Planted" from="FieldBehaviour" to="PlantCreationEventRaiser" method="RaiseEvents"] [connection signal="Interacted" from="InteractionArea" to="FieldBehaviour" method="Farm"] diff --git a/project.godot b/project.godot index 177a1b4..30e30a1 100644 --- a/project.godot +++ b/project.godot @@ -145,6 +145,7 @@ directories/tres_directory={ "default_stylebox": "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/default_stylebox.tres", "default_vn_style": "res://addons/dialogic/Modules/DefaultLayoutParts/Style_VN_Default/default_vn_style.tres", "event_colorButtonClicked": "res://resources/low code/test/event_colorButtonClicked.tres", +"event_newPlantCreated": "res://resources/low code/farming/event_newPlantCreated.tres", "event_textLabelClicked": "res://resources/low code/test/event_textLabelClicked.tres", "farming_equipment_glossary": "res://dialog/farming_equipment_glossary.tres", "hoe": "res://resources/items/hoe.tres", @@ -215,7 +216,6 @@ folder_colors={ [global_group] -PlantGrowing="" Pickup="" [input] diff --git a/resources/low code/farming/event_newPlantCreated.tres b/resources/low code/farming/event_newPlantCreated.tres new file mode 100644 index 0000000..754f2e2 --- /dev/null +++ b/resources/low code/farming/event_newPlantCreated.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://b4hawvsc7cmkn"] + +[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_o6pnj"] + +[resource] +script = ExtResource("1_o6pnj") +metadata/_custom_type_script = "uid://ci3t5mvnopntg" diff --git a/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs b/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs index 19ad9d0..30d8f4d 100644 --- a/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs +++ b/scripts/CSharp/Common/Farming/FieldBehaviour2D.cs @@ -21,6 +21,8 @@ public partial class FieldBehaviour2D : Sprite2D public Vector2 FieldPosition; + [Signal] public delegate void PlantedEventHandler(); + public override void _Ready() { UpdateFieldState(FieldState); @@ -65,13 +67,14 @@ public partial class FieldBehaviour2D : Sprite2D } /// - /// Called when the player enters the field's interaction area and presses . + /// Called when the player enters the field's interaction area and presses or clicks. /// public void Farm() { if (TryPlant()) - { - UpdateFieldState(FieldState.Planted); + { + EmitSignal(SignalName.Planted); + UpdateFieldState(FieldState.Planted); } } diff --git a/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs b/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs index 6a3439a..ca8bc30 100644 --- a/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs +++ b/scripts/CSharp/Common/Farming/PlantBehaviour2D.cs @@ -39,7 +39,6 @@ public partial class PlantBehaviour2D : Node2D { if (_state == PlantState.None) { - GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation); _state = PlantState.Planted; _currentPlantSprite = GetRandomSprite(_seeds); _currentPlantSprite.Visible = true; @@ -52,7 +51,6 @@ public partial class PlantBehaviour2D : Node2D public void Grow() { - GetTree().CallGroup("PlantGrowing", VesnaAnimations.MethodName.PlayFarmingAnimation); GrowPlant(); }