fixes n stuff

This commit is contained in:
NotAKidoS 2023-02-02 01:09:16 -06:00
parent 760ab0b0ae
commit 6634a4163d
5 changed files with 31 additions and 25 deletions

View file

@ -17,7 +17,10 @@ internal class HarmonyPatches
public static void GrabbedObjectPatch(ref CVRPickupObject __instance) public static void GrabbedObjectPatch(ref CVRPickupObject __instance)
{ {
// Need to only run when the object is grabbed by the local player // 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; Quaternion originalRotation = __instance.transform.rotation;
Transform referenceTransform = __instance._controllerRay.transform; Transform referenceTransform = __instance._controllerRay.transform;

View file

@ -29,8 +29,8 @@ public class PickupPushPull_Module : CVRInputModule
public bool Desktop_UseZoomForRotate = true; public bool Desktop_UseZoomForRotate = true;
//VR settings //VR settings
public BindingOptionsVR.BindHand VR_RotateHand; public BindingOptionsVR.BindHand VR_RotateHand = BindingOptionsVR.BindHand.LeftHand;
public BindingOptionsVR.BindingOptions VR_RotateBind; public BindingOptionsVR.BindingOptions VR_RotateBind = BindingOptionsVR.BindingOptions.ButtonATouch;
private SteamVR_Action_Boolean VR_RotateBind_Boolean; private SteamVR_Action_Boolean VR_RotateBind_Boolean;
//Local stuff //Local stuff
@ -49,9 +49,9 @@ public class PickupPushPull_Module : CVRInputModule
public new void Start() public new void Start()
{ {
base.Start();
_inputManager = CVRInputManager.Instance; _inputManager = CVRInputManager.Instance;
Instance = this; Instance = this;
base.Start();
//Get desktop controller ray //Get desktop controller ray
desktopControllerRay = PlayerSetup.Instance.desktopCamera.GetComponent<ControllerRay>(); desktopControllerRay = PlayerSetup.Instance.desktopCamera.GetComponent<ControllerRay>();
@ -65,13 +65,13 @@ public class PickupPushPull_Module : CVRInputModule
steamVrButtonATouch = (SteamVR_Action_Boolean)EI_SteamVR_Info.im_steamVrButtonATouch.GetValue(inputModuleSteamVR); steamVrButtonATouch = (SteamVR_Action_Boolean)EI_SteamVR_Info.im_steamVrButtonATouch.GetValue(inputModuleSteamVR);
steamVrButtonBTouch = (SteamVR_Action_Boolean)EI_SteamVR_Info.im_steamVrButtonBTouch.GetValue(inputModuleSteamVR); steamVrButtonBTouch = (SteamVR_Action_Boolean)EI_SteamVR_Info.im_steamVrButtonBTouch.GetValue(inputModuleSteamVR);
UpdateVRBinding();
controlGamepadEnabled = (bool)MetaPort.Instance.settings.GetSettingsBool("ControlDeadZoneRight", false); controlGamepadEnabled = (bool)MetaPort.Instance.settings.GetSettingsBool("ControlDeadZoneRight", false);
MetaPort.Instance.settings.settingBoolChanged.AddListener(new UnityAction<string, bool>(SettingsBoolChanged)); MetaPort.Instance.settings.settingBoolChanged.AddListener(new UnityAction<string, bool>(SettingsBoolChanged));
deadzoneRightValue = (float)MetaPort.Instance.settings.GetSettingInt("ControlDeadZoneRight", 0) / 100f; deadzoneRightValue = (float)MetaPort.Instance.settings.GetSettingInt("ControlDeadZoneRight", 0) / 100f;
MetaPort.Instance.settings.settingIntChanged.AddListener(new UnityAction<string, int>(SettingsIntChanged)); MetaPort.Instance.settings.settingIntChanged.AddListener(new UnityAction<string, int>(SettingsIntChanged));
UpdateVRBinding();
} }
private void SettingsBoolChanged(string name, bool value) private void SettingsBoolChanged(string name, bool value)
@ -122,7 +122,7 @@ public class PickupPushPull_Module : CVRInputModule
objectRotation = Vector2.zero; objectRotation = Vector2.zero;
CVRPickupObject desktopObject = (CVRPickupObject)_grabbedObject.GetValue(desktopControllerRay); CVRPickupObject desktopObject = (CVRPickupObject)_grabbedObject.GetValue(desktopControllerRay);
if (desktopObject != null) if (desktopObject != null && desktopObject.gripType == CVRPickupObject.GripType.Free)
{ {
//Desktop Input //Desktop Input
DoDesktopInput(); DoDesktopInput();
@ -132,11 +132,7 @@ public class PickupPushPull_Module : CVRInputModule
//VR Input //VR Input
if (!MetaPort.Instance.isUsingVr) return; if (!MetaPort.Instance.isUsingVr) return;
DoSteamVRInput();
CVRPickupObject vrObject = (CVRPickupObject)_grabbedObject.GetValue(PlayerSetup.Instance.leftRay);
CVRPickupObject vrObject2 = (CVRPickupObject)_grabbedObject.GetValue(PlayerSetup.Instance.rightRay);
if (vrObject != null || vrObject2 != null)
DoSteamVRInput();
} }
private void DoDesktopInput() private void DoDesktopInput()
@ -180,19 +176,26 @@ public class PickupPushPull_Module : CVRInputModule
private void DoSteamVRInput() 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 >:((( bool canRotate = (leftObject != null && leftObject.gripType == CVRPickupObject.GripType.Free) ||
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)); (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.x += Setting_RotationSpeed * rawLookVector.x;
objectRotation.y += Setting_RotationSpeed * rawLookVector.y * -1; objectRotation.y += Setting_RotationSpeed * rawLookVector.y * -1;
_inputManager.lookVector = Vector2.zero; _inputManager.lookVector = Vector2.zero;
return; return;
} }
CVRInputManager.Instance.objectPushPull += CVRInputManager.Instance.floatDirection * Setting_PushPullSpeed * Time.deltaTime; CVRInputManager.Instance.objectPushPull += CVRInputManager.Instance.floatDirection * Setting_PushPullSpeed * Time.deltaTime;
} }
} }

