NAK_CVR_Mods/.Experimental/OriginShift/Integrations/ThirdPerson/ThirdPersonAddon.cs
2025-04-03 03:03:24 -05:00

36 lines
1.2 KiB
C#

using System.Collections;
using ABI_RC.Core.Base;
using ABI_RC.Core.Player;
using MelonLoader;
using NAK.OriginShift;
using NAK.OriginShift.Hacks;
using UnityEngine;
using AccessTools = HarmonyLib.AccessTools;
using HarmonyMethod = HarmonyLib.HarmonyMethod;
namespace OriginShift.Integrations;
public static class ThirdPersonAddon
{
public static void Initialize()
{
OriginShiftMod.HarmonyInst.Patch(
AccessTools.Method(typeof(PlayerSetup), nameof(PlayerSetup.Start)),
postfix: new HarmonyMethod(typeof(ThirdPersonAddon), nameof(OnPostPlayerSetupStart))
);
}
private static void OnPostPlayerSetupStart()
{
OriginShiftMod.Logger.Msg("Found ThirdPerson, fixing compatibility...");
MelonCoroutines.Start(FixThirdPersonCompatibility());
}
private static IEnumerator FixThirdPersonCompatibility()
{
yield return null; // wait a frame for the camera to be setup
GameObject thirdPersonCameraObj = GameObject.Find("_PLAYERLOCAL/[CameraRigDesktop]/Camera/ThirdPersonCameraObj");
thirdPersonCameraObj.AddComponentIfMissing<OriginShiftOcclusionCullingDisabler>();
}
}