Better avatar setup detection

This commit is contained in:
SDraw 2022-09-02 21:25:40 +03:00
parent 2f9a46e471
commit 0794564563
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
5 changed files with 38 additions and 50 deletions

View file

@ -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