mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Chest animation, alarm box entity
This commit is contained in:
parent
f28a3b70fd
commit
164c186201
25 changed files with 177 additions and 23 deletions
42
Scripts/Interactables/AlarmBox3D.cs
Normal file
42
Scripts/Interactables/AlarmBox3D.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
1
Scripts/Interactables/AlarmBox3D.cs.uid
Normal file
1
Scripts/Interactables/AlarmBox3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dxhf1twoxf4j0
|
||||
Loading…
Add table
Add a link
Reference in a new issue