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)
{
// 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;

View file

@ -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,9 +49,9 @@ 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<ControllerRay>();
@ -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<string, bool>(SettingsBoolChanged));
deadzoneRightValue = (float)MetaPort.Instance.settings.GetSettingInt("ControlDeadZoneRight", 0) / 100f;
MetaPort.Instance.settings.settingIntChanged.AddListener(new UnityAction<string, int>(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,10 +132,6 @@ 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();
}
@ -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;
}
}

View file

@ -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();
}

View file

@ -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";
}

View file

@ -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"
}