From 8375a1323cef9826ce142e86cebce32cf445ea63 Mon Sep 17 00:00:00 2001 From: SDraw Date: Fri, 8 Mar 2024 01:55:16 +0300 Subject: [PATCH] Version bump --- README.md | 18 +- ml_amt/Properties/AssemblyInfo.cs | 2 +- ml_asl/Main.cs | 50 ++-- ml_asl/Properties/AssemblyInfo.cs | 8 +- ml_asl/ml_asl.csproj | 128 +++++----- ml_dht/DataParser.cs | 58 ++--- ml_dht/HeadTracked.cs | 394 +++++++++++++++--------------- ml_dht/Main.cs | 308 +++++++++++------------ ml_dht/Properties/AssemblyInfo.cs | 6 +- ml_dht/Utils.cs | 46 ++-- ml_dht/ml_dht.csproj | 168 ++++++------- ml_lme/Main.cs | 332 ++++++++++++------------- ml_lme/PoseHelper.cs | 52 ++-- ml_lme/Properties/AssemblyInfo.cs | 2 +- ml_pam/Main.cs | 320 ++++++++++++------------ ml_pam/PoseHelper.cs | 52 ++-- ml_pam/Properties/AssemblyInfo.cs | 2 +- ml_pam/Utils.cs | 44 ++-- ml_pin/Main.cs | 226 ++++++++--------- ml_pin/Properties/AssemblyInfo.cs | 8 +- ml_pin/ml_pin.csproj | 172 ++++++------- ml_pmc/Properties/AssemblyInfo.cs | 2 +- ml_prm/Properties/AssemblyInfo.cs | 2 +- ml_vei/Properties/AssemblyInfo.cs | 8 +- ml_vei/ml_vei.csproj | 156 ++++++------ 25 files changed, 1282 insertions(+), 1282 deletions(-) diff --git a/README.md b/README.md index 85d30e1..f51ede5 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ Merged set of MelonLoader mods for ChilloutVR. **Table for game build 2023r173:** | Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | |:---------:|:----------:|:--------------:| :----------------------------------------------------------------| -| [Avatar Motion Tweaker](/ml_amt/README.md) | ml_amt | 1.3.6 [:arrow_down:](../../releases/latest/download/ml_amt.dll)| ✔ Yes | -| [Avatar Synced Look](/ml_asl/README.md) | ml_asl | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_asl.dll)| ✔ Yes | -| [Desktop Head Tracking](/ml_dht/README.md) | ml_dht | 1.2.0 [:arrow_down:](../../releases/latest/download/ml_dht.dll) | ✔ Yes | -| [Leap Motion Extension](/ml_lme/README.md)| ml_lme | 1.4.5 [:arrow_down:](../../releases/latest/download/ml_lme.dll)| ✔ Yes | -| [Pickup Arm Movement](/ml_pam/README.md)| ml_pam | 1.0.9 [:arrow_down:](../../releases/latest/download/ml_pam.dll)| ✔ Yes | -| [Player Movement Copycat](/ml_pmc/README.md)| ml_pmc | 1.0.4 [:arrow_down:](../../releases/latest/download/ml_pmc.dll)| ✔ Yes | -| [Player Ragdoll Mod](/ml_prm/README.md) | ml_prm | 1.1.2 [:arrow_down:](../../releases/latest/download/ml_prm.dll)| ✔ Yes | -| [Players Instance Notifier](/ml_pin/README.md) | ml_pin | 1.0.1 [:arrow_down:](../../releases/latest/download/ml_ml_pin.dll)| ✔ Yes | -| [Vive Extended Input](/ml_vei/README.md) | ml_vei | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_vei.dll)| ✔ Yes | +| [Avatar Motion Tweaker](/ml_amt/README.md) | ml_amt | 1.3.7 [:arrow_down:](../../releases/latest/download/ml_amt.dll)| ✔ Yes
Update review | +| [Avatar Synced Look](/ml_asl/README.md) | ml_asl | 1.0.1 [:arrow_down:](../../releases/latest/download/ml_asl.dll)| ✔ Yes
Update review | +| [Desktop Head Tracking](/ml_dht/README.md) | ml_dht | 1.2.1 [:arrow_down:](../../releases/latest/download/ml_dht.dll) | ✔ Yes
Update review | +| [Leap Motion Extension](/ml_lme/README.md)| ml_lme | 1.4.6 [:arrow_down:](../../releases/latest/download/ml_lme.dll)| ✔ Yes
Update review | +| [Pickup Arm Movement](/ml_pam/README.md)| ml_pam | 1.1.0 [:arrow_down:](../../releases/latest/download/ml_pam.dll)| ✔ Yes
Update review | +| [Player Movement Copycat](/ml_pmc/README.md)| ml_pmc | 1.0.5 [:arrow_down:](../../releases/latest/download/ml_pmc.dll)| ✔ Yes
Update review | +| [Player Ragdoll Mod](/ml_prm/README.md) | ml_prm | 1.1.3 [:arrow_down:](../../releases/latest/download/ml_prm.dll)| ✔ Yes
Update review | +| [Players Instance Notifier](/ml_pin/README.md) | ml_pin | 1.0.2 [:arrow_down:](../../releases/latest/download/ml_ml_pin.dll)| ✔ Yes
Update review | +| [Vive Extended Input](/ml_vei/README.md) | ml_vei | 1.0.1 [:arrow_down:](../../releases/latest/download/ml_vei.dll)| ✔ Yes
Update review | **Archived mods:** | Full name | Short name | Notes | diff --git a/ml_amt/Properties/AssemblyInfo.cs b/ml_amt/Properties/AssemblyInfo.cs index 4273301..c0ff1dd 100644 --- a/ml_amt/Properties/AssemblyInfo.cs +++ b/ml_amt/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.7-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.7", "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_asl/Main.cs b/ml_asl/Main.cs index 968e458..8f7e414 100644 --- a/ml_asl/Main.cs +++ b/ml_asl/Main.cs @@ -1,25 +1,25 @@ -using ABI_RC.Core.Player; -using System.Reflection; - -namespace ml_asl -{ - public class AvatarSyncedLook : MelonLoader.MelonMod - { - public override void OnInitializeMelon() - { - Settings.Init(); - - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod("UpdatePlayerAvatarMovementData", BindingFlags.NonPublic | BindingFlags.Instance), - null, - new HarmonyLib.HarmonyMethod(typeof(AvatarSyncedLook).GetMethod(nameof(OnPlayerAvatarMovementDataUpdate_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) - ); - } - - static void OnPlayerAvatarMovementDataUpdate_Postfix(ref PlayerSetup __instance, PlayerAvatarMovementData ____playerAvatarMovementData) - { - if(Settings.Enabled && (__instance.EyeMovementController != null)) - ____playerAvatarMovementData.EyeTrackingOverride = true; - } - } -} +using ABI_RC.Core.Player; +using System.Reflection; + +namespace ml_asl +{ + public class AvatarSyncedLook : MelonLoader.MelonMod + { + public override void OnInitializeMelon() + { + Settings.Init(); + + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod("UpdatePlayerAvatarMovementData", BindingFlags.NonPublic | BindingFlags.Instance), + null, + new HarmonyLib.HarmonyMethod(typeof(AvatarSyncedLook).GetMethod(nameof(OnPlayerAvatarMovementDataUpdate_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) + ); + } + + static void OnPlayerAvatarMovementDataUpdate_Postfix(ref PlayerSetup __instance, PlayerAvatarMovementData ____playerAvatarMovementData) + { + if(Settings.Enabled && (__instance.EyeMovementController != null)) + ____playerAvatarMovementData.EyeTrackingOverride = true; + } + } +} diff --git a/ml_asl/Properties/AssemblyInfo.cs b/ml_asl/Properties/AssemblyInfo.cs index fcbf161..dcc9c32 100644 --- a/ml_asl/Properties/AssemblyInfo.cs +++ b/ml_asl/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_asl.AvatarSyncedLook), "AvatarSyncedLook", "1.0.1-ex", "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)] +[assembly: MelonLoader.MelonInfo(typeof(ml_asl.AvatarSyncedLook), "AvatarSyncedLook", "1.0.1", "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_asl/ml_asl.csproj b/ml_asl/ml_asl.csproj index 2e5e075..26aad9a 100644 --- a/ml_asl/ml_asl.csproj +++ b/ml_asl/ml_asl.csproj @@ -1,64 +1,64 @@ - - - - netstandard2.1 - x64 - AvatarSyncedLook - SDraw - None - AvatarSyncedLook - 1.0.1 - - - - - - - - - D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll - false - false - - - - - - - - - - - - - + + + + netstandard2.1 + x64 + AvatarSyncedLook + SDraw + None + AvatarSyncedLook + 1.0.1 + + + + + + + + + D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll + false + false + + + + + + + + + + + + + diff --git a/ml_dht/DataParser.cs b/ml_dht/DataParser.cs index abcceaf..a1844ed 100644 --- a/ml_dht/DataParser.cs +++ b/ml_dht/DataParser.cs @@ -1,29 +1,29 @@ -namespace ml_dht -{ - class DataParser - { - MemoryMapReader m_mapReader = null; - byte[] m_buffer = null; - TrackingData m_trackingData; - - public DataParser() - { - m_buffer = new byte[1024]; - m_mapReader = new MemoryMapReader(); - m_mapReader.Open("head/data"); - } - ~DataParser() - { - m_mapReader.Close(); - m_mapReader = null; - } - - public void Update() - { - if(m_mapReader.Read(ref m_buffer)) - m_trackingData = TrackingData.ToObject(m_buffer); - } - - public ref TrackingData GetLatestTrackingData() => ref m_trackingData; - } -} +namespace ml_dht +{ + class DataParser + { + MemoryMapReader m_mapReader = null; + byte[] m_buffer = null; + TrackingData m_trackingData; + + public DataParser() + { + m_buffer = new byte[1024]; + m_mapReader = new MemoryMapReader(); + m_mapReader.Open("head/data"); + } + ~DataParser() + { + m_mapReader.Close(); + m_mapReader = null; + } + + public void Update() + { + if(m_mapReader.Read(ref m_buffer)) + m_trackingData = TrackingData.ToObject(m_buffer); + } + + public ref TrackingData GetLatestTrackingData() => ref m_trackingData; + } +} diff --git a/ml_dht/HeadTracked.cs b/ml_dht/HeadTracked.cs index ab2a265..93811a8 100644 --- a/ml_dht/HeadTracked.cs +++ b/ml_dht/HeadTracked.cs @@ -1,197 +1,197 @@ -using ABI.CCK.Components; -using ABI_RC.Core.Player; -using ABI_RC.Core.Player.EyeMovement; -using ABI_RC.Systems.FaceTracking; -using ABI_RC.Systems.VRModeSwitch; -using RootMotion.FinalIK; -using System; -using System.Reflection; -using UnityEngine; -using ViveSR.anipal.Lip; - -namespace ml_dht -{ - [DisallowMultipleComponent] - class HeadTracked : MonoBehaviour - { - static FieldInfo ms_emotePlaying = typeof(PlayerSetup).GetField("_emotePlaying", BindingFlags.NonPublic | BindingFlags.Instance); - - bool m_enabled = false; - bool m_headTracking = true; - float m_smoothing = 0.5f; - - CVRAvatar m_avatarDescriptor = null; - Transform m_camera = null; - LookAtIK m_lookIK = null; - Transform m_headBone = null; - - Vector3 m_headPosition; - Quaternion m_headRotation; - Vector2 m_gazeDirection; - float m_blinkProgress = 0f; - LipData_v2 m_lipData; - bool m_lipDataSent = false; - - Quaternion m_bindRotation; - Quaternion m_lastHeadRotation; - - internal HeadTracked() - { - m_lipData = new LipData_v2(); - m_lipData.frame = 0; - m_lipData.time = 0; - m_lipData.image = IntPtr.Zero; - m_lipData.prediction_data = new PredictionData_v2(); - m_lipData.prediction_data.blend_shape_weight = new float[(int)LipShape_v2.Max]; - } - - // Unity events - void Start() - { - SetEnabled(Settings.Enabled); - SetHeadTracking(Settings.HeadTracking); - SetSmoothing(Settings.Smoothing); - - Settings.EnabledChange += this.SetEnabled; - Settings.HeadTrackingChange += this.SetHeadTracking; - Settings.SmoothingChange += this.SetSmoothing; - } - - void OnDestroy() - { - Settings.EnabledChange -= this.SetEnabled; - Settings.HeadTrackingChange -= this.SetHeadTracking; - Settings.SmoothingChange -= this.SetSmoothing; - } - - void Update() - { - if(m_lipDataSent) - m_lipDataSent = false; - } - - // Tracking updates - public void UpdateTrackingData(ref TrackingData p_data) - { - m_headPosition.Set(p_data.m_headPositionX * (Settings.Mirrored ? -1f : 1f), p_data.m_headPositionY, p_data.m_headPositionZ); - m_headRotation.Set(p_data.m_headRotationX, p_data.m_headRotationY * (Settings.Mirrored ? -1f : 1f), p_data.m_headRotationZ * (Settings.Mirrored ? -1f : 1f), p_data.m_headRotationW); - m_gazeDirection.Set(Settings.Mirrored ? (1f - p_data.m_gazeX) : p_data.m_gazeX, p_data.m_gazeY); - m_blinkProgress = p_data.m_blink; - - float l_weight = Mathf.Clamp01(Mathf.InverseLerp(0.25f, 1f, Mathf.Abs(p_data.m_mouthShape))); - m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Jaw_Open] = p_data.m_mouthOpen; - m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Mouth_Pout] = ((p_data.m_mouthShape > 0f) ? l_weight : 0f); - m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Mouth_Smile_Left] = ((p_data.m_mouthShape < 0f) ? l_weight : 0f); - m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Mouth_Smile_Right] = ((p_data.m_mouthShape < 0f) ? l_weight : 0f); - } - - void OnLookIKPostUpdate() - { - if(m_enabled && m_headTracking && (m_headBone != null)) - { - m_lastHeadRotation = Quaternion.Slerp(m_lastHeadRotation, m_avatarDescriptor.transform.rotation * (m_headRotation * m_bindRotation), m_smoothing); - - if(!(bool)ms_emotePlaying.GetValue(PlayerSetup.Instance)) - m_headBone.rotation = m_lastHeadRotation; - } - } - - // Game events - internal void OnSetupAvatar() - { - m_camera = PlayerSetup.Instance.GetActiveCamera().transform; - m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent(); - m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head); - m_lookIK = PlayerSetup.Instance._avatar.GetComponent(); - - if(m_headBone != null) - m_bindRotation = (m_avatarDescriptor.transform.GetMatrix().inverse * m_headBone.GetMatrix()).rotation; - - if(m_lookIK != null) - m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate); - - } - internal void OnAvatarClear() - { - m_avatarDescriptor = null; - m_lookIK = null; - m_headBone = null; - m_lastHeadRotation = Quaternion.identity; - m_bindRotation = Quaternion.identity; - } - internal void OnAvatarReinitialize() - { - m_camera = PlayerSetup.Instance.GetActiveCamera().transform; - m_lookIK = PlayerSetup.Instance._avatar.GetComponent(); - if(m_lookIK != null) - m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate); - } - - internal void OnEyeControllerUpdate(EyeMovementController p_component) - { - if(m_enabled) - { - // Gaze - if(Settings.EyeTracking && (m_camera != null)) - { - p_component.manualViewTarget = true; - p_component.targetViewPosition = m_camera.position + m_camera.rotation * new Vector3((m_gazeDirection.x - 0.5f) * 2f, (m_gazeDirection.y - 0.5f) * 2f, 1f); - } - - // Blink - if(Settings.Blinking) - { - p_component.manualBlinking = true; - p_component.blinkProgress = m_blinkProgress; - } - } - } - - internal bool UpdateFaceTracking(CVRFaceTracking p_component) - { - bool l_result = false; - if(m_enabled && Settings.FaceTracking) - { - if(!m_lipDataSent) - { - FaceTrackingManager.Instance.SubmitNewFacialData(m_lipData); - m_lipDataSent = true; - } - p_component.LipSyncWasUpdated = true; - p_component.UpdateShapesLocal_Private(); - - l_result = true; - } - return l_result; - } - - // Settings - void SetEnabled(bool p_state) - { - if(m_enabled != p_state) - { - m_enabled = p_state; - TryRestoreHeadRotation(); - } - } - void SetHeadTracking(bool p_state) - { - if(m_headTracking != p_state) - { - m_headTracking = p_state; - TryRestoreHeadRotation(); - } - } - void SetSmoothing(float p_value) - { - m_smoothing = 1f - Mathf.Clamp(p_value, 0f, 0.99f); - } - - // Arbitrary - void TryRestoreHeadRotation() - { - if(m_enabled && m_headTracking) - m_lastHeadRotation = ((m_headBone != null) ? m_headBone.rotation : m_bindRotation); - } - } -} +using ABI.CCK.Components; +using ABI_RC.Core.Player; +using ABI_RC.Core.Player.EyeMovement; +using ABI_RC.Systems.FaceTracking; +using ABI_RC.Systems.VRModeSwitch; +using RootMotion.FinalIK; +using System; +using System.Reflection; +using UnityEngine; +using ViveSR.anipal.Lip; + +namespace ml_dht +{ + [DisallowMultipleComponent] + class HeadTracked : MonoBehaviour + { + static FieldInfo ms_emotePlaying = typeof(PlayerSetup).GetField("_emotePlaying", BindingFlags.NonPublic | BindingFlags.Instance); + + bool m_enabled = false; + bool m_headTracking = true; + float m_smoothing = 0.5f; + + CVRAvatar m_avatarDescriptor = null; + Transform m_camera = null; + LookAtIK m_lookIK = null; + Transform m_headBone = null; + + Vector3 m_headPosition; + Quaternion m_headRotation; + Vector2 m_gazeDirection; + float m_blinkProgress = 0f; + LipData_v2 m_lipData; + bool m_lipDataSent = false; + + Quaternion m_bindRotation; + Quaternion m_lastHeadRotation; + + internal HeadTracked() + { + m_lipData = new LipData_v2(); + m_lipData.frame = 0; + m_lipData.time = 0; + m_lipData.image = IntPtr.Zero; + m_lipData.prediction_data = new PredictionData_v2(); + m_lipData.prediction_data.blend_shape_weight = new float[(int)LipShape_v2.Max]; + } + + // Unity events + void Start() + { + SetEnabled(Settings.Enabled); + SetHeadTracking(Settings.HeadTracking); + SetSmoothing(Settings.Smoothing); + + Settings.EnabledChange += this.SetEnabled; + Settings.HeadTrackingChange += this.SetHeadTracking; + Settings.SmoothingChange += this.SetSmoothing; + } + + void OnDestroy() + { + Settings.EnabledChange -= this.SetEnabled; + Settings.HeadTrackingChange -= this.SetHeadTracking; + Settings.SmoothingChange -= this.SetSmoothing; + } + + void Update() + { + if(m_lipDataSent) + m_lipDataSent = false; + } + + // Tracking updates + public void UpdateTrackingData(ref TrackingData p_data) + { + m_headPosition.Set(p_data.m_headPositionX * (Settings.Mirrored ? -1f : 1f), p_data.m_headPositionY, p_data.m_headPositionZ); + m_headRotation.Set(p_data.m_headRotationX, p_data.m_headRotationY * (Settings.Mirrored ? -1f : 1f), p_data.m_headRotationZ * (Settings.Mirrored ? -1f : 1f), p_data.m_headRotationW); + m_gazeDirection.Set(Settings.Mirrored ? (1f - p_data.m_gazeX) : p_data.m_gazeX, p_data.m_gazeY); + m_blinkProgress = p_data.m_blink; + + float l_weight = Mathf.Clamp01(Mathf.InverseLerp(0.25f, 1f, Mathf.Abs(p_data.m_mouthShape))); + m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Jaw_Open] = p_data.m_mouthOpen; + m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Mouth_Pout] = ((p_data.m_mouthShape > 0f) ? l_weight : 0f); + m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Mouth_Smile_Left] = ((p_data.m_mouthShape < 0f) ? l_weight : 0f); + m_lipData.prediction_data.blend_shape_weight[(int)LipShape_v2.Mouth_Smile_Right] = ((p_data.m_mouthShape < 0f) ? l_weight : 0f); + } + + void OnLookIKPostUpdate() + { + if(m_enabled && m_headTracking && (m_headBone != null)) + { + m_lastHeadRotation = Quaternion.Slerp(m_lastHeadRotation, m_avatarDescriptor.transform.rotation * (m_headRotation * m_bindRotation), m_smoothing); + + if(!(bool)ms_emotePlaying.GetValue(PlayerSetup.Instance)) + m_headBone.rotation = m_lastHeadRotation; + } + } + + // Game events + internal void OnSetupAvatar() + { + m_camera = PlayerSetup.Instance.GetActiveCamera().transform; + m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent(); + m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head); + m_lookIK = PlayerSetup.Instance._avatar.GetComponent(); + + if(m_headBone != null) + m_bindRotation = (m_avatarDescriptor.transform.GetMatrix().inverse * m_headBone.GetMatrix()).rotation; + + if(m_lookIK != null) + m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate); + + } + internal void OnAvatarClear() + { + m_avatarDescriptor = null; + m_lookIK = null; + m_headBone = null; + m_lastHeadRotation = Quaternion.identity; + m_bindRotation = Quaternion.identity; + } + internal void OnAvatarReinitialize() + { + m_camera = PlayerSetup.Instance.GetActiveCamera().transform; + m_lookIK = PlayerSetup.Instance._avatar.GetComponent(); + if(m_lookIK != null) + m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate); + } + + internal void OnEyeControllerUpdate(EyeMovementController p_component) + { + if(m_enabled) + { + // Gaze + if(Settings.EyeTracking && (m_camera != null)) + { + p_component.manualViewTarget = true; + p_component.targetViewPosition = m_camera.position + m_camera.rotation * new Vector3((m_gazeDirection.x - 0.5f) * 2f, (m_gazeDirection.y - 0.5f) * 2f, 1f); + } + + // Blink + if(Settings.Blinking) + { + p_component.manualBlinking = true; + p_component.blinkProgress = m_blinkProgress; + } + } + } + + internal bool UpdateFaceTracking(CVRFaceTracking p_component) + { + bool l_result = false; + if(m_enabled && Settings.FaceTracking) + { + if(!m_lipDataSent) + { + FaceTrackingManager.Instance.SubmitNewFacialData(m_lipData); + m_lipDataSent = true; + } + p_component.LipSyncWasUpdated = true; + p_component.UpdateShapesLocal_Private(); + + l_result = true; + } + return l_result; + } + + // Settings + void SetEnabled(bool p_state) + { + if(m_enabled != p_state) + { + m_enabled = p_state; + TryRestoreHeadRotation(); + } + } + void SetHeadTracking(bool p_state) + { + if(m_headTracking != p_state) + { + m_headTracking = p_state; + TryRestoreHeadRotation(); + } + } + void SetSmoothing(float p_value) + { + m_smoothing = 1f - Mathf.Clamp(p_value, 0f, 0.99f); + } + + // Arbitrary + void TryRestoreHeadRotation() + { + if(m_enabled && m_headTracking) + m_lastHeadRotation = ((m_headBone != null) ? m_headBone.rotation : m_bindRotation); + } + } +} diff --git a/ml_dht/Main.cs b/ml_dht/Main.cs index c701136..ae4f9f8 100644 --- a/ml_dht/Main.cs +++ b/ml_dht/Main.cs @@ -1,155 +1,155 @@ -using ABI.CCK.Components; -using ABI_RC.Core.Player; -using ABI_RC.Core.Player.EyeMovement; -using ABI_RC.Core.Savior; -using ABI_RC.Systems.IK; -using System.Reflection; - -namespace ml_dht -{ - public class DesktopHeadTracking : MelonLoader.MelonMod - { - static DesktopHeadTracking ms_instance = null; - - DataParser m_dataParser = null; - HeadTracked m_localTracked = null; - - public override void OnInitializeMelon() - { - if(ms_instance == null) - ms_instance = this; - - Settings.Init(); - - // Patches - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public), - null, - new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - - MelonLoader.MelonCoroutines.Start(WaitForInstances()); - } - - System.Collections.IEnumerator WaitForInstances() - { - while(MetaPort.Instance == null) - yield return null; - - while(PlayerSetup.Instance == null) - yield return null; - - m_dataParser = new DataParser(); - m_localTracked = PlayerSetup.Instance.gameObject.AddComponent(); - - // If you think it's a joke to put patch here, go on, try to put it in OnInitializeMelon, you melon :> - HarmonyInstance.Patch( - typeof(EyeMovementController).GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic), - null, - new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnEyeControllerUpdate_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(CVRFaceTracking).GetMethod("UpdateLocalData", BindingFlags.Instance | BindingFlags.NonPublic), - new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnFaceTrackingLocalUpdate_Prefix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - } - - public override void OnDeinitializeMelon() - { - if(ms_instance == this) - ms_instance = null; - - m_dataParser = null; - m_localTracked = null; - } - - public override void OnUpdate() - { - if(Settings.Enabled && (m_dataParser != null)) - { - m_dataParser.Update(); - if(m_localTracked != null) - m_localTracked.UpdateTrackingData(ref m_dataParser.GetLatestTrackingData()); - } - } - - static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar(); - void OnSetupAvatar() - { - try - { - if(m_localTracked != null) - m_localTracked.OnSetupAvatar(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); - void OnAvatarClear() - { - try - { - if(m_localTracked != null) - m_localTracked.OnAvatarClear(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnAvatarReinitialize_Postfix() => ms_instance?.OnAvatarReinitialize(); - void OnAvatarReinitialize() - { - try - { - if(m_localTracked != null) - m_localTracked.OnAvatarReinitialize(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnEyeControllerUpdate_Postfix(ref EyeMovementController __instance) => ms_instance?.OnEyeControllerUpdate(__instance); - void OnEyeControllerUpdate(EyeMovementController p_component) - { - try - { - if(p_component.IsLocal && (m_localTracked != null)) - m_localTracked.OnEyeControllerUpdate(p_component); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static bool OnFaceTrackingLocalUpdate_Prefix(ref CVRFaceTracking __instance) - { - bool? l_result = ms_instance?.OnFaceTrackingLocalUpdate(__instance); - return l_result.GetValueOrDefault(true); - } - bool OnFaceTrackingLocalUpdate(CVRFaceTracking p_component) - { - bool l_result = true; - if(p_component.UseFacialTracking && (m_localTracked != null)) - l_result = !m_localTracked.UpdateFaceTracking(p_component); - return l_result; - } - } +using ABI.CCK.Components; +using ABI_RC.Core.Player; +using ABI_RC.Core.Player.EyeMovement; +using ABI_RC.Core.Savior; +using ABI_RC.Systems.IK; +using System.Reflection; + +namespace ml_dht +{ + public class DesktopHeadTracking : MelonLoader.MelonMod + { + static DesktopHeadTracking ms_instance = null; + + DataParser m_dataParser = null; + HeadTracked m_localTracked = null; + + public override void OnInitializeMelon() + { + if(ms_instance == null) + ms_instance = this; + + Settings.Init(); + + // Patches + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public), + null, + new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + + MelonLoader.MelonCoroutines.Start(WaitForInstances()); + } + + System.Collections.IEnumerator WaitForInstances() + { + while(MetaPort.Instance == null) + yield return null; + + while(PlayerSetup.Instance == null) + yield return null; + + m_dataParser = new DataParser(); + m_localTracked = PlayerSetup.Instance.gameObject.AddComponent(); + + // If you think it's a joke to put patch here, go on, try to put it in OnInitializeMelon, you melon :> + HarmonyInstance.Patch( + typeof(EyeMovementController).GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic), + null, + new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnEyeControllerUpdate_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(CVRFaceTracking).GetMethod("UpdateLocalData", BindingFlags.Instance | BindingFlags.NonPublic), + new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnFaceTrackingLocalUpdate_Prefix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + } + + public override void OnDeinitializeMelon() + { + if(ms_instance == this) + ms_instance = null; + + m_dataParser = null; + m_localTracked = null; + } + + public override void OnUpdate() + { + if(Settings.Enabled && (m_dataParser != null)) + { + m_dataParser.Update(); + if(m_localTracked != null) + m_localTracked.UpdateTrackingData(ref m_dataParser.GetLatestTrackingData()); + } + } + + static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar(); + void OnSetupAvatar() + { + try + { + if(m_localTracked != null) + m_localTracked.OnSetupAvatar(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); + void OnAvatarClear() + { + try + { + if(m_localTracked != null) + m_localTracked.OnAvatarClear(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnAvatarReinitialize_Postfix() => ms_instance?.OnAvatarReinitialize(); + void OnAvatarReinitialize() + { + try + { + if(m_localTracked != null) + m_localTracked.OnAvatarReinitialize(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnEyeControllerUpdate_Postfix(ref EyeMovementController __instance) => ms_instance?.OnEyeControllerUpdate(__instance); + void OnEyeControllerUpdate(EyeMovementController p_component) + { + try + { + if(p_component.IsLocal && (m_localTracked != null)) + m_localTracked.OnEyeControllerUpdate(p_component); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static bool OnFaceTrackingLocalUpdate_Prefix(ref CVRFaceTracking __instance) + { + bool? l_result = ms_instance?.OnFaceTrackingLocalUpdate(__instance); + return l_result.GetValueOrDefault(true); + } + bool OnFaceTrackingLocalUpdate(CVRFaceTracking p_component) + { + bool l_result = true; + if(p_component.UseFacialTracking && (m_localTracked != null)) + l_result = !m_localTracked.UpdateFaceTracking(p_component); + return l_result; + } + } } \ No newline at end of file diff --git a/ml_dht/Properties/AssemblyInfo.cs b/ml_dht/Properties/AssemblyInfo.cs index 7b7e58e..e58c6a7 100644 --- a/ml_dht/Properties/AssemblyInfo.cs +++ b/ml_dht/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_dht.DesktopHeadTracking), "DesktopHeadTracking", "1.2.1-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] -[assembly: MelonLoader.MelonGame(null, "ChilloutVR")] -[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonLoader.MelonInfo(typeof(ml_dht.DesktopHeadTracking), "DesktopHeadTracking", "1.2.1", "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)] \ No newline at end of file diff --git a/ml_dht/Utils.cs b/ml_dht/Utils.cs index e3cff3c..fc2681d 100644 --- a/ml_dht/Utils.cs +++ b/ml_dht/Utils.cs @@ -1,23 +1,23 @@ -using ABI.CCK.Components; -using ABI_RC.Core.UI; -using System.Reflection; -using UnityEngine; - -namespace ml_dht -{ - static class Utils - { - static readonly object[] ms_emptyArray = new object[0]; - static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); - static readonly MethodInfo ms_updateShapesLocal = typeof(CVRFaceTracking).GetMethod("UpdateShapesLocal", BindingFlags.NonPublic | BindingFlags.Instance); - - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); - - static public void UpdateShapesLocal_Private(this CVRFaceTracking p_instance) => ms_updateShapesLocal?.Invoke(p_instance, ms_emptyArray); - - public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) - { - return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); - } - } -} +using ABI.CCK.Components; +using ABI_RC.Core.UI; +using System.Reflection; +using UnityEngine; + +namespace ml_dht +{ + static class Utils + { + static readonly object[] ms_emptyArray = new object[0]; + static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly MethodInfo ms_updateShapesLocal = typeof(CVRFaceTracking).GetMethod("UpdateShapesLocal", BindingFlags.NonPublic | BindingFlags.Instance); + + static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + + static public void UpdateShapesLocal_Private(this CVRFaceTracking p_instance) => ms_updateShapesLocal?.Invoke(p_instance, ms_emptyArray); + + public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) + { + return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); + } + } +} diff --git a/ml_dht/ml_dht.csproj b/ml_dht/ml_dht.csproj index 85d58d2..bef7127 100644 --- a/ml_dht/ml_dht.csproj +++ b/ml_dht/ml_dht.csproj @@ -1,84 +1,84 @@ - - - - netstandard2.1 - DesktopHeadTracking - SDraw - None - DesktopHeadTracking - 1.2.1 - x64 - - - - x64 - none - false - - - - - - - - - - - - - - - - - - D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll - false - false - - - - - - - - + + + + netstandard2.1 + DesktopHeadTracking + SDraw + None + DesktopHeadTracking + 1.2.1 + x64 + + + + x64 + none + false + + + + + + + + + + + + + + + + + + D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll + false + false + + + + + + + + diff --git a/ml_lme/Main.cs b/ml_lme/Main.cs index 5ee3cc0..2210141 100644 --- a/ml_lme/Main.cs +++ b/ml_lme/Main.cs @@ -1,166 +1,166 @@ -using ABI.CCK.Components; -using ABI_RC.Core.Player; -using ABI_RC.Systems.IK; -using System.Collections; -using System.Reflection; -using UnityEngine; - -namespace ml_lme -{ - - public class LeapMotionExtension : MelonLoader.MelonMod - { - static LeapMotionExtension ms_instance = null; - - LeapManager m_leapManager = null; - - public override void OnInitializeMelon() - { - if(ms_instance == null) - ms_instance = this; - - DependenciesHandler.ExtractDependencies(); - Settings.Init(); - AssetsHandler.Load(); - - // Patches - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public), - null, - new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetControllerRayScale)), - null, - new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnRayScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod("SetPlaySpaceScale", BindingFlags.NonPublic | BindingFlags.Instance), - null, - new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - - typeof(CVRPickupObject).GetMethod(nameof(CVRPickupObject.Grab), BindingFlags.Public | BindingFlags.Instance), - null, - new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnPickupGrab_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - - ModSupporter.Init(); - MelonLoader.MelonCoroutines.Start(WaitForRootLogic()); - } - - public override void OnDeinitializeMelon() - { - if(ms_instance == this) - ms_instance = null; - - if(m_leapManager != null) - Object.Destroy(m_leapManager); - m_leapManager = null; - } - - IEnumerator WaitForRootLogic() - { - while(ABI_RC.Core.RootLogic.Instance == null) - yield return null; - - m_leapManager = new GameObject("LeapMotionManager").AddComponent(); - } - - // Patches - static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); - void OnAvatarClear() - { - try - { - if(m_leapManager != null) - m_leapManager.OnAvatarClear(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar(); - void OnSetupAvatar() - { - try - { - if(m_leapManager != null) - m_leapManager.OnAvatarSetup(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnAvatarReinitialize_Postfix() => ms_instance?.OnAvatarReinitialize(); - void OnAvatarReinitialize() - { - try - { - if(m_leapManager != null) - m_leapManager.OnAvatarReinitialize(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnRayScale_Postfix(float __0) => ms_instance?.OnRayScale(__0); - void OnRayScale(float p_scale) - { - try - { - if(m_leapManager != null) - m_leapManager.OnRayScale(p_scale); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnPlayspaceScale_Postfix(float ____avatarScaleRelation) => ms_instance?.OnPlayspaceScale(____avatarScaleRelation); - void OnPlayspaceScale(float p_relation) - { - try - { - if(m_leapManager != null) - m_leapManager.OnPlayspaceScale(p_relation); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnPickupGrab_Postfix(ref CVRPickupObject __instance) => ms_instance?.OnPickupGrab(__instance); - void OnPickupGrab(CVRPickupObject p_pickup) - { - try - { - if(m_leapManager != null) - m_leapManager.OnPickupGrab(p_pickup); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - } -} +using ABI.CCK.Components; +using ABI_RC.Core.Player; +using ABI_RC.Systems.IK; +using System.Collections; +using System.Reflection; +using UnityEngine; + +namespace ml_lme +{ + + public class LeapMotionExtension : MelonLoader.MelonMod + { + static LeapMotionExtension ms_instance = null; + + LeapManager m_leapManager = null; + + public override void OnInitializeMelon() + { + if(ms_instance == null) + ms_instance = this; + + DependenciesHandler.ExtractDependencies(); + Settings.Init(); + AssetsHandler.Load(); + + // Patches + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public), + null, + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetControllerRayScale)), + null, + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnRayScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod("SetPlaySpaceScale", BindingFlags.NonPublic | BindingFlags.Instance), + null, + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + + typeof(CVRPickupObject).GetMethod(nameof(CVRPickupObject.Grab), BindingFlags.Public | BindingFlags.Instance), + null, + new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnPickupGrab_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + + ModSupporter.Init(); + MelonLoader.MelonCoroutines.Start(WaitForRootLogic()); + } + + public override void OnDeinitializeMelon() + { + if(ms_instance == this) + ms_instance = null; + + if(m_leapManager != null) + Object.Destroy(m_leapManager); + m_leapManager = null; + } + + IEnumerator WaitForRootLogic() + { + while(ABI_RC.Core.RootLogic.Instance == null) + yield return null; + + m_leapManager = new GameObject("LeapMotionManager").AddComponent(); + } + + // Patches + static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); + void OnAvatarClear() + { + try + { + if(m_leapManager != null) + m_leapManager.OnAvatarClear(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar(); + void OnSetupAvatar() + { + try + { + if(m_leapManager != null) + m_leapManager.OnAvatarSetup(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnAvatarReinitialize_Postfix() => ms_instance?.OnAvatarReinitialize(); + void OnAvatarReinitialize() + { + try + { + if(m_leapManager != null) + m_leapManager.OnAvatarReinitialize(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnRayScale_Postfix(float __0) => ms_instance?.OnRayScale(__0); + void OnRayScale(float p_scale) + { + try + { + if(m_leapManager != null) + m_leapManager.OnRayScale(p_scale); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnPlayspaceScale_Postfix(float ____avatarScaleRelation) => ms_instance?.OnPlayspaceScale(____avatarScaleRelation); + void OnPlayspaceScale(float p_relation) + { + try + { + if(m_leapManager != null) + m_leapManager.OnPlayspaceScale(p_relation); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnPickupGrab_Postfix(ref CVRPickupObject __instance) => ms_instance?.OnPickupGrab(__instance); + void OnPickupGrab(CVRPickupObject p_pickup) + { + try + { + if(m_leapManager != null) + m_leapManager.OnPickupGrab(p_pickup); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + } +} diff --git a/ml_lme/PoseHelper.cs b/ml_lme/PoseHelper.cs index 4dbf3e7..7982a2d 100644 --- a/ml_lme/PoseHelper.cs +++ b/ml_lme/PoseHelper.cs @@ -1,26 +1,26 @@ -using UnityEngine; -using ABI_RC.Systems.IK; - -namespace ml_lme -{ - static class PoseHelper - { - public static void ForceTPose(Animator p_animator) - { - if(p_animator.isHuman) - { - HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform); - HumanPose l_pose = new HumanPose(); - l_handler.GetHumanPose(ref l_pose); - - for(int i=0, j = Mathf.Min(l_pose.muscles.Length,MusclePoses.TPoseMuscles.Length); i < j; i++) - l_pose.muscles[i] = MusclePoses.TPoseMuscles[i]; - - l_pose.bodyPosition = Vector3.up; - l_pose.bodyRotation = Quaternion.identity; - l_handler.SetHumanPose(ref l_pose); - l_handler.Dispose(); - } - } - } -} +using UnityEngine; +using ABI_RC.Systems.IK; + +namespace ml_lme +{ + static class PoseHelper + { + public static void ForceTPose(Animator p_animator) + { + if(p_animator.isHuman) + { + HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform); + HumanPose l_pose = new HumanPose(); + l_handler.GetHumanPose(ref l_pose); + + for(int i=0, j = Mathf.Min(l_pose.muscles.Length,MusclePoses.TPoseMuscles.Length); i < j; i++) + l_pose.muscles[i] = MusclePoses.TPoseMuscles[i]; + + l_pose.bodyPosition = Vector3.up; + l_pose.bodyRotation = Quaternion.identity; + l_handler.SetHumanPose(ref l_pose); + l_handler.Dispose(); + } + } + } +} diff --git a/ml_lme/Properties/AssemblyInfo.cs b/ml_lme/Properties/AssemblyInfo.cs index 2a759ab..066024d 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.4.6-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.4.6", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonOptionalDependencies("ml_pmc")] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] diff --git a/ml_pam/Main.cs b/ml_pam/Main.cs index b6e17a9..24da047 100644 --- a/ml_pam/Main.cs +++ b/ml_pam/Main.cs @@ -1,160 +1,160 @@ -using ABI.CCK.Components; -using ABI_RC.Core.InteractionSystem; -using ABI_RC.Core.Player; -using ABI_RC.Systems.IK; -using System; -using System.Reflection; -using UnityEngine; - -namespace ml_pam -{ - public class PickupArmMovement : MelonLoader.MelonMod - { - static PickupArmMovement ms_instance = null; - - ArmMover m_localMover = null; - - public override void OnInitializeMelon() - { - if(ms_instance == null) - ms_instance = this; - - Settings.Init(); - - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) - ); - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), - null, - new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public), - null, - new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(CVRPickupObject).GetMethod(nameof(CVRPickupObject.Grab)), - null, - new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnCVRPickupObjectGrab_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(CVRPickupObject).GetMethod(nameof(CVRPickupObject.Drop)), - null, - new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnCVRPickupObjectDrop_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - HarmonyInstance.Patch( - typeof(PlayerSetup).GetMethod("SetPlaySpaceScale", BindingFlags.NonPublic | BindingFlags.Instance), - null, - new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) - ); - - MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer()); - } - - System.Collections.IEnumerator WaitForLocalPlayer() - { - while(PlayerSetup.Instance == null) - yield return null; - - m_localMover = PlayerSetup.Instance.gameObject.AddComponent(); - } - - public override void OnDeinitializeMelon() - { - if(ms_instance == this) - ms_instance = null; - - if(m_localMover != null) - UnityEngine.Object.Destroy(m_localMover); - m_localMover = null; - } - - static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); - void OnAvatarClear() - { - try - { - if(m_localMover != null) - m_localMover.OnAvatarClear(); - } - catch(Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar(); - void OnSetupAvatar() - { - try - { - if(m_localMover != null) - m_localMover.OnAvatarSetup(); - } - catch(Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnAvatarReinitialize_Postfix() => ms_instance?.OnAvatarReinitialize(); - void OnAvatarReinitialize() - { - try - { - if(m_localMover != null) - m_localMover.OnAvatarReinitialize(); - } - catch(System.Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnCVRPickupObjectGrab_Postfix(ref CVRPickupObject __instance, ControllerRay __1, Vector3 __2) => ms_instance?.OnCVRPickupObjectGrab(__instance, __1, __2); - void OnCVRPickupObjectGrab(CVRPickupObject p_pickup, ControllerRay p_ray, Vector3 p_hit) - { - try - { - if(p_pickup.IsGrabbedByMe() && (m_localMover != null)) - m_localMover.OnPickupGrab(p_pickup, p_ray, p_hit); - } - catch(Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnCVRPickupObjectDrop_Postfix(ref CVRPickupObject __instance) => ms_instance?.OnCVRPickupObjectDrop(__instance); - void OnCVRPickupObjectDrop(CVRPickupObject p_pickup) - { - try - { - if(m_localMover != null) - m_localMover.OnPickupDrop(p_pickup); - } - catch(Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - - static void OnPlayspaceScale_Postfix(float ____avatarScaleRelation) => ms_instance?.OnPlayspaceScale(____avatarScaleRelation); - void OnPlayspaceScale(float p_relation) - { - try - { - if(m_localMover != null) - m_localMover.OnPlayspaceScale(p_relation); - } - catch(Exception e) - { - MelonLoader.MelonLogger.Error(e); - } - } - } -} +using ABI.CCK.Components; +using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core.Player; +using ABI_RC.Systems.IK; +using System; +using System.Reflection; +using UnityEngine; + +namespace ml_pam +{ + public class PickupArmMovement : MelonLoader.MelonMod + { + static PickupArmMovement ms_instance = null; + + ArmMover m_localMover = null; + + public override void OnInitializeMelon() + { + if(ms_instance == null) + ms_instance = this; + + Settings.Init(); + + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) + ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)), + null, + new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public), + null, + new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(CVRPickupObject).GetMethod(nameof(CVRPickupObject.Grab)), + null, + new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnCVRPickupObjectGrab_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(CVRPickupObject).GetMethod(nameof(CVRPickupObject.Drop)), + null, + new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnCVRPickupObjectDrop_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod("SetPlaySpaceScale", BindingFlags.NonPublic | BindingFlags.Instance), + null, + new HarmonyLib.HarmonyMethod(typeof(PickupArmMovement).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic)) + ); + + MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer()); + } + + System.Collections.IEnumerator WaitForLocalPlayer() + { + while(PlayerSetup.Instance == null) + yield return null; + + m_localMover = PlayerSetup.Instance.gameObject.AddComponent(); + } + + public override void OnDeinitializeMelon() + { + if(ms_instance == this) + ms_instance = null; + + if(m_localMover != null) + UnityEngine.Object.Destroy(m_localMover); + m_localMover = null; + } + + static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear(); + void OnAvatarClear() + { + try + { + if(m_localMover != null) + m_localMover.OnAvatarClear(); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnSetupAvatar_Postfix() => ms_instance?.OnSetupAvatar(); + void OnSetupAvatar() + { + try + { + if(m_localMover != null) + m_localMover.OnAvatarSetup(); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnAvatarReinitialize_Postfix() => ms_instance?.OnAvatarReinitialize(); + void OnAvatarReinitialize() + { + try + { + if(m_localMover != null) + m_localMover.OnAvatarReinitialize(); + } + catch(System.Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnCVRPickupObjectGrab_Postfix(ref CVRPickupObject __instance, ControllerRay __1, Vector3 __2) => ms_instance?.OnCVRPickupObjectGrab(__instance, __1, __2); + void OnCVRPickupObjectGrab(CVRPickupObject p_pickup, ControllerRay p_ray, Vector3 p_hit) + { + try + { + if(p_pickup.IsGrabbedByMe() && (m_localMover != null)) + m_localMover.OnPickupGrab(p_pickup, p_ray, p_hit); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnCVRPickupObjectDrop_Postfix(ref CVRPickupObject __instance) => ms_instance?.OnCVRPickupObjectDrop(__instance); + void OnCVRPickupObjectDrop(CVRPickupObject p_pickup) + { + try + { + if(m_localMover != null) + m_localMover.OnPickupDrop(p_pickup); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnPlayspaceScale_Postfix(float ____avatarScaleRelation) => ms_instance?.OnPlayspaceScale(____avatarScaleRelation); + void OnPlayspaceScale(float p_relation) + { + try + { + if(m_localMover != null) + m_localMover.OnPlayspaceScale(p_relation); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + } +} diff --git a/ml_pam/PoseHelper.cs b/ml_pam/PoseHelper.cs index ecf871f..7ed7ba1 100644 --- a/ml_pam/PoseHelper.cs +++ b/ml_pam/PoseHelper.cs @@ -1,26 +1,26 @@ -using UnityEngine; -using ABI_RC.Systems.IK; - -namespace ml_pam -{ - static class PoseHelper - { - public static void ForceTPose(Animator p_animator) - { - if(p_animator.isHuman) - { - HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform); - HumanPose l_pose = new HumanPose(); - l_handler.GetHumanPose(ref l_pose); - - for(int i = 0, j = Mathf.Min(l_pose.muscles.Length, MusclePoses.TPoseMuscles.Length); i < j; i++) - l_pose.muscles[i] = MusclePoses.TPoseMuscles[i]; - - l_pose.bodyPosition = Vector3.up; - l_pose.bodyRotation = Quaternion.identity; - l_handler.SetHumanPose(ref l_pose); - l_handler.Dispose(); - } - } - } -} +using UnityEngine; +using ABI_RC.Systems.IK; + +namespace ml_pam +{ + static class PoseHelper + { + public static void ForceTPose(Animator p_animator) + { + if(p_animator.isHuman) + { + HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform); + HumanPose l_pose = new HumanPose(); + l_handler.GetHumanPose(ref l_pose); + + for(int i = 0, j = Mathf.Min(l_pose.muscles.Length, MusclePoses.TPoseMuscles.Length); i < j; i++) + l_pose.muscles[i] = MusclePoses.TPoseMuscles[i]; + + l_pose.bodyPosition = Vector3.up; + l_pose.bodyRotation = Quaternion.identity; + l_handler.SetHumanPose(ref l_pose); + l_handler.Dispose(); + } + } + } +} diff --git a/ml_pam/Properties/AssemblyInfo.cs b/ml_pam/Properties/AssemblyInfo.cs index 9bd9a57..1cfa86b 100644 --- a/ml_pam/Properties/AssemblyInfo.cs +++ b/ml_pam/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_pam.PickupArmMovement), "PickupArmMovement", "1.1.0-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_pam.PickupArmMovement), "PickupArmMovement", "1.1.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPriority(1)] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] diff --git a/ml_pam/Utils.cs b/ml_pam/Utils.cs index ec4513b..2ddbeef 100644 --- a/ml_pam/Utils.cs +++ b/ml_pam/Utils.cs @@ -1,22 +1,22 @@ -using ABI_RC.Core.Savior; -using ABI_RC.Core.UI; -using System.Reflection; -using UnityEngine; - -namespace ml_pam -{ - static class Utils - { - static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); - - public static bool IsInVR() => ((MetaPort.Instance != null) && MetaPort.Instance.isUsingVr); - - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); - - // Extensions - public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) - { - return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); - } - } -} +using ABI_RC.Core.Savior; +using ABI_RC.Core.UI; +using System.Reflection; +using UnityEngine; + +namespace ml_pam +{ + static class Utils + { + static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); + + public static bool IsInVR() => ((MetaPort.Instance != null) && MetaPort.Instance.isUsingVr); + + static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + + // Extensions + public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) + { + return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); + } + } +} diff --git a/ml_pin/Main.cs b/ml_pin/Main.cs index 59f5c03..4a4cf1b 100644 --- a/ml_pin/Main.cs +++ b/ml_pin/Main.cs @@ -1,113 +1,113 @@ -using ABI_RC.Core.AudioEffects; -using ABI_RC.Core.Networking.IO.Social; -using ABI_RC.Core.Player; -using ABI_RC.Core.Savior; -using ABI_RC.Systems.GameEventSystem; -using System; -using System.Collections; - -namespace ml_pin -{ - public class PlayersInstanceNotifier : MelonLoader.MelonMod - { - SoundManager m_soundManager = null; - - public override void OnInitializeMelon() - { - Settings.Init(); - ResourcesHandler.ExtractAudioResources(); - - MelonLoader.MelonCoroutines.Start(WaitForInstances()); - } - - public override void OnDeinitializeMelon() - { - m_soundManager = null; - } - - IEnumerator WaitForInstances() - { - if(InterfaceAudio.Instance == null) - yield return null; - - m_soundManager = new SoundManager(); - m_soundManager.LoadSounds(); - - CVRGameEventSystem.Player.OnJoin.AddListener(OnPlayerJoin); - CVRGameEventSystem.Player.OnLeave.AddListener(OnPlayerLeave); - } - - void OnPlayerJoin(PlayerDescriptor p_player) - { - try - { - if(p_player != null) // This happens sometimes, no idea why - { - bool l_isFriend = Friends.FriendsWith(p_player.ownerId); - bool l_notify = false; - - switch(Settings.NotifyType) - { - case Settings.NotificationType.None: - l_notify = false; - break; - case Settings.NotificationType.Friends: - l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); - break; - case Settings.NotificationType.All: - l_notify = ShouldNotifyInCurrentInstance(); - break; - } - l_notify |= (l_isFriend && Settings.FriendsAlways); - - if(l_notify) - m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendJoin : SoundManager.SoundType.PlayerJoin); - } - } - catch(Exception e) - { - MelonLoader.MelonLogger.Warning(e); - } - } - void OnPlayerLeave(PlayerDescriptor p_player) - { - try - { - if(p_player != null) // This happens sometimes, no idea why - { - bool l_isFriend = Friends.FriendsWith(p_player.ownerId); - bool l_notify = false; - - switch(Settings.NotifyType) - { - case Settings.NotificationType.None: - l_notify = false; - break; - case Settings.NotificationType.Friends: - l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); - break; - case Settings.NotificationType.All: - l_notify = ShouldNotifyInCurrentInstance(); - break; - } - l_notify |= (l_isFriend && Settings.FriendsAlways); - - if(l_notify) - m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendLeave : SoundManager.SoundType.PlayerLeave); - } - } - catch(Exception e) - { - MelonLoader.MelonLogger.Warning(e); - } - } - - bool ShouldNotifyInCurrentInstance() - { - bool l_isInPublic = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Public") && Settings.NotifyInPublic); - bool l_isInFriends = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends") && Settings.NotifyInFriends); - bool l_isInPrivate = (MetaPort.Instance.CurrentInstancePrivacy.Contains("invite") && Settings.NotifyInPrivate); - return (l_isInPublic || l_isInFriends || l_isInPrivate); - } - } -} +using ABI_RC.Core.AudioEffects; +using ABI_RC.Core.Networking.IO.Social; +using ABI_RC.Core.Player; +using ABI_RC.Core.Savior; +using ABI_RC.Systems.GameEventSystem; +using System; +using System.Collections; + +namespace ml_pin +{ + public class PlayersInstanceNotifier : MelonLoader.MelonMod + { + SoundManager m_soundManager = null; + + public override void OnInitializeMelon() + { + Settings.Init(); + ResourcesHandler.ExtractAudioResources(); + + MelonLoader.MelonCoroutines.Start(WaitForInstances()); + } + + public override void OnDeinitializeMelon() + { + m_soundManager = null; + } + + IEnumerator WaitForInstances() + { + if(InterfaceAudio.Instance == null) + yield return null; + + m_soundManager = new SoundManager(); + m_soundManager.LoadSounds(); + + CVRGameEventSystem.Player.OnJoin.AddListener(OnPlayerJoin); + CVRGameEventSystem.Player.OnLeave.AddListener(OnPlayerLeave); + } + + void OnPlayerJoin(PlayerDescriptor p_player) + { + try + { + if(p_player != null) // This happens sometimes, no idea why + { + bool l_isFriend = Friends.FriendsWith(p_player.ownerId); + bool l_notify = false; + + switch(Settings.NotifyType) + { + case Settings.NotificationType.None: + l_notify = false; + break; + case Settings.NotificationType.Friends: + l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); + break; + case Settings.NotificationType.All: + l_notify = ShouldNotifyInCurrentInstance(); + break; + } + l_notify |= (l_isFriend && Settings.FriendsAlways); + + if(l_notify) + m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendJoin : SoundManager.SoundType.PlayerJoin); + } + } + catch(Exception e) + { + MelonLoader.MelonLogger.Warning(e); + } + } + void OnPlayerLeave(PlayerDescriptor p_player) + { + try + { + if(p_player != null) // This happens sometimes, no idea why + { + bool l_isFriend = Friends.FriendsWith(p_player.ownerId); + bool l_notify = false; + + switch(Settings.NotifyType) + { + case Settings.NotificationType.None: + l_notify = false; + break; + case Settings.NotificationType.Friends: + l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); + break; + case Settings.NotificationType.All: + l_notify = ShouldNotifyInCurrentInstance(); + break; + } + l_notify |= (l_isFriend && Settings.FriendsAlways); + + if(l_notify) + m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendLeave : SoundManager.SoundType.PlayerLeave); + } + } + catch(Exception e) + { + MelonLoader.MelonLogger.Warning(e); + } + } + + bool ShouldNotifyInCurrentInstance() + { + bool l_isInPublic = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Public") && Settings.NotifyInPublic); + bool l_isInFriends = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends") && Settings.NotifyInFriends); + bool l_isInPrivate = (MetaPort.Instance.CurrentInstancePrivacy.Contains("invite") && Settings.NotifyInPrivate); + return (l_isInPublic || l_isInFriends || l_isInPrivate); + } + } +} diff --git a/ml_pin/Properties/AssemblyInfo.cs b/ml_pin/Properties/AssemblyInfo.cs index 67b4925..8698d98 100644 --- a/ml_pin/Properties/AssemblyInfo.cs +++ b/ml_pin/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_pin.PlayersInstanceNotifier), "PlayersInstanceNotifier", "1.0.2-ex", "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)] +[assembly: MelonLoader.MelonInfo(typeof(ml_pin.PlayersInstanceNotifier), "PlayersInstanceNotifier", "1.0.2", "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_pin/ml_pin.csproj b/ml_pin/ml_pin.csproj index 9228213..baa0a25 100644 --- a/ml_pin/ml_pin.csproj +++ b/ml_pin/ml_pin.csproj @@ -1,86 +1,86 @@ - - - - netstandard2.1 - x64 - PlayersInstanceNotifier - SDraw - None - PlayersInstanceNotifier - 1.0.2 - - - - - - - - - - - - - - - - - - - - - D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AudioModule.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.UnityWebRequestModule.dll - false - false - - - - - - - - + + + + netstandard2.1 + x64 + PlayersInstanceNotifier + SDraw + None + PlayersInstanceNotifier + 1.0.2 + + + + + + + + + + + + + + + + + + + + + D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AudioModule.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.UnityWebRequestModule.dll + false + false + + + + + + + + diff --git a/ml_pmc/Properties/AssemblyInfo.cs b/ml_pmc/Properties/AssemblyInfo.cs index 518b369..58290fc 100644 --- a/ml_pmc/Properties/AssemblyInfo.cs +++ b/ml_pmc/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_pmc.PlayerMovementCopycat), "PlayerMovementCopycat", "1.0.5-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_pmc.PlayerMovementCopycat), "PlayerMovementCopycat", "1.0.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPriority(3)] [assembly: MelonLoader.MelonAdditionalDependencies("BTKUILib")] diff --git a/ml_prm/Properties/AssemblyInfo.cs b/ml_prm/Properties/AssemblyInfo.cs index 3b540bd..0a8d1f9 100644 --- a/ml_prm/Properties/AssemblyInfo.cs +++ b/ml_prm/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.1.3-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.1.3", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPriority(2)] [assembly: MelonLoader.MelonOptionalDependencies("BTKUILib")] diff --git a/ml_vei/Properties/AssemblyInfo.cs b/ml_vei/Properties/AssemblyInfo.cs index 1fb0b47..129e479 100644 --- a/ml_vei/Properties/AssemblyInfo.cs +++ b/ml_vei/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_vei.ViveExtendedInput), "ViveExtendedInput", "1.0.1-ex", "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)] +[assembly: MelonLoader.MelonInfo(typeof(ml_vei.ViveExtendedInput), "ViveExtendedInput", "1.0.1", "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_vei/ml_vei.csproj b/ml_vei/ml_vei.csproj index ffd4ad5..cb12959 100644 --- a/ml_vei/ml_vei.csproj +++ b/ml_vei/ml_vei.csproj @@ -1,78 +1,78 @@ - - - - netstandard2.1 - x64 - ViveExtendedInput - 1.0.1 - SDraw - None - ViveExtendedInput - - - - - - - - - - D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.Postprocessing.Runtime.dll - false - false - - - D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll - false - false - - - D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll - false - false - - - - - - - - - - - - - - - - + + + + netstandard2.1 + x64 + ViveExtendedInput + 1.0.1 + SDraw + None + ViveExtendedInput + + + + + + + + + + D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\cohtml.Net.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.Postprocessing.Runtime.dll + false + false + + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll + false + false + + + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll + false + false + + + + + + + + + + + + + + + +