Ejemplo n.º 1
0
                private static bool PreUpdateRumble(object[] ___m_theList, bool ___m_isEnabled)
                {
                    if (OWTime.IsPaused())
                    {
                        return(false);
                    }

                    var a = Vector2.zero;

                    if (___m_isEnabled && OWInput.UsingGamepad())
                    {
                        var deltaTime = Time.deltaTime;
                        for (var i = 0; i < ___m_theList.Length; i++)
                        {
                            var rumble  = ___m_theList[i];
                            var isAlive = (bool)rumble.GetType().GetMethod("IsAlive").Invoke(rumble, new object[] { });

                            if (isAlive)
                            {
                                rumble.Invoke("Update", deltaTime);
                            }

                            var isAliveAgain = (bool)rumble.GetType().GetMethod("IsAlive").Invoke(rumble, new object[] { });

                            if (isAliveAgain)
                            {
                                var power = (Vector2)rumble.GetType().GetMethod("GetPower").Invoke(rumble, new object[] { });
                                a += power;
                            }
                        }
                        a.x *= 1.42857146f;
                        a.y *= 1.42857146f;

                        var haptic     = SteamVR_Actions.default_Haptic;
                        var frequency  = 0.1f;
                        var amplitudeY = a.y * ModSettings.VibrationStrength;
                        var amplitudeX = a.x * ModSettings.VibrationStrength;
                        haptic.Execute(0, frequency, 10, amplitudeY, SteamVR_Input_Sources.RightHand);
                        haptic.Execute(0, frequency, 50, amplitudeX, SteamVR_Input_Sources.RightHand);
                        haptic.Execute(0, frequency, 10, amplitudeY, SteamVR_Input_Sources.LeftHand);
                        haptic.Execute(0, frequency, 50, amplitudeX, SteamVR_Input_Sources.LeftHand);
                    }

                    return(false);
                }
Ejemplo n.º 2
0
 public static void DoubleAxisUpdatePost(
     DoubleAxisCommand __instance,
     ref Vector2 ____value,
     List <KeyCode> ____posXKeyCodes,
     List <KeyCode> ____negXKeyCodes,
     List <KeyCode> ____posYKeyCodes,
     List <KeyCode> ____negYKeyCodes
     )
 {
     if (OWInput.UsingGamepad())
     {
         return;
     }
     foreach (var key in ____posXKeyCodes)
     {
         if (ModInputHandler.Instance.IsPressedAndIgnored(key))
         {
             ____value.x = 0f;
         }
     }
     foreach (var key in ____negXKeyCodes)
     {
         if (ModInputHandler.Instance.IsPressedAndIgnored(key))
         {
             ____value.x = 0f;
         }
     }
     foreach (var key in ____posYKeyCodes)
     {
         if (ModInputHandler.Instance.IsPressedAndIgnored(key))
         {
             ____value.y = 0f;
         }
     }
     foreach (var key in ____negYKeyCodes)
     {
         if (ModInputHandler.Instance.IsPressedAndIgnored(key))
         {
             ____value.y = 0f;
         }
     }
 }
Ejemplo n.º 3
0
        public void Open(InputType inputType, string value)
        {
            _inputMenu.OnPopupConfirm += OnPopupConfirm;
            _inputMenu.OnPopupCancel  += OnPopupCancel;

            if (inputType == InputType.Number)
            {
                _inputMenu.OnInputPopupValidateChar += OnValidateCharNumber;
                _inputMenu.OnPopupValidate          += OnValidateNumber;
            }
            var message = inputType == InputType.Number ? "Write a number" : "Write some text";

            _inputMenu.EnableMenu(true);

            var okPrompt      = new ScreenPrompt(InputLibrary.confirm2, "OK");
            var cancelCommand = OWInput.UsingGamepad() ? InputLibrary.cancel : InputLibrary.escape;
            var cancelPrompt  = new ScreenPrompt(cancelCommand, "Cancel");

            _inputMenu.SetUpPopup(message, InputLibrary.confirm2, cancelCommand, okPrompt, cancelPrompt);
            _inputMenu.SetInputFieldPlaceholderText("");
            _inputMenu.GetInputField().text = value;
            _inputMenu.GetValue <Text>("_labelText").text = message;
        }