mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-07 20:19:18 +00:00
Removed animation override fix from AMT into GMF
This commit is contained in:
parent
65632c763e
commit
674f572415
13 changed files with 25 additions and 49 deletions
58
ml_gmf/Fixes/AnimationOverrides.cs
Normal file
58
ml_gmf/Fixes/AnimationOverrides.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using ABI_RC.Core;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ml_gmf.Fixes
|
||||
{
|
||||
static class AnimationOverrides
|
||||
{
|
||||
internal static void Init(HarmonyLib.Harmony p_instance)
|
||||
{
|
||||
p_instance.Patch(
|
||||
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.SetOverrideAnimation)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AnimationOverrides).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AnimationOverrides).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
p_instance.Patch(
|
||||
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.RestoreOverrideAnimation)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AnimationOverrides).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AnimationOverrides).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
}
|
||||
|
||||
static void OnOverride_Prefix(ref CVRAnimatorManager __instance, out AnimatorAnalyzer __state)
|
||||
{
|
||||
__state = new AnimatorAnalyzer();
|
||||
try
|
||||
{
|
||||
if(__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(__instance.animator != null)
|
||||
{
|
||||
__state.ApplyTo(__instance.animator);
|
||||
if(__state.IsEnabled())
|
||||
__instance.animator.Update(0f);
|
||||
}
|
||||
}
|
||||
catch(Exception l_exception)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(l_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue