mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 17:15:55 +00:00
3D Cameras with sweep and animation
This commit is contained in:
parent
4cc7a0c004
commit
7e76edc153
48 changed files with 3211 additions and 1511 deletions
|
|
@ -5,35 +5,53 @@ namespace Cirno.Scripts.Interactables;
|
|||
[Tool]
|
||||
public partial class AlarmBox3D : Interactable3D
|
||||
{
|
||||
private AudioStreamPlayer _activationSound;
|
||||
private readonly string _activationSoundName = "ActivationSound";
|
||||
private AnimationPlayer _animationPlayer;
|
||||
public StringName FlashAnimationName { get; private set; } = "Flash";
|
||||
|
||||
[Signal] public delegate void OnActivatedEventHandler(ActivationType activationType);
|
||||
|
||||
[Signal]
|
||||
public delegate void PlayActivationSoundEventHandler();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
|
||||
_activationSound = GetNodeOrNull<AudioStreamPlayer>(_activationSoundName);
|
||||
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
|
||||
//CallDeferred(MethodName.InitDeferred);
|
||||
InitDeferred();
|
||||
}
|
||||
|
||||
private void InitDeferred()
|
||||
{
|
||||
if (AlarmManager.Instance is not null)
|
||||
{
|
||||
AlarmManager.Instance.AlarmEnabled3D += OnAlarmEnabled3D;
|
||||
AlarmManager.Instance.AlarmDisabled += InstanceOnAlarmDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void InstanceOnAlarmDisabled()
|
||||
{
|
||||
_animationPlayer.Stop();
|
||||
}
|
||||
|
||||
private void OnAlarmEnabled3D(Vector3 location)
|
||||
{
|
||||
// TODO: set animation, make blinky
|
||||
GD.Print($"Enabled alarm in box {this.Name}");
|
||||
_animationPlayer.Play(FlashAnimationName);
|
||||
}
|
||||
|
||||
public override bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
EmitSignal(SignalName.OnActivated, (int)activationType);
|
||||
|
||||
EmitSignalPlayActivationSound();
|
||||
if (AlarmManager.Instance is not null)
|
||||
{
|
||||
_activationSound.Play();
|
||||
//_activationSound?.Play();
|
||||
|
||||
AlarmManager.Instance.DisableAlarm();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue