major cleanup

This commit is contained in:
NotAKidoS 2023-04-26 15:32:02 -05:00
parent b33e15377f
commit e5242f76c7
85 changed files with 584 additions and 571 deletions

View file

@ -6,17 +6,17 @@ namespace NAK.BadAnimatorFix;
public static class BadAnimatorFixManager
{
private static List<BadAnimatorFix> badAnimatorFixes = new List<BadAnimatorFix>();
private static List<BadAnimatorFixer> badAnimatorFixes = new List<BadAnimatorFixer>();
private static int currentIndex = 0;
private static float checkInterval = 5f;
public static void Add(BadAnimatorFix bad)
public static void Add(BadAnimatorFixer bad)
{
if (!badAnimatorFixes.Contains(bad))
badAnimatorFixes.Add(bad);
}
public static void Remove(BadAnimatorFix bad)
public static void Remove(BadAnimatorFixer bad)
{
if (badAnimatorFixes.Contains(bad))
badAnimatorFixes.Remove(bad);
@ -24,7 +24,7 @@ public static class BadAnimatorFixManager
public static void OnPlayerLoaded()
{
ToggleJob(BadAnimatorFixMod.EntryEnabled.Value);
ToggleJob(BadAnimatorFix.EntryEnabled.Value);
}
public static void OnSceneInitialized(string sceneName)
@ -36,9 +36,9 @@ public static class BadAnimatorFixManager
foreach (var animator in allAnimators)
{
// Ignore objects that have our "fix", this shouldn't be needed but eh
if (!animator.TryGetComponent<BadAnimatorFix>(out _))
if (!animator.TryGetComponent<BadAnimatorFixer>(out _))
{
animator.gameObject.AddComponent<BadAnimatorFix>();
animator.gameObject.AddComponent<BadAnimatorFixer>();
}
}
}
@ -48,7 +48,7 @@ public static class BadAnimatorFixManager
if (badAnimatorFixes.Count == 0) return;
currentIndex = (currentIndex + 1) % badAnimatorFixes.Count;
BadAnimatorFix currentAnimatorFix = badAnimatorFixes[currentIndex];
BadAnimatorFixer currentAnimatorFix = badAnimatorFixes[currentIndex];
currentAnimatorFix.AttemptRewindAnimator();
}

View file

@ -3,7 +3,7 @@ using UnityEngine.Playables;
namespace NAK.BadAnimatorFix;
public class BadAnimatorFix : MonoBehaviour
public class BadAnimatorFixer : MonoBehaviour
{
private const float StateLimit = 20f;
@ -42,11 +42,11 @@ public class BadAnimatorFix : MonoBehaviour
PlayableExtensions.SetTime<Playable>(animator.playableGraph.GetRootPlayable(0), 0);
}
}
if (BadAnimatorFixMod.EntryLogging.Value)
if (BadAnimatorFix.EntryLogging.Value)
{
string message = rewound ? $"Rewound animator and playable {animator}." : $"Animator did not meet criteria to rewind {animator}.";
BadAnimatorFixMod.Logger.Msg(message);
BadAnimatorFix.Logger.Msg(message);
}
}
}

View file

@ -19,7 +19,7 @@ internal static class AnimatorPatches
[HarmonyPatch(typeof(CVRAvatar), "Start")]
private static void Postfix_CVRAvatar_Start(CVRAvatar __instance)
{
if (!BadAnimatorFixMod.EntryCVRAvatar.Value) return;
if (!BadAnimatorFix.EntryCVRAvatar.Value) return;
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
}
@ -27,7 +27,7 @@ internal static class AnimatorPatches
[HarmonyPatch(typeof(CVRSpawnable), "Start")]
private static void Postfix_CVRSpawnable_Start(CVRSpawnable __instance)
{
if (!BadAnimatorFixMod.EntryCVRSpawnable.Value) return;
if (!BadAnimatorFix.EntryCVRSpawnable.Value) return;
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
}
@ -36,7 +36,7 @@ internal static class AnimatorPatches
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance)
{
if (!BadAnimatorFixMod.EntryMenus.Value) return;
if (!BadAnimatorFix.EntryMenus.Value) return;
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
}
@ -45,7 +45,7 @@ internal static class AnimatorPatches
[HarmonyPatch(typeof(ViewManager), "Start")]
private static void Postfix_ViewManager_Start(ref ViewManager __instance)
{
if (!BadAnimatorFixMod.EntryMenus.Value) return;
if (!BadAnimatorFix.EntryMenus.Value) return;
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
}
@ -54,9 +54,9 @@ internal static class AnimatorPatches
Animator[] animators = gameObject.GetComponentsInChildren<Animator>(true);
foreach (Animator animator in animators)
{
if (!animator.TryGetComponent<BadAnimatorFix>(out _))
if (!animator.TryGetComponent<BadAnimatorFixer>(out _))
{
animator.gameObject.AddComponent<BadAnimatorFix>();
animator.gameObject.AddComponent<BadAnimatorFixer>();
}
}
}

View file

@ -2,11 +2,12 @@
namespace NAK.BadAnimatorFix;
public class BadAnimatorFixMod : MelonMod
public class BadAnimatorFix : MelonMod
{
internal static MelonLogger.Instance Logger;
public const string SettingsCategory = "BadAnimatorFix";
public static readonly MelonPreferences_Category CategoryBadAnimatorFix = MelonPreferences.CreateCategory(SettingsCategory);
public static readonly MelonPreferences_Category CategoryBadAnimatorFix =
MelonPreferences.CreateCategory(nameof(BadAnimatorFix));
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
CategoryBadAnimatorFix.CreateEntry("Enabled", true, description: "Toggle BadAnimatorFix entirely. Requires avatar/spawnable/world reload.");

View file

@ -10,11 +10,11 @@ using System.Reflection;
[assembly: AssemblyProduct(nameof(NAK.BadAnimatorFix))]
[assembly: MelonInfo(
typeof(NAK.BadAnimatorFix.BadAnimatorFixMod),
typeof(NAK.BadAnimatorFix.BadAnimatorFixer),
nameof(NAK.BadAnimatorFix),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidOnSteam/BadAnimatorFix"
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/BadAnimatorFix"
)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]

View file

@ -16,8 +16,8 @@
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidOnSteam/BadAnimatorFix/releases/download/v1.0.0/BadAnimatorFix.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/BadAnimatorFix/",
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/BadAnimatorFix.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/BadAnimatorFix/",
"changelog": "Initial Release",
"embedcolor": "7F3F99"
}