mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using ABI_RC.Core.IO;
|
|
|
|
namespace NAK.Melons.BadAnimatorFix;
|
|
|
|
public static class BadAnimatorFixManager
|
|
{
|
|
public static List<BadAnimatorFix> badAnimatorFixes = new List<BadAnimatorFix>();
|
|
private static int currentIndex = 0;
|
|
|
|
public static void Add(BadAnimatorFix bad)
|
|
{
|
|
if (!badAnimatorFixes.Contains(bad))
|
|
{
|
|
badAnimatorFixes.Add(bad);
|
|
}
|
|
}
|
|
|
|
public static void Remove(BadAnimatorFix bad)
|
|
{
|
|
if (badAnimatorFixes.Contains(bad))
|
|
{
|
|
badAnimatorFixes.Remove(bad);
|
|
}
|
|
}
|
|
|
|
// Runs every 5 seconds to see if an animator has played longer than PlayableTimeLimit
|
|
public static void CheckNextAnimator()
|
|
{
|
|
if (badAnimatorFixes.Count == 0) return;
|
|
|
|
if (currentIndex >= badAnimatorFixes.Count) currentIndex = 0;
|
|
|
|
BadAnimatorFix currentAnimatorFix = badAnimatorFixes[currentIndex];
|
|
if (currentAnimatorFix.GetTime() > BadAnimatorFixMod.EntryPlayableTimeLimit.Value)
|
|
{
|
|
currentAnimatorFix.AttemptRewindAnimator();
|
|
}
|
|
|
|
currentIndex++;
|
|
}
|
|
|
|
public static void ToggleJob(bool enable)
|
|
{
|
|
var job = SchedulerSystem.Instance.activeJobs.FirstOrDefault(pair => pair.Job.Method.Name == "CheckNextAnimator").Job;
|
|
if (enable && job == null)
|
|
{
|
|
SchedulerSystem.AddJob(new SchedulerSystem.Job(BadAnimatorFixManager.CheckNextAnimator), 0f, 5f, -1);
|
|
}
|
|
else if (!enable && job != null)
|
|
{
|
|
SchedulerSystem.RemoveJob(job);
|
|
}
|
|
}
|
|
}
|