Removed animation override fix from AMT into GMF

This commit is contained in:
SDraw 2023-09-09 19:57:17 +03:00
parent 65632c763e
commit 674f572415
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
13 changed files with 25 additions and 49 deletions

View file

@ -1,71 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace ml_amt.Fixes
{
class AnimatorAnalyzer
{
bool m_enabled = true;
List<AnimatorControllerParameter> 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;
}
}

View file

@ -1,60 +0,0 @@
using ABI_RC.Core;
using System;
using System.Reflection;
namespace ml_amt.Fixes
{
static class AnimatorOverrideControllerFix
{
internal static void Init(HarmonyLib.Harmony p_instance)
{
// AAS overriding fix
p_instance.Patch(
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.SetOverrideAnimation)),
new HarmonyLib.HarmonyMethod(typeof(AnimatorOverrideControllerFix).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
new HarmonyLib.HarmonyMethod(typeof(AnimatorOverrideControllerFix).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
p_instance.Patch(
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.RestoreOverrideAnimation)),
new HarmonyLib.HarmonyMethod(typeof(AnimatorOverrideControllerFix).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
new HarmonyLib.HarmonyMethod(typeof(AnimatorOverrideControllerFix).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
}
// AnimatorOverrideController runtime animation replacement fix
static void OnOverride_Prefix(ref CVRAnimatorManager __instance, out AnimatorAnalyzer __state)
{
__state = new AnimatorAnalyzer();
try
{
if(Settings.OverrideFix && (__instance.animator != null))
{
__state.AnalyzeFrom(__instance.animator);
if(__state.IsEnabled())
__instance.animator.enabled = false;
__instance.animator.WriteDefaultValues();
}
}
catch(Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
static void OnOverride_Postfix(ref CVRAnimatorManager __instance, AnimatorAnalyzer __state)
{
try
{
if(Settings.OverrideFix && (__instance.animator != null))
{
__state.ApplyTo(__instance.animator);
if(__state.IsEnabled())
__instance.animator.Update(0f);
}
}
catch(Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
}
}

View file

@ -41,9 +41,8 @@ namespace ml_amt
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
// Fixes
Fixes.AnimatorOverrideControllerFix.Init(HarmonyInstance);
Fixes.MovementJumpFix.Init(HarmonyInstance);
// Overhauls
Overhauls.JumpHeight.Init(HarmonyInstance);
ModSupporter.Init();
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());

View file

@ -7,9 +7,9 @@ using System.Collections;
using System.Reflection;
using UnityEngine;
namespace ml_amt.Fixes
namespace ml_amt.Overhauls
{
static class MovementJumpFix
static class JumpHeight
{
static FieldInfo ms_avatarHeight = typeof(PlayerSetup).GetField("_avatarHeight", BindingFlags.NonPublic | BindingFlags.Instance);
@ -20,17 +20,17 @@ namespace ml_amt.Fixes
p_instance.Patch(
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
null,
new HarmonyLib.HarmonyMethod(typeof(MovementJumpFix).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
new HarmonyLib.HarmonyMethod(typeof(JumpHeight).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
p_instance.Patch(
typeof(CVRWorld).GetMethod("SetupWorldRules", BindingFlags.NonPublic | BindingFlags.Instance),
null,
new HarmonyLib.HarmonyMethod(typeof(MovementJumpFix).GetMethod(nameof(OnWorldRulesSetup_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
new HarmonyLib.HarmonyMethod(typeof(JumpHeight).GetMethod(nameof(OnWorldRulesSetup_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
p_instance.Patch(
typeof(PlayerSetup).GetMethod("SetupIKScaling", BindingFlags.NonPublic | BindingFlags.Instance),
null,
new HarmonyLib.HarmonyMethod(typeof(MovementJumpFix).GetMethod(nameof(OnSetupIKScaling_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
new HarmonyLib.HarmonyMethod(typeof(JumpHeight).GetMethod(nameof(OnSetupIKScaling_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
Settings.ScaledJumpChange += OnScaledJumpChange;

View file

@ -1,4 +1,4 @@
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.1", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.2", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonOptionalDependencies("ml_prm", "ml_pmc")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]

View file

@ -24,8 +24,6 @@ Available mod's settings in `Settings - IK - Avatar Motion Tweaker`:
#### Fixes/overhauls options
* **Scaled locomotion jump:** scales locomotion jump according to relation between your player settings height and current avatar height (includes avatar scale); default value - `false`.
* Note: Disabled in worlds that don't allow flight.
* **Fix animation overrides (chairs, etc.):** fixes animations overriding for avatars with AAS; default value - `true`.
* Note: This option is made to address [broken animator in chairs and combat worlds issue](https://feedback.abinteractive.net/p/gestures-getting-stuck-locally-upon-entering-vehicles-chairs).
Available additional parameters for AAS animator:
* **`Upright`:** defines linear coefficient between current viewpoint height and avatar's viewpoint height; float, range - [0.0, 1.0].

View file

@ -16,8 +16,7 @@ namespace ml_amt
DetectEmotes,
FollowHips,
ScaledJump,
MassCenter,
OverrideFix
MassCenter
};
public static float CrouchLimit { get; private set; } = 0.75f;
@ -28,7 +27,6 @@ namespace ml_amt
public static bool FollowHips { get; private set; } = true;
public static bool MassCenter { get; private set; } = true;
public static bool ScaledJump { get; private set; } = false;
public static bool OverrideFix { get; private set; } = true;
static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
@ -56,8 +54,7 @@ namespace ml_amt
ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), DetectEmotes),
ms_category.CreateEntry(ModSetting.FollowHips.ToString(), FollowHips),
ms_category.CreateEntry(ModSetting.ScaledJump.ToString(), ScaledJump),
ms_category.CreateEntry(ModSetting.MassCenter.ToString(), MassCenter),
ms_category.CreateEntry(ModSetting.OverrideFix.ToString(), OverrideFix)
ms_category.CreateEntry(ModSetting.MassCenter.ToString(), MassCenter)
};
CrouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
@ -68,7 +65,6 @@ namespace ml_amt
FollowHips = (bool)ms_entries[(int)ModSetting.FollowHips].BoxedValue;
MassCenter = (bool)ms_entries[(int)ModSetting.MassCenter].BoxedValue;
ScaledJump = (bool)ms_entries[(int)ModSetting.ScaledJump].BoxedValue;
OverrideFix = (bool)ms_entries[(int)ModSetting.OverrideFix].BoxedValue;
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
}
@ -167,13 +163,6 @@ namespace ml_amt
ScaledJumpChange?.Invoke(ScaledJump);
}
break;
case ModSetting.OverrideFix:
{
OverrideFix = bool.Parse(p_value);
OverrideFixChange?.Invoke(OverrideFix);
}
break;
}
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);

View file

@ -12,7 +12,6 @@ namespace ml_amt
static readonly FieldInfo ms_grounded = typeof(MovementSystem).GetField("_isGrounded", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_hasToes = typeof(IKSolverVR).GetField("hasToes", BindingFlags.NonPublic | BindingFlags.Instance);
static MethodInfo ms_getSineKeyframes = typeof(IKSolverVR).GetMethod("GetSineKeyframes", BindingFlags.NonPublic | BindingFlags.Static);
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
@ -20,10 +19,6 @@ namespace ml_amt
public static bool IsGroundedRaw(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(MovementSystem.Instance);
public static bool HasToes(this IKSolverVR p_instance) => (bool)ms_hasToes.GetValue(p_instance);
public static Keyframe[] GetSineKeyframes(float p_mag)
{
return (Keyframe[])ms_getSineKeyframes.Invoke(null, new object[] { p_mag });
}
public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying);
public static float GetWorldJumpHeight()

View file

@ -6,7 +6,7 @@
<Company>None</Company>
<Product>AvatarMotionTweaker</Product>
<PackageId>AvatarMotionTweaker</PackageId>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<Platforms>x64</Platforms>
<AssemblyName>ml_amt</AssemblyName>
</PropertyGroup>
@ -16,6 +16,8 @@
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>

View file

@ -237,13 +237,6 @@ function inp_toggle_mod_amt(_obj, _callbackName) {
<div id="ScaledJump" class ="inp_toggle no-scroll" data-current="false"></div>
</div>
</div>
<div class ="row-wrapper">
<div class ="option-caption">Fix animator overrides (chairs, etc.): </div>
<div class ="option-input">
<div id="OverrideFix" class ="inp_toggle no-scroll" data-current="true"></div>
</div>
</div>
`;
document.getElementById('settings-ik').appendChild(l_block);