EffectBasedPlayer channel settings

This commit is contained in:
Rendo 2025-07-08 00:25:14 +05:00
commit 9820eb9445
2 changed files with 13 additions and 4 deletions

View file

@ -8,20 +8,22 @@ public partial class EffectBasedPlayer : Node
{
[Export] public Array<Effect> effectsToMap;
[Export] public Array<AudioStream> streamsToMapTo;
private System.Collections.Generic.Dictionary<Effect, AudioStream> effectToAudioMap = new();
[Export] public Array<ChannelSettings> streamSettings;
private System.Collections.Generic.Dictionary<Effect, (AudioStream,ChannelSettings)> effectToAudioMap = new();
public override void _Ready()
{
GetParent<Entity>().EffectStarted += OnEffectStarted;
for (int i = 0; i < effectsToMap.Count; i++)
{
effectToAudioMap.Add(effectsToMap[i], streamsToMapTo[i]);
effectToAudioMap.Add(effectsToMap[i], (streamsToMapTo[i],streamSettings[i]));
}
}
public void OnEffectStarted(Effect what)
{
if (effectToAudioMap.ContainsKey(what) == false) return;
AudioSequencer.Play(what.Slot, effectToAudioMap[what]);
AudioSequencer.Play(what.Slot, effectToAudioMap[what].Item1);
AudioSequencer.ChangeSettings(what.Slot, effectToAudioMap[what].Item2);
}
}