Decompiled source of Camera Freedom v1.0.4

Atlyss.CameraFreedom.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Atlyss.CameraFreedom")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Atlyss.CameraFreedom")]
[assembly: AssemblyTitle("Atlyss.CameraFreedom")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Atlyss.CameraFreedom
{
	[BepInPlugin("ATLYSS.CameraFreedom", "Camera Freedom", "1.0.4")]
	public sealed class Mod : BaseUnityPlugin
	{
		private const string modGUID = "ATLYSS.CameraFreedom";

		private const string modName = "Camera Freedom";

		private const string modVersion = "1.0.4";

		public static string HeightScrollKey = "Height Modifier Hotkey";

		public static string HorizKey = "Horizontal Modifier Hotkey";

		public static string IncreaseModifierKey = "Increase Modifier Hotkey";

		public static string DecreaseModifierKey = "Decrease Modifier Hotkey";

		public static string RotationKey = "Rotation Hotkey";

		public static string ShowPlayerKey = "Show Player Hotkey";

		public static string MatchHeightKey = "Match the Player Height";

		public static string AllowNegativeKey = "Allows Negative Zoom Value";

		public static string StiffKey = "Stiff Camera";

		public static string ShowHeadKey = "Show Head Hotkey";

		public Vector3 overridePositionAdjust = Vector3.zero;

		public Vector3 rotationAdjust = Vector3.zero;

		public float changeValue = 3.2f;

		public float matchHeightAdjust = 0f;

		public float prevDistanceHeightScale = 1f;

		public float zoomChangeValue = 35.5f;

		public float zoomChangeValueDPad = 65.5f;

		public float zoomLockedValue = 30f;

		public bool displayHead = true;

		private bool AdjustingRotation = false;

		private float prevHeightScale;

		private float scaleAdjustMultiplier = 0f;

		private static readonly Harmony harmony = new Harmony("ATLYSS.CameraFreedom");

		public static ManualLogSource Log = new ManualLogSource("Camera Freedom");

		public static Mod Instance;

		public static ConfigEntry<KeyCode> HeightScrollModifier { get; set; }

		public static ConfigEntry<KeyCode> HorizontalModifier { get; set; }

		public static ConfigEntry<KeyCode> IncreaseModifier { get; set; }

		public static ConfigEntry<KeyCode> DecreaseModifier { get; set; }

		public static ConfigEntry<KeyCode> RotationHotkey { get; set; }

		public static ConfigEntry<KeyCode> ShowPlayerHotkey { get; set; }

		public static ConfigEntry<bool> MatchPlayerHeight { get; set; }

		public static ConfigEntry<bool> AllowNegativeZoom { get; set; }

		public static ConfigEntry<bool> StiffCamera { get; set; }

		public static ConfigEntry<KeyCode> ShowHeadHotkey { get; set; }

		public Vector3 prevPositionAdjust { get; set; }

		public float cachedDistance { get; set; }

		public float cachedDialogueDistance { get; set; }

		public float currentHeight { get; set; }

		public float currentHoriz { get; set; }

		public float heightScale { get; set; }

		public bool ControllingCamera { get; set; }

		public bool AlwaysShowPlayer { get; set; }

		public bool LockCamera { get; set; }

		public void Awake()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Log = Logger.CreateLogSource("ATLYSS.CameraFreedom");
			Log.LogInfo((object)"Starting Camera Freedom");
			MatchPlayerHeight = ((BaseUnityPlugin)this).Config.Bind<bool>("General", MatchHeightKey, false, new ConfigDescription("Whether or not the camera tries to match the height of the player. Note: You can't adjust the camera's height with this on.", (AcceptableValueBase)null, Array.Empty<object>()));
			AllowNegativeZoom = ((BaseUnityPlugin)this).Config.Bind<bool>("General", AllowNegativeKey, false, new ConfigDescription("Allows the camera to have negative zoom values. This lets you scroll past the \"First Person\" view", (AcceptableValueBase)null, Array.Empty<object>()));
			StiffCamera = ((BaseUnityPlugin)this).Config.Bind<bool>("General", StiffKey, false, new ConfigDescription("Toggles Stiff Camera Mode. The stiff camera follows the player without smooth movement", (AcceptableValueBase)null, Array.Empty<object>()));
			HeightScrollModifier = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", HeightScrollKey, (KeyCode)308, new ConfigDescription("The key to hold in order to change height while scrolling", (AcceptableValueBase)null, Array.Empty<object>()));
			HorizontalModifier = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", HorizKey, (KeyCode)307, new ConfigDescription("The key to hold in order to change horizontal offset while scrolling", (AcceptableValueBase)null, Array.Empty<object>()));
			IncreaseModifier = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", IncreaseModifierKey, (KeyCode)305, new ConfigDescription("The key to increase strength of modifiers", (AcceptableValueBase)null, Array.Empty<object>()));
			DecreaseModifier = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", DecreaseModifierKey, (KeyCode)306, new ConfigDescription("The key to decrease strength of modifiers", (AcceptableValueBase)null, Array.Empty<object>()));
			RotationHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", RotationKey, (KeyCode)110, new ConfigDescription("Press this key to switch position adjust into rotation adjust", (AcceptableValueBase)null, Array.Empty<object>()));
			ShowPlayerHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", ShowPlayerKey, (KeyCode)47, new ConfigDescription("This key toggles whether the player model is always visible or not", (AcceptableValueBase)null, Array.Empty<object>()));
			ShowHeadHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", ShowHeadKey, (KeyCode)46, new ConfigDescription("This key toggles whether the player's head is visible.", (AcceptableValueBase)null, Array.Empty<object>()));
			Log.LogInfo((object)"Camera Freedom: Patching...");
			harmony.PatchAll();
			Log.LogInfo((object)"Camera Freedom: Active!");
		}

		public void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Invalid comparison between Unknown and I4
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(IncreaseModifier.Value))
			{
				changeValue *= 2f;
				zoomChangeValue *= 2f;
				zoomChangeValueDPad *= 2f;
			}
			if (Input.GetKeyDown(DecreaseModifier.Value))
			{
				changeValue /= 2f;
				zoomChangeValue /= 2f;
				zoomChangeValueDPad /= 2f;
			}
			if (Input.GetKeyDown(RotationHotkey.Value) && !Player._mainPlayer._inChat)
			{
				AdjustingRotation = !AdjustingRotation;
			}
			if (Input.GetKeyDown(ShowPlayerHotkey.Value) && !Player._mainPlayer._inChat)
			{
				AlwaysShowPlayer = !AlwaysShowPlayer;
			}
			if ((Object)(object)Player._mainPlayer == (Object)null || (int)Player._mainPlayer._currentGameCondition != 1)
			{
				return;
			}
			if (Input.GetKeyDown(ShowHeadHotkey.Value) && !Player._mainPlayer._inChat)
			{
				displayHead = !displayHead;
			}
			if ((Object)(object)CameraFunction._current == (Object)null)
			{
				return;
			}
			heightScale = Player._mainPlayer._pVisual._playerAppearanceStruct._heightWeight;
			ControllingCamera = false;
			if (Player._mainPlayer._inUI)
			{
				if (Input.GetKey(HeightScrollModifier.Value))
				{
					ControllingCamera = true;
					if (Input.mouseScrollDelta.y > 0f)
					{
						if (AdjustingRotation)
						{
							rotationAdjust.y += changeValue;
						}
						else
						{
							overridePositionAdjust.y += changeValue;
						}
					}
					else if (Input.mouseScrollDelta.y < 0f)
					{
						if (AdjustingRotation)
						{
							rotationAdjust.y -= changeValue;
						}
						else
						{
							overridePositionAdjust.y -= changeValue;
						}
					}
				}
				if (Input.GetKey(HorizontalModifier.Value))
				{
					ControllingCamera = true;
					if (Input.mouseScrollDelta.y > 0f)
					{
						if (AdjustingRotation)
						{
							rotationAdjust.x += changeValue;
						}
						else
						{
							overridePositionAdjust.x += changeValue;
						}
					}
					else if (Input.mouseScrollDelta.y < 0f)
					{
						if (AdjustingRotation)
						{
							rotationAdjust.x -= changeValue;
						}
						else
						{
							overridePositionAdjust.x -= changeValue;
						}
					}
				}
				if (!ControllingCamera)
				{
					float axis = Input.GetAxis("Mouse ScrollWheel");
					if (AdjustingRotation)
					{
						if ((double)axis != 0.0)
						{
							rotationAdjust.z += axis * changeValue;
						}
						if (InputControlManager.current.DpadUp((DpadHoldType)1))
						{
							rotationAdjust.z -= changeValue * Time.deltaTime;
						}
						if (InputControlManager.current.DpadDown((DpadHoldType)1))
						{
							rotationAdjust.z += changeValue * Time.deltaTime;
						}
					}
					else
					{
						if ((double)axis != 0.0)
						{
							zoomLockedValue += axis * zoomChangeValue;
						}
						if (InputControlManager.current.DpadUp((DpadHoldType)1))
						{
							zoomLockedValue -= zoomChangeValueDPad * Time.deltaTime;
						}
						if (InputControlManager.current.DpadDown((DpadHoldType)1))
						{
							zoomLockedValue += zoomChangeValueDPad * Time.deltaTime;
						}
					}
				}
			}
			else
			{
				if (Input.GetKey(HeightScrollModifier.Value))
				{
					ControllingCamera = true;
					if (Input.mouseScrollDelta.y > 0f)
					{
						CameraFunction._current.positionAdjust.y += changeValue;
						if (MatchPlayerHeight.Value)
						{
							matchHeightAdjust += changeValue;
						}
					}
					else if (Input.mouseScrollDelta.y < 0f)
					{
						CameraFunction._current.positionAdjust.y -= changeValue;
						if (MatchPlayerHeight.Value)
						{
							matchHeightAdjust -= changeValue;
						}
					}
					currentHeight = CameraFunction._current.positionAdjust.y;
				}
				if (Input.GetKey(HorizontalModifier.Value))
				{
					ControllingCamera = true;
					if (Input.mouseScrollDelta.y > 0f)
					{
						CameraFunction._current.positionAdjust.x += changeValue;
					}
					else if (Input.mouseScrollDelta.y < 0f)
					{
						CameraFunction._current.positionAdjust.x -= changeValue;
					}
					currentHoriz = CameraFunction._current.positionAdjust.x;
				}
			}
			if (!MatchPlayerHeight.Value)
			{
				return;
			}
			float num = heightScale - prevHeightScale;
			if (Mathf.Abs(num) > 0.001f)
			{
				if (num > 0f)
				{
					scaleAdjustMultiplier += 0.0005f;
				}
				else if (num < 0f)
				{
					scaleAdjustMultiplier -= 0.0005f;
				}
			}
			prevHeightScale = heightScale;
			float num2 = heightScale * scaleAdjustMultiplier;
			if (scaleAdjustMultiplier < 0f)
			{
				num2 = 0f;
			}
			if (scaleAdjustMultiplier > 1f)
			{
				num2 = heightScale;
			}
			if (heightScale < 1f)
			{
				num2 = 0f - (1f - heightScale);
			}
			CameraFunction._current.positionAdjust.y = Player._mainPlayer._pVisual._headPos.y * heightScale + num2 + matchHeightAdjust;
		}
	}
}
namespace Atlyss.CameraFreedom.Patches
{
	[HarmonyPatch(typeof(CameraCollision), "Handle_DetectGroundLayer")]
	internal static class Handle_DetectGroundLayer
	{
		[HarmonyPrefix]
		internal static bool CheckRaycast(CameraCollision __instance, ref bool __result)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((!Player._mainPlayer._inUI) ? CameraFunction._current.positionAdjust : Mod.Instance.overridePositionAdjust);
			LayerMask val2 = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Ground" }));
			__result = Physics.Linecast(((Component)__instance).transform.parent.position + val, ((Component)__instance).transform.parent.TransformPoint(__instance.dollyDir * __instance.maxDistance), ref __instance.hit, LayerMask.op_Implicit(val2), (QueryTriggerInteraction)1);
			return false;
		}
	}
	[HarmonyPatch(typeof(CameraCollision), "LateUpdate")]
	internal static class CameraCollision__LateUpdate
	{
		[HarmonyPrefix]
		internal static bool BeforeHandling(CameraCollision __instance)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player._mainPlayer))
			{
				return false;
			}
			if (Mod.Instance.ControllingCamera)
			{
				return false;
			}
			float num = 1f;
			if (Mod.Instance.heightScale < 1f)
			{
				num = Mod.Instance.heightScale;
			}
			PlayerVisual pVisual = Player._mainPlayer._pVisual;
			Handle_DistanceControl();
			if ((double)__instance.maxDistance <= 0.6000000238418579 && !Mod.AllowNegativeZoom.Value)
			{
				__instance.maxDistance = 0.6f;
			}
			if ((double)Vector3.Distance(((Component)CameraFunction._current._mainCamera).transform.position, ((Component)Player._mainPlayer).transform.position + CameraFunction._current.positionAdjust) <= 2.799999952316284 * (double)num && !Mod.Instance.AlwaysShowPlayer)
			{
				pVisual.RenderPlayerModel(false);
				__instance._unhidePlayerModel = true;
			}
			else if (__instance._unhidePlayerModel)
			{
				pVisual.RenderPlayerModel(true);
				__instance._unhidePlayerModel = false;
			}
			__instance.distance = ((!__instance.Handle_DetectGroundLayer()) ? __instance.maxDistance : Mathf.Clamp(((RaycastHit)(ref __instance.hit)).distance * __instance.step, __instance.minDistance, __instance.maxDistance));
			((Component)__instance).transform.localPosition = __instance.dollyDir * __instance.distance;
			return false;
			void Handle_DistanceControl()
			{
				if (!Player._mainPlayer._bufferingStatus && !Player._mainPlayer._inUI && !Player._mainPlayer._inChat)
				{
					if (Mod.Instance.prevDistanceHeightScale != Mod.Instance.heightScale && Mod.MatchPlayerHeight.Value)
					{
						float num2 = Mod.Instance.heightScale - Mod.Instance.prevDistanceHeightScale;
						if (Mod.Instance.heightScale > 1f)
						{
							CameraCollision obj = __instance;
							obj.maxDistance += num2 * 10f;
						}
						if (Mod.Instance.heightScale < 1f)
						{
							CameraCollision obj2 = __instance;
							obj2.maxDistance += num2 * 10f / Mathf.Clamp(Mod.Instance.heightScale, 0.225f, 1f);
						}
						Mod.Instance.prevDistanceHeightScale = Mod.Instance.heightScale;
					}
					float axis = Input.GetAxis("Mouse ScrollWheel");
					if ((double)axis != 0.0)
					{
						CameraCollision obj3 = __instance;
						obj3.maxDistance += axis * Mod.Instance.zoomChangeValue;
						if (!GamepadInput.GetButton((GamepadButton)8))
						{
							if (GamepadInput.GetButton((GamepadButton)11))
							{
								return;
							}
						}
						else if (0 == 0)
						{
							return;
						}
						if (InputControlManager.current.DpadUp((DpadHoldType)1))
						{
							CameraCollision obj4 = __instance;
							obj4.maxDistance -= Mod.Instance.zoomChangeValueDPad * Time.deltaTime;
						}
						if (InputControlManager.current.DpadDown((DpadHoldType)1))
						{
							CameraCollision obj5 = __instance;
							obj5.maxDistance += Mod.Instance.zoomChangeValueDPad * Time.deltaTime;
						}
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(CameraCollision), "Start")]
	internal static class CameraCollision__Start
	{
		[HarmonyPostfix]
		internal static void SetMaxDistance(CameraCollision __instance)
		{
			if (Mod.Instance.cachedDistance != 0f)
			{
				CameraCollision._current.maxDistance = Mod.Instance.cachedDistance;
			}
		}
	}
	[HarmonyPatch(typeof(CameraFunction), "CameraReset_Lerp")]
	internal static class CameraFunction__CameraReset_Lerp
	{
		[HarmonyPostfix]
		internal static void ResetExtraValues(CameraFunction __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(InputControlManager.current._resetCamera) || (GamepadInput.GetButton((GamepadButton)13) && !Object.op_Implicit((Object)(object)Player._mainPlayer._pTargeting._foundEntity)))
			{
				if ((Object)(object)Player._mainPlayer != (Object)null)
				{
					__instance.positionAdjust = Player._mainPlayer._pVisual._headPos;
				}
				Mod.Instance.overridePositionAdjust = Vector3.zero;
				Mod.Instance.rotationAdjust = Vector3.zero;
				Mod.Instance.zoomLockedValue = 30f;
				if (Mod.MatchPlayerHeight.Value)
				{
					Mod.Instance.matchHeightAdjust = 0f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(CameraFunction), "FollowTargetObj")]
	internal static class CameraFunction__FollowTargetObj
	{
		[HarmonyPrefix]
		internal static bool AltFollowTarget(CameraFunction __instance)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player._mainPlayer) || !Object.op_Implicit((Object)(object)__instance._CameraFollowObj))
			{
				return false;
			}
			bool flag = (int)Player._mainPlayer._currentGameCondition == 0 && (double)__instance._snapLoadCameraBuffer >= 0.30000001192092896;
			if ((int)Player._mainPlayer._currentGameCondition == 0 && (double)__instance._snapLoadCameraBuffer < 0.30000001192092896)
			{
				__instance._snapLoadCameraBuffer += Time.deltaTime;
			}
			if ((int)Player._mainPlayer._currentGameCondition > 0)
			{
				__instance._snapLoadCameraBuffer = 0f;
			}
			if (__instance._initCameraOverride)
			{
				return false;
			}
			if (flag || Mod.StiffCamera.Value)
			{
				((Component)__instance).transform.position = __instance._CameraFollowObj.position + __instance.positionAdjust;
			}
			else
			{
				((Component)__instance).transform.position = Vector3.Lerp(((Component)__instance).transform.position, __instance._CameraFollowObj.position + __instance.positionAdjust, __instance.step * Time.deltaTime);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CameraFunction), "Handle_CameraControl")]
	internal static class CameraFunction__Handle_CameraControl
	{
		[HarmonyPostfix]
		internal static void PositionAdjustAffectsOverride(CameraFunction __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (__instance._initCameraOverride)
			{
				((Component)__instance).transform.SetPositionAndRotation(Vector3.Lerp(((Component)__instance).transform.position, __instance._overridePosition + Mod.Instance.overridePositionAdjust, 3f * Time.deltaTime), Quaternion.Lerp(((Component)__instance).transform.rotation, Quaternion.Euler(__instance._overrideRotation + Mod.Instance.rotationAdjust), 3f * Time.deltaTime));
				CameraCollision._current.maxDistance = Mathf.Lerp(CameraCollision._current.maxDistance, Mod.Instance.zoomLockedValue, 3f * Time.deltaTime);
			}
		}
	}
	[HarmonyPatch(typeof(DialogManager), "End_Dialog")]
	internal static class DialogManager__End_Dialog
	{
		[HarmonyPostfix]
		internal static void ResetMaxDistance()
		{
			if (Mod.Instance.cachedDistance != 0f)
			{
				CameraCollision._current.maxDistance = Mod.Instance.cachedDistance;
			}
		}
	}
	[HarmonyPatch(typeof(DialogManager), "Start_Dialog")]
	internal static class DialogManager__Start_Dialog
	{
		[HarmonyPrefix]
		internal static void SaveCameraDistance()
		{
			Mod.Instance.cachedDistance = CameraCollision._current.maxDistance;
		}
	}
	[HarmonyPatch(typeof(PlayerTargeting), "Client_EndTarget")]
	internal static class PlayerTargeting__Client_EndTarget
	{
		[HarmonyPrefix]
		internal static void SaveAdjustedPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Mod.Instance.prevPositionAdjust = CameraFunction._current.positionAdjust;
		}

		[HarmonyPostfix]
		internal static void SetAdjustedPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			CameraFunction._current.positionAdjust = Mod.Instance.prevPositionAdjust;
		}
	}
	[HarmonyPatch(typeof(RaceModelEquipDisplay), "Apply_EquipmentVisualDisplay")]
	internal static class RaceModelEquipDisplay__Apply_EquipmentVisualDisplay
	{
		[HarmonyPostfix]
		internal static void HeadDisplay(RaceModelEquipDisplay __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			if (!((Object)(object)Player._mainPlayer == (Object)null) && (int)Player._mainPlayer._currentGameCondition == 1 && (Object)(object)__instance._player == (Object)(object)Player._mainPlayer)
			{
				__instance._playerRaceModel.Init_CullHead(!Mod.Instance.displayHead);
				__instance._playerRaceModel._hideEars = !Mod.Instance.displayHead;
				__instance._playerRaceModel.Apply_CharacterDisplay();
			}
		}
	}
}