diff --git a/art/farm/Babushka_house_frontDoor.png b/art/farm/Babushka_house_frontDoor.png new file mode 100644 index 0000000..f8378f8 Binary files /dev/null and b/art/farm/Babushka_house_frontDoor.png differ diff --git a/art/farm/Babushka_house_frontDoor.png.import b/art/farm/Babushka_house_frontDoor.png.import new file mode 100644 index 0000000..6b13bf1 --- /dev/null +++ b/art/farm/Babushka_house_frontDoor.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ccy6bwunhfvrf" +path="res://.godot/imported/Babushka_house_frontDoor.png-345830acb7ae8cbbb97011f89455fd91.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/farm/Babushka_house_frontDoor.png" +dest_files=["res://.godot/imported/Babushka_house_frontDoor.png-345830acb7ae8cbbb97011f89455fd91.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/Babushka_scene_farm_outside_2d.tscn b/scenes/Babushka_scene_farm_outside_2d.tscn index a788d7f..8cf2734 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=105 format=3 uid="uid://gigb28qk8t12"] +[gd_scene load_steps=108 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"] @@ -37,13 +37,16 @@ [ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/wateringcan.tres" id="28_ipqaa"] [ext_resource type="Resource" uid="uid://datee0flk1e84" path="res://resources/items/scythe.tres" id="29_wtdui"] [ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="32_2nee2"] +[ext_resource type="Script" uid="uid://boehox1ydbcnx" path="res://scripts/CSharp/Common/Farming/WellBehaviour.cs" id="32_lbnqo"] [ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="34_e5b7x"] [ext_resource type="Texture2D" uid="uid://65e44yde224q" path="res://art/farm/Babushka_house_01.png" id="36_e5b7x"] [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"] [ext_resource type="Texture2D" uid="uid://bq2wojyy4ptva" path="res://art/nature/baum märz 2025/sonnenblume7.png" id="38_2rjny"] +[ext_resource type="Material" uid="uid://blch5kdhkbj75" path="res://art/materials/intaractable_outline.tres" id="38_tm0yg"] [ext_resource type="AudioStream" uid="uid://fsiypqhql67w" path="res://audio/sfx/Farming/SFX_GettingWater_01.wav" id="39_di1ed"] +[ext_resource type="Texture2D" uid="uid://ccy6bwunhfvrf" path="res://art/farm/Babushka_house_frontDoor.png" id="39_lbnqo"] [ext_resource type="AudioStream" uid="uid://foyw26hq1qp5" path="res://audio/sfx/Farming/SFX_GettingWater_02.wav" id="40_ceriq"] [ext_resource type="Script" uid="uid://cfnrd5k1k0gxw" path="res://scripts/CSharp/Common/AudioPlayer.cs" id="40_w3jkj"] [ext_resource type="Texture2D" uid="uid://dgavbfci8x178" path="res://art/nature/grass/grass-1.png" id="41_apj51"] @@ -1031,7 +1034,7 @@ _wateringCan = ExtResource("28_ipqaa") [node name="FarmingControls" parent="YSorted/Vesna" index="1" node_paths=PackedStringArray("_camera")] _camera = NodePath("../../../Camera2D") -[node name="Brünnen" type="Sprite2D" parent="YSorted"] +[node name="Brünnen" type="Sprite2D" parent="YSorted" node_paths=PackedStringArray("_interactionArea")] z_index = 1 y_sort_enabled = true material = SubResource("ShaderMaterial_2vojv") @@ -1040,6 +1043,8 @@ texture = ExtResource("21_ualyd") offset = Vector2(0, -800) region_enabled = true region_rect = Rect2(0, 0, 1504, 1686) +script = ExtResource("32_lbnqo") +_interactionArea = NodePath("InteractionArea") [node name="StaticBody2D" type="StaticBody2D" parent="YSorted/Brünnen"] collision_mask = 4 @@ -1048,7 +1053,10 @@ collision_mask = 4 position = Vector2(145.5, -224) shape = SubResource("RectangleShape2D_0sfl7") -[node name="InteractionArea" parent="YSorted/Brünnen" instance=ExtResource("27_klb81")] +[node name="InteractionArea" parent="YSorted/Brünnen" node_paths=PackedStringArray("_spriteToOutline") instance=ExtResource("27_klb81")] +_active = false +_outlineMaterial = ExtResource("38_tm0yg") +_spriteToOutline = NodePath("..") _id = 1 [node name="CollisionShape3D" parent="YSorted/Brünnen/InteractionArea/Area2D" index="0"] @@ -1124,13 +1132,18 @@ collision_mask = 6 position = Vector2(-252.56, 231.32) polygon = PackedVector2Array(247.227, 43.5123, 44.7822, 43.5123, -87.2178, 45.123, -104.329, -55.2797, -154.107, -73.5347, -160.107, -380.38, -175.44, -400.783, -63.44, -512.461, 97.8934, -541.991, 261.671, -599.172, 374.782, -526.421, 502.338, -526.421, 637.893, -396.488, 598.56, -360.783, 596.338, -58.2327, 528.782, -58.2327, 501.449, 45.9283) -[node name="EnterHouseInteraction" parent="YSorted/Farm visuals/Static" instance=ExtResource("27_klb81")] +[node name="EnterHouseInteraction" parent="YSorted/Farm visuals/Static" node_paths=PackedStringArray("_spriteToOutline") instance=ExtResource("27_klb81")] position = Vector2(5839, 2349) scale = Vector2(2.425, 2.425) -_useOutline = false -_useSprite = false +_outlineMaterial = ExtResource("38_tm0yg") +_spriteToOutline = NodePath("DoorSprite") _id = 0 +[node name="DoorSprite" type="Sprite2D" parent="YSorted/Farm visuals/Static/EnterHouseInteraction"] +position = Vector2(0.412364, -33.1959) +scale = Vector2(1.8649, 1.54554) +texture = ExtResource("39_lbnqo") + [node name="greenery" type="Node2D" parent="YSorted/Farm visuals/Static"] [node name="left side" type="Node2D" parent="YSorted/Farm visuals/Static/greenery"] diff --git a/scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs b/scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs index 6e5187f..13278fa 100644 --- a/scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs +++ b/scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs @@ -1,3 +1,4 @@ +using System; using Godot; namespace Babushka.scripts.CSharp.Common.CharacterControls; @@ -6,6 +7,7 @@ public partial class InteractionArea2D : Node2D { [Export] private Area2D _area; [Export] private Label _label; + [Export] private bool _active = true; [Export] private bool _useOutline = true; [Export] private ShaderMaterial _outlineMaterial; [Export] private bool _useSprite = true; @@ -17,17 +19,32 @@ public partial class InteractionArea2D : Node2D [Signal] public delegate void InteractedToolEventHandler(int id); // TODO: remove [Signal] public delegate void InteractedEventHandler(); - public bool IsActive { get; set; } = true; + public bool IsActive + { + get => _active; + set => _active = value; + } + public override void _Ready() { - if(_useSprite && _useOutline) - _backupMaterial = _spriteToOutline.Material; + if (_useSprite && _useOutline) + { + try + { + _backupMaterial = _spriteToOutline.Material; + } + catch(Exception exception) + { + GD.PrintErr($"No sprite to outline found on: {GetParent().Name}" + exception.Message); + } + } + } public void OnPlayerEntered(Node2D player) { - if (!IsActive) + if (!_active) return; if(_showLabel) @@ -41,7 +58,7 @@ public partial class InteractionArea2D : Node2D public void OnPlayerExited(Node2D player) { - if (!IsActive) + if (!_active) return; _label.Hide(); @@ -54,31 +71,34 @@ public partial class InteractionArea2D : Node2D public override void _Input(InputEvent @event) { - if (!IsActive) + if (!_active) return; - if (@event.IsAction("interact") && @event.IsPressed() && _area.HasOverlappingBodies()) + if (@event.IsAction("interact") && @event.IsPressed()) { - _label.Hide(); + if (_area.HasOverlappingBodies()) + { + _label.Hide(); - if (_useSprite && _useOutline) - _spriteToOutline.Material = _backupMaterial; + if (_useSprite && _useOutline) + _spriteToOutline.Material = _backupMaterial; - EmitSignal(SignalName.InteractedTool, _id); - EmitSignal(SignalName.Interacted); + EmitSignal(SignalName.InteractedTool, _id); + EmitSignal(SignalName.Interacted); + } } } public void SetSpriteActiveState(bool success, int id) // TODO: remove { GD.PrintErr("SetSpriteActiveState is being called."); - if(!IsActive) + if(!_active) return; } public void ToggleActive() { - IsActive = !IsActive; + _active = !_active; _label.Hide(); } } \ No newline at end of file diff --git a/scripts/CSharp/Common/Farming/FieldState.cs.uid b/scripts/CSharp/Common/Farming/FieldState.cs.uid new file mode 100644 index 0000000..2f0fe65 --- /dev/null +++ b/scripts/CSharp/Common/Farming/FieldState.cs.uid @@ -0,0 +1 @@ +uid://cqtlic8xxtvkc diff --git a/scripts/CSharp/Common/Farming/PlantState.cs.uid b/scripts/CSharp/Common/Farming/PlantState.cs.uid new file mode 100644 index 0000000..714ae0d --- /dev/null +++ b/scripts/CSharp/Common/Farming/PlantState.cs.uid @@ -0,0 +1 @@ +uid://dw5dl5yscbyaw diff --git a/scripts/CSharp/Common/Farming/WateringCanState.cs b/scripts/CSharp/Common/Farming/WateringCanState.cs index 8e4e89c..333a44d 100644 --- a/scripts/CSharp/Common/Farming/WateringCanState.cs +++ b/scripts/CSharp/Common/Farming/WateringCanState.cs @@ -23,6 +23,10 @@ public static class WateringCanState /// Triggers animations and ui. /// public static bool Active = false; + + public delegate void WateringCanDelegate(bool state); + public static event WateringCanDelegate WateringCanActiveStateChanged; + /// @@ -65,6 +69,8 @@ public static class WateringCanState /// public static void SetActive(bool active) { + if(active != Active) + WateringCanActiveStateChanged?.Invoke(active); Active = active; } } \ No newline at end of file diff --git a/scripts/CSharp/Common/Farming/WellBehaviour.cs b/scripts/CSharp/Common/Farming/WellBehaviour.cs new file mode 100644 index 0000000..51b2958 --- /dev/null +++ b/scripts/CSharp/Common/Farming/WellBehaviour.cs @@ -0,0 +1,19 @@ +using Babushka.scripts.CSharp.Common.CharacterControls; +using Godot; + +namespace Babushka.scripts.CSharp.Common.Farming; + +public partial class WellBehaviour : Node2D +{ + [Export] private InteractionArea2D _interactionArea; + + public override void _Ready() + { + WateringCanState.WateringCanActiveStateChanged += OnWateringCanStateChanged; + } + + private void OnWateringCanStateChanged(bool state) + { + _interactionArea.IsActive = state; + } +} \ No newline at end of file diff --git a/scripts/CSharp/Common/Farming/WellBehaviour.cs.uid b/scripts/CSharp/Common/Farming/WellBehaviour.cs.uid new file mode 100644 index 0000000..cec2b49 --- /dev/null +++ b/scripts/CSharp/Common/Farming/WellBehaviour.cs.uid @@ -0,0 +1 @@ +uid://boehox1ydbcnx diff --git a/scripts/CSharp/Common/Fight/FightAttack.cs.uid b/scripts/CSharp/Common/Fight/FightAttack.cs.uid new file mode 100644 index 0000000..5744876 --- /dev/null +++ b/scripts/CSharp/Common/Fight/FightAttack.cs.uid @@ -0,0 +1 @@ +uid://cnggo5jyimosu