From ee28311d5d332ded62067c544f6e78745bdc9093 Mon Sep 17 00:00:00 2001 From: SDraw Date: Sat, 20 Jun 2026 15:58:34 +0300 Subject: [PATCH] Fixed LeapMotionExtension --- ml_lme/GameEvents.cs | 19 +++++++++++++++++++ ml_lme/LeapInput.cs | 2 -- ml_lme/LeapManager.cs | 2 +- ml_lme/LeapTracked.cs | 13 +++++++++++++ ml_lme/LeapTracking.cs | 10 +++++----- ml_lme/Properties/AssemblyInfo.cs | 2 +- ml_lme/ml_lme.csproj | 2 +- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/ml_lme/GameEvents.cs b/ml_lme/GameEvents.cs index dfb023f..4916ab2 100644 --- a/ml_lme/GameEvents.cs +++ b/ml_lme/GameEvents.cs @@ -28,6 +28,7 @@ namespace ml_lme public static readonly GameEvent OnRayScale = new GameEvent(); public static readonly GameEvent OnPlayspaceScale = new GameEvent(); public static readonly GameEvent OnPickupGrab = new GameEvent(); + public static readonly GameEvent OnPostLocalPlayerMovementDataUpdate = new GameEvent(); internal static void Init(HarmonyLib.Harmony p_instance) { @@ -56,6 +57,12 @@ namespace ml_lme null, new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnPickupGrab_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) ); + + p_instance.Patch( + typeof(PlayerSetup).GetMethod("UpdatePlayerAvatarMovementData", BindingFlags.Instance | BindingFlags.NonPublic), + null, + new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnPlayerAvatarMovementDataUpdate_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); } catch(Exception e) { @@ -110,5 +117,17 @@ namespace ml_lme MelonLoader.MelonLogger.Error(e); } } + + static void OnPlayerAvatarMovementDataUpdate_Postfix(PlayerAvatarMovementData ____playerAvatarMovementData) + { + try + { + OnPostLocalPlayerMovementDataUpdate.Invoke(____playerAvatarMovementData); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } } } diff --git a/ml_lme/LeapInput.cs b/ml_lme/LeapInput.cs index a97e86d..e66bd50 100644 --- a/ml_lme/LeapInput.cs +++ b/ml_lme/LeapInput.cs @@ -2,7 +2,6 @@ using ABI.CCK.Components; using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.Player; using ABI_RC.Core.Savior; -using ABI_RC.Systems.IK; using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.VRModeSwitch; using System.Collections; @@ -651,7 +650,6 @@ namespace ml_lme void SetGameFingersTracking(bool p_state) { base._inputManager.individualFingerTracking = p_state; - IKSystem.Instance.FingerSystem.ControlActive = base._inputManager.individualFingerTracking; } } } diff --git a/ml_lme/LeapManager.cs b/ml_lme/LeapManager.cs index 11c674b..3d7ffd3 100644 --- a/ml_lme/LeapManager.cs +++ b/ml_lme/LeapManager.cs @@ -21,7 +21,7 @@ namespace ml_lme { if(Instance != null) { - DestroyImmediate(this); + Destroy(this); return; } diff --git a/ml_lme/LeapTracked.cs b/ml_lme/LeapTracked.cs index 22062d2..3dce4d2 100644 --- a/ml_lme/LeapTracked.cs +++ b/ml_lme/LeapTracked.cs @@ -153,6 +153,7 @@ namespace ml_lme CVRGameEventSystem.Avatar.OnLocalAvatarLoad.AddListener(this.OnAvatarSetup); CVRGameEventSystem.Avatar.OnLocalAvatarClear.AddListener(this.OnAvatarClear); GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); + GameEvents.OnPostLocalPlayerMovementDataUpdate.AddListener(this.OnMovementDataUpdate); } void OnDestroy() @@ -179,6 +180,7 @@ namespace ml_lme CVRGameEventSystem.Avatar.OnLocalAvatarLoad.RemoveListener(this.OnAvatarSetup); CVRGameEventSystem.Avatar.OnLocalAvatarClear.RemoveListener(this.OnAvatarClear); GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); + GameEvents.OnPostLocalPlayerMovementDataUpdate.RemoveListener(this.OnMovementDataUpdate); } void Update() @@ -326,6 +328,17 @@ namespace ml_lme } } + void OnMovementDataUpdate(PlayerAvatarMovementData p_data) + { + if(Settings.Enabled && (m_poseHandler != null)) + { + p_data.UseIndividualFingers = true; + + System.Array.Copy(m_pose.muscles, PlayerAvatarMovementData.MuscleGroups.LeftFingersStart, p_data.MuscleValues, PlayerAvatarMovementData.MuscleGroups.LeftFingersStart, PlayerAvatarMovementData.MuscleGroups.LeftFingersCount); + System.Array.Copy(m_pose.muscles, PlayerAvatarMovementData.MuscleGroups.RightFingersStart, p_data.MuscleValues, PlayerAvatarMovementData.MuscleGroups.RightFingersStart, PlayerAvatarMovementData.MuscleGroups.RightFingersCount); + } + } + void OnAvatarReuse() { // Old VRIK is destroyed by game diff --git a/ml_lme/LeapTracking.cs b/ml_lme/LeapTracking.cs index 9c62dc1..45ab6ce 100644 --- a/ml_lme/LeapTracking.cs +++ b/ml_lme/LeapTracking.cs @@ -1,4 +1,5 @@ using ABI_RC.Core.Player; +using ABI_RC.Core.Savior; using UnityEngine; namespace ml_lme @@ -24,10 +25,9 @@ namespace ml_lme { if(Instance != null) { - Object.DestroyImmediate(this); + Object.Destroy(this); return; } - Instance = this; m_root = new GameObject("Root").transform; @@ -136,9 +136,9 @@ namespace ml_lme { if(Settings.Enabled) { - Transform l_camera = PlayerSetup.Instance.activeCam.transform; - m_root.position = l_camera.position; - m_root.rotation = (Settings.HeadAttach ? l_camera.rotation : PlayerSetup.Instance.GetPlayerRotation()); + Transform l_pivot = MetaPort.Instance.isUsingVr ? PlayerSetup.Instance.vrCamera.transform : PlayerSetup.Instance.desktopCameraPivot; + m_root.position = l_pivot.position; + m_root.rotation = (Settings.HeadAttach ? l_pivot.rotation : PlayerSetup.Instance.GetPlayerRotation()); LeapParser.LeapData l_data = LeapManager.Instance.GetLatestData(); diff --git a/ml_lme/Properties/AssemblyInfo.cs b/ml_lme/Properties/AssemblyInfo.cs index e383520..51598d0 100644 --- a/ml_lme/Properties/AssemblyInfo.cs +++ b/ml_lme/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.6.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.6.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] diff --git a/ml_lme/ml_lme.csproj b/ml_lme/ml_lme.csproj index f4ee57b..ca169d5 100644 --- a/ml_lme/ml_lme.csproj +++ b/ml_lme/ml_lme.csproj @@ -4,7 +4,7 @@ netstandard2.1 x64 LeapMotionExtension - 1.6.4 + 1.6.5 SDraw SDraw LeapMotionExtension