Fixed LeapMotionExtension

This commit is contained in:
SDraw 2026-06-20 15:58:34 +03:00
parent 92357d3076
commit ee28311d5d
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
7 changed files with 40 additions and 10 deletions

View file

@ -28,6 +28,7 @@ namespace ml_lme
public static readonly GameEvent<float> OnRayScale = new GameEvent<float>(); public static readonly GameEvent<float> OnRayScale = new GameEvent<float>();
public static readonly GameEvent<float> OnPlayspaceScale = new GameEvent<float>(); public static readonly GameEvent<float> OnPlayspaceScale = new GameEvent<float>();
public static readonly GameEvent<CVRPickupObject> OnPickupGrab = new GameEvent<CVRPickupObject>(); public static readonly GameEvent<CVRPickupObject> OnPickupGrab = new GameEvent<CVRPickupObject>();
public static readonly GameEvent<PlayerAvatarMovementData> OnPostLocalPlayerMovementDataUpdate = new GameEvent<PlayerAvatarMovementData>();
internal static void Init(HarmonyLib.Harmony p_instance) internal static void Init(HarmonyLib.Harmony p_instance)
{ {
@ -56,6 +57,12 @@ namespace ml_lme
null, null,
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnPickupGrab_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) 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) catch(Exception e)
{ {
@ -110,5 +117,17 @@ namespace ml_lme
MelonLoader.MelonLogger.Error(e); MelonLoader.MelonLogger.Error(e);
} }
} }
static void OnPlayerAvatarMovementDataUpdate_Postfix(PlayerAvatarMovementData ____playerAvatarMovementData)
{
try
{
OnPostLocalPlayerMovementDataUpdate.Invoke(____playerAvatarMovementData);
}
catch(Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
} }
} }

View file

@ -2,7 +2,6 @@ using ABI.CCK.Components;
using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.InputManagement;
using ABI_RC.Systems.VRModeSwitch; using ABI_RC.Systems.VRModeSwitch;
using System.Collections; using System.Collections;
@ -651,7 +650,6 @@ namespace ml_lme
void SetGameFingersTracking(bool p_state) void SetGameFingersTracking(bool p_state)
{ {
base._inputManager.individualFingerTracking = p_state; base._inputManager.individualFingerTracking = p_state;
IKSystem.Instance.FingerSystem.ControlActive = base._inputManager.individualFingerTracking;
} }
} }
} }

View file

@ -21,7 +21,7 @@ namespace ml_lme
{ {
if(Instance != null) if(Instance != null)
{ {
DestroyImmediate(this); Destroy(this);
return; return;
} }

View file

@ -153,6 +153,7 @@ namespace ml_lme
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.AddListener(this.OnAvatarSetup); CVRGameEventSystem.Avatar.OnLocalAvatarLoad.AddListener(this.OnAvatarSetup);
CVRGameEventSystem.Avatar.OnLocalAvatarClear.AddListener(this.OnAvatarClear); CVRGameEventSystem.Avatar.OnLocalAvatarClear.AddListener(this.OnAvatarClear);
GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse);
GameEvents.OnPostLocalPlayerMovementDataUpdate.AddListener(this.OnMovementDataUpdate);
} }
void OnDestroy() void OnDestroy()
@ -179,6 +180,7 @@ namespace ml_lme
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.RemoveListener(this.OnAvatarSetup); CVRGameEventSystem.Avatar.OnLocalAvatarLoad.RemoveListener(this.OnAvatarSetup);
CVRGameEventSystem.Avatar.OnLocalAvatarClear.RemoveListener(this.OnAvatarClear); CVRGameEventSystem.Avatar.OnLocalAvatarClear.RemoveListener(this.OnAvatarClear);
GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse);
GameEvents.OnPostLocalPlayerMovementDataUpdate.RemoveListener(this.OnMovementDataUpdate);
} }
void Update() 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() void OnAvatarReuse()
{ {
// Old VRIK is destroyed by game // Old VRIK is destroyed by game

View file

@ -1,4 +1,5 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using UnityEngine; using UnityEngine;
namespace ml_lme namespace ml_lme
@ -24,10 +25,9 @@ namespace ml_lme
{ {
if(Instance != null) if(Instance != null)
{ {
Object.DestroyImmediate(this); Object.Destroy(this);
return; return;
} }
Instance = this; Instance = this;
m_root = new GameObject("Root").transform; m_root = new GameObject("Root").transform;
@ -136,9 +136,9 @@ namespace ml_lme
{ {
if(Settings.Enabled) if(Settings.Enabled)
{ {
Transform l_camera = PlayerSetup.Instance.activeCam.transform; Transform l_pivot = MetaPort.Instance.isUsingVr ? PlayerSetup.Instance.vrCamera.transform : PlayerSetup.Instance.desktopCameraPivot;
m_root.position = l_camera.position; m_root.position = l_pivot.position;
m_root.rotation = (Settings.HeadAttach ? l_camera.rotation : PlayerSetup.Instance.GetPlayerRotation()); m_root.rotation = (Settings.HeadAttach ? l_pivot.rotation : PlayerSetup.Instance.GetPlayerRotation());
LeapParser.LeapData l_data = LeapManager.Instance.GetLatestData(); LeapParser.LeapData l_data = LeapManager.Instance.GetLatestData();

View file

@ -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.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] [assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<PackageId>LeapMotionExtension</PackageId> <PackageId>LeapMotionExtension</PackageId>
<Version>1.6.4</Version> <Version>1.6.5</Version>
<Authors>SDraw</Authors> <Authors>SDraw</Authors>
<Company>SDraw</Company> <Company>SDraw</Company>
<Product>LeapMotionExtension</Product> <Product>LeapMotionExtension</Product>