mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
32 lines
761 B
C#
32 lines
761 B
C#
|
|
using Godot;
|
|||
|
|
|
|||
|
|
namespace Cirno.Scripts;
|
|||
|
|
|
|||
|
|
public partial class AlarmManager : Node2D
|
|||
|
|
{
|
|||
|
|
public bool IsAlarmOn { get; private set; } = false;
|
|||
|
|
|
|||
|
|
public Vector2 LastAlarmPosition { get; private set; } = new Vector2();
|
|||
|
|
|
|||
|
|
[Signal]
|
|||
|
|
public delegate void AlarmEnabledEventHandler(Vector2 location);
|
|||
|
|
|
|||
|
|
[Signal]
|
|||
|
|
public delegate void AlarmDisabledEventHandler();
|
|||
|
|
|
|||
|
|
public void SoundAlarm(Vector2 location)
|
|||
|
|
{
|
|||
|
|
if (IsAlarmOn) return;
|
|||
|
|
IsAlarmOn = true;
|
|||
|
|
LastAlarmPosition = location;
|
|||
|
|
EmitSignal(nameof(AlarmEnabled), location);
|
|||
|
|
|
|||
|
|
GD.Print($"Alarm sounded at {location}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void DisableAlarm()
|
|||
|
|
{
|
|||
|
|
IsAlarmOn = false;
|
|||
|
|
EmitSignal(nameof(AlarmDisabled));
|
|||
|
|
}
|
|||
|
|
}
|