mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-04 23:39:22 +00:00
[RelativeSync] actually fixed distance hider
This commit is contained in:
parent
6249696efa
commit
fea10ac221
2 changed files with 17 additions and 22 deletions
|
@ -6,6 +6,7 @@ using ABI.CCK.Components;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using NAK.RelativeSync.Components;
|
using NAK.RelativeSync.Components;
|
||||||
using NAK.RelativeSync.Networking;
|
using NAK.RelativeSync.Networking;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.RelativeSync.Patches;
|
namespace NAK.RelativeSync.Patches;
|
||||||
|
|
||||||
|
@ -27,20 +28,6 @@ internal static class PuppetMasterPatches
|
||||||
{
|
{
|
||||||
__instance.AddComponentIfMissing<RelativeSyncController>();
|
__instance.AddComponentIfMissing<RelativeSyncController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ShouldProcessAvatarVisibility { get; set; }
|
|
||||||
|
|
||||||
[HarmonyPrefix]
|
|
||||||
[HarmonyPatch(typeof(PuppetMaster), nameof(PuppetMaster.ProcessAvatarVisibility))]
|
|
||||||
private static bool Prefix_PuppetMaster_ProcessAvatarVisibility()
|
|
||||||
=> ShouldProcessAvatarVisibility;
|
|
||||||
|
|
||||||
public static void ForceProcessAvatarVisibility(PuppetMaster puppetMaster)
|
|
||||||
{
|
|
||||||
ShouldProcessAvatarVisibility = true;
|
|
||||||
puppetMaster.ProcessAvatarVisibility();
|
|
||||||
ShouldProcessAvatarVisibility = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class CVRSeatPatches
|
internal static class CVRSeatPatches
|
||||||
|
@ -104,16 +91,18 @@ internal static class NetIKController_Patches
|
||||||
{
|
{
|
||||||
if (!RelativeSyncManager.NetIkControllersToRelativeSyncControllers.TryGetValue(__instance,
|
if (!RelativeSyncManager.NetIkControllersToRelativeSyncControllers.TryGetValue(__instance,
|
||||||
out RelativeSyncController syncController))
|
out RelativeSyncController syncController))
|
||||||
{
|
|
||||||
// Process visibility only after applying network IK
|
|
||||||
PuppetMasterPatches.ForceProcessAvatarVisibility(__instance._puppetMaster);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Apply relative sync after the network IK has been applied
|
// Apply relative sync after the network IK has been applied
|
||||||
syncController.OnPostNetIkControllerLateUpdate();
|
syncController.OnPostNetIkControllerLateUpdate();
|
||||||
|
}
|
||||||
// Process visibility after we have moved the remote player
|
|
||||||
PuppetMasterPatches.ForceProcessAvatarVisibility(__instance._puppetMaster);
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(NetIKController), nameof(NetIKController.GetLocalPlayerPosition))]
|
||||||
|
private static bool Prefix_NetIKController_GetLocalPlayerPosition(ref NetIKController __instance, ref Vector3 __result)
|
||||||
|
{
|
||||||
|
// why is the original method so bad
|
||||||
|
__result = PlayerSetup.Instance.activeCam.transform.position;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
|
using ABI_RC.Systems.Movement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NAK.RelativeSync.Components;
|
namespace NAK.RelativeSync.Components;
|
||||||
|
@ -62,7 +63,7 @@ public class RelativeSyncController : MonoBehaviour
|
||||||
Animator animator = puppetMaster._animator;
|
Animator animator = puppetMaster._animator;
|
||||||
if (animator == null)
|
if (animator == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Transform avatarTransform = animator.transform;
|
Transform avatarTransform = animator.transform;
|
||||||
Transform hipTrans = (animator.avatar != null && animator.isHuman)
|
Transform hipTrans = (animator.avatar != null && animator.isHuman)
|
||||||
? animator.GetBoneTransform(HumanBodyBones.Hips) : null;
|
? animator.GetBoneTransform(HumanBodyBones.Hips) : null;
|
||||||
|
@ -97,6 +98,11 @@ public class RelativeSyncController : MonoBehaviour
|
||||||
hipTrans.position = transform.position + transform.rotation * relativeHipPos;
|
hipTrans.position = transform.position + transform.rotation * relativeHipPos;
|
||||||
hipTrans.rotation = transform.rotation * relativeHipRot;
|
hipTrans.rotation = transform.rotation * relativeHipRot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reprocess the root distance so we don't fuck avatar distance hider
|
||||||
|
NetIKController netIkController = puppetMaster.netIkController;
|
||||||
|
netIkController._rootDistance = Vector3.Distance((netIkController._collider.transform.position + netIkController._collider.center),
|
||||||
|
netIkController.GetLocalPlayerPosition()) - (netIkController._collider.radius + BetterBetterCharacterController.Instance.Radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyRelativeRotation(Transform avatarTransform, Transform hipTransform, float lerp)
|
private void ApplyRelativeRotation(Transform avatarTransform, Transform hipTransform, float lerp)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue