NAK_CVR_Mods/.DepricatedMods/HeadBobbingFix/HarmonyPatches.cs
2023-07-26 11:30:19 -05:00

30 lines
991 B
C#

using ABI_RC.Core.Player;
using ABI_RC.Systems.MovementSystem;
using HarmonyLib;
using UnityEngine;
namespace NAK.HeadBobbingFix.HarmonyPatches;
class PlayerSetupPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.HandleDesktopCameraPosition))]
public static void Postfix_PlayerSetup_HandleDesktopCameraPosition(bool ignore, ref PlayerSetup __instance, ref MovementSystem ____movementSystem, ref int ___headBobbingLevel)
{
if (!HeadBobbingFix.EntryEnabled.Value)
return;
// this would be much simplier if I bothered with transpilers
if (____movementSystem.disableCameraControl && !ignore)
return;
if (___headBobbingLevel != 2)
return;
Transform viewpointTransform = __instance._viewPoint.pointer.transform;
if (viewpointTransform != null)
{
__instance.desktopCamera.transform.position = viewpointTransform.position;
}
}
}