View file

@ -20,7 +20,6 @@ public class PickupPushPull : MelonMod
public override void OnInitializeMelon() public override void OnInitializeMelon()
{ {
Category_PickupPushPull = MelonPreferences.CreateCategory(nameof(PickupPushPull)); Category_PickupPushPull = MelonPreferences.CreateCategory(nameof(PickupPushPull));
Category_PickupPushPull.SaveToFile(false);
//Global settings //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."); 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) while (PickupPushPull_Module.Instance == null)
yield return null; yield return null;
UpdateVRBinding();
UpdateAllSettings(); UpdateAllSettings();
} }

View file

@ -25,6 +25,6 @@ using System.Reflection;
namespace PickupPushPull.Properties; namespace PickupPushPull.Properties;
internal static class AssemblyInfoParams internal static class AssemblyInfoParams
{ {
public const string Version = "2.0.0"; public const string Version = "3.0.1";
public const string Author = "NotAKidoS"; public const string Author = "NotAKidoS";
} }

View file

@ -1,12 +1,12 @@
{ {
"_id": 91, "_id": 91,
"name": "PickupPushPull", "name": "PickupPushPull",
"modversion": "3.0.0", "modversion": "3.0.1",
"gameversion": "2022r168", "gameversion": "2022r170",
"loaderversion": "0.5.7", "loaderversion": "0.5.7",
"modtype": "Mod", "modtype": "Mod",
"author": "NotAKidoS", "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": [ "searchtags": [
"pull", "pull",
"push", "push",
@ -16,8 +16,8 @@
"requirements": [ "requirements": [
"None" "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/", "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" "embedcolor": "804221"
} }