Effect based audio
This commit is contained in:
parent
63930450a3
commit
c0145c7c7d
4 changed files with 39 additions and 3 deletions
27
scripts/audio/EffectBasedPlayer.cs
Normal file
27
scripts/audio/EffectBasedPlayer.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newlon.Components;
|
||||
using Newlon.Systems.Effects;
|
||||
|
||||
public partial class EffectBasedPlayer : Node
|
||||
{
|
||||
[Export] public Array<Effect> effectsToMap;
|
||||
[Export] public Array<AudioStream> streamsToMapTo;
|
||||
private System.Collections.Generic.Dictionary<Effect, AudioStream> effectToAudioMap = new();
|
||||
public override void _Ready()
|
||||
{
|
||||
GetParent<Entity>().EffectStarted += OnEffectStarted;
|
||||
|
||||
for (int i = 0; i < effectsToMap.Count; i++)
|
||||
{
|
||||
effectToAudioMap.Add(effectsToMap[i], streamsToMapTo[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEffectStarted(Effect what)
|
||||
{
|
||||
if (effectToAudioMap.ContainsKey(what) == false) return;
|
||||
AudioSequencer.Play(what.Slot, effectToAudioMap[what]);
|
||||
}
|
||||
}
|
||||
1
scripts/audio/EffectBasedPlayer.cs.uid
Normal file
1
scripts/audio/EffectBasedPlayer.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b8r6fxsfjdo3a
|
||||
Loading…
Add table
Add a link
Reference in a new issue