mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-04 07:19:22 +00:00
[PlaySpaceScaleFix] Initial Commit
This commit is contained in:
parent
84fe655eb5
commit
df8bbf279f
5 changed files with 128 additions and 0 deletions
41
PlaySpaceScaleFix/HarmonyPatches.cs
Normal file
41
PlaySpaceScaleFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.IK;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.PlaySpaceScaleFix.HarmonyPatches;
|
||||
|
||||
class PlayerSetupPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
||||
private static void Prefix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
{
|
||||
__state = __instance.vrCamera.transform.position;
|
||||
__state.y = __instance.transform.position.y;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
||||
private static void Postfix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
{
|
||||
if (!PlaySpaceScaleFix.EntryEnabled.Value)
|
||||
return;
|
||||
|
||||
Vector3 newPosition = __instance.vrCamera.transform.position;
|
||||
newPosition.y = __instance.transform.position.y;
|
||||
|
||||
Vector3 offset = __state + newPosition;
|
||||
|
||||
// Offset _PlayerLocal to keep player in place
|
||||
__instance.transform.position += offset;
|
||||
|
||||
// TODO: Figure out why VRIK is wonky still
|
||||
if (IKSystem.vrik != null)
|
||||
{
|
||||
IKSystem.vrik.solver.locomotion.AddDeltaPosition(offset);
|
||||
IKSystem.vrik.solver.raycastOriginPelvis += offset;
|
||||
IKSystem.vrik.transform.position += offset;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue