using System.Collections.Generic; using Entitas; using Framw.AudioFramework; namespace CoreGame.Render { public struct AudioData { public string soundId; public bool isLoop; public bool isStop; public int soundIndex; } [Combat] public class AudioComponent : IComponent, IReset { public int eid; internal Queue audioDatas = new(); internal List audioLoopIndexes = new(); public void PushAudioData(ref AudioData audioData) { var ent = Contexts.Combat.GetEntity(eid); if (audioDatas.Count == 0) { ent.ReplaceComponent(CombatComponentsLookup.Audio, this); } audioDatas.Enqueue(audioData); } public void Reset() { audioDatas.Clear(); for (int i = 0; i < audioLoopIndexes.Count; i++) { SoundManager.Instance.StopLoop(audioLoopIndexes[i]); } audioLoopIndexes.Clear(); } } }