Ejemplo n.º 1
0
        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
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Update()
        {
            if (!_init || _songAudio == null)
            {
                return;
            }
            if (!(_skippableIntro || _skippableOutro))
            {
                if (_skipPrompt.gameObject.activeSelf)
                {
                    _skipPrompt.gameObject.SetActive(false);
                }
                return;
            }

            float time       = _songAudio.time;
            bool  introPhase = (time < _introSkipTime) && _skippableIntro;
            bool  outroPhase = (time > _lastObjectSkipTime && time < _outroSkipTime) && _skippableOutro;

            if (introPhase || outroPhase)
            {
                if (!_skipPrompt.gameObject.activeSelf)
                {
                    _skipPrompt.gameObject.SetActive(true);
                }
            }
            else
            {
                if (_skipPrompt.gameObject.activeSelf)
                {
                    _skipPrompt.gameObject.SetActive(false);
                }
                return;
            }
            if (_audioTimeSyncController.state == AudioTimeSyncController.State.Playing && (_vrControllersInputManager.TriggerValue(UnityEngine.XR.XRNode.LeftHand) >= .8 || _vrControllersInputManager.TriggerValue(UnityEngine.XR.XRNode.RightHand) >= .8 || Input.GetKey(KeyCode.I)))
            {
                Logger.log.Debug("Skip Triggered At:" + time);
                _vrPlatformHelper.TriggerHapticPulse(UnityEngine.XR.XRNode.LeftHand, 0.1f, 0.2f, 1);
                _vrPlatformHelper.TriggerHapticPulse(UnityEngine.XR.XRNode.RightHand, 0.1f, 0.2f, 1);
                if (introPhase)
                {
                    _songAudio.time = _introSkipTime;
                    _skippableIntro = false;
                }
                else if (outroPhase)
                {
                    _songAudio.time = _outroSkipTime;
                    _skippableOutro = false;
                }
            }
        }
        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
                    }
                }
            }
        }
 public static bool RightTrigger()
 {
     return(VRControllersInputManager.TriggerValue(UnityEngine.XR.XRNode.RightHand) > 0.75f);
 }