mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 13:45:55 +00:00
Changed events to generic node
This commit is contained in:
parent
b89043cd8c
commit
7b2d32e727
17 changed files with 166 additions and 135 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Cirno.Scripts;
|
||||
|
||||
public partial class AlarmManager : Node2D
|
||||
public partial class AlarmManager : Node
|
||||
{
|
||||
[Export]
|
||||
public AudioStream AlarmSound { get; private set; }
|
||||
|
|
@ -12,10 +12,14 @@ public partial class AlarmManager : Node2D
|
|||
public bool IsAlarmOn { get; private set; } = false;
|
||||
|
||||
public Vector2 LastAlarmPosition { get; private set; } = new Vector2();
|
||||
public Vector3 LastAlarmPosition3D { get; private set; } = new Vector3();
|
||||
|
||||
[Signal]
|
||||
public delegate void AlarmEnabledEventHandler(Vector2 location);
|
||||
|
||||
[Signal]
|
||||
public delegate void AlarmEnabled3DEventHandler(Vector3 location);
|
||||
|
||||
[Signal]
|
||||
public delegate void AlarmDisabledEventHandler();
|
||||
|
||||
|
|
@ -40,7 +44,18 @@ public partial class AlarmManager : Node2D
|
|||
if (IsAlarmOn) return;
|
||||
IsAlarmOn = true;
|
||||
LastAlarmPosition = location;
|
||||
EmitSignal(nameof(AlarmEnabled), location);
|
||||
EmitSignalAlarmEnabled(location);
|
||||
|
||||
GD.Print($"Alarm sounded at {location}");
|
||||
_player?.Play();
|
||||
}
|
||||
|
||||
public void SoundAlarm(Vector3 location)
|
||||
{
|
||||
if (IsAlarmOn) return;
|
||||
IsAlarmOn = true;
|
||||
LastAlarmPosition3D = location;
|
||||
EmitSignalAlarmEnabled3D(location);
|
||||
|
||||
GD.Print($"Alarm sounded at {location}");
|
||||
_player?.Play();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue