diff --git a/prefabs/characters/Player2D.tscn b/prefabs/characters/Player2D.tscn index 3388b8a..52279ee 100644 --- a/prefabs/characters/Player2D.tscn +++ b/prefabs/characters/Player2D.tscn @@ -2086,6 +2086,7 @@ stream_6/stream = ExtResource("476_deeju") [node name="Vesna" type="Node2D" node_paths=PackedStringArray("_farmingControls", "_player2d", "_vesnaAnimations")] y_sort_enabled = true +position = Vector2(0, 2) script = ExtResource("1_yd5ep") _farmingControls = NodePath("FarmingControls") _player2d = NodePath("CharacterBody2D") @@ -2162,10 +2163,6 @@ _movingPlayer = NodePath("../CharacterBody2D") _wateringParticles = NodePath("../pouring water vfx") _wateringCanParticlesVerticalOffset = -100.0 -[node name="dialogic toggle" type="Node2D" parent="."] -position = Vector2(0, 374) -script = ExtResource("819_4na52") - [node name="pouring water vfx" type="CPUParticles2D" parent="."] position = Vector2(-652, -599) rotation = -0.333807 @@ -2209,7 +2206,5 @@ wait_time = 0.5 [connection signal="EventRaised" from="CharacterBody2D/PickedUpInteractableListener" to="CharacterBody2D/visuals" method="PlayPickUpAnimation"] [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"] -[connection signal="timelineStarted" from="dialogic toggle" to="." method="DisableMovement"] [connection signal="timelineStarted" from="DialogicToggle" to="SFX/FootstepsAudio/Timer" method="stop"] [connection signal="timeout" from="SFX/FootstepsAudio/Timer" to="SFX/FootstepsAudio" method="PlayOneShot"] diff --git a/project.godot b/project.godot index ba8ecf8..f394b07 100644 --- a/project.godot +++ b/project.godot @@ -147,7 +147,6 @@ directories/tres_directory={ "default_vn_style": "res://addons/dialogic/Modules/DefaultLayoutParts/Style_VN_Default/default_vn_style.tres", "event_PickedUpInteractable": "res://resources/low code/interactables/event_PickedUpInteractable.tres", "event_colorButtonClicked": "res://resources/low code/test/event_colorButtonClicked.tres", -"event_fieldCreated": "res://resources/low code/farming/event_fieldCreated.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", diff --git a/resources/low code/farming/event_fieldCreated.tres b/resources/low code/farming/event_fieldCreated.tres deleted file mode 100644 index 9422781..0000000 --- a/resources/low code/farming/event_fieldCreated.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="Resource" script_class="EventResource" load_steps=2 format=3 uid="uid://cvgs0ojdo1jyu"] - -[ext_resource type="Script" uid="uid://ci3t5mvnopntg" path="res://scripts/CSharp/Low Code/Events/EventResource.cs" id="1_x3jnq"] - -[resource] -script = ExtResource("1_x3jnq") -metadata/_custom_type_script = "uid://ci3t5mvnopntg" diff --git a/scenes/Babushka_scene_farm_outside_2d.tscn b/scenes/Babushka_scene_farm_outside_2d.tscn index 549d7e2..792a193 100644 --- a/scenes/Babushka_scene_farm_outside_2d.tscn +++ b/scenes/Babushka_scene_farm_outside_2d.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=117 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="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"] @@ -28,7 +28,6 @@ [ext_resource type="Texture2D" uid="uid://dg7rlugnq0t45" path="res://art/farm/farming/farmobjekte/brünnen.png" id="21_ualyd"] [ext_resource type="Texture2D" uid="uid://bcw6oeovkmiup" path="res://art/nature/baum märz 2025/sonnenblumeseamless.png" id="23_d77e7"] [ext_resource type="PackedScene" uid="uid://dfvgp1my5rydh" path="res://prefabs/characters/Yeli.tscn" id="24_wtdui"] -[ext_resource type="Script" uid="uid://dhxtdhfqx3bte" path="res://scripts/CSharp/Common/Farming/FieldService2D.cs" id="25_0qu0h"] [ext_resource type="PackedScene" uid="uid://dpbbroif2tnil" path="res://prefabs/interactions/generic_item_on_ground_2d.tscn" id="25_hukxv"] [ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="27_klb81"] [ext_resource type="Resource" uid="uid://dlcmqfjvgphqu" path="res://resources/items/rake.tres" id="28_6b2nr"] @@ -39,7 +38,6 @@ [ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="35_64mdn"] [ext_resource type="Texture2D" uid="uid://65e44yde224q" path="res://art/farm/Babushka_house_01.png" id="36_e5b7x"] [ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="36_fv1t2"] -[ext_resource type="Texture2D" uid="uid://b4krfobwq3r3h" path="res://art/test_tomatos.png" id="36_l7ekk"] [ext_resource type="AudioStream" uid="uid://cfqg50am0swb7" path="res://audio/Music/Farming_90BPM_69Bars_Loop.wav" id="37_8ey8m"] [ext_resource type="AudioStream" uid="uid://dku1rq5cocisg" path="res://audio/Music/Farming_90BPM_69Bars.wav" id="37_di1ed"] [ext_resource type="Shader" uid="uid://braevmqauoek7" path="res://shader/swaying_plant.gdshader" id="37_taxvr"] @@ -211,13 +209,13 @@ shader_parameter/tiling_scale = Vector2(1, 20) shader = ExtResource("13_kt1wx") shader_parameter/tiling_scale = Vector2(1, 25) -[sub_resource type="RectangleShape2D" id="RectangleShape2D_2nee2"] -size = Vector2(5782, 1176) - [sub_resource type="RectangleShape2D" id="RectangleShape2D_p6n74"] resource_local_to_scene = true size = Vector2(7150, 1192) +[sub_resource type="RectangleShape2D" id="RectangleShape2D_2nee2"] +size = Vector2(5782, 1176) + [sub_resource type="ShaderMaterial" id="ShaderMaterial_lwk6t"] shader = ExtResource("13_7p0hq") shader_parameter/hue_shift = 0.0 @@ -1106,10 +1104,6 @@ shape = SubResource("CircleShape2D_tm0yg") [node name="Icon" parent="YSorted/SeedPickup" index="4"] scale = Vector2(1, 1) -[node name="Sprite2D" type="Sprite2D" parent="YSorted/SeedPickup"] -texture = ExtResource("36_l7ekk") -region_enabled = true - [node name="SeedPickup2" parent="YSorted" instance=ExtResource("25_hukxv")] position = Vector2(10705, 2257) _finiteSupply = 3 @@ -2099,27 +2093,22 @@ rotation = 1.5708 scale = Vector2(0.1, 10.8) texture = ExtResource("21_if5vh") -[node name="FieldParent" type="Node2D" parent="YSorted/Farm visuals" node_paths=PackedStringArray("fields", "_allowedArea")] -position = Vector2(53, 20) +[node name="Area2D" type="Area2D" parent="YSorted/Farm visuals"] +position = Vector2(5, 4.098892) scale = Vector2(1, 0.993819) -script = ExtResource("25_0qu0h") -fields = {} -_allowedArea = NodePath("Area2D") -metadata/_custom_type_script = "uid://dhxtdhfqx3bte" - -[node name="Area2D" type="Area2D" parent="YSorted/Farm visuals/FieldParent"] -position = Vector2(-48, -16) collision_mask = 5 collision_priority = 10.0 -[node name="CollisionShape2D" type="CollisionShape2D" parent="YSorted/Farm visuals/FieldParent/Area2D"] -position = Vector2(2896, 2949) -shape = SubResource("RectangleShape2D_2nee2") - -[node name="CollisionShape2D2" type="CollisionShape2D" parent="YSorted/Farm visuals/FieldParent/Area2D"] -position = Vector2(11914, 2960) +[node name="CollisionShape2D2" type="CollisionShape2D" parent="YSorted/Farm visuals/Area2D"] +position = Vector2(11913.999, 2960) +scale = Vector2(0.99999994, 0.99999994) shape = SubResource("RectangleShape2D_p6n74") +[node name="CollisionShape2D" type="CollisionShape2D" parent="YSorted/Farm visuals/Area2D"] +position = Vector2(2895.9998, 2949) +scale = Vector2(0.99999994, 0.99999994) +shape = SubResource("RectangleShape2D_2nee2") + [node name="Blocker" type="Node2D" parent="YSorted"] [node name="Fence Door2" type="Sprite2D" parent="YSorted/Blocker"] @@ -2428,8 +2417,8 @@ timeline = "quest2_tomatoes_end" [connection signal="SuccessfulPickUp" from="YSorted/SeedPickup" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="SuccessfulPickUp" from="YSorted/SeedPickup2" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="InteractedTool" from="YSorted/Farm visuals/Static/EnterHouseInteraction" to="." method="LoadSceneAtIndex"] -[connection signal="FieldCreated" from="YSorted/Farm visuals/FieldParent" to="Audio/SFX/Farming SFX" method="PlayOneShot"] -[connection signal="input_event" from="YSorted/Farm visuals/FieldParent/Area2D" to="YSorted/Vesna/FarmingControls" method="InputEventPressedOn"] +[connection signal="mouse_entered" from="YSorted/Farm visuals/Area2D" to="YSorted/Vesna/FarmingControls" method="CanCreateFields"] +[connection signal="mouse_exited" from="YSorted/Farm visuals/Area2D" to="YSorted/Vesna/FarmingControls" method="CannotCreateFields"] [connection signal="InteractedTool" from="YSorted/Blocker/InteractionArea" to="." method="LoadSceneAtIndex"] [connection signal="GoalReached" from="YSorted/ducks" to="YSorted/ducks/DialogicToggle" method="ToggleDialogue"] [connection signal="DuckCollected" from="YSorted/ducks/Duck2" to="YSorted/ducks" method="Increment"] diff --git a/scripts/CSharp/Common/Farming/FarmingControls2D.cs b/scripts/CSharp/Common/Farming/FarmingControls2D.cs index d0c4080..1a19e83 100644 --- a/scripts/CSharp/Common/Farming/FarmingControls2D.cs +++ b/scripts/CSharp/Common/Farming/FarmingControls2D.cs @@ -1,3 +1,4 @@ +using System; using Babushka.scripts.CSharp.Low_Code.Variables; using Godot; using Godot.Collections; @@ -17,7 +18,7 @@ public partial class FarmingControls2D : Node2D private int _toolId = -1; private bool _wateringCanFilled = false; - + private bool _canCreateFields = false; [Signal] public delegate void WateringFieldEventHandler(); @@ -60,14 +61,12 @@ public partial class FarmingControls2D : Node2D if (_toolId == WateringCanState.WATERING_CAN_ID && WateringCanState.GetFillState() > 0) { - GD.Print("Trying to use the watering can."); Vector2I adjustedPosition = GetAdjustedMousePosition(); WaterTheField(adjustedPosition); } - if (_toolId == 0) + if (_canCreateFields && _toolId == 0) { - GD.Print("Trying to create a field."); Vector2I adjustedPosition = GetAdjustedMousePosition(); MakeField(adjustedPosition); } @@ -82,43 +81,19 @@ public partial class FarmingControls2D : Node2D return adjustedPosition; } - /// - /// Called by the allowed farming area collision area 2d. - /// - /// - /// - /// - public void InputEventPressedOn(Node node, InputEvent inputEvent, int shapeIndex) + private Vector2I AdjustValue(Vector2I input, Vector2I step) { - // Bug is here: Whenever I use the collider to limit the farming area, Godot crashes after 10 fields. - /* - GD.Print($"Input event registered on {node.Name} as {inputEvent.GetType().Name}."); - if (!inputEvent.IsPressed()) - { - return; - } + return input.Snapped(step); + } + + public void CanCreateFields() + { + _canCreateFields = true; + } - if (!inputEvent.IsActionPressed("click")) - return; - - if (inputEvent is InputEventMouseButton inputEventMouseButton) - { - if (!inputEventMouseButton.Pressed) - { - return; - } - } - else - { - return; - } - - if (_toolId == 0) - { - Vector2I adjustedPosition = GetAdjustedMousePosition(); - MakeField(adjustedPosition); - } - */ + public void CannotCreateFields() + { + _canCreateFields = false; } #region WATERING @@ -135,14 +110,12 @@ public partial class FarmingControls2D : Node2D FieldBehaviour2D? field = FieldService.Instance.TryGet(_sceneKeyProvider.Payload.AsString(), fieldPosition); if (field == null || field.FieldState == FieldState.Watered) { - GD.Print($"The field at position {fieldPosition} is null!"); return; } field.Water(); _wateringParticles.GlobalPosition = new Vector2(field.GlobalPosition.X, field.GlobalPosition.Y + _wateringCanParticlesVerticalOffset); WateringCanState.Water(); - GD.Print($"Watered the field at {fieldPosition}."); EmitSignal(SignalName.WateringField); } @@ -163,20 +136,20 @@ public partial class FarmingControls2D : Node2D // add dictionary entry for the field Array fields = field2d.FindChildren("*", nameof(FieldBehaviour2D)); if (fields.Count > 0) + { FieldService.Instance.TryAddEntry(_sceneKeyProvider.Payload.AsString(), fieldPosition, fields[0] as FieldBehaviour2D); + } // reposition and reparent the instance - field2d.Position = new Vector2(fieldPosition.X, fieldPosition.Y);; + field2d.Position = new Vector2(fieldPosition.X, fieldPosition.Y); + FieldService.Instance.AddChild(fieldInstance); EmitSignal(SignalName.FieldCreated); } } } - private Vector2I AdjustValue(Vector2I input, Vector2I step) - { - return input.Snapped(step); - } + #endregion } \ No newline at end of file diff --git a/scripts/CSharp/Common/Farming/FieldService.cs b/scripts/CSharp/Common/Farming/FieldService.cs index 0647892..80e4770 100644 --- a/scripts/CSharp/Common/Farming/FieldService.cs +++ b/scripts/CSharp/Common/Farming/FieldService.cs @@ -51,11 +51,9 @@ public partial class FieldService : Node { if (field.fields.TryGetValue(fieldPosition, out FieldBehaviour2D? fieldInstance)) { - GD.Print("Getting field..."); return fieldInstance; } } - GD.Print($"No field found for key: {key} and position: {fieldPosition} "); return null; }