mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
I lost the first attempt when switching branches. Lot of this still needs to be redone, as it is just quickly slapped together atm.
80 lines
No EOL
2.4 KiB
C#
80 lines
No EOL
2.4 KiB
C#
using ABI_RC.Core.Player;
|
|
using HarmonyLib;
|
|
using NAK.AvatarScaleMod.AvatarScaling;
|
|
using NAK.AvatarScaleMod.GestureReconizer;
|
|
using UnityEngine;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace NAK.AvatarScaleMod.HarmonyPatches;
|
|
|
|
internal class PlayerSetupPatches
|
|
{
|
|
[HarmonyPostfix]
|
|
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
|
|
private static void Postfix_PlayerSetup_Start()
|
|
{
|
|
try
|
|
{
|
|
GameObject scaleManager = new(nameof(AvatarScaleManager), typeof(AvatarScaleManager));
|
|
Object.DontDestroyOnLoad(scaleManager);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
AvatarScaleMod.Logger.Error($"Error during the patched method {nameof(Postfix_PlayerSetup_Start)}");
|
|
AvatarScaleMod.Logger.Error(e);
|
|
}
|
|
}
|
|
|
|
[HarmonyPostfix]
|
|
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetupAvatar))]
|
|
private static void Postfix_PlayerSetup_SetupAvatar(ref PlayerSetup __instance)
|
|
{
|
|
try
|
|
{
|
|
AvatarScaleManager.Instance.OnAvatarInstantiated(__instance);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
AvatarScaleMod.Logger.Error($"Error during the patched method {nameof(Postfix_PlayerSetup_SetupAvatar)}");
|
|
AvatarScaleMod.Logger.Error(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal class PuppetMasterPatches
|
|
{
|
|
[HarmonyPostfix]
|
|
[HarmonyPatch(typeof(PuppetMaster), nameof(PuppetMaster.AvatarInstantiated))]
|
|
private static void Postfix_PuppetMaster_AvatarInstantiated(ref PuppetMaster __instance)
|
|
{
|
|
try
|
|
{
|
|
AvatarScaleManager.Instance.OnNetworkAvatarInstantiated(__instance);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
AvatarScaleMod.Logger.Error(
|
|
$"Error during the patched method {nameof(Postfix_PuppetMaster_AvatarInstantiated)}");
|
|
AvatarScaleMod.Logger.Error(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal class GesturePlaneTestPatches
|
|
{
|
|
[HarmonyPostfix]
|
|
[HarmonyPatch(typeof(GesturePlaneTest), nameof(GesturePlaneTest.Start))]
|
|
private static void Postfix_GesturePlaneTest_Start()
|
|
{
|
|
try
|
|
{
|
|
// nicked from Kafe >:))))
|
|
ScaleReconizer.Initialize();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
AvatarScaleMod.Logger.Error($"Error during the patched method {nameof(Postfix_GesturePlaneTest_Start)}");
|
|
AvatarScaleMod.Logger.Error(e);
|
|
}
|
|
}
|
|
} |