mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Better avatar setup detection
This commit is contained in:
parent
2f9a46e471
commit
0794564563
5 changed files with 38 additions and 50 deletions
|
@ -20,11 +20,10 @@ namespace ml_amt
|
|||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAvatarClear_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
|
||||
);
|
||||
|
||||
HarmonyInstance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
|
||||
typeof(PlayerSetup).GetMethod("SetupAvatarGeneral", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnLocalAvatarSetup_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnSetupAvatarGeneral_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||
|
@ -44,18 +43,18 @@ namespace ml_amt
|
|||
m_localTweaker.SetCrouchLimit(p_value);
|
||||
}
|
||||
|
||||
static void OnLocalAvatarSetup_Postfix() => ms_instance?.OnLocalAvatarSetup();
|
||||
void OnLocalAvatarSetup()
|
||||
{
|
||||
if((m_localTweaker != null) && !PlayerSetup.Instance._inVr)
|
||||
m_localTweaker.OnAvatarSetup();
|
||||
}
|
||||
|
||||
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
|
||||
void OnAvatarClear()
|
||||
{
|
||||
if(m_localTweaker != null)
|
||||
m_localTweaker.OnAvatarClear();
|
||||
}
|
||||
|
||||
static void OnSetupAvatarGeneral_Postfix() => ms_instance?.OnSetupAvatarGeneral();
|
||||
void OnSetupAvatarGeneral()
|
||||
{
|
||||
if(m_localTweaker != null)
|
||||
m_localTweaker.OnSetupAvatarGeneral();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,12 +46,6 @@ namespace ml_amt
|
|||
m_parameters = new List<AdditionalParameterInfo>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(PlayerSetup.Instance._inVr)
|
||||
PlayerSetup.Instance.avatarSetupCompleted.AddListener(this.OnAvatarSetup);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(m_ready)
|
||||
|
@ -96,8 +90,8 @@ namespace ml_amt
|
|||
|
||||
public void OnAvatarClear()
|
||||
{
|
||||
m_vrIk = null;
|
||||
m_ready = false;
|
||||
m_vrIk = null;
|
||||
m_standing = true;
|
||||
m_parameters.Clear();
|
||||
m_locomotionWeight = 1f;
|
||||
|
@ -107,7 +101,7 @@ namespace ml_amt
|
|||
m_locomotionOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
public void OnAvatarSetup()
|
||||
public void OnSetupAvatarGeneral()
|
||||
{
|
||||
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<RootMotion.FinalIK.VRIK>();
|
||||
|
||||
|
@ -142,7 +136,7 @@ namespace ml_amt
|
|||
|
||||
l_customTransform = PlayerSetup.Instance._avatar.transform.Find("LocomotionOffset");
|
||||
m_customLocomotionOffset = (l_customTransform != null);
|
||||
m_locomotionOffset = m_customLocomotionOffset ? Vector3.zero : l_customTransform.localPosition;
|
||||
m_locomotionOffset = m_customLocomotionOffset ? l_customTransform.localPosition : Vector3.zero;
|
||||
|
||||
// Apply VRIK tweaks
|
||||
if(m_vrIk != null)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using RootMotion.FinalIK;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme
|
||||
|
@ -19,15 +18,9 @@ namespace ml_lme
|
|||
Transform m_leftHand = null;
|
||||
Transform m_rightHand = null;
|
||||
|
||||
bool m_knucklesInUse = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_indexIK = this.GetComponent<IndexIK>();
|
||||
m_knucklesInUse = PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles");
|
||||
|
||||
if(PlayerSetup.Instance._inVr)
|
||||
PlayerSetup.Instance.avatarSetupCompleted.AddListener(this.OnAvatarSetup);
|
||||
}
|
||||
|
||||
public void SetEnabled(bool p_state)
|
||||
|
@ -36,8 +29,8 @@ namespace ml_lme
|
|||
|
||||
if(m_indexIK != null)
|
||||
{
|
||||
m_indexIK.activeControl = (m_enabled || m_knucklesInUse);
|
||||
CVRInputManager.Instance.individualFingerTracking = (m_enabled || m_knucklesInUse);
|
||||
m_indexIK.activeControl = (m_enabled || Utils.AreKnucklesInUse());
|
||||
CVRInputManager.Instance.individualFingerTracking = (m_enabled || Utils.AreKnucklesInUse());
|
||||
}
|
||||
|
||||
if(m_leapIK != null)
|
||||
|
@ -56,6 +49,9 @@ namespace ml_lme
|
|||
{
|
||||
m_leftHand = p_left;
|
||||
m_rightHand = p_right;
|
||||
|
||||
if(m_leapIK != null)
|
||||
m_leapIK.SetHands(m_leftHand, m_rightHand);
|
||||
}
|
||||
|
||||
public void UpdateTracking(GestureMatcher.GesturesData p_gesturesData)
|
||||
|
@ -145,13 +141,13 @@ namespace ml_lme
|
|||
m_vrIK = null;
|
||||
}
|
||||
|
||||
public void OnAvatarSetup()
|
||||
public void OnSetupAvatarGeneral()
|
||||
{
|
||||
m_knucklesInUse = PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles");
|
||||
|
||||
if(m_indexIK != null)
|
||||
m_indexIK.activeControl = (m_enabled || m_knucklesInUse);
|
||||
CVRInputManager.Instance.individualFingerTracking = (m_enabled || m_knucklesInUse);
|
||||
m_indexIK.activeControl = (m_enabled || Utils.AreKnucklesInUse());
|
||||
CVRInputManager.Instance.individualFingerTracking = (m_enabled || Utils.AreKnucklesInUse());
|
||||
|
||||
m_vrIK = PlayerSetup.Instance._animator.GetComponent<VRIK>();
|
||||
|
||||
if(!PlayerSetup.Instance._inVr)
|
||||
{
|
||||
|
@ -160,8 +156,6 @@ namespace ml_lme
|
|||
m_leapIK.SetFingersOnly(m_fingersOnly);
|
||||
m_leapIK.SetHands(m_leftHand, m_rightHand);
|
||||
}
|
||||
else
|
||||
m_vrIK = PlayerSetup.Instance._animator.GetComponent<VRIK>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,6 @@ namespace ml_lme
|
|||
m_leapHands = new GameObject[GestureMatcher.GesturesData.ms_handsCount];
|
||||
|
||||
// Patches
|
||||
HarmonyInstance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarSetup_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
|
||||
);
|
||||
HarmonyInstance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
||||
null,
|
||||
|
@ -66,6 +61,7 @@ namespace ml_lme
|
|||
new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnSetupAvatarGeneral_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(CreateTrackingObjects());
|
||||
}
|
||||
|
||||
|
@ -334,15 +330,6 @@ namespace ml_lme
|
|||
m_leapTracked.OnAvatarClear();
|
||||
}
|
||||
|
||||
static void OnAvatarSetup_Postfix() => ms_instance?.OnAvatarSetup();
|
||||
void OnAvatarSetup()
|
||||
{
|
||||
if(!PlayerSetup.Instance._inVr && (m_leapTracked != null))
|
||||
m_leapTracked.OnAvatarSetup();
|
||||
|
||||
OnSettingsHeadAttachChange(Settings.HeadAttach);
|
||||
}
|
||||
|
||||
// Sneaky forced IndexIK calibration
|
||||
static void OnSetupAvatarGeneral_Prefix(ref PlayerSetup __instance)
|
||||
{
|
||||
|
@ -353,6 +340,15 @@ namespace ml_lme
|
|||
{
|
||||
if(__instance != null)
|
||||
__instance._inVr = ms_vrState;
|
||||
|
||||
ms_instance?.OnSetupAvatarGeneral();
|
||||
}
|
||||
void OnSetupAvatarGeneral()
|
||||
{
|
||||
if(m_leapTracked != null)
|
||||
m_leapTracked.OnSetupAvatarGeneral();
|
||||
|
||||
OnSettingsHeadAttachChange(Settings.HeadAttach);
|
||||
}
|
||||
|
||||
// Utilities
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
namespace ml_lme
|
||||
using ABI_RC.Core.Player;
|
||||
using System.Linq;
|
||||
|
||||
namespace ml_lme
|
||||
{
|
||||
static class Utils
|
||||
{
|
||||
public static bool AreKnucklesInUse() => PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles");
|
||||
|
||||
public static void Swap<T>(ref T lhs, ref T rhs)
|
||||
{
|
||||
T temp = lhs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue