This commit is contained in:
NotAKidoS 2023-03-24 19:09:08 -05:00
parent 38445efae3
commit 7b5ad71060
4 changed files with 21 additions and 1 deletions

View file

@ -2,6 +2,7 @@
using UnityEngine.Playables; using UnityEngine.Playables;
namespace NAK.Melons.BadAnimatorFix; namespace NAK.Melons.BadAnimatorFix;
public class BadAnimatorFix : MonoBehaviour public class BadAnimatorFix : MonoBehaviour
{ {
private const float StateLimit = 20f; private const float StateLimit = 20f;
@ -44,7 +45,13 @@ public class BadAnimatorFix : MonoBehaviour
PlayableExtensions.SetTime<Playable>(rootPlayable, 0); PlayableExtensions.SetTime<Playable>(rootPlayable, 0);
if (BadAnimatorFixMod.EntryLogging.Value) if (BadAnimatorFixMod.EntryLogging.Value)
{
BadAnimatorFixMod.Logger.Msg($"Rewound animator and playable {animator}."); BadAnimatorFixMod.Logger.Msg($"Rewound animator and playable {animator}.");
} }
} }
else if (BadAnimatorFixMod.EntryLogging.Value)
{
BadAnimatorFixMod.Logger.Msg($"Animator did not meet criteria to rewind {animator}.");
}
}
} }

View file

@ -22,6 +22,11 @@ public static class BadAnimatorFixManager
badAnimatorFixes.Remove(bad); badAnimatorFixes.Remove(bad);
} }
public static void OnPlayerLoaded()
{
ToggleJob(BadAnimatorFixMod.EntryEnabled.Value);
}
public static void OnSceneInitialized(string sceneName) public static void OnSceneInitialized(string sceneName)
{ {
// Get all the animators in the loaded world // Get all the animators in the loaded world

View file

@ -2,11 +2,19 @@
using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.InteractionSystem;
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
using ABI_RC.Core.Player;
namespace NAK.Melons.BadAnimatorFix.HarmonyPatches; namespace NAK.Melons.BadAnimatorFix.HarmonyPatches;
internal static class AnimatorPatches internal static class AnimatorPatches
{ {
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "Start")]
private static void Post_PlayerSetup_Start()
{
BadAnimatorFixManager.OnPlayerLoaded();
}
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(CVRAvatar), "Start")] [HarmonyPatch(typeof(CVRAvatar), "Start")]
private static void Post_CVRAvatar_Start(CVRAvatar __instance) private static void Post_CVRAvatar_Start(CVRAvatar __instance)

View file

@ -24,7 +24,7 @@ public class BadAnimatorFixMod : MelonMod
CategoryBadAnimatorFix.CreateEntry("Add to Menus", true, description: "Should BadAnimatorFix run for QM & MM? Requires game restart."); CategoryBadAnimatorFix.CreateEntry("Add to Menus", true, description: "Should BadAnimatorFix run for QM & MM? Requires game restart.");
public static readonly MelonPreferences_Entry<bool> EntryLogging = public static readonly MelonPreferences_Entry<bool> EntryLogging =
CategoryBadAnimatorFix.CreateEntry("Logging", false, description: "Toggle to log each rewind if successful. Only needed for debugging."); CategoryBadAnimatorFix.CreateEntry("Debugging", false, description: "Toggle to log each rewind if successful. Only needed for debugging.");
public override void OnInitializeMelon() public override void OnInitializeMelon()
{ {