mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 22:05:55 +00:00
Alarm box
This commit is contained in:
parent
d8e1459194
commit
60dad2d002
15 changed files with 581 additions and 401 deletions
32
Scripts/AlarmManager.cs
Normal file
32
Scripts/AlarmManager.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue