mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
42 lines
No EOL
1.1 KiB
C#
42 lines
No EOL
1.1 KiB
C#
using Godot;
|
|
|
|
namespace Cirno.Scripts.Interactables;
|
|
|
|
[Tool]
|
|
public partial class AlarmBox3D : Interactable3D
|
|
{
|
|
private AudioStreamPlayer _activationSound;
|
|
private readonly string _activationSoundName = "ActivationSound";
|
|
|
|
[Signal] public delegate void OnActivatedEventHandler(ActivationType activationType);
|
|
public override void _Ready()
|
|
{
|
|
if (Engine.IsEditorHint()) return;
|
|
|
|
_activationSound = GetNodeOrNull<AudioStreamPlayer>(_activationSoundName);
|
|
|
|
if (AlarmManager.Instance is not null)
|
|
{
|
|
AlarmManager.Instance.AlarmEnabled3D += OnAlarmEnabled3D;
|
|
}
|
|
}
|
|
|
|
private void OnAlarmEnabled3D(Vector3 location)
|
|
{
|
|
// TODO: set animation, make blinky
|
|
GD.Print($"Enabled alarm in box {this.Name}");
|
|
}
|
|
|
|
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
|
{
|
|
EmitSignal(SignalName.OnActivated, (int)activationType);
|
|
|
|
if (AlarmManager.Instance is not null)
|
|
{
|
|
_activationSound.Play();
|
|
AlarmManager.Instance.DisableAlarm();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
} |