mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
final touches
completely migrated to new setup using a helper monobehavior, which makes code a lot cleaner
This commit is contained in:
parent
50c5016cc6
commit
22391d1fcc
5 changed files with 148 additions and 296 deletions
|
@ -1,10 +1,9 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI.CCK.Components;
|
||||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.IK;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using RootMotion.FinalIK;
|
||||
|
||||
namespace DesktopVRIK;
|
||||
|
@ -14,22 +13,59 @@ internal class HarmonyPatches
|
|||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "SetupAvatarGeneral")]
|
||||
private static void InitializeDesktopIKSystem(ref CVRAvatar ____avatarDescriptor)
|
||||
private static void SetupDesktopIKSystem(ref CVRAvatar ____avatarDescriptor)
|
||||
{
|
||||
if (MetaPort.Instance.isUsingVr) return;
|
||||
|
||||
//this will stop at the useless isVr return (the function is only ever called by vr anyways...)
|
||||
IKSystem.Instance.InitializeAvatar(____avatarDescriptor);
|
||||
if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Instance.Setting_Enabled)
|
||||
{
|
||||
//this will stop at the useless isVr return (the function is only ever called by vr anyways...)
|
||||
IKSystem.Instance.InitializeAvatar(____avatarDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(IKSystem), "InitializeAvatar")]
|
||||
private static void InitializeDesktopAvatar(CVRAvatar avatar, ref VRIK ____vrik)
|
||||
private static void InitializeDesktopAvatarVRIK(CVRAvatar avatar, ref VRIK ____vrik)
|
||||
{
|
||||
//need IKSystem to see VRIK component for setup
|
||||
____vrik = avatar.gameObject.AddComponent<VRIK>();
|
||||
//now i add my own VRIK stuff
|
||||
NAKDesktopVRIK NAKVRIK = avatar.gameObject.AddComponent<NAKDesktopVRIK>();
|
||||
NAKVRIK.CalibrateAvatarVRIK(avatar);
|
||||
if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Instance.Setting_Enabled)
|
||||
{
|
||||
//need IKSystem to see VRIK component for setup
|
||||
____vrik = avatar.gameObject.AddComponent<VRIK>();
|
||||
//now I calibrate DesktopVRIK
|
||||
DesktopVRIK.Instance.CalibrateAvatarVRIK(avatar);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool emotePlayed = false;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "Update")]
|
||||
private static void CorrectVRIK(ref bool ____emotePlaying, ref LookAtIK ___lookIK)
|
||||
{
|
||||
if (MetaPort.Instance.isUsingVr || DesktopVRIK.Instance == null) return;
|
||||
|
||||
//might need to rework this in the future
|
||||
if (____emotePlaying && !emotePlayed)
|
||||
{
|
||||
emotePlayed = true;
|
||||
if (DesktopVRIK.Instance.Setting_EmoteVRIK)
|
||||
{
|
||||
BodySystem.TrackingEnabled = false;
|
||||
//IKSystem.vrik.solver.Reset();
|
||||
}
|
||||
if (DesktopVRIK.Instance.Setting_EmoteLookAtIK && ___lookIK != null)
|
||||
{
|
||||
___lookIK.enabled = false;
|
||||
}
|
||||
}
|
||||
else if (!____emotePlaying && emotePlayed)
|
||||
{
|
||||
emotePlayed = false;
|
||||
IKSystem.vrik.solver.Reset();
|
||||
BodySystem.TrackingEnabled = true;
|
||||
if (___lookIK != null)
|
||||
{
|
||||
___lookIK.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue