void PauseCue(MySoundCue? cue) { if (cue != null && cue.Value.IsPlaying) { cue.Value.Pause(); } }
void ResumeCue(MySoundCue? cue) { if (cue != null && cue.Value.IsValid && cue.Value.IsPaused) { cue.Value.Resume(); } }
// Weapons sounds are unified per miner ship (two or more weapons of same type and shooting simultanously will produce only one sound) public void UnifiedWeaponCueSet(MySoundCuesEnum cueEnum, MySoundCue? value) { m_unifiedWeaponCues[(int)cueEnum] = value; }
public bool IsSame(MySoundCue cue) { return m_cue == cue.m_cue && m_version == cue.m_version; }
// Updates pitch of a cue (this is per instance pitch, not all sounds pitch). Rotation speed values are in interval <0..100> -> it's normalized rotation speed // IMPORTANT: Every cue for which we want to set pitch needs to have RPC for it. This can be done in XACT. public static void UpdateCueRotationSpeed(MySoundCue? cue, float rotationSpeed) { if (m_canPlay == false) return; if (cue == null) return; CheckCue(cue.Value); cue.Value.SetVariable(MyCueVariableEnum.RotatingSpeed, rotationSpeed); }
// Updates pitch of a cue (this is per instance pitch, not all sounds pitch). Pitch values are in interval <-1..+1>. // IMPORTANT: Every cue for which we want to set pitch needs to have RPC for it. This can be done in XACT. public static void UpdateCuePitch(MySoundCue? cue, float pitch) { if (m_canPlay == false) return; if (cue == null) return; CheckCue(cue.Value); cue.Value.SetVariable(MyCueVariableEnum.Pitch, pitch); }
public static void CalculateOcclusion(MySoundCue cue, Vector3 position) { // Occlusions are disabled return; if (MyFakes.OPTIMIZATION_FOR_300_SMALLSHIPS) return; if (m_canPlay == false) return; CheckCue(cue); MyCueParameters cueParams = m_cueParameters[(int)cue.CueEnum].Value; if (!cueParams.UseOcclusion) return; if (MyMinerGame.TotalGamePlayTimeInMilliseconds - cueParams.LastUpdate < MyAudioConstants.OCCLUSION_INTERVAL) return; cueParams.LastUpdate = MyMinerGame.TotalGamePlayTimeInMilliseconds; float distance = Vector3.Distance(MyCamera.Position, position); if ((distance <= cueParams.MaxDistance) && (distance > MyMwcMathConstants.EPSILON)) { cue.SetVariable(MyCueVariableEnum.Occluder, CalculateOcclusion(ref position)); } }
// Updates pitch of a cue (this is per instance pitch, not all sounds pitch). Volume values are in interval <0..1..2> -> same as for master pitch (see below). // IMPORTANT: Every cue for which we want to set pitch needs to have RPC for it. This can be done in XACT. public static void UpdateCueAmbVolume(MySoundCue? cue, float volume) { if (m_canPlay == false) return; if (cue == null) return; CheckCue(cue.Value); cue.Value.SetVariable(MyCueVariableEnum.AmbVolume, volume); }
// Updates the position and velocity settings of a 3D cue public static void UpdateCuePosition(MySoundCue? cue, Vector3 position, Vector3 forward, Vector3 up, Vector3 velocity) { if (cue.HasValue == false) return; UpdateCuePosition(cue.Value, position, forward, up, velocity); }
public static void UpdateCuePosition(MySoundCue cue, Vector3 position, Vector3 forward, Vector3 up, Vector3 velocity) { if (m_canPlay == false) return; if (!cue.IsValid) return; if (!cue.Is3D) return; CheckCue(cue); if (!MyFakes.OPTIMIZATION_FOR_300_SMALLSHIPS) { CalculateOcclusion(cue, position); } m_helperEmitter.UpdateValues(ref position, ref forward, ref up, ref velocity); cue.Apply3D(m_listener, m_helperEmitter); }
private static void CheckCue(MySoundCue cue) { Debug.Assert(cue.IsValid, "This method can't be called with this cue, because cue is disposed"); }
public bool IsSame(MySoundCue cue) { return(m_cue == cue.m_cue && m_version == cue.m_version); }
void PlayLoopSound(ref MySoundCue? sound, MySoundCuesEnum? soundCue) { if (soundCue != null) { if (m_starting && sound.HasValue && sound.Value.IsPlaying) { m_starting = false; m_playing = true; } if (sound == null || (m_playing && !sound.Value.IsPlaying)) { m_playing = false; sound = MyAudio.AddCue3D( soundCue.Value, m_kinematicPartOwner.WorldMatrix.Translation, Vector3.Forward, Vector3.Forward, Vector3.Zero); m_starting = sound != null; } } }
protected void StopSound(ref MySoundCue? soundToStop, MySoundCue? except) { bool stopSound = soundToStop != null && (except == null || except.Value.IsSame(soundToStop.Value)); if (stopSound) { if (soundToStop.Value.IsPlaying) { soundToStop.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } soundToStop = null; } }
protected void StopKinematicSounds(MySoundCue? except = null) { StopSound(ref m_startSound, except); StopSound(ref m_loopSound, except); StopSound(ref m_loopDamagedSound, except); StopSound(ref m_endSound, except); }