private void PlayShipSound(ShipEmitters emitter, ShipSounds sound, bool checkIfAlreadyPlaying = true, bool stopPrevious = true, bool useForce2D = true, bool useFadeOut = false) { MySoundPair soundPair = GetShipSound(sound); if (soundPair == MySoundPair.Empty) { return; } if (m_emitters[(int)emitter] != null) { if (checkIfAlreadyPlaying && m_emitters[(int)emitter].IsPlaying && m_emitters[(int)emitter].SoundPair == soundPair) { return; } if (m_emitters[(int)emitter].IsPlaying && useFadeOut) { var effect = MyAudio.Static.ApplyEffect(m_emitters[(int)emitter].Sound, MyStringHash.GetOrCompute("CrossFade"), new MyCueId[] { soundPair.SoundId }, 1500); m_emitters[(int)emitter].Sound = effect.OutputSound; } else { m_emitters[(int)emitter].PlaySound(soundPair, stopPrevious, force2D: useForce2D && m_shouldPlay2D); } } }
private void FadeOutSound(ShipEmitters emitter = ShipEmitters.SingleSounds, int duration = 2000) { if (m_emitters[(int)emitter].IsPlaying) { var effectSourceVoice = MyAudio.Static.ApplyEffect(m_emitters[(int)emitter].Sound, m_fadeOut, new MyCueId[] { }, duration); m_emitters[(int)emitter].Sound = effectSourceVoice.OutputSound; } if (emitter == ShipEmitters.SingleSounds) { m_playingSpeedUpOrDown = false; } }
private void PlayShipSound(ShipEmitters emitter, ShipSystemSoundsEnum sound, bool checkIfAlreadyPlaying = true, bool stopPrevious = true, bool useForce2D = true, bool useFadeOut = false) { MySoundPair soundPair = GetShipSound(sound); if (soundPair == MySoundPair.Empty) return; if (m_emitters[(int)emitter] != null) { if (checkIfAlreadyPlaying && m_emitters[(int)emitter].IsPlaying && m_emitters[(int)emitter].SoundPair == soundPair) return; if (m_emitters[(int)emitter].IsPlaying && useFadeOut) { var effect = MyAudio.Static.ApplyEffect(m_emitters[(int)emitter].Sound, MyStringHash.GetOrCompute("CrossFade"), new MyCueId[] { soundPair.SoundId }, 1500); m_emitters[(int)emitter].Sound = effect.OutputSound; } else m_emitters[(int)emitter].PlaySound(soundPair, stopPrevious, force2D: useForce2D && m_shouldPlay2D); } }
private void FadeOutSound(ShipEmitters emitter = ShipEmitters.SingleSounds, int duration = 2000) { if (m_emitters[(int)emitter].IsPlaying) { var effectSourceVoice = MyAudio.Static.ApplyEffect(m_emitters[(int)emitter].Sound, m_fadeOut, new MyCueId[] { }, duration); m_emitters[(int)emitter].Sound = effectSourceVoice.OutputSound; } if (emitter == ShipEmitters.SingleSounds) m_playingSpeedUpOrDown = false; }