mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 19:15:53 +00:00
Animated switches
This commit is contained in:
parent
07be138a1b
commit
f7240e1167
6 changed files with 422 additions and 233 deletions
|
|
@ -15,13 +15,13 @@ public partial class Switch3D : Interactable3D
|
|||
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
||||
|
||||
[Signal]
|
||||
public delegate void OnActivatedEventHandler(ActivationType activationType);
|
||||
public delegate void OnActivatedEventHandler(ActivationType activationType, bool success);
|
||||
|
||||
private AudioStreamPlayer _activationSound;
|
||||
private AudioStreamPlayer _denySound;
|
||||
|
||||
private readonly string _activationSoundName = "ActivationSound";
|
||||
private readonly string _denySoundName = "ActivationSound";
|
||||
private readonly string _denySoundName = "DenySound";
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -60,8 +60,6 @@ public partial class Switch3D : Interactable3D
|
|||
_denySound?.Play();
|
||||
return false;
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.OnActivated, (int)activationTypeToUse);
|
||||
|
||||
// Compatibility for old single system
|
||||
bool success = ActivateTarget(Target, activationTypeToUse);
|
||||
|
|
@ -83,13 +81,14 @@ public partial class Switch3D : Interactable3D
|
|||
_denySound?.Play();
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.OnActivated, (int)activationTypeToUse, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool ActivateTarget(Node target, ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
if (target is not IActivable activable) return false;
|
||||
activable?.Activate(activationType);
|
||||
activable.Activate(activationType);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue