mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
inputmodule update
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.
This commit is contained in:
parent
4ed64d0f17
commit
0f5781aec1
6 changed files with 347 additions and 181 deletions
31
PickupPushPull/HarmonyPatches.cs
Normal file
31
PickupPushPull/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using PickupPushPull.InputModules;
|
||||
|
||||
namespace PickupPushPull.HarmonyPatches;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class HarmonyPatches
|
||||
{
|
||||
//uses code from https://github.com/ljoonal/CVR-Plugins/tree/main/RotateIt
|
||||
//GPL-3.0 license - Thank you ljoonal for being smart brain :plead:
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRPickupObject), "Update")]
|
||||
public static void GrabbedObjectPatch(ref CVRPickupObject __instance)
|
||||
{
|
||||
// Need to only run when the object is grabbed by the local player
|
||||
if (!__instance.IsGrabbedByMe()) return;
|
||||
|
||||
Quaternion originalRotation = __instance.transform.rotation;
|
||||
Transform referenceTransform = __instance._controllerRay.transform;
|
||||
|
||||
__instance.transform.RotateAround(__instance.transform.position, referenceTransform.right, PickupPushPull_Module.Instance.objectRotation.y * Time.deltaTime);
|
||||
__instance.transform.RotateAround(__instance.transform.position, referenceTransform.up, PickupPushPull_Module.Instance.objectRotation.x * Time.deltaTime);
|
||||
|
||||
// Add the new difference between the og rotation and our newly added rotation the the stored offset.
|
||||
__instance.initialRotationalOffset *= Quaternion.Inverse(__instance.transform.rotation) * originalRotation;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue