mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 01:45:53 +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);
|
||||
|
|
|
|||
|
|
@ -30,9 +30,10 @@ public partial class ElevatorProxy : Area2D, IActivable
|
|||
|
||||
public InteractionController CachedPlayer { get; private set; }
|
||||
|
||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
EmitSignal(SignalName.Activated, (int)activationType);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _on_area_entered(Area2D area)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue