using System.Collections.Generic; using System.IO; using CoreGame; using Entitas; using Framw.AudioFramework; namespace CoreGame.Render { public class AudioPlaySystem : ReactiveSystem { private IGroup m_AudioPlayProxyGroup; public AudioPlaySystem(Contexts contexts) : base(contexts.combat) { // m_AudioPlayProxyGroup = contexts.combat.GetGroup(CombatMatcher.Audio); } protected override ICollector GetTrigger(IContext context) { return context.CreateCollector(CombatMatcher.Audio); } protected override bool Filter(CombatEntity entity) { return true; } protected override void Execute(List entities) { for (int i = 0; i < entities.Count; i++) { var audio = entities[i].audio; while (audio != null && audio.audioDatas.Count > 0) { var audioData = audio.audioDatas.Dequeue(); var tbSound = SoundDescMgr.Instance.GetConfig(audioData.soundId); if(tbSound == null) continue; if (audioData.isStop && audioData.soundIndex != 0) { SoundManager.Instance.StopLoop(audioData.soundIndex); audio.audioLoopIndexes.Remove(audioData.soundIndex); continue; } if (audioData.isLoop) { audioData.soundIndex = SoundManager.Instance.PlayLoop(tbSound.path); audio.audioLoopIndexes.Add(audioData.soundIndex); } else { audioData.soundIndex = SoundManager.Instance.PlayOneShot(tbSound.path); } } } } } }