Decompiled source of ThirdPersonComfort v1.1.0

plugins/BigWalkThirdPerson.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BigWalkThirdPerson")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+022e8c40bb7888deb39a565770965929a1bff485")]
[assembly: AssemblyProduct("BigWalkThirdPerson")]
[assembly: AssemblyTitle("BigWalkThirdPerson")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BigWalkThirdPerson
{
	internal static class CameraCastPatch
	{
		private sealed class HitDistanceComparer : IComparer<RaycastHit>
		{
			internal static readonly HitDistanceComparer Instance = new HitDistanceComparer();

			public int Compare(RaycastHit a, RaycastHit b)
			{
				return ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance);
			}
		}

		private static RaycastHit[] buffer;

		private static int loggedSearchFail;

		private static bool loggedCastCall;

		private static bool loggedCastApply;

		private static bool loggedSearchCall;

		private static bool loggedSearchApply;

		internal static void Apply(Harmony harmony)
		{
			Patch(harmony, "CastThroughHands", "CastThroughHandsPrefix", null);
			Patch(harmony, "SearchThroughHands", "SearchThroughHandsPrefix", "SearchThroughHandsFinalizer");
		}

		private static void Patch(Harmony harmony, string name, string prefix, string finalizer)
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0065: 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_002c: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(PlayerCaster), name, (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					ManualLogSource logSource = Plugin.LogSource;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlayerCaster.");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" not found; skipping that patch.");
					}
					logSource.LogWarning(val);
					return;
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CameraCastPatch), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (finalizer == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(CameraCastPatch), finalizer, (Type[])null), (HarmonyMethod)null);
				ManualLogSource logSource2 = Plugin.LogSource;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Patched PlayerCaster.");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" for camera-space casts.");
				}
				logSource2.LogInfo(val2);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource3 = Plugin.LogSource;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(28, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Patch PlayerCaster.");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource3.LogWarning(val);
			}
		}

		private static bool TryCameraRay(PlayerCaster caster, out Ray ray, out float reachBonus)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			ray = default(Ray);
			reachBonus = 0f;
			ThirdPersonComponent current = ThirdPersonComponent.Current;
			if ((Object)(object)current == (Object)null || !current.IsActiveForCast)
			{
				return false;
			}
			if (caster == null || (Object)(object)caster.playerCharacter == (Object)null)
			{
				return false;
			}
			try
			{
				if (!((NetworkBehaviour)caster.playerCharacter).isLocalPlayer)
				{
					return false;
				}
			}
			catch
			{
				return false;
			}
			ray = new Ray(current.LastBoomPos, current.LastBoomRot * Vector3.forward);
			reachBonus = Vector3.Distance(current.LastBoomPos, current.LastEyePos);
			return true;
		}

		private static void CastThroughHandsPrefix(PlayerCaster __instance, ref Ray ray, ref float maxDistance)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!loggedCastCall)
				{
					loggedCastCall = true;
					Plugin.LogSource.LogInfo((object)"PlayerCaster.CastThroughHands invoked (seam is live).");
				}
				if (!TryCameraRay(__instance, out var ray2, out var reachBonus))
				{
					return;
				}
				Vector3 val = ((Ray)(ref ray)).origin - ThirdPersonComponent.Current.LastEyePos;
				if (!(((Vector3)(ref val)).sqrMagnitude > 2.25f))
				{
					maxDistance += reachBonus;
					ray = ray2;
					if (!loggedCastApply)
					{
						loggedCastApply = true;
						Plugin.LogSource.LogInfo((object)"Interact cast now routed through the camera.");
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private static void SearchThroughHandsPrefix(PlayerCaster __instance, Il2CppStructArray<RaycastHit> hits, ref int hitCount)
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_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)
			try
			{
				if (!loggedSearchCall)
				{
					loggedSearchCall = true;
					Plugin.LogSource.LogInfo((object)"PlayerCaster.SearchThroughHands invoked (seam is live).");
				}
				if (!TryCameraRay(__instance, out var ray, out var reachBonus) || hits == null)
				{
					return;
				}
				if (buffer == null || buffer.Length < ((Il2CppArrayBase<RaycastHit>)(object)hits).Length)
				{
					buffer = (RaycastHit[])(object)new RaycastHit[((Il2CppArrayBase<RaycastHit>)(object)hits).Length];
				}
				float max = __instance.GetMaxDistanceForDirection(((Ray)(ref ray)).direction) + reachBonus;
				Ray ray2 = ray;
				RaycastHit[] buf = buffer;
				LayerMask layerMask = __instance.layerMask;
				int num = CameraCast(ray2, buf, max, ((LayerMask)(ref layerMask)).value);
				if (num < 0)
				{
					return;
				}
				Transform transform = ((Component)__instance.playerCharacter).transform;
				Array.Sort(buffer, 0, num, HitDistanceComparer.Instance);
				int num2 = 0;
				for (int i = 0; i < num && num2 < ((Il2CppArrayBase<RaycastHit>)(object)hits).Length; i++)
				{
					Collider collider = ((RaycastHit)(ref buffer[i])).collider;
					if ((Object)(object)collider == (Object)null)
					{
						continue;
					}
					try
					{
						if (((Component)collider).transform.IsChildOf(transform))
						{
							continue;
						}
					}
					catch (Exception)
					{
					}
					((Il2CppArrayBase<RaycastHit>)(object)hits)[num2++] = buffer[i];
				}
				hitCount = num2;
				if (!loggedSearchApply)
				{
					loggedSearchApply = true;
					Plugin.LogSource.LogInfo((object)"Interact hit search now fed by the camera cast.");
				}
			}
			catch (Exception e)
			{
				LogSearchFail(e);
			}
		}

		private static Exception SearchThroughHandsFinalizer(Exception __exception)
		{
			ThirdPersonComponent current = ThirdPersonComponent.Current;
			if (__exception != null && (Object)(object)current != (Object)null && current.IsActiveForCast)
			{
				LogSearchFail(__exception);
				return null;
			}
			return __exception;
		}

		private static int CameraCast(Ray ray, RaycastHit[] buf, float max, int mask)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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)
			try
			{
				return Physics.RaycastNonAlloc(ray, Il2CppStructArray<RaycastHit>.op_Implicit(buf), max, mask, (QueryTriggerInteraction)1);
			}
			catch (Exception e)
			{
				LogSearchFail(e);
			}
			try
			{
				Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(ray, max, mask, (QueryTriggerInteraction)1);
				int num = Mathf.Min(((Il2CppArrayBase<RaycastHit>)(object)val).Length, buf.Length);
				for (int i = 0; i < num; i++)
				{
					buf[i] = ((Il2CppArrayBase<RaycastHit>)(object)val)[i];
				}
				return num;
			}
			catch (Exception e2)
			{
				LogSearchFail(e2);
			}
			return -1;
		}

		private static void LogSearchFail(Exception e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (loggedSearchFail < 3)
			{
				loggedSearchFail++;
				ManualLogSource logSource = Plugin.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("camera cast query failed (likely stripped): ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
				}
				logSource.LogWarning(val);
			}
		}
	}
	[BepInPlugin("dev.sopur.bigwalk.thirdperson", "Big Walk Third Person", "1.0.0")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "dev.sopur.bigwalk.thirdperson";

		public const string Name = "Big Walk Third Person";

		public const string Version = "1.0.0";

		internal static ManualLogSource LogSource;

		internal static ConfigEntry<CameraMode> Mode;

		internal static ConfigEntry<KeyCode> ToggleKey;

		internal static ConfigEntry<KeyCode> DumpKey;

		internal static ConfigEntry<bool> StartEnabled;

		internal static ConfigEntry<float> Distance;

		internal static ConfigEntry<float> MinDistance;

		internal static ConfigEntry<float> MaxDistance;

		internal static ConfigEntry<float> Height;

		internal static ConfigEntry<float> Shoulder;

		internal static ConfigEntry<float> ZoomSpeed;

		internal static ConfigEntry<bool> Collision;

		internal static ConfigEntry<float> CollisionRadius;

		internal static ConfigEntry<bool> Stabilize;

		internal static ConfigEntry<float> StabilizeAmount;

		internal static ConfigEntry<float> StabilizeSmoothTime;

		internal static ConfigEntry<bool> LevelHorizon;

		internal static ConfigEntry<bool> AimConverge;

		internal static ConfigEntry<float> AimSmoothTime;

		internal static ConfigEntry<float> AimMaxAngle;

		internal static ConfigEntry<float> InteractDistance;

		internal static ConfigEntry<float> InteractZoomTime;

		internal static ConfigEntry<bool> CastFromCamera;

		internal static ConfigEntry<bool> ShowBody;

		internal static ConfigEntry<bool> HideHead;

		internal static ConfigEntry<bool> ShowStatus;

		internal static ConfigEntry<bool> ShowAimDot;

		public override void Load()
		{
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Expected O, but got Unknown
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Expected O, but got Unknown
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			LogSource = ((BasePlugin)this).Log;
			string text = "Camera";
			Mode = ((BasePlugin)this).Config.Bind<CameraMode>(text, "Mode", CameraMode.Direct, "Direct = move the camera itself before rendering (recommended). Guide = reroute the game's camera guide mechanism (experimental).");
			ToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>(text, "ToggleKey", (KeyCode)285, "Key that toggles third person.");
			DumpKey = ((BasePlugin)this).Config.Bind<KeyCode>(text, "DumpKey", (KeyCode)289, "Key that dumps the local player hierarchy to the BepInEx log (for troubleshooting).");
			StartEnabled = ((BasePlugin)this).Config.Bind<bool>(text, "StartEnabled", true, "Start in third person as soon as a local player exists.");
			Distance = ((BasePlugin)this).Config.Bind<float>(text, "Distance", 3.2f, "Camera distance behind the player (meters).");
			MinDistance = ((BasePlugin)this).Config.Bind<float>(text, "MinDistance", 1f, "Minimum zoom distance.");
			MaxDistance = ((BasePlugin)this).Config.Bind<float>(text, "MaxDistance", 7f, "Maximum zoom distance.");
			Height = ((BasePlugin)this).Config.Bind<float>(text, "Height", 0.45f, "Camera pivot height above the eye position.");
			Shoulder = ((BasePlugin)this).Config.Bind<float>(text, "Shoulder", 0.45f, "Sideways (over-shoulder) offset of the camera.");
			ZoomSpeed = ((BasePlugin)this).Config.Bind<float>(text, "ZoomSpeed", 1.6f, "Mouse wheel zoom speed.");
			Collision = ((BasePlugin)this).Config.Bind<bool>(text, "Collision", true, "Pull the camera in when geometry blocks the view.");
			CollisionRadius = ((BasePlugin)this).Config.Bind<float>(text, "CollisionRadius", 0.22f, "Sphere radius used for camera collision.");
			Stabilize = ((BasePlugin)this).Config.Bind<bool>(text, "Stabilize", true, "Smooth the camera pivot to remove head bob. Main motion-sickness comfort feature.");
			StabilizeAmount = ((BasePlugin)this).Config.Bind<float>(text, "StabilizeAmount", 0.85f, "How much of the pivot bob is removed (0 = off, 1 = fully smoothed).");
			StabilizeSmoothTime = ((BasePlugin)this).Config.Bind<float>(text, "StabilizeSmoothTime", 0.12f, "Seconds of smoothing on the pivot. Higher = steadier but laggier.");
			LevelHorizon = ((BasePlugin)this).Config.Bind<bool>(text, "LevelHorizon", false, "Force the camera level with the horizon (removes roll).");
			AimConverge = ((BasePlugin)this).Config.Bind<bool>(text, "AimConverge", true, "Rotate the camera so the screen centre lands on whatever the game is aiming at (grabs, pecks, switches). Fixes the interaction point being offset from the crosshair in third person.");
			AimSmoothTime = ((BasePlugin)this).Config.Bind<float>(text, "AimSmoothTime", 0.08f, "Seconds of smoothing on the aim point as it moves between targets. 0 = snap.");
			AimMaxAngle = ((BasePlugin)this).Config.Bind<float>(text, "AimMaxAngle", 20f, "Maximum degrees the camera may tilt away from the look direction to centre a target, applied only while leaned in to an interactable.");
			InteractDistance = ((BasePlugin)this).Config.Bind<float>(text, "InteractDistance", 0.05f, "Boom distance while an interactable is targeted: at ~0 the camera sits on the eye itself, so the game's aim ray runs exactly through the screen centre. Returns to third person when the target clears.");
			InteractZoomTime = ((BasePlugin)this).Config.Bind<float>(text, "InteractZoomTime", 0.4f, "SmoothDamp time for the lean-in/out; the return takes ~1.5x longer. Raise for a slower, more cinematic ease.");
			CastFromCamera = ((BasePlugin)this).Config.Bind<bool>(text, "CastFromCamera", false, "EXPERIMENTAL: route the local player's interact cast through the third-person camera, so whatever is under the screen centre is what you interact with. The game's caster feeds reach/hand checks too, so this can destabilise the character. Off = character-forward cast.");
			string text2 = "Body";
			ShowBody = ((BasePlugin)this).Config.Bind<bool>(text2, "ShowBody", true, "Show the full (remote-mode) body on the local player while in third person.");
			HideHead = ((BasePlugin)this).Config.Bind<bool>(text2, "HideHead", false, "Hide the head renderers in third person (use if the head blocks the view).");
			string text3 = "UI";
			ShowStatus = ((BasePlugin)this).Config.Bind<bool>(text3, "ShowStatus", true, "Show a small on-screen label while third person is active.");
			ShowAimDot = ((BasePlugin)this).Config.Bind<bool>(text3, "ShowAimDot", true, "Draw a small dot where the game is actually aiming: on the target when one is highlighted, or on the character's eye ray when nothing is (only in character-forward cast mode). Makes the invisible aim legible and doubles as a diagnostic for CastFromCamera.");
			ClassInjector.RegisterTypeInIl2Cpp<ThirdPersonComponent>();
			ClassInjector.RegisterTypeInIl2Cpp<CameraDriver>();
			GameObject val = new GameObject("BigWalkThirdPerson");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent(Il2CppType.Of<ThirdPersonComponent>());
			bool flag = default(bool);
			try
			{
				CameraCastPatch.Apply(new Harmony("dev.sopur.bigwalk.thirdperson.cameracast"));
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = LogSource;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Camera-cast patch failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val2);
			}
			ManualLogSource logSource2 = LogSource;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(23, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("Big Walk Third Person");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" loaded. Toggle with ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<KeyCode>(ToggleKey.Value);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
			}
			logSource2.LogInfo(val3);
		}
	}
	public enum CameraMode
	{
		Guide,
		Direct
	}
	public class ThirdPersonComponent : MonoBehaviour
	{
		private PlayerCharacter pc;

		private PlayerCameraReferences pcr;

		private PlayerCameraMinder minder;

		private Camera cam;

		private Transform pivot;

		private Transform guide;

		private Transform gameGuide;

		private CameraDriver driver;

		private bool active;

		private bool suspended;

		private float curDistance;

		private float nextResolve;

		private float nextBodyCheck;

		private bool wantEnabled;

		private bool bodyApplied;

		private bool origHideTorso;

		private Vector3 origCamLocalPos;

		private Quaternion origCamLocalRot;

		private int collideMode = -1;

		private int collisionMask;

		private string lastError;

		private float lastErrorTime;

		private Vector3 smoothPivot;

		private bool hasSmoothPivot;

		private Vector3 smoothAim;

		private bool hasSmoothAim;

		private bool hasBoom;

		private Quaternion gameRot;

		private Quaternion appliedRot;

		private Quaternion prevPivotRot;

		private Quaternion prevCharRot;

		private bool hasGameRot;

		private bool hasAppliedRot;

		private bool hasPrevPivot;

		private bool hasPrevChar;

		private float aimProx;

		private float aimProxVel;

		private float aimGraceUntil;

		private float fpProx;

		private float fpProxVel;

		private bool wheelFP;

		private bool proxHeadHidden;

		internal static ThirdPersonComponent Current;

		private static Texture2D dotTex;

		internal bool IsActiveForCast
		{
			get
			{
				if (active && !suspended && hasBoom)
				{
					return Plugin.CastFromCamera.Value;
				}
				return false;
			}
		}

		internal Vector3 LastBoomPos { get; private set; }

		internal Quaternion LastBoomRot { get; private set; }

		internal Vector3 LastEyePos { get; private set; }

		internal Quaternion LastEyeRot { get; private set; }

		public ThirdPersonComponent(IntPtr ptr)
			: base(ptr)
		{
		}

		public ThirdPersonComponent()
			: base(ClassInjector.DerivedConstructorPointer<ThirdPersonComponent>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("BigWalkThirdPersonGuide");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			guide = val.transform;
			curDistance = Plugin.Distance.Value;
			wantEnabled = Plugin.StartEnabled.Value;
			Current = this;
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Input.GetKeyDown(Plugin.ToggleKey.Value))
				{
					wantEnabled = !wantEnabled;
				}
				if (Input.GetKeyDown(Plugin.DumpKey.Value))
				{
					Dump();
				}
				if (active && !suspended)
				{
					float axis = Input.GetAxis("Mouse ScrollWheel");
					if (axis != 0f)
					{
						if (axis > 0f && !wheelFP && curDistance <= Plugin.MinDistance.Value + 0.001f)
						{
							wheelFP = true;
						}
						else if (axis < 0f && wheelFP)
						{
							wheelFP = false;
						}
						else if (!wheelFP)
						{
							curDistance = Mathf.Clamp(curDistance - axis * Plugin.ZoomSpeed.Value, Plugin.MinDistance.Value, Plugin.MaxDistance.Value);
						}
					}
				}
			}
			catch (Exception ex)
			{
				LogThrottled("input", "Input handling failed: " + ex.Message);
			}
			if (Time.unscaledTime >= nextResolve)
			{
				nextResolve = Time.unscaledTime + 0.5f;
				try
				{
					ResolveRefs();
				}
				catch (Exception ex2)
				{
					LogThrottled("resolve", "ResolveRefs: " + ex2.Message);
				}
			}
			try
			{
				if (wantEnabled && !active && RefsOk())
				{
					Enter();
				}
				if (!wantEnabled && active)
				{
					Exit();
				}
			}
			catch (Exception value)
			{
				LogThrottled("enterexit", $"Enter/Exit: {value}");
			}
			if (active && !suspended && Plugin.ShowBody.Value && Time.unscaledTime >= nextBodyCheck)
			{
				nextBodyCheck = Time.unscaledTime + 0.5f;
				try
				{
					ApplyBody();
				}
				catch (Exception ex3)
				{
					LogThrottled("body", "ApplyBody: " + ex3.Message);
				}
			}
			Vector3 val;
			if (active && RefsOk() && (Object)(object)pivot != (Object)null)
			{
				Vector3 position = pivot.position;
				if (hasSmoothPivot)
				{
					val = position - smoothPivot;
					if (!(((Vector3)(ref val)).sqrMagnitude > 2.25f))
					{
						float num = Mathf.Max(0.01f, Plugin.StabilizeSmoothTime.Value);
						smoothPivot = Vector3.Lerp(smoothPivot, position, 1f - Mathf.Exp((0f - Time.deltaTime) / num));
						goto IL_02d2;
					}
				}
				smoothPivot = position;
				hasSmoothPivot = true;
			}
			else
			{
				hasSmoothPivot = false;
			}
			goto IL_02d2;
			IL_03ca:
			bool flag;
			float num2 = (flag ? Plugin.InteractZoomTime.Value : (Plugin.InteractZoomTime.Value * 1.5f));
			aimProx = Mathf.SmoothDamp(aimProx, flag ? 1f : 0f, ref aimProxVel, Mathf.Max(0.05f, num2));
			if (!flag && aimProx <= 0.001f)
			{
				aimProx = 0f;
				aimProxVel = 0f;
				hasSmoothAim = false;
			}
			fpProx = Mathf.SmoothDamp(fpProx, wheelFP ? 1f : 0f, ref fpProxVel, Mathf.Max(0.05f, Plugin.InteractZoomTime.Value));
			if (!wheelFP && fpProx <= 0.001f)
			{
				fpProx = 0f;
				fpProxVel = 0f;
			}
			float num3 = Mathf.Max(aimProx, fpProx);
			if (active && Plugin.ShowBody.Value && (Object)(object)pc != (Object)null && pc.looks != null)
			{
				bool flag2 = (proxHeadHidden ? (num3 > 0.35f) : (num3 > 0.5f));
				if (flag2 != proxHeadHidden)
				{
					proxHeadHidden = flag2;
					SetHeadVisible(!proxHeadHidden && !Plugin.HideHead.Value);
					SetRenderersVisible(pc.looks.torsoRenderers, !proxHeadHidden);
					SetRenderersVisible(pc.looks.legsRenderers, !proxHeadHidden);
					pc.looks.SetHideLocalTorso(proxHeadHidden);
				}
			}
			return;
			IL_02d2:
			Vector3 aim = default(Vector3);
			bool flag3 = active && RefsOk() && Plugin.AimConverge.Value && TryGetAimPoint(out aim);
			if (!flag3 && active && RefsOk() && Plugin.AimConverge.Value && TryGetCursorInteractable(out var aim2))
			{
				flag3 = true;
				aim = aim2;
			}
			if (flag3)
			{
				aimGraceUntil = Time.unscaledTime + 0.15f;
			}
			flag = flag3 || Time.unscaledTime < aimGraceUntil;
			if (flag3)
			{
				if (hasSmoothAim)
				{
					val = aim - smoothAim;
					if (!(((Vector3)(ref val)).sqrMagnitude > 4f))
					{
						float num4 = Mathf.Max(0.01f, Plugin.AimSmoothTime.Value);
						smoothAim = Vector3.Lerp(smoothAim, aim, 1f - Mathf.Exp((0f - Time.deltaTime) / num4));
						goto IL_03ca;
					}
				}
				smoothAim = aim;
				hasSmoothAim = true;
			}
			goto IL_03ca;
		}

		private void LateUpdate()
		{
			if (!active || !RefsOk())
			{
				return;
			}
			try
			{
				if (Plugin.Mode.Value == CameraMode.Guide)
				{
					LateUpdateGuide();
				}
				else
				{
					ApplyDirect();
				}
			}
			catch (Exception ex)
			{
				LogThrottled("lateupdate", "LateUpdate: " + ex.Message);
			}
		}

		private bool RefsOk()
		{
			if ((Object)(object)pc != (Object)null)
			{
				return (Object)(object)cam != (Object)null;
			}
			return false;
		}

		private void ResolveRefs()
		{
			if ((Object)(object)pcr == (Object)null)
			{
				pcr = Object.FindObjectOfType<PlayerCameraReferences>();
			}
			if ((Object)(object)cam == (Object)null)
			{
				cam = (((Object)(object)pcr != (Object)null && (Object)(object)pcr.playerCamera != (Object)null) ? pcr.playerCamera : Camera.main);
			}
			if ((Object)(object)pc == (Object)null && PlayerCharacter.allPlayerCharacters != null)
			{
				PlayerCharacter val = null;
				for (int i = 0; i < PlayerCharacter.allPlayerCharacters.Count; i++)
				{
					PlayerCharacter val2 = PlayerCharacter.allPlayerCharacters[i];
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					try
					{
						if (((NetworkBehaviour)val2).isLocalPlayer)
						{
							pc = val2;
							break;
						}
					}
					catch (Exception)
					{
					}
					if ((Object)(object)val == (Object)null && (Object)(object)val2.cameraTransform != (Object)null && val2.cameraMinder != null)
					{
						val = val2;
					}
				}
				if ((Object)(object)pc == (Object)null)
				{
					pc = val;
				}
			}
			if ((Object)(object)pc != (Object)null)
			{
				minder = pc.cameraMinder;
				if ((Object)(object)cam == (Object)null && (Object)(object)pc.cameraTransform != (Object)null)
				{
					cam = ((Component)pc.cameraTransform).GetComponent<Camera>();
				}
				if ((Object)(object)pivot == (Object)null && (Object)(object)cam != (Object)null && (Object)(object)((Component)cam).transform.parent != (Object)null)
				{
					pivot = ((Component)cam).transform.parent;
				}
				if ((Object)(object)pivot == (Object)null && pc.registry != null && (Object)(object)pc.registry.headBone != (Object)null)
				{
					pivot = pc.registry.headBone;
				}
			}
		}

		private void Enter()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			active = true;
			suspended = false;
			bool flag = (hasGameRot = (hasAppliedRot = (hasPrevPivot = (hasPrevChar = false))));
			hasSmoothAim = false;
			hasBoom = false;
			aimProx = 0f;
			aimProxVel = 0f;
			fpProx = 0f;
			fpProxVel = 0f;
			wheelFP = false;
			proxHeadHidden = false;
			origCamLocalPos = ((Component)cam).transform.localPosition;
			origCamLocalRot = ((Component)cam).transform.localRotation;
			BuildCollisionMask();
			if (Plugin.Mode.Value == CameraMode.Guide)
			{
				if (minder != null)
				{
					gameGuide = minder._cameraGuide;
					minder.cameraGuide = guide;
				}
			}
			else
			{
				EnsureDriver();
			}
			if (Plugin.ShowBody.Value && pc.looks != null)
			{
				origHideTorso = pc.looks.hideLocalTorso;
				ApplyBody();
			}
			ManualLogSource logSource = Plugin.LogSource;
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Third person ON (");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CameraMode>(Plugin.Mode.Value);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
			}
			logSource.LogInfo(val);
		}

		private void Exit()
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			active = false;
			suspended = false;
			try
			{
				if (Plugin.Mode.Value == CameraMode.Guide && minder != null)
				{
					if ((Object)(object)minder._cameraGuide == (Object)null || ((Il2CppObjectBase)minder._cameraGuide).Pointer == ((Il2CppObjectBase)guide).Pointer)
					{
						minder.cameraGuide = gameGuide;
					}
				}
				else
				{
					if ((Object)(object)driver != (Object)null)
					{
						((Behaviour)driver).enabled = false;
					}
					if ((Object)(object)cam != (Object)null)
					{
						((Component)cam).transform.localPosition = origCamLocalPos;
					}
				}
				RestoreBody();
				Plugin.LogSource.LogInfo((object)"Third person OFF");
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = Plugin.LogSource;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Exit failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logSource.LogError(val);
			}
		}

		private void EnsureDriver()
		{
			if (!((Object)(object)driver != (Object)null) && !((Object)(object)cam == (Object)null))
			{
				driver = ((Il2CppObjectBase)((Component)cam).gameObject.AddComponent(Il2CppType.Of<CameraDriver>())).TryCast<CameraDriver>();
				if ((Object)(object)driver != (Object)null)
				{
					driver.owner = this;
				}
			}
		}

		private void BuildCollisionMask()
		{
			int num = 4;
			if ((Object)(object)pc != (Object)null)
			{
				Il2CppArrayBase<Collider> componentsInChildren = ((Component)pc).GetComponentsInChildren<Collider>(true);
				if (componentsInChildren != null)
				{
					for (int i = 0; i < componentsInChildren.Count; i++)
					{
						if ((Object)(object)componentsInChildren[i] != (Object)null)
						{
							num |= 1 << ((Component)componentsInChildren[i]).gameObject.layer;
						}
					}
				}
				num |= 1 << ((Component)pc).gameObject.layer;
			}
			collisionMask = ~num;
		}

		private int CollideMode()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (collideMode != -1)
			{
				return collideMode;
			}
			Vector3 val = (((Object)(object)pivot != (Object)null) ? pivot.position : Vector3.zero);
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(val, Vector3.down);
			RaycastHit val3 = default(RaycastHit);
			try
			{
				Physics.SphereCast(val2, 0.1f, ref val3, 1f, collisionMask, (QueryTriggerInteraction)1);
				collideMode = 1;
			}
			catch (Exception)
			{
				collideMode = -2;
			}
			if (collideMode == -2)
			{
				try
				{
					Physics.Raycast(val2, ref val3, 1f, collisionMask, (QueryTriggerInteraction)1);
					collideMode = 2;
				}
				catch (Exception)
				{
					collideMode = 0;
				}
			}
			if (collideMode == 0)
			{
				Plugin.LogSource.LogWarning((object)"No usable physics query found (all stripped); camera collision disabled.");
			}
			else
			{
				ManualLogSource logSource = Plugin.LogSource;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Collision probe: mode ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(collideMode);
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (1=sphere,2=ray)");
				}
				logSource.LogInfo(val4);
			}
			return collideMode;
		}

		internal bool ComputeBoom(out Vector3 pos, out Quaternion rot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0045: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			pos = default(Vector3);
			rot = default(Quaternion);
			if (!RefsOk())
			{
				return false;
			}
			Vector3 val = (((Object)(object)pivot != (Object)null) ? pivot.position : (((Component)pc).transform.position + Vector3.up * 1.5f));
			if (Plugin.Stabilize.Value && hasSmoothPivot)
			{
				val = Vector3.Lerp(val, smoothPivot, Mathf.Clamp01(Plugin.StabilizeAmount.Value));
			}
			Quaternion rotation = ((Component)cam).transform.rotation;
			Quaternion val2 = (((Object)(object)pivot != (Object)null) ? pivot.rotation : Quaternion.identity);
			Quaternion rotation2 = ((Component)pc).transform.rotation;
			Quaternion val3 = (hasPrevPivot ? (val2 * Quaternion.Inverse(prevPivotRot)) : Quaternion.identity);
			Quaternion val4 = Quaternion.Inverse(hasPrevChar ? (rotation2 * Quaternion.Inverse(prevCharRot)) : Quaternion.identity) * val3;
			if ((Object)(object)pivot != (Object)null && Quaternion.Angle(val2, rotation) < 60f)
			{
				gameRot = val2;
				hasGameRot = true;
			}
			else if (!hasGameRot)
			{
				gameRot = rotation;
				hasGameRot = true;
			}
			else if (!hasAppliedRot || !(Quaternion.Angle(rotation, appliedRot) < 0.001f))
			{
				if (hasAppliedRot && Quaternion.Angle(rotation, val4 * appliedRot) < 0.5f)
				{
					gameRot = val4 * gameRot;
				}
				else
				{
					gameRot = rotation;
				}
			}
			Vector3 eulerAngles = ((Quaternion)(ref gameRot)).eulerAngles;
			if (Mathf.Abs(eulerAngles.z) > 0.01f)
			{
				gameRot = Quaternion.Euler(eulerAngles.x, eulerAngles.y, 0f);
			}
			prevPivotRot = val2;
			prevCharRot = rotation2;
			hasPrevPivot = (hasPrevChar = true);
			rot = gameRot;
			if (Plugin.LevelHorizon.Value)
			{
				Vector3 eulerAngles2 = ((Quaternion)(ref rot)).eulerAngles;
				rot = Quaternion.Euler(eulerAngles2.x, eulerAngles2.y, 0f);
			}
			Quaternion lastEyeRot = rot;
			Vector3 val5 = rot * Vector3.forward;
			Vector3 val6 = rot * Vector3.right;
			float num = Mathf.Clamp01(Mathf.Max(aimProx, fpProx));
			Vector3 val7 = val + Vector3.up * (Plugin.Height.Value * (1f - num)) + val6 * (Plugin.Shoulder.Value * (1f - num));
			float num2 = Mathf.Max(0.05f, Mathf.Lerp(curDistance, Plugin.InteractDistance.Value, num));
			Vector3 val8 = val7 - val5 * num2;
			if (Plugin.Collision.Value && CollideMode() != 0)
			{
				Vector3 val9 = val8 - val7;
				Vector3 normalized = ((Vector3)(ref val9)).normalized;
				float num3 = 0.25f;
				RaycastHit val10 = default(RaycastHit);
				bool flag = ((collideMode != 1) ? Physics.Raycast(val7, normalized, ref val10, num2, collisionMask, (QueryTriggerInteraction)1) : Physics.SphereCast(val7, Plugin.CollisionRadius.Value, normalized, ref val10, num2, collisionMask, (QueryTriggerInteraction)1));
				if (flag && ((RaycastHit)(ref val10)).distance < num2)
				{
					val8 = val7 + normalized * Mathf.Max(((RaycastHit)(ref val10)).distance, num3);
				}
			}
			pos = val8;
			if (hasSmoothAim && num > 0.001f)
			{
				Vector3 val11 = smoothAim - val8;
				if (((Vector3)(ref val11)).sqrMagnitude > 0.0025f && Vector3.Dot(val11, val5) > 0f && Mathf.Abs(Vector3.Dot(((Vector3)(ref val11)).normalized, Vector3.up)) < 0.98f)
				{
					Quaternion val12 = Quaternion.LookRotation(val11, Vector3.up);
					rot = Quaternion.RotateTowards(rot, val12, Mathf.Min(Plugin.AimMaxAngle.Value, Plugin.AimMaxAngle.Value * num * (1f - num) * 4f));
				}
			}
			Vector3 val13 = (((Object)(object)pivot != (Object)null) ? (pivot.position + val2 * origCamLocalPos) : val8);
			Quaternion val14 = val2 * origCamLocalRot;
			pos = Vector3.Lerp(pos, val13, num);
			rot = Quaternion.Slerp(rot, val14, num);
			LastBoomPos = pos;
			LastBoomRot = rot;
			LastEyePos = val;
			LastEyeRot = lastEyeRot;
			appliedRot = rot;
			hasAppliedRot = true;
			hasBoom = true;
			return true;
		}

		private bool TryGetAimPoint(out Vector3 aim)
		{
			//IL_0001: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			aim = default(Vector3);
			if ((Object)(object)pc == (Object)null)
			{
				return false;
			}
			try
			{
				PlayerCaster caster = pc.caster;
				if (caster != null)
				{
					if ((Object)(object)caster.castableTarget != (Object)null)
					{
						Transform crosshairTransform = caster.castableTarget.GetCrosshairTransform();
						aim = (((Object)(object)crosshairTransform != (Object)null) ? crosshairTransform.position : caster.hitPosition);
						return true;
					}
					if ((Object)(object)caster.castProp != (Object)null)
					{
						Transform customCrosshairPoint = caster.castProp.customCrosshairPoint;
						aim = (((Object)(object)customCrosshairPoint != (Object)null) ? customCrosshairPoint.position : caster.hitPosition);
						return true;
					}
					if ((Object)(object)caster.castCharacter != (Object)null)
					{
						aim = caster.hitPosition;
						return true;
					}
				}
				PlayerDecisions decisions = pc.decisions;
				if (decisions != null && (Object)(object)decisions.heldDownSwitch != (Object)null)
				{
					Transform crosshairTransform2 = decisions.heldDownSwitch.GetCrosshairTransform();
					aim = (((Object)(object)crosshairTransform2 != (Object)null) ? crosshairTransform2.position : ((Component)decisions.heldDownSwitch).transform.position);
					return true;
				}
			}
			catch (Exception)
			{
			}
			return false;
		}

		private bool TryGetCursorInteractable(out Vector3 aim)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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)
			aim = default(Vector3);
			if (!hasBoom || (Object)(object)cam == (Object)null || CollideMode() == 0)
			{
				return false;
			}
			try
			{
				Vector3 val = LastEyeRot * Vector3.forward;
				Vector3 val2 = LastEyeRot * Vector3.right;
				Vector3 val3 = LastEyePos + Vector3.up * Plugin.Height.Value + val2 * Plugin.Shoulder.Value;
				Ray val4 = default(Ray);
				((Ray)(ref val4))..ctor(val3 - val * curDistance, val);
				float num = curDistance + 4f;
				int value;
				if (pc.caster == null)
				{
					value = collisionMask;
				}
				else
				{
					LayerMask layerMask = pc.caster.layerMask;
					value = ((LayerMask)(ref layerMask)).value;
				}
				int num2 = value;
				RaycastHit val5 = default(RaycastHit);
				if (!((collideMode == 1) ? Physics.SphereCast(val4, 0.05f, ref val5, num, num2, (QueryTriggerInteraction)1) : Physics.Raycast(val4, ref val5, num, num2, (QueryTriggerInteraction)1)) || (Object)(object)((RaycastHit)(ref val5)).collider == (Object)null)
				{
					return false;
				}
				try
				{
					if (((Component)((RaycastHit)(ref val5)).collider).transform.IsChildOf(((Component)pc).transform))
					{
						return false;
					}
				}
				catch (Exception)
				{
				}
				if (!IsInteractable(((RaycastHit)(ref val5)).collider))
				{
					return false;
				}
				float num3 = 2f;
				try
				{
					if (pc.caster != null)
					{
						num3 = pc.caster.raycastMaxDistance;
					}
				}
				catch (Exception)
				{
				}
				if (Vector3.Distance(((RaycastHit)(ref val5)).point, LastEyePos) > num3 * 1.15f)
				{
					return false;
				}
				aim = ((RaycastHit)(ref val5)).point;
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static bool IsInteractable(Collider col)
		{
			try
			{
				if ((Object)(object)((Component)col).GetComponentInParent(Il2CppType.Of<Prop>()) != (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)col).GetComponentInParent(Il2CppType.Of<CastableTarget>()) != (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)col).GetComponentInParent(Il2CppType.Of<PeckSwitch>()) != (Object)null)
				{
					return true;
				}
			}
			catch (Exception)
			{
			}
			return false;
		}

		private void LateUpdateGuide()
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (minder == null)
			{
				return;
			}
			Transform cameraGuide = minder._cameraGuide;
			if ((Object)(object)cameraGuide == (Object)null || ((Il2CppObjectBase)cameraGuide).Pointer == ((Il2CppObjectBase)guide).Pointer)
			{
				suspended = false;
				if ((Object)(object)cameraGuide == (Object)null || ((Il2CppObjectBase)cameraGuide).Pointer != ((Il2CppObjectBase)guide).Pointer)
				{
					minder.cameraGuide = guide;
				}
			}
			else
			{
				if ((Object)(object)gameGuide == (Object)null || ((Il2CppObjectBase)cameraGuide).Pointer != ((Il2CppObjectBase)gameGuide).Pointer)
				{
					suspended = true;
					gameGuide = cameraGuide;
					return;
				}
				suspended = false;
				minder.cameraGuide = guide;
			}
			suspended = false;
			if (ComputeBoom(out var pos, out var rot))
			{
				guide.SetPositionAndRotation(pos, rot);
			}
		}

		internal void ApplyDirect()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (ComputeBoom(out var pos, out var rot))
			{
				((Component)cam).transform.SetPositionAndRotation(pos, rot);
			}
		}

		private void ApplyBody()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pc == (Object)null || pc.looks == null)
			{
				return;
			}
			if (!bodyApplied || (int)pc.looks.currentLookType != 1)
			{
				if (bodyApplied)
				{
					LogThrottled("bodymode", $"Game reset look mode to {pc.looks.currentLookType}; re-applying remote body.");
				}
				pc.looks.SetBodyToRemoteMode();
			}
			pc.looks.SetHideLocalTorso(proxHeadHidden);
			SetHeadVisible(!Plugin.HideHead.Value && !proxHeadHidden);
			SetRenderersVisible(pc.looks.torsoRenderers, !proxHeadHidden);
			SetRenderersVisible(pc.looks.legsRenderers, !proxHeadHidden);
			bodyApplied = true;
		}

		private void RestoreBody()
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			if ((Object)(object)pc == (Object)null || pc.looks == null || !bodyApplied)
			{
				return;
			}
			try
			{
				SetHeadVisible(visible: true);
				SetRenderersVisible(pc.looks.torsoRenderers, visible: true);
				SetRenderersVisible(pc.looks.legsRenderers, visible: true);
				pc.looks.SetBodyToLocalMode();
				if (pc.looks.hideLocalTorso != origHideTorso)
				{
					pc.looks.SetHideLocalTorso(origHideTorso);
				}
				bodyApplied = false;
			}
			catch (Exception ex)
			{
				ManualLogSource logSource = Plugin.LogSource;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("RestoreBody: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logSource.LogWarning(val);
			}
		}

		private void SetHeadVisible(bool visible)
		{
			if (pc.looks != null)
			{
				SetRenderersVisible(pc.looks.headRenderers, visible);
			}
		}

		private static void SetRenderersVisible(Il2CppReferenceArray<LooksRenderer> list, bool visible)
		{
			if (list == null)
			{
				return;
			}
			for (int i = 0; i < ((Il2CppArrayBase<LooksRenderer>)(object)list).Count; i++)
			{
				if (((Il2CppArrayBase<LooksRenderer>)(object)list)[i] != null && (Object)(object)((Il2CppArrayBase<LooksRenderer>)(object)list)[i].renderer != (Object)null)
				{
					((Il2CppArrayBase<LooksRenderer>)(object)list)[i].renderer.enabled = visible;
				}
			}
		}

		private void OnGUI()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (active && Plugin.ShowStatus.Value)
				{
					Rect val = default(Rect);
					((Rect)(ref val))..ctor(12f, (float)(Screen.height - 34), 340f, 22f);
					string text = $"3rd person [{Plugin.ToggleKey.Value}]  zoom:{curDistance:0.0}m{(suspended ? " (cutscene)" : "")}";
					GUI.color = new Color(0f, 0f, 0f, 0.7f);
					GUI.Label(new Rect(((Rect)(ref val)).x + 1f, ((Rect)(ref val)).y + 1f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text);
					GUI.color = Color.white;
					GUI.Label(val, text);
					if (Plugin.ShowAimDot.Value && hasBoom)
					{
						DrawAimDot();
					}
				}
			}
			catch (Exception ex)
			{
				LogThrottled("gui", "OnGUI: " + ex.Message);
			}
		}

		private void DrawAimDot()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetAimPoint(out var aim))
			{
				Vector3 val = cam.WorldToScreenPoint(aim);
				if (!(val.z <= 0f))
				{
					GUI.color = new Color(1f, 1f, 1f, 0.95f);
					GUI.DrawTexture(new Rect(val.x - 6f, (float)Screen.height - val.y - 6f, 12f, 12f), (Texture)(object)DotTex());
					GUI.color = Color.white;
				}
			}
		}

		private static Texture2D DotTex()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_00ce: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)dotTex != (Object)null)
			{
				return dotTex;
			}
			Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[256];
			for (int i = 0; i < 16; i++)
			{
				for (int j = 0; j < 16; j++)
				{
					float num = (float)j - 7.5f;
					float num2 = (float)i - 7.5f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					array[i * 16 + j] = (Color)((num3 >= 3.5f && num3 <= 6.5f) ? Color.white : ((num3 < 3.5f) ? new Color(1f, 1f, 1f, 0.25f) : ((num3 <= 7.5f) ? new Color(1f, 1f, 1f, 0.35f) : new Color(1f, 1f, 1f, 0f))));
				}
			}
			val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
			val.Apply();
			dotTex = val;
			return val;
		}

		private void LogThrottled(string key, string msg)
		{
			if (!(lastError == key) || !(Time.unscaledTime - lastErrorTime < 5f))
			{
				lastError = key;
				lastErrorTime = Time.unscaledTime;
				Plugin.LogSource.LogError((object)msg);
			}
		}

		private void Dump()
		{
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pc == (Object)null)
			{
				Plugin.LogSource.LogInfo((object)"Dump: no local player yet");
				return;
			}
			Plugin.LogSource.LogInfo((object)"=== ThirdPerson dump ===");
			ManualLogSource logSource = Plugin.LogSource;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("cam=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)cam != (Object)null) ? ((Object)cam).name : "null");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" pivot=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)pivot != (Object)null) ? ((Object)pivot).name : "null");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("camLocal=");
				BepInExInfoLogInterpolatedStringHandler obj = val;
				Camera obj2 = cam;
				((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<Vector3?>((obj2 != null) ? new Vector3?(((Component)obj2).transform.localPosition) : ((Vector3?)null));
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" collideMode=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(collideMode);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mask=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(collisionMask);
			}
			logSource.LogInfo(val);
			try
			{
				PlayerCaster caster = pc.caster;
				if (caster != null)
				{
					ManualLogSource logSource2 = Plugin.LogSource;
					val = new BepInExInfoLogInterpolatedStringHandler(54, 6, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("caster: prop=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)caster.castProp != (Object)null) ? ((Object)caster.castProp).name : "-");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("castable=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)caster.castableTarget != (Object)null) ? ((Object)caster.castableTarget).name : "-");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("character=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)caster.castCharacter != (Object)null) ? ((Object)caster.castCharacter).name : "-");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("hit=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(caster.hitPosition);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" dist=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(caster.castDistance);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" maxDist=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(caster.raycastMaxDistance);
					}
					logSource2.LogInfo(val);
				}
				PlayerHighlighter highlighter = pc.highlighter;
				if (highlighter != null)
				{
					ManualLogSource logSource3 = Plugin.LogSource;
					val = new BepInExInfoLogInterpolatedStringHandler(32, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("highlighter: target=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)highlighter.target != (Object)null) ? ((Object)highlighter.target).name : "-");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ringActive=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>((Object)(object)highlighter.inWorldCrosshair != (Object)null && ((Component)highlighter.inWorldCrosshair).gameObject.activeInHierarchy);
					}
					logSource3.LogInfo(val);
				}
				PlayerLooks looks = pc.looks;
				if (looks != null)
				{
					ManualLogSource logSource4 = Plugin.LogSource;
					val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("looks: type=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<LookType>(looks.currentLookType);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" hideTorso=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(looks.hideLocalTorso);
					}
					logSource4.LogInfo(val);
				}
				ManualLogSource logSource5 = Plugin.LogSource;
				val = new BepInExInfoLogInterpolatedStringHandler(29, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("boom=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(LastBoomPos);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" eye=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(LastEyePos);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" castFromCam=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(IsActiveForCast);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" prox=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(aimProx, "0.00");
				}
				logSource5.LogInfo(val);
				ManualLogSource logSource6 = Plugin.LogSource;
				val = new BepInExInfoLogInterpolatedStringHandler(35, 5, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("rot: cam=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)cam).transform.eulerAngles);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" game=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Quaternion)(ref gameRot)).eulerAngles);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("pivot=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Object)(object)pivot != (Object)null) ? pivot.eulerAngles : Vector3.zero);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" char=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)pc).transform.eulerAngles);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("guide=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>((minder != null && (Object)(object)minder._cameraGuide != (Object)null) ? minder._cameraGuide.eulerAngles : Vector3.zero);
				}
				logSource6.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logSource7 = Plugin.LogSource;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("dump caster: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logSource7.LogWarning(val2);
			}
			DumpTransform(((Component)pc).transform, 0);
		}

		private void DumpTransform(Transform t, int depth)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			Renderer component = ((Component)t).GetComponent<Renderer>();
			string text = (((Object)(object)component != (Object)null) ? $" renderer.enabled={component.enabled} layer={((Component)t).gameObject.layer}" : $" layer={((Component)t).gameObject.layer}");
			ManualLogSource logSource = Plugin.LogSource;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(new string(' ', depth * 2));
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)t).name);
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
			}
			logSource.LogInfo(val);
			for (int i = 0; i < t.childCount; i++)
			{
				DumpTransform(t.GetChild(i), depth + 1);
			}
		}

		private void OnDestroy()
		{
			if (active)
			{
				Exit();
			}
			if ((Object)(object)Current == (Object)(object)this)
			{
				Current = null;
			}
		}
	}
	public class CameraDriver : MonoBehaviour
	{
		internal ThirdPersonComponent owner;

		public CameraDriver(IntPtr ptr)
			: base(ptr)
		{
		}

		public CameraDriver()
			: base(ClassInjector.DerivedConstructorPointer<CameraDriver>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		private void OnPreRender()
		{
			try
			{
				owner?.ApplyDirect();
			}
			catch (Exception)
			{
			}
		}
	}
}