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(); } GD.Print("Colliding with: " + interactionArea.GetParent().Name); _lastDetected = interactionArea; interactionArea.Detected(); } } } }