27 lines
745 B
C#
27 lines
745 B
C#
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]);
|
|
}
|
|
}
|