private void VisibilityChanged(object sender, bool isVisible) { if (Visible) { Position = m_position + this.Size / 2; RecreateControls(); m_currentFrame = 0; if (m_currentSoundID == null) { m_currentSoundID = MyAudio.Static.PlaySound(m_highlightSound); } } else { m_currentFrame = float.MaxValue; if (m_currentSoundID != null) { m_currentSoundID.Stop(); m_currentSoundID = null; } } }
void OnPlaySelected(MyGuiControlButton button) { if ((m_sound != null) && (m_sound.IsPlaying)) { m_sound.Stop(true); } var cue = new MyCueId(MyStringHash.TryGet(m_cuesCombo.GetSelectedValue().ToString())); m_sound = MyAudio.Static.PlaySound(cue); var effect = MyStringHash.TryGet(m_effects.GetSelectedValue().ToString()); if (effect != MyStringHash.NullOrEmpty) { foreach (var box in m_cues) { var effCue = new MyCueId(MyStringHash.TryGet(box.GetSelectedValue().ToString())); m_cueCache.Add(effCue); } var eff = MyAudio.Static.ApplyEffect(m_sound, effect, m_cueCache.ToArray()); m_sound = eff.OutputSound; m_cueCache.Clear(); } }
public void PlaySoundWithDistance(MyCueId soundId, bool stopPrevious = false, bool skipIntro = false, bool force2D = false, bool useDistanceCheck = true, bool alwaysHearOnRealistic = false, bool skipToEnd = false) { m_lastSoundData = MyAudio.Static.GetCue(soundId); if (useDistanceCheck) { m_closeSoundCueId = soundId; } if (useDistanceCheck && ShouldPlay2D() == false && force2D == false) { soundId = CheckDistanceSounds(soundId); } bool usesDistanceSoundsCache = m_usesDistanceSounds; if (m_sound != null) { if (stopPrevious) { StopSound(true); } else if (m_sound.IsLoopable) { var sound = Sound; StopSound(true); m_soundsQueue.Add(sound.CueEnum); } } if (m_secondarySound != null) { m_secondarySound.Stop(true); } SoundId = soundId; PlaySoundInternal((skipIntro || skipToEnd), force2D: force2D, alwaysHearOnRealistic: alwaysHearOnRealistic, skipToEnd: skipToEnd); m_usesDistanceSounds = usesDistanceSoundsCache; }
public void StopSound(bool forced, bool cleanUp = true) { m_usesDistanceSounds = false; if (m_sound != null) { m_sound.Stop(forced); if (Loop && !forced) { PlaySoundInternal(true, true); } if (m_soundsQueue.Count == 0) { m_sound = null; if (cleanUp) { Loop = false; SoundId = myEmptyCueId; } } else { if (cleanUp) { SoundId = m_soundsQueue[0]; PlaySoundInternal(true); m_soundsQueue.RemoveAt(0); } } } else { if (cleanUp) { Loop = false; SoundId = myEmptyCueId; } } if (m_secondarySound != null) { m_secondarySound.Stop(true); } }
public void StopSound(bool forced, bool cleanUp = true) { if (m_sound != null) { m_sound.Stop(forced); if (Loop && !forced) { PlaySoundInternal(true, true); } if (m_soundsQueue.Count == 0) { m_sound = null; if (cleanUp) { Loop = false; SoundId = MyStringId.NullOrEmpty; } } else { if (cleanUp) { SoundId = m_soundsQueue[0]; PlaySoundInternal(true); m_soundsQueue.RemoveAt(0); } } } else { if (cleanUp) { Loop = false; SoundId = MyStringId.NullOrEmpty; } } }
public void Update(bool force = false) { if (MySession.Static == null || MySession.Static.LocalCharacter != m_character) { return; } if (CurrentState == State.Heated) { m_staminaDepletion = Math.Min(m_staminaDepletion + STAMINA_AMOUNT_RUN, STAMINA_AMOUNT_MAX); } else if (CurrentState == State.VeryHeated) { m_staminaDepletion = Math.Min(m_staminaDepletion + STAMINA_AMOUNT_SPRINT, STAMINA_AMOUNT_MAX); } else { m_staminaDepletion = Math.Max(m_staminaDepletion - MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS, 0f); } if (CurrentState == State.NoBreath) { if (m_sound != null) { m_sound.Stop(); m_sound = null; } return; } float health = m_character.StatComp.Health.Value; if (CurrentState == State.Choking) { if (health >= CHOKE_TRESHOLD_LOW && (m_sound == null || m_sound.CueEnum != OXYGEN_CHOKE_NORMAL.SoundId)) { PlaySound(OXYGEN_CHOKE_NORMAL.SoundId, false); } else if (health >= CHOKE_TRESHOLD_CRITICAL && health < CHOKE_TRESHOLD_LOW && (m_sound == null || m_sound.CueEnum != OXYGEN_CHOKE_LOW.SoundId)) { PlaySound(OXYGEN_CHOKE_LOW.SoundId, false); } else if (health > 0f && health < CHOKE_TRESHOLD_CRITICAL && (m_sound == null || m_sound.CueEnum != OXYGEN_CHOKE_CRITICAL.SoundId)) { PlaySound(OXYGEN_CHOKE_CRITICAL.SoundId, false); } return; } if (CurrentState == State.Calm || CurrentState == State.Heated || CurrentState == State.VeryHeated) { if (m_staminaDepletion < STAMINA_RECOVERY_CALM_TO_ZERO && health > 20f) { if (!BREATH_CALM.SoundId.IsNull && (m_sound == null || m_sound.CueEnum != BREATH_CALM.SoundId)) { PlaySound(BREATH_CALM.SoundId, true); } } else { if (!BREATH_HEAVY.SoundId.IsNull && (m_sound == null || m_sound.CueEnum != BREATH_HEAVY.SoundId)) { PlaySound(BREATH_HEAVY.SoundId, true); } } } }