Move many mods to Deprecated folder, fix spelling

This commit is contained in:
NotAKidoS 2025-04-03 02:57:35 -05:00
parent 5e822cec8d
commit 0042590aa6
539 changed files with 7475 additions and 3120 deletions

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"/>

View file

@ -0,0 +1,55 @@
using ABI_RC.Core.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace NAK.BadAnimatorFix;
public static class BadAnimatorFixManager
{
private static List<BadAnimatorFixer> _animatorFixers = new List<BadAnimatorFixer>();
private static readonly float _checkInterval = 5f;
private static int _currentIndex = 0;
public static void Add(BadAnimatorFixer bad)
{
if (!_animatorFixers.Contains(bad))
_animatorFixers.Add(bad);
}
public static void Remove(BadAnimatorFixer bad)
{
if (_animatorFixers.Contains(bad))
_animatorFixers.Remove(bad);
}
public static void OnPlayerLoaded()
{
SchedulerSystem.AddJob(new SchedulerSystem.Job(CheckNextAnimator), 0f, _checkInterval, -1);
}
public static void OnSceneInitialized(string sceneName)
{
// Get all the animators in the loaded world
var allAnimators = SceneManager.GetSceneByName(sceneName).GetRootGameObjects()
.SelectMany(x => x.GetComponentsInChildren<Animator>(true));
foreach (var animator in allAnimators)
{
// Ignore objects that have our "fix", this shouldn't be needed but eh
if (!animator.TryGetComponent<BadAnimatorFixer>(out _))
animator.gameObject.AddComponent<BadAnimatorFixer>();
}
}
private static void CheckNextAnimator()
{
if (!BadAnimatorFix.EntryEnabled.Value)
return;
if (_animatorFixers.Count == 0)
return;
_currentIndex = (_currentIndex + 1) % _animatorFixers.Count;
_animatorFixers[_currentIndex].AttemptRewindAnimator();
}
}

View file

@ -0,0 +1,45 @@
using UnityEngine;
using UnityEngine.Playables;
namespace NAK.BadAnimatorFix;
public class BadAnimatorFixer : MonoBehaviour
{
private const float StateLimit = 20f;
private Animator animator;
private void Start() => animator = GetComponent<Animator>();
private void OnEnable() => BadAnimatorFixManager.Add(this);
private void OnDisable() => BadAnimatorFixManager.Remove(this);
public void AttemptRewindAnimator()
{
bool rewound = false;
if (animator != null && animator.isActiveAndEnabled)
{
for (int layerIndex = 0; layerIndex < animator.layerCount; layerIndex++)
{
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layerIndex);
AnimatorTransitionInfo transitionInfo = animator.GetAnimatorTransitionInfo(layerIndex);
// Skip if mid-transition
if (transitionInfo.fullPathHash != 0) continue;
// Skip if anim doesn't loop, or hasn't looped enough
if (!stateInfo.loop || stateInfo.normalizedTime < StateLimit) continue;
// Rewind state, with 10f as buffer, to account for reasonable use of ExitTime
float offset = 10f + (stateInfo.normalizedTime % 1f);
animator.Play(stateInfo.fullPathHash, layerIndex, offset);
rewound = true;
}
if (rewound)
PlayableExtensions.SetTime<Playable>(animator.playableGraph.GetRootPlayable(0), 0);
}
if (BadAnimatorFix.EntryLogging.Value)
{
string message = rewound ? $"Rewound animator and playable {animator}." : $"Animator did not meet criteria to rewind {animator}.";
BadAnimatorFix.Logger.Msg(message);
}
}
}

View file

