mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 23:05:55 +00:00
Interactable interface
This commit is contained in:
parent
49e58ff735
commit
54d9824581
27 changed files with 102 additions and 61 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using Cirno.Scripts.Components.FSM;
|
||||
using Cirno.Scripts.Interactables;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
|
@ -17,11 +18,11 @@ public partial class ActivationProvider : Area2D
|
|||
|
||||
[Export] private AudioStreamPlayer2D _errorSound;
|
||||
|
||||
[Signal]
|
||||
public delegate void InteractableAreaEnteredEventHandler(Interactable interactable);
|
||||
//[Signal]
|
||||
//public delegate void InteractableAreaEnteredEventHandler(Interactable interactable);
|
||||
|
||||
[Signal]
|
||||
public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
|
||||
//[Signal]
|
||||
//public delegate void InteractableAreaExitedEventHandler(Interactable interactable);
|
||||
|
||||
public void Init(CharacterBody2D actor)
|
||||
{
|
||||
|
|
@ -80,9 +81,9 @@ public partial class ActivationProvider : Area2D
|
|||
private void _on_interaction_controller_area_entered(Area2D area)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
if (area.IsInGroup("Interactable") && area is Interactable interactable && interactable.CanActivate())
|
||||
if (area.IsInGroup("Interactable") && area is IInteractable interactable && interactable.CanActivate())
|
||||
{
|
||||
EmitSignal(nameof(InteractableAreaEntered), interactable);
|
||||
//EmitSignal(nameof(InteractableAreaEntered), interactable);
|
||||
|
||||
if (_selector == null) return;
|
||||
|
||||
|
|
@ -93,9 +94,9 @@ public partial class ActivationProvider : Area2D
|
|||
private void _on_interaction_controller_area_exited(Area2D area)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
if (area.IsInGroup("Interactable") && area is Interactable interactable)
|
||||
if (area.IsInGroup("Interactable") && area is IInteractable interactable)
|
||||
{
|
||||
EmitSignal(nameof(InteractableAreaExited), interactable);
|
||||
//EmitSignal(nameof(InteractableAreaExited), interactable);
|
||||
|
||||
if (_selector == null) return;
|
||||
_selector.RemoveInteractable(interactable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue