public SoundEffectInstance PlaySoundEffect(string soundEffect, bool looped = false, AudioEmitter emitter = null, AudioListener listener = null) { if (null != SkipContent.SkipCutscene && SkipContent.SkipCutscene.Enabled) { return(null); } LoadSoundEffect(soundEffect); var Instance = SoundEffects[soundEffect].CreateInstance(); Instance.Volume = EffectiveSoundEffectVolume; Instance.IsLooped = looped; if (null != emitter && null != listener) { try { Instance.Apply3D(listener.Listener, emitter.Emitter); } catch (AccessViolationException) { } } PlayingInstances.Add(Instance); if (!SoundDisabled) { Instance.Play(); } else { Instance.Stop(); } return(Instance); }
/// <summary> /// Plays a sound effect and returns the SoundEffectInstance. /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static SoundEffectInstance PlaySoundEffect(string fileName, bool looped = false, STACK.Components.AudioEmitter emitter = null, STACK.Components.AudioListener listener = null) { return(Tree.World.Get <AudioManager>().PlaySoundEffect(fileName, looped, emitter, listener)); }