mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
i dont know what im doing
implement shit fix for shit problem
This commit is contained in:
parent
41f8db5dcf
commit
83c101f5ee
7 changed files with 330 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 HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.Melons.BadAnimatorFix.HarmonyPatches;
|
||||
|
||||
internal class AnimatorPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRAvatar), "Start")]
|
||||
private static void Post_CVRAvatar_Start(CVRAvatar __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryCVRAvatar.Value) return;
|
||||
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRSpawnable), "Start")]
|
||||
private static void Post_CVRSpawnable_Start(CVRSpawnable __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryCVRSpawnable.Value) return;
|
||||
AddBadAnimatorFixComponentIfAnimatorExists(__instance.gameObject);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRWorld), "Start")]
|
||||
private static void Post_CVRWorld_Start(CVRWorld __instance)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryCVRWorld.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, ref GameObject ____leftVrAnchor)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!BadAnimatorFixMod.EntryEnabled.Value) return;
|
||||
Animator[] animators = gameObject.GetComponentsInChildren<Animator>();
|
||||
foreach (Animator animator in animators.Where(a => a.gameObject.GetComponent<BadAnimatorFix>() == null))
|
||||
{
|
||||
if (animator.runtimeAnimatorController != null)
|
||||
animator.gameObject.AddComponent<BadAnimatorFix>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue