private void UpdatePlayback() { var now = MySandboxGame.Static.UpdateTime; var speakerFadeout = MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * 60 * 1000; m_keys.AddRange(m_receivedVoiceData.Keys); foreach (var id in m_keys) { bool update = false; var playerId = id; var data = m_receivedVoiceData[id]; var player = Sync.Players.TryGetPlayerById(new MyPlayer.PlayerId(playerId)); float maxDistance = 0; MySoundDimensions dimension = MySoundDimensions.D2; if (data.Timestamp != MyTimeSpan.Zero && m_voiceChatLogic.ShouldPlayVoice(player, data.Timestamp, out dimension, out maxDistance)) { PlayVoice(data.UncompressedBuffer.ToArray(), data.UncompressedBuffer.Count, playerId, dimension, maxDistance); data.ClearData(); update = true; } if (data.SpeakerTimestamp != MyTimeSpan.Zero && (now - data.SpeakerTimestamp).Miliseconds > speakerFadeout) { data.ClearSpeakerTimestamp(); update = true; } if (update) { m_receivedVoiceData[id] = data; } } m_keys.Clear(); }
private void UpdatePlayback() { var now = MySandboxGame.Static.UpdateTime; var speakerFadeout = VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * 60 * 1000; m_keys.AddRange(m_receivedVoiceData.Keys); foreach (var id in m_keys) { bool update = false; var playerId = id; var data = m_receivedVoiceData[id]; var player = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(playerId)); float maxDistance = 0; MySoundDimensions dimension = MySoundDimensions.D2; if (data.Timestamp != MyTimeSpan.Zero && m_voiceChatLogic.ShouldPlayVoice(player, data.Timestamp, out dimension, out maxDistance)) { if (!MySandboxGame.Config.MutedPlayers.Contains(player.Id.SteamId)) { PlayVoice(data.UncompressedBuffer.ToArray(), data.UncompressedBuffer.Count, playerId, dimension, maxDistance); data.ClearData(); update = true; } else { // this player should be muted - send him a mute message if (lastMessageTime == 0 || System.Environment.TickCount > lastMessageTime + 5000) // sending of mute messages is diluted { MutePlayerRequest(player.Id.SteamId, true); lastMessageTime = System.Environment.TickCount; } } } if (data.SpeakerTimestamp != MyTimeSpan.Zero && (now - data.SpeakerTimestamp).Miliseconds > speakerFadeout) { data.ClearSpeakerTimestamp(); update = true; } if (update) { m_receivedVoiceData[id] = data; } } m_keys.Clear(); }