@ -0,0 +1,45 @@
using ABI.CCK.Components;
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using HarmonyLib;
using UnityEngine;
namespace NAK.BadAnimatorFix.HarmonyPatches;
internal static class AnimatorPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
private static void Postfix_PlayerSetup_Start()
{
BadAnimatorFixManager.OnPlayerLoaded();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CVRAvatar), nameof(CVRAvatar.Start))]
private static void Postfix_CVRAvatar_Start(CVRAvatar __instance)
{
if (!BadAnimatorFix.EntryCVRAvatar.Value) return;
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CVRSpawnable), nameof(CVRSpawnable.Start))]
private static void Postfix_CVRSpawnable_Start(CVRSpawnable __instance)
{
if (!BadAnimatorFix.EntryCVRSpawnable.Value) return;
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
}
private static void AddBadAnimatorFixComponentIfAnimatorExists(GameObject gameObject)
{
Animator[] animators = gameObject.GetComponentsInChildren<Animator>(true);
foreach (Animator animator in animators)
{
if (!animator.TryGetComponent<BadAnimatorFixer>(out _))
{
animator.gameObject.AddComponent<BadAnimatorFixer>();
}
}
}
}

View file

@ -0,0 +1,53 @@
using MelonLoader;
namespace NAK.BadAnimatorFix;
public class BadAnimatorFix : MelonMod
{
internal static MelonLogger.Instance Logger;
public static readonly MelonPreferences_Category Category =
MelonPreferences.CreateCategory(nameof(BadAnimatorFix));
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
Category.CreateEntry("Enabled", true, description: "Toggle BadAnimatorFix entirely. Requires avatar/spawnable/world reload.");
public static readonly MelonPreferences_Entry<bool> EntryCVRAvatar =
Category.CreateEntry("Add to CVRAvatar", true, description: "Should BadAnimatorFix run for CVRAvatar? Requires avatar reload.");
public static readonly MelonPreferences_Entry<bool> EntryCVRSpawnable =
Category.CreateEntry("Add to CVRSpawnable", true, description: "Should BadAnimatorFix run for CVRSpawnable? Requires spawnable reload.");
public static readonly MelonPreferences_Entry<bool> EntryCVRWorld =
Category.CreateEntry("Add to CVRWorld", true, description: "Should BadAnimatorFix run for CVRWorld? Requires world reload.");
public static readonly MelonPreferences_Entry<bool> EntryLogging =
Category.CreateEntry("Debugging", false, description: "Toggle to log each rewind if successful. Only needed for debugging.");
public override void OnInitializeMelon()
{
Logger = LoggerInstance;
ApplyPatches(typeof(HarmonyPatches.AnimatorPatches));
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
if (!EntryCVRWorld.Value) return;
if (buildIndex < 0) // -1 is custom world: 0 to 3 is game login, init, hq
BadAnimatorFixManager.OnSceneInitialized(sceneName);
}
private void ApplyPatches(Type type)
{
try
{
HarmonyInstance.PatchAll(type);
}
catch (Exception e)
{
Logger.Msg($"Failed while patching {type.Name}!");
Logger.Error(e);
}
}
}

View file

@ -0,0 +1,32 @@
using MelonLoader;
using NAK.BadAnimatorFix.Properties;
using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyTitle(nameof(NAK.BadAnimatorFix))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
[assembly: AssemblyProduct(nameof(NAK.BadAnimatorFix))]
[assembly: MelonInfo(
typeof(NAK.BadAnimatorFix.BadAnimatorFix),
nameof(NAK.BadAnimatorFix),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/BadAnimatorFix"
)]
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonColor(255, 226, 83, 82)]
[assembly: MelonAuthorColor(255, 158, 21, 32)]
[assembly: HarmonyDontPatchAll]
namespace NAK.BadAnimatorFix.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.3";
public const string Author = "NotAKidoS";
}

View file

@ -0,0 +1,23 @@
{
"_id": 152,
"name": "BadAnimatorFix",
"modversion": "1.0.3",
"gameversion": "2023r171",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "This mod periodically rewinds looping animation states.\nIt resolves issues with locomotion animations freezing after extended AFK periods.\nIf you aren't AFK frequently, this mod might not be essential for you.",
"searchtags": [
"bad",
"fix",
"animator",
"loop"
],
"requirements": [
"None"
],
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r18/BadAnimatorFix.dll",
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/BadAnimatorFix/",
"changelog": "- No longer rewinds states without loop specifically enabled.\n- Removed performance improvement claim, which has seemingly been fixed in 2021.\n- Fixed not being able to disable mod with the Enabled button.",
"embedcolor": "#e25352"
}