parent
bef54420e4
commit
9499c27444
@ -1,12 +1,20 @@
|
|||||||
[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="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"]
|
[ext_resource type="PackedScene" uid="uid://dugr6ff1g7hi0" path="res://prefabs/interactions/detector.tscn" id="2_8hh05"]
|
||||||
|
[ext_resource type="Script" uid="uid://b4n0nlu4ckqga" path="res://scripts/CSharp/Common/CharacterControls/RaycastDetector.cs" id="2_va8tx"]
|
||||||
|
|
||||||
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_detector")]
|
[node name="DetectionCross" type="Node2D" node_paths=PackedStringArray("_collider", "_detector")]
|
||||||
script = ExtResource("1_va8tx")
|
script = ExtResource("1_va8tx")
|
||||||
_detector = NodePath("detector")
|
_collider = NodePath("detector")
|
||||||
_xOffset = 400.0
|
_detector = NodePath("Raycast")
|
||||||
_yOffset = 300.0
|
_xOffset = 200.0
|
||||||
|
_yOffset = 200.0
|
||||||
|
|
||||||
|
[node name="Raycast" type="RayCast2D" parent="."]
|
||||||
|
top_level = true
|
||||||
|
target_position = Vector2(257, -149)
|
||||||
|
collide_with_areas = true
|
||||||
|
script = ExtResource("2_va8tx")
|
||||||
|
|
||||||
[node name="detector" parent="." instance=ExtResource("2_8hh05")]
|
[node name="detector" parent="." instance=ExtResource("2_8hh05")]
|
||||||
|
|||||||
@ -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"
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||||
|
|
||||||
|
public partial class RaycastDetector : RayCast2D
|
||||||
|
{
|
||||||
|
[Export] private bool _active = true;
|
||||||
|
|
||||||
|
private DetectableInteractionArea? _lastDetected;
|
||||||
|
|
||||||
|
public bool IsActive
|
||||||
|
{
|
||||||
|
get => _active;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Visible = value;
|
||||||
|
_active = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
|
if (!_active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (IsColliding())
|
||||||
|
{
|
||||||
|
if (GetCollider() is DetectableInteractionArea interactionArea)
|
||||||
|
{
|
||||||
|
if (_lastDetected != null && _lastDetected != interactionArea)
|
||||||
|
{
|
||||||
|
_lastDetected.NoLongerDetected();
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastDetected = interactionArea;
|
||||||
|
interactionArea.Detected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
uid://b4n0nlu4ckqga
|
||||||
Loading…
Reference in new issue