mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 02:25:54 +00:00
Event System
This commit is contained in:
parent
797e24d766
commit
f379eac5c3
10 changed files with 336 additions and 10 deletions
6
Scripts/Interactables/AreaEventTrigger.cs
Normal file
6
Scripts/Interactables/AreaEventTrigger.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace Cirno.Scripts.Interactables;
|
||||
|
||||
public partial class AreaEventTrigger
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,9 @@ public partial class AreaTrigger : Area2D
|
|||
[Export] public bool DoNotActivateOnFirst { get; set; }
|
||||
|
||||
private int _activations = 0;
|
||||
|
||||
[Signal]
|
||||
public delegate void ActivatedEventHandler();
|
||||
|
||||
public bool Activate(InteractionController player)
|
||||
{
|
||||
|
|
@ -23,12 +26,17 @@ public partial class AreaTrigger : Area2D
|
|||
|
||||
if (OneTime && _activations > 0) return false;
|
||||
|
||||
if (Target is not IActivable target)
|
||||
if (Target != null)
|
||||
{
|
||||
GD.PrintErr($"Target {Target.Name} is not activable");
|
||||
return false;
|
||||
if (Target is not IActivable target)
|
||||
{
|
||||
GD.PrintErr($"Target {Target.Name} is not activable");
|
||||
return false;
|
||||
}
|
||||
target.Activate();
|
||||
}
|
||||
target.Activate();
|
||||
|
||||
EmitSignal(nameof(Activated));
|
||||
|
||||
_activations++;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue