Effect based audio

This commit is contained in:
Rendo 2025-07-07 17:42:55 +05:00
commit c0145c7c7d
4 changed files with 39 additions and 3 deletions

View 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]);
}
}

View file

@ -0,0 +1 @@
uid://b8r6fxsfjdo3a