public void Update() { if (_messageDisplayTime > 0f) { _messageDisplayTime -= Time.deltaTime; if (_messageDisplayTime <= 0f) { _messageDisplayTime = 0f; _messageDisplayText.text = ""; } } if (Config.Instance.EnableVoiceChat && Config.Instance.MicEnabled) { if (!Config.Instance.PushToTalk) { isRecording = true; } else { switch (Config.Instance.PushToTalkButton) { case 0: isRecording = ControllersHelper.GetLeftGrip(); break; case 1: isRecording = ControllersHelper.GetRightGrip(); break; case 2: isRecording = VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 3: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f; break; case 4: isRecording = ControllersHelper.GetLeftGrip() && ControllersHelper.GetRightGrip(); break; case 5: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f && VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 6: isRecording = ControllersHelper.GetLeftGrip() || ControllersHelper.GetRightGrip(); break; case 7: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f || VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; default: isRecording = Input.anyKey; break; } } } else { isRecording = false; } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { if (Input.GetKeyDown(KeyCode.Keypad0)) { fixedSendRate = 0; Misc.Logger.Info($"Variable send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad1)) { fixedSendRate = 1; Misc.Logger.Info($"Forced full send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad2)) { fixedSendRate = 2; Misc.Logger.Info($"Forced half send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad3)) { fixedSendRate = 3; Misc.Logger.Info($"Forced one third send rate"); } } if (needToSendUpdates) { if (fixedSendRate == 1 || (fixedSendRate == 0 && Client.Instance.Tickrate > 67.5f * (1f / 90 / Time.deltaTime))) { sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Misc.Logger.Info($"Full send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}"); #endif } else if (fixedSendRate == 2 || (fixedSendRate == 0 && Client.Instance.Tickrate > 37.5f * (1f / 90 / Time.deltaTime))) { sendRateCounter++; if (sendRateCounter >= 1) { sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Misc.Logger.Info($"Half send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}"); #endif } } else if (fixedSendRate == 3 || (fixedSendRate == 0 && Client.Instance.Tickrate <= 37.5f * (1f / 90 / Time.deltaTime))) { sendRateCounter++; if (sendRateCounter >= 2) { sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Misc.Logger.Info($"One third send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}"); #endif } } } }
public void Update() { if (!Client.Instance.connected) { return; } if (_messageDisplayTime > 0f) { _messageDisplayTime -= Time.deltaTime; if (_messageDisplayTime <= 0f) { _messageDisplayTime = 0f; if (_messageDisplayText != null) { _messageDisplayText.text = ""; } } } if (Config.Instance.EnableVoiceChat && Config.Instance.MicEnabled) { if (!Config.Instance.PushToTalk) { isRecording = true; } else { switch (Config.Instance.PushToTalkButton) { case 0: isRecording = ControllersHelper.GetLeftGrip(); break; case 1: isRecording = ControllersHelper.GetRightGrip(); break; case 2: isRecording = VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 3: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f; break; case 4: isRecording = ControllersHelper.GetLeftGrip() && ControllersHelper.GetRightGrip(); break; case 5: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f && VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; case 6: isRecording = ControllersHelper.GetLeftGrip() || ControllersHelper.GetRightGrip(); break; case 7: isRecording = VRControllersInputManager.TriggerValue(XRNode.RightHand) > 0.85f || VRControllersInputManager.TriggerValue(XRNode.LeftHand) > 0.85f; break; default: isRecording = Input.anyKey; break; } } } else { isRecording = false; } if (isVoiceChatActive && voiceChatListener != null) { voiceChatListener.isListening = isRecording; } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { if (Input.GetKeyDown(KeyCode.Keypad0)) { _fixedSendRate = 0; Plugin.log.Info($"Variable send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad1)) { _fixedSendRate = 1; Plugin.log.Info($"Forced full send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad2)) { _fixedSendRate = 2; Plugin.log.Info($"Forced half send rate"); } else if (Input.GetKeyDown(KeyCode.Keypad3)) { _fixedSendRate = 3; Plugin.log.Info($"Forced one third send rate"); } } if (needToSendUpdates) { if (_fixedSendRate == 1 || (_fixedSendRate == 0 && Client.Instance.tickrate > (1f / Time.deltaTime / 3f * 2f + 5f)) || _spectatorInRoom) { _sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Plugin.log.Info($"Full send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}, Trigger: TPS>{1f / Time.deltaTime / 3f * 2f + 5f}"); #endif } else if (_fixedSendRate == 2 || (_fixedSendRate == 0 && Client.Instance.tickrate > (1f / Time.deltaTime / 3f + 5f))) { _sendRateCounter++; if (_sendRateCounter >= 1) { _sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Plugin.log.Info($"Half send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}, Trigger: TPS>{1f / Time.deltaTime / 3f + 5f}"); #endif } } else if (_fixedSendRate == 3 || (_fixedSendRate == 0 && Client.Instance.tickrate <= (1f / Time.deltaTime / 3f + 5f))) { _sendRateCounter++; if (_sendRateCounter >= 2) { _sendRateCounter = 0; UpdatePlayerInfo(); #if DEBUG && VERBOSE Plugin.log.Info($"One third send rate! FPS: {(1f / Time.deltaTime).ToString("0.0")}, TPS: {Client.Instance.Tickrate.ToString("0.0")}, Trigger: TPS<={1f / Time.deltaTime / 3f + 5f}"); #endif } } } }