feature/detection_cross #21
@@ -1,4 +1,5 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArea2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fefbd3244e8e427e388f389cc304f90548d56b58a375097a197ac2eb8259990bb_003FArea2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArea3D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F8a54226fa2e1c9371a8091f24cfd744aef11fe6869527dc23b9b837623a29b9_003FArea3D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAudioStreamPlayer2D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F848324b1c23114c3f5e8bbb5a42c4ade394c59a7a7a133a66b76581ca571_003FAudioStreamPlayer2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ABabushka_002Escripts_002ECSharp_002ECommon_002EFarming_002EFieldBehaviour2D_005FScriptMethods_002Egenerated_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F75d11718f1abbc2572fd32e4b83acbec9d79ac_003FBabushka_002Escripts_002ECSharp_002ECommon_002EFarming_002EFieldBehaviour2D_005FScriptMethods_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=481 format=3 uid="uid://c25udixd5m6l0"]
|
||||
[gd_scene load_steps=482 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"]
|
||||
@@ -270,6 +270,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://cw68t2kbcvlen" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0004.png" id="460_6b7gh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dh3cfbcqm0fs4" path="res://art/animation/Vesna2D/Vesna Anims Tools/F01-Idle-Gießkanne/0006.png" id="462_6yyoj"]
|
||||
[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://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"]
|
||||
@@ -2101,6 +2102,7 @@ z_index = 1
|
||||
y_sort_enabled = true
|
||||
position = Vector2(-24, -13)
|
||||
shape = SubResource("CircleShape2D_ssqtd")
|
||||
disabled = true
|
||||
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"]]
|
||||
@@ -2139,6 +2141,9 @@ step = 0.0
|
||||
editable = false
|
||||
scrollable = false
|
||||
|
||||
[node name="DetectionCross" parent="CharacterBody2D" instance=ExtResource("466_e04c3")]
|
||||
position = Vector2(0, -400)
|
||||
|
||||
[node name="FarmingControls" type="Node2D" parent="." node_paths=PackedStringArray("_movingPlayer", "_wateringParticles")]
|
||||
script = ExtResource("817_6nrw3")
|
||||
_fieldPrefab = ExtResource("818_16w6h")
|
||||
@@ -2188,6 +2193,10 @@ wait_time = 0.5
|
||||
[connection signal="InventorySelectionChanged" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"]
|
||||
[connection signal="PickedUpTool" from="." to="CharacterBody2D/visuals" method="ActivateTool"]
|
||||
[connection signal="PickedUpTool" from="." to="CharacterBody2D/WateringCanUI" method="IsWateringCanActive"]
|
||||
[connection signal="LookingDown" from="CharacterBody2D/visuals" to="CharacterBody2D/DetectionCross" method="ActivateDown"]
|
||||
[connection signal="LookingLeft" from="CharacterBody2D/visuals" to="CharacterBody2D/DetectionCross" method="ActivateLeft"]
|
||||
[connection signal="LookingRight" from="CharacterBody2D/visuals" to="CharacterBody2D/DetectionCross" method="ActivateRight"]
|
||||
[connection signal="LookingUp" from="CharacterBody2D/visuals" to="CharacterBody2D/DetectionCross" method="ActivateUp"]
|
||||
[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"]
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
[gd_scene load_steps=3 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("_left", "_right", "_up", "_down")]
|
||||
script = ExtResource("1_va8tx")
|
||||
_left = NodePath("detector_left")
|
||||
_right = NodePath("detector_right")
|
||||
_up = NodePath("detector_top")
|
||||
_down = NodePath("detector_bottom")
|
||||
|
||||
[node name="detector_right" parent="." instance=ExtResource("2_8hh05")]
|
||||
position = Vector2(300, 250)
|
||||
|
||||
[node name="detector_left" parent="." instance=ExtResource("2_8hh05")]
|
||||
position = Vector2(-300, 250)
|
||||
|
||||
[node name="detector_top" parent="." instance=ExtResource("2_8hh05")]
|
||||
position = Vector2(0, -200)
|
||||
|
||||
[node name="detector_bottom" parent="." instance=ExtResource("2_8hh05")]
|
||||
position = Vector2(0, 700)
|
||||
@@ -0,0 +1,17 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dugr6ff1g7hi0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c3pd60biootsx" path="res://scripts/CSharp/Common/CharacterControls/Detector.cs" id="1_6pib0"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qwv4c"]
|
||||
size = Vector2(300, 300)
|
||||
|
||||
[node name="right" type="Area2D"]
|
||||
collision_layer = 4
|
||||
script = ExtResource("1_6pib0")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_qwv4c")
|
||||
debug_color = Color(0.9459047, 7.2196126e-06, 0.5925879, 0.41960785)
|
||||
|
||||
[connection signal="InteractableEntered" from="." to="CollisionShape2D" method="hide"]
|
||||
[connection signal="InteractableExited" from="." to="CollisionShape2D" method="show"]
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cqc72e4hq6bcd"]
|
||||
[gd_scene load_steps=6 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="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"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_npluf"]
|
||||
resource_local_to_scene = true
|
||||
@@ -16,8 +17,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")
|
||||
@@ -49,5 +52,5 @@ text = "[E]"
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 2
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="OnPlayerEntered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="OnPlayerExited"]
|
||||
[connection signal="area_entered" from="Area2D" to="." method="OnPlayerEntered"]
|
||||
[connection signal="area_exited" from="Area2D" to="." method="OnPlayerExited"]
|
||||
|
||||
@@ -14,6 +14,11 @@ public partial class VesnaAnimations : Node
|
||||
private string _toolString;
|
||||
private int _toolID = -1; // -1 means no tool.
|
||||
private Vector2 _lastDirection = Vector2.Zero;
|
||||
|
||||
[Signal] public delegate void LookingRightEventHandler();
|
||||
[Signal] public delegate void LookingLeftEventHandler();
|
||||
[Signal] public delegate void LookingUpEventHandler();
|
||||
[Signal] public delegate void LookingDownEventHandler();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -44,6 +49,7 @@ public partial class VesnaAnimations : Node
|
||||
_sprite.Animation = "back walking" + _toolString;
|
||||
anyActionPressed = true;
|
||||
_lastDirection = Vector2.Up;
|
||||
EmitSignal(SignalName.LookingUp);
|
||||
walkingAnimationPicked = true;
|
||||
}
|
||||
|
||||
@@ -52,6 +58,7 @@ public partial class VesnaAnimations : Node
|
||||
_sprite.Animation = "front walking" + _toolString;
|
||||
anyActionPressed = true;
|
||||
_lastDirection = Vector2.Down;
|
||||
EmitSignal(SignalName.LookingDown);
|
||||
walkingAnimationPicked = true;
|
||||
}
|
||||
|
||||
@@ -61,6 +68,7 @@ public partial class VesnaAnimations : Node
|
||||
_sprite.Animation = "side walking" + _toolString;
|
||||
anyActionPressed = true;
|
||||
_lastDirection = Vector2.Right;
|
||||
EmitSignal(SignalName.LookingRight);
|
||||
walkingAnimationPicked = true;
|
||||
}
|
||||
|
||||
@@ -70,6 +78,7 @@ public partial class VesnaAnimations : Node
|
||||
_sprite.Animation = "side walking" + _toolString;
|
||||
anyActionPressed = true;
|
||||
_lastDirection = Vector2.Left;
|
||||
EmitSignal(SignalName.LookingLeft);
|
||||
walkingAnimationPicked = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
|
||||
public partial class DetectableInteractionArea : Area2D
|
||||
{
|
||||
[Export] private InteractionArea2D _interactionArea2D;
|
||||
|
||||
public void ActivateInteractionArea(bool activate)
|
||||
{
|
||||
_interactionArea2D.IsActive = activate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cp2q4k62sjo6h
|
||||
@@ -0,0 +1,125 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks where an interactable object is with regards to the player.
|
||||
/// </summary>
|
||||
public partial class DetectionCross : Node2D
|
||||
{
|
||||
[Export] private Detector _left;
|
||||
[Export] private Detector _right;
|
||||
[Export] private Detector _up;
|
||||
[Export] private Detector _down;
|
||||
[Export] private bool _active = true;
|
||||
|
||||
[Signal] public delegate void InteractableDetectedLeftEventHandler(bool flag);
|
||||
[Signal] public delegate void InteractableDetectedRightEventHandler(bool flag);
|
||||
[Signal] public delegate void InteractableDetectedUpEventHandler(bool flag);
|
||||
[Signal] public delegate void InteractableDetectedDownEventHandler(bool flag);
|
||||
|
||||
private bool _leftOccupied;
|
||||
private bool _rightOccupied;
|
||||
private bool _upOccupied;
|
||||
private bool _downOccupied;
|
||||
public bool LeftOccupied {
|
||||
get
|
||||
{
|
||||
return _leftOccupied;
|
||||
}
|
||||
private set
|
||||
{
|
||||
EmitSignal(SignalName.InteractableDetectedLeft, value);
|
||||
_leftOccupied = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RightOccupied
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rightOccupied;
|
||||
}
|
||||
private set
|
||||
{
|
||||
EmitSignal(SignalName.InteractableDetectedRight, value);
|
||||
_rightOccupied = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpOccupied
|
||||
{
|
||||
get
|
||||
{
|
||||
return _upOccupied;
|
||||
}
|
||||
private set
|
||||
{
|
||||
EmitSignal(SignalName.InteractableDetectedUp, value);
|
||||
_upOccupied = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DownOccupied
|
||||
{
|
||||
get
|
||||
{
|
||||
return _downOccupied;
|
||||
}
|
||||
private set
|
||||
{
|
||||
EmitSignal(SignalName.InteractableDetectedDown, value);
|
||||
_downOccupied = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get => _active;
|
||||
set => _active = value;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_right.InteractableEntered += () => RightOccupied = true;
|
||||
_right.InteractableExited += () => RightOccupied = false;
|
||||
_left.InteractableEntered += () => LeftOccupied = true;
|
||||
_left.InteractableExited += () => LeftOccupied = false;
|
||||
_up.InteractableEntered += () => UpOccupied = true;
|
||||
_up.InteractableExited += () => UpOccupied = false;
|
||||
_down.InteractableEntered += () => DownOccupied = true;
|
||||
_down.InteractableExited += () => DownOccupied = false;
|
||||
}
|
||||
|
||||
public void ActivateUp()
|
||||
{
|
||||
_up.IsActive = true;
|
||||
_down.IsActive = false;
|
||||
_left.IsActive = false;
|
||||
_right.IsActive = false;
|
||||
}
|
||||
|
||||
public void ActivateDown()
|
||||
{
|
||||
_up.IsActive = false;
|
||||
_down.IsActive = true;
|
||||
_left.IsActive = false;
|
||||
_right.IsActive = false;
|
||||
}
|
||||
|
||||
public void ActivateRight()
|
||||
{
|
||||
_up.IsActive = false;
|
||||
_down.IsActive = false;
|
||||
_left.IsActive = false;
|
||||
_right.IsActive = true;
|
||||
}
|
||||
|
||||
public void ActivateLeft()
|
||||
{
|
||||
_up.IsActive = false;
|
||||
_down.IsActive = false;
|
||||
_left.IsActive = true;
|
||||
_right.IsActive = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ccc6m6c5khd2x
|
||||
@@ -0,0 +1,63 @@
|
||||
using Babushka.scripts.CSharp.Common.Services;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
|
||||
public partial class Detector : Area2D
|
||||
{
|
||||
[Export] private bool _active = true;
|
||||
[Export] private bool _oneAtATime = true;
|
||||
|
||||
[Signal] public delegate void InteractableEnteredEventHandler();
|
||||
[Signal] public delegate void InteractableExitedEventHandler();
|
||||
|
||||
private DetectableInteractionArea? _currentInteractionArea;
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get => _active;
|
||||
set => _active = value;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
AreaEntered += OnEnteredInteractable;
|
||||
AreaExited += OnExitedInteractable;
|
||||
}
|
||||
|
||||
public void OnEnteredInteractable(Node body)
|
||||
{
|
||||
if (!_active || !InputService.Instance.InputEnabled)
|
||||
return;
|
||||
|
||||
GD.Print("Entered Node2D.");
|
||||
|
||||
if (body is DetectableInteractionArea interactionArea2D)
|
||||
{
|
||||
GD.Print("Entered interactable.");
|
||||
_currentInteractionArea = interactionArea2D;
|
||||
interactionArea2D.ActivateInteractionArea(true);
|
||||
EmitSignal(SignalName.InteractableEntered);
|
||||
if (_oneAtATime)
|
||||
_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnExitedInteractable(Node body)
|
||||
{
|
||||
GD.Print("Exited Node2D.");
|
||||
|
||||
if (body is DetectableInteractionArea interactionArea2D)
|
||||
{
|
||||
GD.Print("Exited interactable.");
|
||||
|
||||
if (_oneAtATime && _currentInteractionArea != interactionArea2D)
|
||||
return;
|
||||
|
||||
interactionArea2D.ActivateInteractionArea(false);
|
||||
_currentInteractionArea = null;
|
||||
EmitSignal(SignalName.InteractableExited);
|
||||
_active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c3pd60biootsx
|
||||
Reference in New Issue
Block a user