From b3a65f31242cf16e864876ddaec8d986d7b0a64a Mon Sep 17 00:00:00 2001 From: SDraw Date: Sat, 18 Mar 2023 11:35:51 +0300 Subject: [PATCH 1/3] Animator parameters save and restore (reverted from commit 3a6304e566685529ef10fa218b2e42ad41e18e4e) --- ml_amt/AnimatorAnalyzer.cs | 71 -------------------------------------- ml_amt/Main.cs | 13 ++++--- 2 files changed, 6 insertions(+), 78 deletions(-) delete mode 100644 ml_amt/AnimatorAnalyzer.cs diff --git a/ml_amt/AnimatorAnalyzer.cs b/ml_amt/AnimatorAnalyzer.cs deleted file mode 100644 index 80c4531..0000000 --- a/ml_amt/AnimatorAnalyzer.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -namespace ml_amt -{ - class AnimatorAnalyzer - { - bool m_enabled = true; - List m_parameters = null; - - public void AnalyzeFrom(Animator p_animator) - { - m_enabled = p_animator.enabled; - m_parameters = p_animator.parameters?.ToList(); - - if(m_parameters != null) - { - foreach(var l_param in m_parameters) - { - switch(l_param.type) - { - case AnimatorControllerParameterType.Bool: - case AnimatorControllerParameterType.Trigger: - l_param.defaultBool = p_animator.GetBool(l_param.nameHash); - break; - case AnimatorControllerParameterType.Float: - l_param.defaultFloat = p_animator.GetFloat(l_param.nameHash); - break; - case AnimatorControllerParameterType.Int: - l_param.defaultInt = p_animator.GetInteger(l_param.nameHash); - break; - - } - } - } - } - - public void ApplyTo(Animator p_animator) - { - p_animator.enabled = m_enabled; - - if(m_parameters != null) - { - foreach(var l_param in m_parameters) - { - switch(l_param.type) - { - case AnimatorControllerParameterType.Bool: - p_animator.SetBool(l_param.nameHash, l_param.defaultBool); - break; - case AnimatorControllerParameterType.Float: - p_animator.SetFloat(l_param.nameHash, l_param.defaultFloat); - break; - case AnimatorControllerParameterType.Int: - p_animator.SetInteger(l_param.nameHash, l_param.defaultInt); - break; - case AnimatorControllerParameterType.Trigger: - { - if(l_param.defaultBool) - p_animator.SetTrigger(l_param.nameHash); - } - break; - } - } - } - } - - public bool IsEnabled() => m_enabled; - } -} diff --git a/ml_amt/Main.cs b/ml_amt/Main.cs index c913150..05ecf6b 100644 --- a/ml_amt/Main.cs +++ b/ml_amt/Main.cs @@ -256,15 +256,14 @@ namespace ml_amt return false; } - static void OnOverride_Prefix(ref CVRAnimatorManager __instance, out AnimatorAnalyzer __state) + static void OnOverride_Prefix(ref CVRAnimatorManager __instance, ref bool __state) { - __state = new AnimatorAnalyzer(); try { if(Settings.OverrideFix && (__instance.animator != null)) { - __state.AnalyzeFrom(__instance.animator); - if(__state.IsEnabled()) + __state = __instance.animator.enabled; + if(__state) __instance.animator.enabled = false; __instance.animator.WriteDefaultValues(); } @@ -274,14 +273,14 @@ namespace ml_amt MelonLoader.MelonLogger.Error(l_exception); } } - static void OnOverride_Postfix(ref CVRAnimatorManager __instance, AnimatorAnalyzer __state) + static void OnOverride_Postfix(ref CVRAnimatorManager __instance, bool __state) { try { if(Settings.OverrideFix && (__instance.animator != null)) { - __state.ApplyTo(__instance.animator); - if(__state.IsEnabled()) + __instance.animator.enabled = __state; + if(__state) __instance.animator.Update(0f); } } From 7acc7636f22d92ddc4c6b40c0589e267ff9540cb Mon Sep 17 00:00:00 2001 From: SDraw Date: Sat, 18 Mar 2023 12:45:24 +0300 Subject: [PATCH 2/3] Remove controller state change --- ml_amt/Main.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ml_amt/Main.cs b/ml_amt/Main.cs index 05ecf6b..881352a 100644 --- a/ml_amt/Main.cs +++ b/ml_amt/Main.cs @@ -222,8 +222,6 @@ namespace ml_amt if(__0 || (Mathf.Abs(l_currentHeight - l_newHeight) > (l_currentHeight * 0.05f)) || (Vector3.Distance(l_currentCenter, l_newCenter) > (l_currentHeight * 0.05f))) { - bool l_active = ___controller.enabled; - if(__0) ___controller.radius = l_newRadius; ___controller.height = l_newHeight; @@ -243,8 +241,6 @@ namespace ml_amt __instance.forceObject.transform.localScale = new Vector3(l_newRadius + 0.1f, l_newHeight, l_newRadius + 0.1f); if(__instance.groundCheck != null) __instance.groundCheck.localPosition = ____colliderCenter; - - ___controller.enabled = l_active; } } } From c0bff7310740703d06b4c34ede57cbcf28fc060c Mon Sep 17 00:00:00 2001 From: SDraw Date: Sun, 19 Mar 2023 14:12:01 +0300 Subject: [PATCH 3/3] Destroyed pickup detection Matching versions with stable build --- ml_drs/Properties/AssemblyInfo.cs | 2 +- ml_drs/ml_drs.csproj | 2 +- ml_egn/Properties/AssemblyInfo.cs | 2 +- ml_egn/ml_egn.csproj | 2 +- ml_pam/ArmMover.cs | 11 ++++++++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ml_drs/Properties/AssemblyInfo.cs b/ml_drs/Properties/AssemblyInfo.cs index 3e29b95..31fc69a 100644 --- a/ml_drs/Properties/AssemblyInfo.cs +++ b/ml_drs/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_drs.DesktopReticleSwitch), "DesktopReticleSwitch", "1.0.1-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_drs.DesktopReticleSwitch), "DesktopReticleSwitch", "1.0.0-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)] \ No newline at end of file diff --git a/ml_drs/ml_drs.csproj b/ml_drs/ml_drs.csproj index b1153cc..05af04f 100644 --- a/ml_drs/ml_drs.csproj +++ b/ml_drs/ml_drs.csproj @@ -7,7 +7,7 @@ DesktopReticleSwitch SDraw None - 1.0.1 + 1.0.0 diff --git a/ml_egn/Properties/AssemblyInfo.cs b/ml_egn/Properties/AssemblyInfo.cs index 7a56a6b..b1c8d98 100644 --- a/ml_egn/Properties/AssemblyInfo.cs +++ b/ml_egn/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -[assembly: MelonLoader.MelonInfo(typeof(ml_egn.ExtendedGameNotifications), "ExtendedGameNotifications", "1.0.2-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_egn.ExtendedGameNotifications), "ExtendedGameNotifications", "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)] \ No newline at end of file diff --git a/ml_egn/ml_egn.csproj b/ml_egn/ml_egn.csproj index 6441a3f..1bde6ae 100644 --- a/ml_egn/ml_egn.csproj +++ b/ml_egn/ml_egn.csproj @@ -4,7 +4,7 @@ netstandard2.1 x64 ExtendedGameNotifications - 1.0.2 + 1.0.1 SDraw None ExtendedGameNotifications diff --git a/ml_pam/ArmMover.cs b/ml_pam/ArmMover.cs index d9c5f7f..c9940ae 100644 --- a/ml_pam/ArmMover.cs +++ b/ml_pam/ArmMover.cs @@ -61,10 +61,15 @@ namespace ml_pam void Update() { - if(m_enabled && (m_pickup != null)) + if(m_enabled && !ReferenceEquals(m_pickup, null)) { - Matrix4x4 l_result = m_pickup.transform.GetMatrix() * m_offset; - m_target.position = l_result * ms_pointVector; + if(m_pickup != null) + { + Matrix4x4 l_result = m_pickup.transform.GetMatrix() * m_offset; + m_target.position = l_result * ms_pointVector; + } + else + this.OnPickupDrop(m_pickup); } }