diff --git a/PickupPushPull/HarmonyPatches.cs b/PickupPushPull/HarmonyPatches.cs index b89ab59..f3bd2a3 100644 --- a/PickupPushPull/HarmonyPatches.cs +++ b/PickupPushPull/HarmonyPatches.cs @@ -17,7 +17,10 @@ internal class HarmonyPatches public static void GrabbedObjectPatch(ref CVRPickupObject __instance) { // Need to only run when the object is grabbed by the local player - if (!__instance.IsGrabbedByMe()) return; + if (__instance._controllerRay == null) return; + + //and only if its a prop we support + if (__instance.gripType == CVRPickupObject.GripType.Origin) return; Quaternion originalRotation = __instance.transform.rotation; Transform referenceTransform = __instance._controllerRay.transform; diff --git a/PickupPushPull/InputModules/PickupPushPull_Module.cs b/PickupPushPull/InputModules/PickupPushPull_Module.cs index 70a5519..c5b3e91 100644 --- a/PickupPushPull/InputModules/PickupPushPull_Module.cs +++ b/PickupPushPull/InputModules/PickupPushPull_Module.cs @@ -29,8 +29,8 @@ public class PickupPushPull_Module : CVRInputModule public bool Desktop_UseZoomForRotate = true; //VR settings - public BindingOptionsVR.BindHand VR_RotateHand; - public BindingOptionsVR.BindingOptions VR_RotateBind; + public BindingOptionsVR.BindHand VR_RotateHand = BindingOptionsVR.BindHand.LeftHand; + public BindingOptionsVR.BindingOptions VR_RotateBind = BindingOptionsVR.BindingOptions.ButtonATouch; private SteamVR_Action_Boolean VR_RotateBind_Boolean; //Local stuff @@ -49,10 +49,10 @@ public class PickupPushPull_Module : CVRInputModule public new void Start() { - base.Start(); _inputManager = CVRInputManager.Instance; Instance = this; - + base.Start(); + //Get desktop controller ray desktopControllerRay = PlayerSetup.Instance.desktopCamera.GetComponent(); @@ -65,13 +65,13 @@ public class PickupPushPull_Module : CVRInputModule steamVrButtonATouch = (SteamVR_Action_Boolean)EI_SteamVR_Info.im_steamVrButtonATouch.GetValue(inputModuleSteamVR); steamVrButtonBTouch = (SteamVR_Action_Boolean)EI_SteamVR_Info.im_steamVrButtonBTouch.GetValue(inputModuleSteamVR); - UpdateVRBinding(); - controlGamepadEnabled = (bool)MetaPort.Instance.settings.GetSettingsBool("ControlDeadZoneRight", false); MetaPort.Instance.settings.settingBoolChanged.AddListener(new UnityAction(SettingsBoolChanged)); deadzoneRightValue = (float)MetaPort.Instance.settings.GetSettingInt("ControlDeadZoneRight", 0) / 100f; MetaPort.Instance.settings.settingIntChanged.AddListener(new UnityAction(SettingsIntChanged)); + + UpdateVRBinding(); } private void SettingsBoolChanged(string name, bool value) @@ -122,7 +122,7 @@ public class PickupPushPull_Module : CVRInputModule objectRotation = Vector2.zero; CVRPickupObject desktopObject = (CVRPickupObject)_grabbedObject.GetValue(desktopControllerRay); - if (desktopObject != null) + if (desktopObject != null && desktopObject.gripType == CVRPickupObject.GripType.Free) { //Desktop Input DoDesktopInput(); @@ -132,11 +132,7 @@ public class PickupPushPull_Module : CVRInputModule //VR Input if (!MetaPort.Instance.isUsingVr) return; - - CVRPickupObject vrObject = (CVRPickupObject)_grabbedObject.GetValue(PlayerSetup.Instance.leftRay); - CVRPickupObject vrObject2 = (CVRPickupObject)_grabbedObject.GetValue(PlayerSetup.Instance.rightRay); - if (vrObject != null || vrObject2 != null) - DoSteamVRInput(); + DoSteamVRInput(); } private void DoDesktopInput() @@ -180,19 +176,26 @@ public class PickupPushPull_Module : CVRInputModule private void DoSteamVRInput() { - bool button = VR_RotateBind_Boolean.GetState((SteamVR_Input_Sources)VR_RotateHand); + CVRPickupObject leftObject = (CVRPickupObject)_grabbedObject.GetValue(PlayerSetup.Instance.leftRay); + CVRPickupObject rightObject = (CVRPickupObject)_grabbedObject.GetValue(PlayerSetup.Instance.rightRay); + if (leftObject == null && rightObject == null) return; - //I get my own lookVector cause fucking CVR alters **rawLookVector** with digital deadzones >:((( - Vector2 rawLookVector = new(CVRTools.AxisDeadZone(vrLookAction.GetAxis(SteamVR_Input_Sources.Any).x, deadzoneRightValue, true), CVRTools.AxisDeadZone(vrLookAction.GetAxis(SteamVR_Input_Sources.Any).y, deadzoneRightValue, true)); + bool canRotate = (leftObject != null && leftObject.gripType == CVRPickupObject.GripType.Free) || + (rightObject != null && rightObject.gripType == CVRPickupObject.GripType.Free); - if (Setting_EnableRotation && button) + if (Setting_EnableRotation && canRotate && VR_RotateBind_Boolean.GetState((SteamVR_Input_Sources)VR_RotateHand)) { + Vector2 rawLookVector = new Vector2(CVRTools.AxisDeadZone(vrLookAction.GetAxis(SteamVR_Input_Sources.Any).x, deadzoneRightValue, true), + CVRTools.AxisDeadZone(vrLookAction.GetAxis(SteamVR_Input_Sources.Any).y, deadzoneRightValue, true)); + objectRotation.x += Setting_RotationSpeed * rawLookVector.x; objectRotation.y += Setting_RotationSpeed * rawLookVector.y * -1; + _inputManager.lookVector = Vector2.zero; return; } CVRInputManager.Instance.objectPushPull += CVRInputManager.Instance.floatDirection * Setting_PushPullSpeed * Time.deltaTime; } + } \ No newline at end of file diff --git a/PickupPushPull/Main.cs b/PickupPushPull/Main.cs index a0e0e0d..fe9d0a4 100644 --- a/PickupPushPull/Main.cs +++ b/PickupPushPull/Main.cs @@ -20,7 +20,6 @@ public class PickupPushPull : MelonMod public override void OnInitializeMelon() { Category_PickupPushPull = MelonPreferences.CreateCategory(nameof(PickupPushPull)); - Category_PickupPushPull.SaveToFile(false); //Global settings Setting_PushPullSpeed = Category_PickupPushPull.CreateEntry("Push Pull Speed", 2f, description: "Up/down on right joystick for VR. Left buSettingr + Up/down on right joystick for Gamepad."); @@ -58,6 +57,7 @@ public class PickupPushPull : MelonMod while (PickupPushPull_Module.Instance == null) yield return null; + UpdateVRBinding(); UpdateAllSettings(); } @@ -77,7 +77,7 @@ public class PickupPushPull : MelonMod //VR settings PickupPushPull_Module.Instance.VR_RotateHand = Setting_VR_RotateHand.Value; } - + private void UpdateVRBinding() { //VR special settings diff --git a/PickupPushPull/Properties/AssemblyInfo.cs b/PickupPushPull/Properties/AssemblyInfo.cs index e1b8ee0..130b54f 100644 --- a/PickupPushPull/Properties/AssemblyInfo.cs +++ b/PickupPushPull/Properties/AssemblyInfo.cs @@ -25,6 +25,6 @@ using System.Reflection; namespace PickupPushPull.Properties; internal static class AssemblyInfoParams { - public const string Version = "2.0.0"; + public const string Version = "3.0.1"; public const string Author = "NotAKidoS"; } \ No newline at end of file diff --git a/PickupPushPull/format.json b/PickupPushPull/format.json index 1e75e34..1aad746 100644 --- a/PickupPushPull/format.json +++ b/PickupPushPull/format.json @@ -1,12 +1,12 @@ { "_id": 91, "name": "PickupPushPull", - "modversion": "3.0.0", - "gameversion": "2022r168", + "modversion": "3.0.1", + "gameversion": "2022r170", "loaderversion": "0.5.7", "modtype": "Mod", "author": "NotAKidoS", - "description": "Allows you to push & pull pickups with Mouse, Gamepad, & VR.\nCan also optionally rotate props via keybind.", + "description": "Allows you to push & pull pickups with Mouse, Gamepad, & VR.\nCan also optionally rotate props via keybind.\n\nIndex users will need to manually bind the missing SteamVR binds.", "searchtags": [ "pull", "push", @@ -16,8 +16,8 @@ "requirements": [ "None" ], - "downloadlink": "https://github.com/NotAKidOnSteam/PickupPushPull/releases/download/r2/PickupPushPull.dll", + "downloadlink": "https://github.com/NotAKidOnSteam/PickupPushPull/releases/download/v3.0.1/PickupPushPull.dll", "sourcelink": "https://github.com/NotAKidOnSteam/PickupPushPull/", - "changelog": "Switched to input module setup. Desktop will rotate held pickups when zoom bind is pressed. Rotation bind no longer prevents rotation when pickup is not being held.", + "changelog": "- Fixed issue where saved preferences weren't properly applied on startup.\n- Rotation is now only limited while holding a prop that can be rotated, instead of when the rotation bind is held.", "embedcolor": "804221" } \ No newline at end of file