mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
Added BadAnimatorFix manually
This commit is contained in:
parent
6b313bc7bd
commit
a123b91c4e
8 changed files with 390 additions and 0 deletions
63
BadAnimatorFix/HarmonyPatches.cs
Normal file
63
BadAnimatorFix/HarmonyPatches.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Player;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Melons.BadAnimatorFix.HarmonyPatches;
|
||||
|
||||
internal static class AnimatorPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), "Start")]
|
||||
private static void Postfix_PlayerSetup_Start()
|
||||
{
|
||||
BadAnimatorFixManager.OnPlayerLoaded();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRAvatar), "Start")]
|
||||
private static void Postfix_CVRAvatar_Start(CVRAvatar __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryCVRAvatar.Value) return;
|
||||
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRSpawnable), "Start")]
|
||||
private static void Postfix_CVRSpawnable_Start(CVRSpawnable __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryCVRSpawnable.Value) return;
|
||||
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
|
||||
}
|
||||
|
||||
// Set QM stuff
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
|
||||
private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryMenus.Value) return;
|
||||
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
|
||||
}
|
||||
|
||||
// Set MM stuff
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ViewManager), "Start")]
|
||||
private static void Postfix_ViewManager_Start(ref ViewManager __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryMenus.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<BadAnimatorFix>(out _))
|
||||
{
|
||||
animator.gameObject.AddComponent<BadAnimatorFix>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue