Compare commits

...

9 Commits

18 changed files with 148 additions and 61 deletions
+4 -2
View File
@@ -9,7 +9,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="_builds/Babushka_win_0_5/Babushka.exe"
export_path="_builds/Babushka_showcase_6a/Babushka.exe"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
@@ -26,6 +26,7 @@ debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/timestamp=true
@@ -79,7 +80,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="_builds/Babushka_linux_0_5/Babushka.x86_64"
export_path="_builds/Babushka_showcase_lux_06a/Babushka.x86_64"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
@@ -96,6 +97,7 @@ debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
+3 -3
View File
@@ -2123,9 +2123,6 @@ frame = 7
frame_progress = 0.229832
offset = Vector2(0, -450)
[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")])
@@ -2175,6 +2172,9 @@ scrollable = false
script = ExtResource("472_kduih")
_wateringCanFillStateNode = NodePath("../WateringCanFillState")
[node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")]
position = Vector2(0, -260)
[node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer")]
script = ExtResource("817_6nrw3")
_sceneKeyProvider = ExtResource("471_83c4i")
+1 -3
View File
@@ -1,8 +1,7 @@
[gd_scene load_steps=25 format=3 uid="uid://muuxxgvx33fp"]
[gd_scene load_steps=24 format=3 uid="uid://muuxxgvx33fp"]
[ext_resource type="Script" uid="uid://7m1rt7agb6rm" path="res://scripts/CSharp/Common/Temp/MVPDuck.cs" id="1_54k4r"]
[ext_resource type="Texture2D" uid="uid://hvchk6t0xe7j" path="res://art/animals/Ente.png" id="1_cgxhx"]
[ext_resource type="Resource" uid="uid://tt3d166mntmi" path="res://resources/low code/farming/var_sceneNameProvider.tres" id="2_fdf3t"]
[ext_resource type="AudioStream" uid="uid://qv0aubjeyi0u" path="res://audio/sfx/Animals/SFX_Duck_Quack_01.wav" id="3_kjie1"]
[ext_resource type="Script" uid="uid://cfnrd5k1k0gxw" path="res://scripts/CSharp/Common/AudioPlayer2D.cs" id="3_rdn2q"]
[ext_resource type="AudioStream" uid="uid://da84l8e44scwh" path="res://audio/sfx/Animals/SFX_Duck_Quack_02.wav" id="4_54k4r"]
@@ -143,7 +142,6 @@ viewport_path = NodePath("SubViewport")
z_index = 1
y_sort_enabled = true
script = ExtResource("1_54k4r")
_sceneKeyProvider = ExtResource("2_fdf3t")
_transferDelayMs = 1000
_animationPlayer = NodePath("AnimationPlayer")
+1
View File
@@ -74,6 +74,7 @@ texture = ExtResource("5_wx561")
y_sort_enabled = true
[node name="InteractionArea" parent="FieldBehaviour" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("7_2eegd")]
process_mode = 4
position = Vector2(-28.88889, -57)
scale = Vector2(1.1111112, 1)
_active = false
+16 -7
View File
@@ -1,12 +1,21 @@
[gd_scene load_steps=3 format=3 uid="uid://pflu0uaig7vv"]
[gd_scene load_steps=4 format=3 uid="uid://pflu0uaig7vv"]
[ext_resource type="Script" uid="uid://ccc6m6c5khd2x" path="res://scripts/CSharp/Common/CharacterControls/DetectionCross.cs" id="1_va8tx"]
[ext_resource type="PackedScene" uid="uid://dugr6ff1g7hi0" path="res://prefabs/interactions/detector.tscn" id="2_8hh05"]
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_detector")]
script = ExtResource("1_va8tx")
_detector = NodePath("detector")
_xOffset = 400.0
_yOffset = 300.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_va8tx"]
[node name="detector" parent="." instance=ExtResource("2_8hh05")]
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_collider", "_shapeCast2D")]
script = ExtResource("1_va8tx")
_collider = NodePath("detector")
_shapeCast2D = NodePath("ShapeCast2D")
_xOffset = 200.0
_yOffset = 200.0
[node name="detector" parent="." node_paths=PackedStringArray("_shapeCast2D") instance=ExtResource("2_8hh05")]
_shapeCast2D = NodePath("../ShapeCast2D")
[node name="ShapeCast2D" type="ShapeCast2D" parent="."]
shape = SubResource("RectangleShape2D_va8tx")
target_position = Vector2(200, 0)
collide_with_areas = true
+6 -4
View File
@@ -1,14 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://dugr6ff1g7hi0"]
[gd_scene load_steps=4 format=3 uid="uid://dugr6ff1g7hi0"]
[ext_resource type="Script" uid="uid://c3pd60biootsx" path="res://scripts/CSharp/Common/CharacterControls/Detector.cs" id="1_6pib0"]
[ext_resource type="Resource" uid="uid://clwqh3w5aqi5e" path="res://resources/low code/interactables/var_interactableToTrigger.tres" id="2_3fanv"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qwv4c"]
size = Vector2(100, 400)
[sub_resource type="CircleShape2D" id="CircleShape2D_6pib0"]
radius = 300.0
[node name="detector" type="Area2D"]
collision_layer = 4
script = ExtResource("1_6pib0")
_itemToTriggerResource = ExtResource("2_3fanv")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_qwv4c")
shape = SubResource("CircleShape2D_6pib0")
debug_color = Color(0.9459047, 7.2196126e-06, 0.5925879, 0.41960785)
+10 -4
View File
@@ -1,8 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://cqc72e4hq6bcd"]
[gd_scene load_steps=8 format=3 uid="uid://cqc72e4hq6bcd"]
[ext_resource type="Script" uid="uid://ckp413wrub5fm" path="res://scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs" id="1_5ajrf"]
[ext_resource type="Resource" uid="uid://clwqh3w5aqi5e" path="res://resources/low code/interactables/var_interactableToTrigger.tres" id="2_o1drf"]
[ext_resource type="Material" uid="uid://blch5kdhkbj75" path="res://art/materials/simple_interactable_outline.tres" id="2_qoey7"]
[ext_resource type="Script" uid="uid://cp2q4k62sjo6h" path="res://scripts/CSharp/Common/CharacterControls/DetectableInteractionArea.cs" id="3_2wrrq"]
[ext_resource type="Script" uid="uid://pqemey80frcq" path="res://scripts/CSharp/Low Code/Variables/VariableListener.cs" id="4_gj2nu"]
[sub_resource type="CircleShape2D" id="CircleShape2D_npluf"]
resource_local_to_scene = true
@@ -17,9 +19,10 @@ _area = NodePath("Area2D")
_label = NodePath("Area2D/CanvasLayer/MarginContainer/Label")
_outlineMaterial = ExtResource("2_qoey7")
[node name="Area2D" type="Area2D" parent="."]
[node name="Area2D" type="Area2D" parent="." node_paths=PackedStringArray("interactionArea2D")]
collision_mask = 4
script = ExtResource("3_2wrrq")
interactionArea2D = NodePath("..")
[node name="CollisionShape3D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_npluf")
@@ -51,5 +54,8 @@ text = "[E]"
horizontal_alignment = 2
vertical_alignment = 2
[connection signal="area_entered" from="Area2D" to="." method="OnPlayerEntered"]
[connection signal="area_exited" from="Area2D" to="." method="OnPlayerExited"]
[node name="SelectionListener" type="Node" parent="."]
script = ExtResource("4_gj2nu")
_variableResources = Array[Object]([ExtResource("2_o1drf")])
[connection signal="NewEventPayload" from="SelectionListener" to="Area2D" method="InteractionAreaSelectionChanged"]
+1
View File
@@ -176,6 +176,7 @@ directories/tres_directory={
"unselected_stylebox": "res://addons/dialogic/Editor/Events/styles/unselected_stylebox.tres",
"var_ColorTestValue": "res://resources/low code/test/var_ColorTestValue.tres",
"var_Counter": "res://resources/low code/test/var_Counter.tres",
"var_interactableToTrigger": "res://resources/low code/interactables/var_interactableToTrigger.tres",
"var_sceneNameProvider": "res://resources/low code/farming/var_sceneNameProvider.tres",
"var_wateredFieldPosition": "res://resources/low code/farming/var_wateredFieldPosition.tres",
"vesna_style": "res://addons/dialogic/vesna_style.tres",
@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="VariableResource" load_steps=2 format=3 uid="uid://clwqh3w5aqi5e"]
[ext_resource type="Script" uid="uid://dtvx2cakx0bey" path="res://scripts/CSharp/Low Code/Variables/VariableResource.cs" id="1_casar"]
[resource]
script = ExtResource("1_casar")
Payload = null
metadata/_custom_type_script = "uid://dtvx2cakx0bey"
+6 -9
View File
@@ -985,7 +985,8 @@ collision_mask = 4
position = Vector2(145.5, -224)
shape = SubResource("RectangleShape2D_0sfl7")
[node name="InteractionArea" parent="YSorted/Well" instance=ExtResource("27_klb81")]
[node name="InteractionArea" parent="YSorted/Well" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("27_klb81")]
_spritesToOutline = [NodePath("..")]
_id = 1
metadata/SaveID = "b8f7b7fe-e057-4974-ba12-9134722998de"
@@ -2313,9 +2314,8 @@ position = Vector2(3183, 2369)
offset = Vector2(1, -50)
region_rect = Rect2(207, 1184, 149, 142)
[node name="InteractionArea" parent="YSorted/trash/trashObject2" index="0" node_paths=PackedStringArray("_spritesToOutline")]
[node name="InteractionArea" parent="YSorted/trash/trashObject2" index="0"]
position = Vector2(-9, -46)
_spritesToOutline = []
metadata/SaveID = "549bbcf4-ea57-4b8f-80b1-b13ca648559b"
[node name="trashObject3" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
@@ -2325,9 +2325,8 @@ position = Vector2(4724, 3519)
offset = Vector2(1, -50)
region_rect = Rect2(400, 1053, 163, 141)
[node name="InteractionArea" parent="YSorted/trash/trashObject3" index="0" node_paths=PackedStringArray("_spritesToOutline")]
[node name="InteractionArea" parent="YSorted/trash/trashObject3" index="0"]
position = Vector2(-13, -53)
_spritesToOutline = []
metadata/SaveID = "29874314-50c1-4a21-9494-18f936d6e097"
[node name="trashObject4" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
@@ -2337,9 +2336,8 @@ position = Vector2(5385, 3391)
offset = Vector2(1, -50)
region_rect = Rect2(1048, 1092, 348, 106)
[node name="InteractionArea" parent="YSorted/trash/trashObject4" index="0" node_paths=PackedStringArray("_spritesToOutline")]
[node name="InteractionArea" parent="YSorted/trash/trashObject4" index="0"]
position = Vector2(0, -59)
_spritesToOutline = []
metadata/SaveID = "7ccaa831-5526-40ed-8ca3-31ba2ad929a6"
[node name="trashObject5" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
@@ -2376,9 +2374,8 @@ rotation = 1.77025
offset = Vector2(0, 0)
region_rect = Rect2(1048, 1092, 348, 106)
[node name="InteractionArea" parent="YSorted/trash/trashObject9" index="0" node_paths=PackedStringArray("_spritesToOutline")]
[node name="InteractionArea" parent="YSorted/trash/trashObject9" index="0"]
position = Vector2(22.40873, 25.05658)
_spritesToOutline = []
metadata/SaveID = "7bf227d6-3844-41e9-a9cd-524052aced3b"
[node name="CanvasLayer" parent="." instance=ExtResource("32_2nee2")]
@@ -553,7 +553,7 @@ region_rect = Rect2(2748, 432, 174, 191)
[node name="Vesna" parent="." instance=ExtResource("15_7a68a")]
y_sort_enabled = false
position = Vector2(-920, 319)
position = Vector2(-4473, 319)
[node name="Yeli" parent="." instance=ExtResource("16_dhsxs")]
z_index = 0
+2 -2
View File
@@ -53,7 +53,7 @@ z_index = -100
[node name="Ceiling" type="Sprite2D" parent="Background"]
z_index = -100
position = Vector2(-2453, -1419)
position = Vector2(-2453, -1303)
scale = Vector2(2, 2)
texture = ExtResource("2_qsw8g")
region_enabled = true
@@ -61,7 +61,7 @@ region_rect = Rect2(0, 1749.6222, 3840, 358.11316)
[node name="WallUpper" type="Sprite2D" parent="Background"]
z_index = -100
position = Vector2(-2469, -969)
position = Vector2(-2469, -975)
scale = Vector2(26, 2)
texture = ExtResource("2_qsw8g")
region_enabled = true
@@ -7,4 +7,18 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// </summary>
public partial class DetectableInteractionArea : Area2D
{
[Export] public InteractionArea2D interactionArea2D;
public void InteractionAreaSelectionChanged(Variant instanceID)
{
if (instanceID.AsString() == GetInstanceId().ToString())
{
interactionArea2D.HighlightInteractable();
}
else
{
interactionArea2D.ResetHighlight();
}
}
}
@@ -7,7 +7,8 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// </summary>
public partial class DetectionCross : Node2D
{
[Export] private Detector _detector;
[Export] private Detector _collider;
[Export] private ShapeCast2D _shapeCast2D;
[Export] private float _xOffset;
[Export] private float _yOffset;
@@ -17,6 +18,8 @@ public partial class DetectionCross : Node2D
/// <param name="direction"></param>
public void SetDirection(Vector2 direction)
{
_detector.Position = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
Vector2 newPos = new Vector2(direction.X * _xOffset, direction.Y * _yOffset);
_collider.Position = newPos;
_shapeCast2D.TargetPosition = newPos;
}
}
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using Babushka.scripts.CSharp.Common.Services;
using Babushka.scripts.CSharp.Low_Code.Variables;
using Godot;
namespace Babushka.scripts.CSharp.Common.CharacterControls;
@@ -8,18 +10,11 @@ namespace Babushka.scripts.CSharp.Common.CharacterControls;
/// </summary>
public partial class Detector : Area2D
{
[Export] private bool _active = true;
[Export] private ShapeCast2D _shapeCast2D;
[Export] private VariableResource _itemToTriggerResource;
/// <summary>
/// Called when entering an interactionArea node.
/// </summary>
[Signal] public delegate void InteractableEnteredEventHandler();
/// <summary>
/// Called when exiting an interactionArea node.
/// </summary>
[Signal] public delegate void InteractableExitedEventHandler();
private List<ulong> _areasInDetector = new();
public bool IsActive
{
@@ -41,29 +36,64 @@ public partial class Detector : Area2D
/// Called every time this node enters an Area2D.
/// </summary>
/// <param name="area"></param>
public void OnEnteredInteractable(Node area)
public void OnEnteredInteractable(Area2D area)
{
if (!_active || !InputService.Instance.InputEnabled)
return;
if (area is DetectableInteractionArea interactionArea2D)
{
EmitSignal(SignalName.InteractableEntered);
}
PopulateList();
CalculateClosestInteractable();
}
/// <summary>
/// Called whenever this node exits an Area2D.
/// </summary>
/// <param name="area"></param>
public void OnExitedInteractable(Node area)
public void OnExitedInteractable(Area2D area)
{
if (!_active || !InputService.Instance.InputEnabled)
return;
if (area is DetectableInteractionArea interactionArea2D)
PopulateList();
CalculateClosestInteractable();
}
private void PopulateList()
{
EmitSignal(SignalName.InteractableExited);
// repopulate the list of areas in the detector to account for enabled / disabled areas
var currentOverlap = GetOverlappingAreas();
_areasInDetector = new List<ulong>();
foreach (var area2D in currentOverlap)
{
if (area2D is DetectableInteractionArea detectable)
{
ulong id = detectable.GetInstanceId();
_areasInDetector.Add(id);
}
}
}
private void CalculateClosestInteractable()
{
GD.Print($"Areas in detector: {_areasInDetector.Count}");
float smallestDistance = float.MaxValue;
string closestInteractable = null;
foreach (var area in _areasInDetector)
{
Area2D? area2D = InstanceFromId(area) as Area2D;
if(area2D == null)
continue;
float distance = area2D.GlobalPosition.DistanceSquaredTo(ToGlobal(_shapeCast2D.TargetPosition));
if (distance < smallestDistance)
{
closestInteractable = area.ToString();
smallestDistance = distance;
}
}
GD.Print($"Closest interactable: {closestInteractable}");
_itemToTriggerResource.Payload = closestInteractable;
}
}
@@ -25,8 +25,15 @@ public partial class InteractionArea2D : Node2D
public bool IsActive
{
get => _active;
set => _active = value;
set
{
ProcessMode = value ? ProcessModeEnum.Inherit : ProcessModeEnum.Disabled;
Visible = value;
_active = value;
}
}
public bool IsSelectedByDetector { get; set; } = false;
public void SetActiveInverse(bool active)
{
@@ -41,8 +48,10 @@ public partial class InteractionArea2D : Node2D
}
}
public void OnPlayerEntered(Node2D player)
public void HighlightInteractable()
{
IsSelectedByDetector = true;
if (!_active || !InputService.Instance.InputEnabled)
return;
@@ -54,12 +63,14 @@ public partial class InteractionArea2D : Node2D
foreach (var sprite in _spritesToOutline)
{
GD.Print($"Highlighting outline material on {sprite.Name} Nr. {GetInstanceId()}");
sprite.Material = _outlineMaterial;
}
}
public void OnPlayerExited(Node2D player)
public void ResetHighlight()
{
IsSelectedByDetector = false;
_label.Hide();
if (!_useOutline)
@@ -68,6 +79,7 @@ public partial class InteractionArea2D : Node2D
for (var i = 0; i < _spritesToOutline.Length; i++)
{
var sprite = _spritesToOutline[i];
GD.Print($"Resetting outline material on {sprite.Name} Nr. {GetInstanceId()}");
sprite.Material = _backupMaterials[i];
}
}
@@ -77,6 +89,9 @@ public partial class InteractionArea2D : Node2D
if (!_active || !InputService.Instance.InputEnabled)
return;
if(!IsSelectedByDetector)
return;
if (@event.IsAction("interact") && @event.IsPressed())
{
TryInteract();
@@ -124,4 +139,5 @@ public partial class InteractionArea2D : Node2D
_label.Hide();
}
}
@@ -32,6 +32,7 @@ public partial class FieldActivator : Node
_field.UpdateFieldState(FieldState.Tilled);
EmitSignal(SignalName.FieldCreated, _field);
_used = true;
ToggleInteractionArea();
}
}
@@ -33,7 +33,6 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
[ExportGroup("Field Interactions")]
[Export] public InteractionArea2D PlantingInteraction;
[Export] public InteractionArea2D FieldInteractionArea;
[ExportGroup("Configuration")]
[Export] public Node2D PlantingPlaceholder;
@@ -61,7 +60,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
// fieldstate == tilled && watering can ausgewählt
_canWater = (FieldState == FieldState.Tilled || FieldState == FieldState.Planted) && _wateringCanActive;
FieldInteractionArea.IsActive = _canPlant || _canWater;
PlantingInteraction.IsActive = _canPlant || _canWater;
}
public void ActivatedSeedInInventory(bool activated)