diff --git a/BadAnimatorFix/BadAnimatorFix.cs b/BadAnimatorFix/BadAnimatorFix.cs index f1cb6f6..e021481 100644 --- a/BadAnimatorFix/BadAnimatorFix.cs +++ b/BadAnimatorFix/BadAnimatorFix.cs @@ -2,6 +2,7 @@ using UnityEngine.Playables; namespace NAK.Melons.BadAnimatorFix; + public class BadAnimatorFix : MonoBehaviour { private const float StateLimit = 20f; @@ -44,7 +45,13 @@ public class BadAnimatorFix : MonoBehaviour PlayableExtensions.SetTime(rootPlayable, 0); if (BadAnimatorFixMod.EntryLogging.Value) + { BadAnimatorFixMod.Logger.Msg($"Rewound animator and playable {animator}."); + } + } + else if (BadAnimatorFixMod.EntryLogging.Value) + { + BadAnimatorFixMod.Logger.Msg($"Animator did not meet criteria to rewind {animator}."); } } } \ No newline at end of file diff --git a/BadAnimatorFix/BadAnimatorFixManager.cs b/BadAnimatorFix/BadAnimatorFixManager.cs index c912296..6497ca4 100644 --- a/BadAnimatorFix/BadAnimatorFixManager.cs +++ b/BadAnimatorFix/BadAnimatorFixManager.cs @@ -22,6 +22,11 @@ public static class BadAnimatorFixManager badAnimatorFixes.Remove(bad); } + public static void OnPlayerLoaded() + { + ToggleJob(BadAnimatorFixMod.EntryEnabled.Value); + } + public static void OnSceneInitialized(string sceneName) { // Get all the animators in the loaded world diff --git a/BadAnimatorFix/HarmonyPatches.cs b/BadAnimatorFix/HarmonyPatches.cs index 6e8b98a..293aa0c 100644 --- a/BadAnimatorFix/HarmonyPatches.cs +++ b/BadAnimatorFix/HarmonyPatches.cs @@ -2,11 +2,19 @@ using ABI_RC.Core.InteractionSystem; using HarmonyLib; using UnityEngine; +using ABI_RC.Core.Player; namespace NAK.Melons.BadAnimatorFix.HarmonyPatches; internal static class AnimatorPatches { + [HarmonyPostfix] + [HarmonyPatch(typeof(PlayerSetup), "Start")] + private static void Post_PlayerSetup_Start() + { + BadAnimatorFixManager.OnPlayerLoaded(); + } + [HarmonyPostfix] [HarmonyPatch(typeof(CVRAvatar), "Start")] private static void Post_CVRAvatar_Start(CVRAvatar __instance) diff --git a/BadAnimatorFix/Main.cs b/BadAnimatorFix/Main.cs index a854527..c25f91f 100644 --- a/BadAnimatorFix/Main.cs +++ b/BadAnimatorFix/Main.cs @@ -24,7 +24,7 @@ public class BadAnimatorFixMod : MelonMod CategoryBadAnimatorFix.CreateEntry("Add to Menus", true, description: "Should BadAnimatorFix run for QM & MM? Requires game restart."); public static readonly MelonPreferences_Entry 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() {