Decompiled source of Big Person View v1.3.1

BepInEx/plugins/Big_Person_View/ThirdPerson.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
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;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ThirdPerson")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Third-person, front-facing and free camera views for Big Walk")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1")]
[assembly: AssemblyProduct("ThirdPerson")]
[assembly: AssemblyTitle("ThirdPerson")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.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 ThirdPerson
{
	internal static class Freecam
	{
		private struct Shift
		{
			public Transform Transform;

			public Vector3 Delta;

			public Quaternion Rotation;
		}

		private struct Pin
		{
			public Transform Transform;

			public Vector3 LocalPosition;

			public Quaternion LocalRotation;

			public Vector3 Position;

			public Quaternion Rotation;
		}

		private static readonly List<Shift> Shifts = new List<Shift>();

		private static readonly List<Pin> Pins = new List<Pin>();

		private static readonly List<Transform> HeldChildren = new List<Transform>();

		private static Transform _heldOwner;

		private static int _heldCount = -1;

		private static bool _active;

		private static bool _seedPending;

		private static Vector3 _position;

		private static float _yaw;

		private static float _pitch;

		private static Vector3 _fromEye;

		private static ViewMode _chosen;

		private const ViewMode Borrowed = ViewMode.Behind;

		public static ViewMode ChosenMode
		{
			get
			{
				if (!_active)
				{
					return Plugin.Mode.Value;
				}
				return _chosen;
			}
			set
			{
				if (_active)
				{
					_chosen = value;
				}
				else
				{
					Plugin.Mode.Value = value;
				}
			}
		}

		public static Vector3 Position => _position;

		public static float Yaw => _yaw;

		public static float Pitch => _pitch;

		public static bool Active => _active;

		public static Quaternion Rotation => Quaternion.Euler(_pitch, _yaw, 0f);

		public static void Toggle()
		{
			SetActive(!_active);
		}

		public static void SetActive(bool active)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			if (active == _active)
			{
				return;
			}
			bool flag = default(bool);
			if (active)
			{
				_chosen = Plugin.Mode.Value;
				_active = true;
				Plugin.Mode.Value = ViewMode.Behind;
				_seedPending = true;
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(95, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("freecam on, taking the camera off your head (view stays ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ViewMode>(_chosen);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("for you, borrowing ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ViewMode>(ViewMode.Behind);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to draw your body)");
				}
				log.LogInfo(val);
			}
			else
			{
				_active = false;
				Restore();
				Plugin.Mode.Value = _chosen;
				if (_chosen == ViewMode.FirstPerson)
				{
					ThirdPersonCamera.Reset();
				}
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("freecam off, camera back on your head, view back to ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ViewMode>(_chosen);
				}
				log2.LogInfo(val);
			}
		}

		public static void Restore()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (Shifts.Count == 0 && Pins.Count == 0)
			{
				return;
			}
			for (int num = Shifts.Count - 1; num >= 0; num--)
			{
				Shift shift = Shifts[num];
				if (!((Object)(object)shift.Transform == (Object)null))
				{
					shift.Transform.rotation = shift.Rotation;
					Transform transform = shift.Transform;
					transform.position -= shift.Delta;
				}
			}
			Shifts.Clear();
			for (int num2 = Pins.Count - 1; num2 >= 0; num2--)
			{
				Pin pin = Pins[num2];
				if (!((Object)(object)pin.Transform == (Object)null))
				{
					pin.Transform.localPosition = pin.LocalPosition;
					pin.Transform.localRotation = pin.LocalRotation;
				}
			}
			Pins.Clear();
		}

		public static void Apply(PlayerCharacter pc)
		{
			//IL_004c: 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_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)
			//IL_005e: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			Restore();
			if (!_active && !Hud.Wanted)
			{
				return;
			}
			Transform ui;
			Camera camera;
			Camera uiCamera;
			Transform val = CameraTransform(pc, out ui, out camera, out uiCamera);
			Hud.Tick(camera, uiCamera);
			if (_active && !((Object)(object)val == (Object)null))
			{
				if (_seedPending)
				{
					_seedPending = false;
					Seed(val);
				}
				Vector3 delta = (_fromEye = _position - val.position);
				Quaternion spin = Rotation * Quaternion.Inverse(val.rotation);
				if (Plugin.PinCameraChildren.Value)
				{
					Hold(val);
				}
				Move(val, delta, spin);
				if ((Object)(object)ui != (Object)null && !ui.IsChildOf(val))
				{
					Move(ui, delta, spin);
				}
				Anchor();
			}
		}

		private static void Seed(Transform main)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			_position = main.position;
			Quaternion rotation = main.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			_yaw = Wrap(eulerAngles.y);
			_pitch = Mathf.Clamp(Wrap(eulerAngles.x), 0f - Limit(), Limit());
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("freecam starting at (");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_position.x, "0.#");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_position.y, "0.#");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_position.z, "0.#");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), facing ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_yaw, "0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("°");
			}
			log.LogInfo(val);
		}

		public static void Steer(float forward, float strafe, float rise, float speed, float dt)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0039: 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_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_0066: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (_active && (forward != 0f || strafe != 0f || rise != 0f))
			{
				Vector3 val = Rotation * new Vector3(strafe, 0f, forward);
				val += Vector3.up * rise;
				if (((Vector3)(ref val)).sqrMagnitude > 1f)
				{
					((Vector3)(ref val)).Normalize();
				}
				_position += val * speed * dt;
			}
		}

		public static void Look(float yaw, float pitch)
		{
			if (_active)
			{
				_yaw = Wrap(_yaw + yaw);
				_pitch = Mathf.Clamp(_pitch + pitch, 0f - Limit(), Limit());
			}
		}

		public static void Level()
		{
			_pitch = 0f;
		}

		public static bool Teleport()
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0071: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00d3: Expected O, but got Unknown
			//IL_00bc: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (!_active)
			{
				return false;
			}
			PlayerCharacter local = ThirdPersonCamera.Local;
			if ((Object)(object)local == (Object)null)
			{
				return false;
			}
			bool flag = default(bool);
			try
			{
				Rigidbody rb = local.rb;
				Transform val = (((Object)(object)rb != (Object)null) ? ((Component)rb).transform : (((Object)(object)local.kernal != (Object)null) ? local.kernal : ((Component)local).transform));
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogWarning((object)"nothing on your character to move, so the teleport did nothing");
					return false;
				}
				Vector3 val2 = val.position + _fromEye;
				if ((Object)(object)rb != (Object)null)
				{
					rb.velocity = Vector3.zero;
					rb.angularVelocity = Vector3.zero;
					rb.position = val2;
				}
				val.position = val2;
				PlayerMover mover = local.mover;
				if (mover != null)
				{
					mover.cachedKernalPos = val2;
				}
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(46, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("brought your character to the camera at ");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("(");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(val2.x, "0.#");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(val2.y, "0.#");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(val2.z, "0.#");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
				}
				log.LogInfo(val3);
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("could not bring your character to the camera: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val4);
				return false;
			}
		}

		private static float Limit()
		{
			return Mathf.Clamp(Plugin.FreecamMaxPitch.Value, 0f, 89.9f);
		}

		private static float Wrap(float degrees)
		{
			degrees %= 360f;
			if (degrees > 180f)
			{
				degrees -= 360f;
			}
			else if (degrees < -180f)
			{
				degrees += 360f;
			}
			return degrees;
		}

		private static void Hold(Transform main)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0051: 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_005e: 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)
			foreach (Transform item in Held(main))
			{
				if (!((Object)(object)item == (Object)null))
				{
					Pins.Add(new Pin
					{
						Transform = item,
						LocalPosition = item.localPosition,
						LocalRotation = item.localRotation,
						Position = item.position,
						Rotation = item.rotation
					});
				}
			}
		}

		private static List<Transform> Held(Transform main)
		{
			if ((Object)(object)_heldOwner == (Object)(object)main && _heldCount == main.childCount)
			{
				return HeldChildren;
			}
			_heldOwner = main;
			_heldCount = main.childCount;
			HeldChildren.Clear();
			for (int i = 0; i < main.childCount; i++)
			{
				Transform child = main.GetChild(i);
				if (!((Object)(object)child == (Object)null))
				{
					Il2CppReferenceArray<Component> componentsInChildren = ((Component)child).GetComponentsInChildren(Il2CppType.Of<Camera>(), true);
					if (componentsInChildren == null || ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length <= 0)
					{
						HeldChildren.Add(child);
					}
				}
			}
			return HeldChildren;
		}

		private static void Anchor()
		{
			//IL_002a: 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)
			foreach (Pin pin in Pins)
			{
				if (!((Object)(object)pin.Transform == (Object)null))
				{
					pin.Transform.position = pin.Position;
					pin.Transform.rotation = pin.Rotation;
				}
			}
		}

		private static void Move(Transform t, Vector3 delta, Quaternion spin)
		{
			//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_0020: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0043: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			Shifts.Add(new Shift
			{
				Transform = t,
				Delta = delta,
				Rotation = t.rotation
			});
			t.position += delta;
			t.rotation = spin * t.rotation;
		}

		private static Transform CameraTransform(PlayerCharacter pc, out Transform ui, out Camera camera, out Camera uiCamera)
		{
			ui = null;
			camera = null;
			uiCamera = null;
			PlayerCameraMinder cameraMinder = pc.cameraMinder;
			PlayerCameraReferences val = ((cameraMinder != null) ? cameraMinder.playerCameraReferences : null);
			if ((Object)(object)val != (Object)null)
			{
				uiCamera = val.playerUICamera;
				if ((Object)(object)uiCamera != (Object)null)
				{
					ui = ((Component)uiCamera).transform;
				}
				camera = val.playerCamera;
				if ((Object)(object)camera != (Object)null)
				{
					return ((Component)camera).transform;
				}
			}
			Transform cameraTransform = pc.cameraTransform;
			if (!((Object)(object)cameraTransform != (Object)null))
			{
				return null;
			}
			return cameraTransform;
		}
	}
	[HarmonyPatch]
	internal static class FreecamPatches
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		[HarmonyPatch(typeof(PlayerCharacter), "FixedUpdate")]
		private static void BeforeFixedUpdate()
		{
			Safely(Freecam.Restore);
		}

		[HarmonyPrefix]
		[HarmonyPriority(800)]
		[HarmonyPatch(typeof(PlayerCharacter), "Update")]
		private static void BeforeUpdate()
		{
			Safely(Freecam.Restore);
		}

		[HarmonyPrefix]
		[HarmonyPriority(800)]
		[HarmonyPatch(typeof(PlayerCharacter), "LateUpdate")]
		private static void BeforeLateUpdate()
		{
			Safely(Freecam.Restore);
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyPatch(typeof(PlayerCharacter), "LateUpdate")]
		private static void AfterLateUpdate(PlayerCharacter __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			try
			{
				if (ThirdPersonCamera.IsLocal(__instance))
				{
					Freecam.Apply(__instance);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("freecam failed, switching it off: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				Safely(delegate
				{
					Freecam.SetActive(active: false);
				});
				Safely(Hud.Restore);
			}
		}

		private static void Safely(Action action)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			try
			{
				action();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(24, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("freecam restore failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}
	}
	internal enum HudPiece
	{
		Crosshair,
		Backpack,
		Belt
	}
	internal static class FreecamPanel
	{
		private static HudPiece _piece;

		public static HudPiece Piece => _piece;

		public static void Body()
		{
			State();
			GUILayout.Space(8f);
			PanelWidgets.Section("Flight", delegate
			{
				PanelWidgets.ResetAll("flight", Plugin.FreecamSpeed, Plugin.FreecamFastMultiplier, Plugin.FreecamSlowMultiplier);
			});
			PanelWidgets.Slider(Plugin.FreecamSpeed, "Speed", 0.5f, 50f, "m/s", 1);
			PanelWidgets.Slider(Plugin.FreecamFastMultiplier, "Fast key", 1f, 20f, "x", 1);
			PanelWidgets.Slider(Plugin.FreecamSlowMultiplier, "Slow key", 0.02f, 1f, "x", 2);
			GUILayout.Space(8f);
			PanelWidgets.Section("Aim", delegate
			{
				PanelWidgets.ResetAll("aim", Plugin.FreecamLookSpeed, Plugin.FreecamMaxPitch);
			});
			PanelWidgets.Slider(Plugin.FreecamLookSpeed, "Mouse speed", 0.1f, 20f, "°", 1);
			PanelWidgets.Slider(Plugin.FreecamMaxPitch, "Pitch limit", 0f, 89.9f, "°", 1);
			PanelWidgets.Toggle(Plugin.FreecamInvertPitch, "Invert up and down");
			if (GUILayout.Button("Level the camera", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				Freecam.Level();
				PanelWidgets.Status = "levelled";
			}
			GUILayout.Space(8f);
			PanelWidgets.Section("While flying");
			PanelWidgets.Toggle(Plugin.FreecamFreezePlayer, "Freeze your character");
		}

		private static void State()
		{
			//IL_0068: 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_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)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("— Freecam: " + (Freecam.Active ? "flying" : "off") + " —", (Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button(Freecam.Active ? "[Land the camera]" : "Take the camera", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				Freecam.Toggle();
				PanelWidgets.Status = (Freecam.Active ? "flying" : "camera back on your head");
			}
			if (Panels.FlyingShown)
			{
				Vector3 position = Freecam.Position;
				GUILayout.Label($"at ({position.x:0.#}, {position.y:0.#}, {position.z:0.#})   " + $"facing {Freecam.Yaw:0}°, {Freecam.Pitch:0}° up", (Il2CppReferenceArray<GUILayoutOption>)null);
				if (GUILayout.Button("Bring your character here", (Il2CppReferenceArray<GUILayoutOption>)null))
				{
					PanelWidgets.Status = (Freecam.Teleport() ? "your character is here now" : "could not move you");
				}
				GUILayout.Label("   (!) single player - this really moves you, and others would see it", (Il2CppReferenceArray<GUILayoutOption>)null);
			}
		}

		public static void HudBody()
		{
			PanelWidgets.Section("Everything");
			PanelWidgets.Toggle(Plugin.HideHud, "Hide the whole HUD");
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			Pick(HudPiece.Crosshair, "Crosshair", HudStyle.Crosshair);
			Pick(HudPiece.Backpack, "Backpack", HudStyle.Backpack);
			Pick(HudPiece.Belt, "Belt", HudStyle.Belt);
			GUILayout.EndHorizontal();
			switch (Panels.PieceShown)
			{
			case HudPiece.Backpack:
				Draw("Backpack", HudStyle.Backpack);
				break;
			case HudPiece.Belt:
				Draw("Belt", HudStyle.Belt);
				break;
			default:
				Draw("Crosshair", HudStyle.Crosshair);
				break;
			}
		}

		private static void Pick(HudPiece piece, string label, HudElement element)
		{
			if (element.Overridden)
			{
				label += " •";
			}
			bool flag = _piece == piece;
			if (!(!GUILayout.Button(flag ? ("[" + label + "]") : label, (Il2CppReferenceArray<GUILayoutOption>)null) || flag))
			{
				_piece = piece;
				PanelWidgets.Status = "";
			}
		}

		private static void Draw(string label, HudElement element)
		{
			GUILayout.Space(4f);
			PanelWidgets.Section(label, delegate
			{
				Reset(label, element);
			});
			if (element == HudStyle.Crosshair && HudStyle.CrosshairTaken)
			{
				GUILayout.Label("Crosshair Resizer owns this. Delete CrosshairResizer.dll to use it here.", (Il2CppReferenceArray<GUILayoutOption>)null);
				return;
			}
			PanelWidgets.Toggle(element.Hide, "Hide it");
			GUI.enabled = !element.Hide.Value;
			PanelWidgets.Slider(element.Scale, "Size", 0.1f, 3f, "x", 2);
			PanelWidgets.Slider(element.Opacity, "Opacity", 0f, 1f, "", 2);
			PanelWidgets.Toggle(element.Tint, "Recolour it");
			GUI.enabled = !element.Hide.Value && element.Tint.Value;
			PanelWidgets.Slider(element.Red, "Red", 0f, 1f, "", 2);
			PanelWidgets.Slider(element.Green, "Green", 0f, 1f, "", 2);
			PanelWidgets.Slider(element.Blue, "Blue", 0f, 1f, "", 2);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			Colour(element, "White", 1f, 1f, 1f);
			Colour(element, "Red", 1f, 0.15f, 0.15f);
			Colour(element, "Green", 0.2f, 1f, 0.2f);
			Colour(element, "Cyan", 0.2f, 1f, 1f);
			Colour(element, "Magenta", 1f, 0.2f, 1f);
			GUILayout.EndHorizontal();
			GUI.enabled = true;
			if (Panels.MissingShown(Panels.PieceShown))
			{
				GUILayout.Label("(not on screen yet — this applies once you are in a game)", (Il2CppReferenceArray<GUILayoutOption>)null);
			}
		}

		private static void Colour(HudElement element, string label, float r, float g, float b)
		{
			if (GUILayout.Button(label, (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				element.Red.Value = r;
				element.Green.Value = g;
				element.Blue.Value = b;
				PanelWidgets.Status = element.Name + ": " + label.ToLowerInvariant();
			}
		}

		private static void Reset(string label, HudElement element)
		{
			element.Hide.Value = false;
			element.Tint.Value = false;
			PanelWidgets.ResetAll(label.ToLowerInvariant(), element.Scale, element.Opacity, element.Red, element.Green, element.Blue);
		}
	}
	public class FreecamRuntime : MonoBehaviour
	{
		private bool _inputDead;

		private bool _axesDead;

		private bool _styleDead;

		private bool _lookHeld;

		private bool _lookWas;

		private bool _lookWarned;

		private bool _playerHeld;

		private bool _playerUpdateWas;

		private bool _playerFixedWas;

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

		private void Update()
		{
			Style();
			if (_inputDead)
			{
				return;
			}
			try
			{
				if (KeyList.AnyDown(Plugin.HudKeys.Value))
				{
					Plugin.HideHud.Value = !Plugin.HideHud.Value;
				}
				if (KeyList.AnyDown(Plugin.FreecamKeys.Value))
				{
					Freecam.Toggle();
				}
				Latch(Freecam.Active);
				if (Freecam.Active)
				{
					if (KeyList.AnyDown(Plugin.FreecamTeleportKeys.Value))
					{
						Freecam.Teleport();
					}
					Fly();
				}
			}
			catch (Exception arg)
			{
				_inputDead = true;
				Latch(held: false);
				Plugin.Log.LogError((object)("keyboard input is unavailable, so the freecam cannot be flown. " + $"Reason: {arg}"));
			}
		}

		private void Style()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (_styleDead)
			{
				return;
			}
			try
			{
				HudStyle.Tick();
			}
			catch (Exception ex)
			{
				_styleDead = true;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("the HUD styling threw, switching it off: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				try
				{
					HudStyle.Restore();
				}
				catch (Exception ex2)
				{
					ManualLogSource log2 = Plugin.Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("could not put the HUD back: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
					}
					log2.LogWarning(val2);
				}
			}
		}

		private void Fly()
		{
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			if (KeyList.AnyHeld(Plugin.FreecamForwardKeys.Value))
			{
				num += 1f;
			}
			if (KeyList.AnyHeld(Plugin.FreecamBackKeys.Value))
			{
				num -= 1f;
			}
			if (KeyList.AnyHeld(Plugin.FreecamRightKeys.Value))
			{
				num2 += 1f;
			}
			if (KeyList.AnyHeld(Plugin.FreecamLeftKeys.Value))
			{
				num2 -= 1f;
			}
			if (KeyList.AnyHeld(Plugin.FreecamUpKeys.Value))
			{
				num3 += 1f;
			}
			if (KeyList.AnyHeld(Plugin.FreecamDownKeys.Value))
			{
				num3 -= 1f;
			}
			float num4 = Plugin.FreecamSpeed.Value;
			if (KeyList.AnyHeld(Plugin.FreecamFastKeys.Value))
			{
				num4 *= Plugin.FreecamFastMultiplier.Value;
			}
			if (KeyList.AnyHeld(Plugin.FreecamSlowKeys.Value))
			{
				num4 *= Plugin.FreecamSlowMultiplier.Value;
			}
			Freecam.Steer(num, num2, num3, num4, Time.unscaledDeltaTime);
			float value = Plugin.FreecamLookSpeed.Value;
			float num5 = MouseAxis("Mouse Y") * value;
			Freecam.Look(MouseAxis("Mouse X") * value, Plugin.FreecamInvertPitch.Value ? num5 : (0f - num5));
		}

		private void Latch(bool held)
		{
			HoldLook(held);
			HoldPlayer(held && Plugin.FreecamFreezePlayer.Value);
		}

		private void HoldLook(bool held)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			try
			{
				PlayerCharacter local = ThirdPersonCamera.Local;
				PlayerHead val = ((local != null) ? local.head : null);
				if (val == null)
				{
					if (held && !_lookWarned)
					{
						_lookWarned = true;
						Plugin.Log.LogWarning((object)"no PlayerHead to freeze yet, so the mouse will turn you as well as the freecam");
					}
					return;
				}
				_lookWarned = false;
				if (held)
				{
					if (!_lookHeld)
					{
						_lookHeld = true;
						_lookWas = val.bypassUpdate;
					}
					val.bypassUpdate = true;
				}
				else if (_lookHeld)
				{
					_lookHeld = false;
					val.bypassUpdate = _lookWas;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("could not freeze the game's look: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
			}
		}

		private void HoldPlayer(bool held)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			try
			{
				PlayerCharacter local = ThirdPersonCamera.Local;
				if ((Object)(object)local == (Object)null)
				{
					_playerHeld = false;
				}
				else if (held)
				{
					if (!_playerHeld)
					{
						_playerHeld = true;
						_playerUpdateWas = local.bypassUpdate;
						_playerFixedWas = local.bypassFixedUpdate;
						Plugin.Log.LogInfo((object)"freecam: your character is frozen while you fly");
					}
					local.bypassUpdate = true;
					local.bypassFixedUpdate = true;
				}
				else if (_playerHeld)
				{
					_playerHeld = false;
					local.bypassUpdate = _playerUpdateWas;
					local.bypassFixedUpdate = _playerFixedWas;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not freeze your character: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
		}

		private float MouseAxis(string axis)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (_axesDead)
			{
				return 0f;
			}
			try
			{
				return Input.GetAxisRaw(axis);
			}
			catch (Exception ex)
			{
				_axesDead = true;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(82, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("this build has no '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(axis);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' axis, so the freecam cannot be aimed ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("with the mouse. Reason: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
				return 0f;
			}
		}

		private void OnDisable()
		{
			Release();
		}

		private void OnDestroy()
		{
			Release();
		}

		private void Release()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			Latch(held: false);
			bool flag = default(bool);
			try
			{
				Hud.Restore();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not put the HUD back: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			try
			{
				HudStyle.Restore();
			}
			catch (Exception ex2)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not restyle the HUD back: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
				}
				log2.LogWarning(val);
			}
		}
	}
	internal static class Hud
	{
		private static Camera _masked;

		private static IntPtr _maskedPtr = IntPtr.Zero;

		private static int _hiddenBits;

		private static string _layerSource;

		private static int _layerMask;

		private static readonly List<Canvas> Canvases = new List<Canvas>();

		private static bool _scanned;

		private static bool _dumped;

		private static bool _reported;

		public static bool Wanted
		{
			get
			{
				if (!Plugin.HideHud.Value && !_reported && !((Object)(object)_masked != (Object)null) && Canvases.Count <= 0)
				{
					if (Plugin.DumpCanvases.Value)
					{
						return !_dumped;
					}
					return false;
				}
				return true;
			}
		}

		public static void Tick(Camera main, Camera ui)
		{
			if (Plugin.DumpCanvases.Value && !_dumped)
			{
				_dumped = true;
				DumpCanvases(main, ui);
			}
			if (!Plugin.HideHud.Value)
			{
				Restore();
				return;
			}
			if (!_reported)
			{
				_reported = true;
				Plugin.Log.LogInfo((object)("hiding the HUD: layers [" + Plugin.HudLayers.Value + "]" + (Plugin.HudHideCanvases.Value ? ", canvases" : "")));
			}
			Mask(main);
			if (Plugin.HudHideCanvases.Value)
			{
				HideCanvases();
			}
			else
			{
				RestoreCanvases();
			}
		}

		public static void Restore()
		{
			if (_reported)
			{
				_reported = false;
				Plugin.Log.LogInfo((object)"HUD is back");
			}
			if ((Object)(object)_masked != (Object)null && _hiddenBits != 0)
			{
				Camera masked = _masked;
				masked.cullingMask |= _hiddenBits;
			}
			_masked = null;
			_maskedPtr = IntPtr.Zero;
			_hiddenBits = 0;
			RestoreCanvases();
		}

		private static void HideCanvases()
		{
			if (!_scanned)
			{
				_scanned = true;
				Collect();
			}
			for (int i = 0; i < Canvases.Count; i++)
			{
				Canvas val = Canvases[i];
				if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled)
				{
					((Behaviour)val).enabled = false;
				}
			}
		}

		private static void Collect()
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			Canvases.Clear();
			try
			{
				int num = LayerMask();
				Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<Canvas>());
				if (val == null)
				{
					return;
				}
				int num2 = 0;
				for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++)
				{
					Object obj = ((Il2CppArrayBase<Object>)(object)val)[i];
					Canvas val2 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Canvas>() : null);
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					GameObject gameObject = ((Component)val2).gameObject;
					if (gameObject.activeInHierarchy && ((Behaviour)val2).enabled)
					{
						int layer = gameObject.layer;
						bool flag = num == 0 || (num & (1 << layer)) != 0;
						Plugin.Log.LogInfo((object)($"canvas '{((Object)gameObject).name}': {val2.renderMode}, layer {layer} " + "'" + LayerMask.LayerToName(layer) + "' — " + (flag ? "hiding" : "left alone, not in HudLayers")));
						if (!flag)
						{
							num2++;
							continue;
						}
						((Behaviour)val2).enabled = false;
						Canvases.Add(val2);
					}
				}
				Plugin.Log.LogInfo((object)($"HUD: switched off {Canvases.Count} canvases, left {num2} alone. " + "If something is still on screen, its canvas is named above — put its layer in HudLayers, or clear HudLayers to hide every canvas."));
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag2 = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("could not collect the HUD canvases: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val3);
			}
		}

		private static void RestoreCanvases()
		{
			for (int i = 0; i < Canvases.Count; i++)
			{
				Canvas val = Canvases[i];
				if ((Object)(object)val != (Object)null)
				{
					((Behaviour)val).enabled = true;
				}
			}
			Canvases.Clear();
			_scanned = false;
		}

		private static void Mask(Camera main)
		{
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			if (_maskedPtr != IntPtr.Zero && ((Il2CppObjectBase)main).Pointer != _maskedPtr)
			{
				Restore();
			}
			int num = LayerMask();
			if (num != 0)
			{
				int num2 = num & main.cullingMask;
				if (num2 != 0)
				{
					main.cullingMask &= ~num2;
					_masked = main;
					_maskedPtr = ((Il2CppObjectBase)main).Pointer;
					_hiddenBits |= num2;
				}
			}
		}

		private static int LayerMask()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			string text = Plugin.HudLayers.Value ?? string.Empty;
			if (text == _layerSource)
			{
				return _layerMask;
			}
			_layerSource = text;
			int num = 0;
			string[] array = text.Split(',');
			bool flag = default(bool);
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (text2.Length == 0)
				{
					continue;
				}
				if (!int.TryParse(text2, out var result))
				{
					result = LayerMask.NameToLayer(text2);
				}
				if (result >= 0 && result < 32)
				{
					num |= 1 << result;
					continue;
				}
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HudLayers: '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' is not a layer, skipping it");
				}
				log.LogWarning(val);
			}
			_layerMask = num;
			return num;
		}

		private static void DumpCanvases(Camera main, Camera ui)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			try
			{
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("main camera mask 0x");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(((Object)(object)main != (Object)null) ? main.cullingMask : 0, "X8");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("UI camera ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)ui != (Object)null) ? ((Object)ui).name : "none");
				}
				log.LogInfo(val);
				Il2CppReferenceArray<Object> val2 = Resources.FindObjectsOfTypeAll(Il2CppType.Of<Canvas>());
				if (val2 == null || ((Il2CppArrayBase<Object>)(object)val2).Length == 0)
				{
					Plugin.Log.LogInfo((object)"no canvases found at all");
					return;
				}
				for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val2).Length; i++)
				{
					Object obj = ((Il2CppArrayBase<Object>)(object)val2)[i];
					Canvas val3 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Canvas>() : null);
					if ((Object)(object)val3 == (Object)null)
					{
						continue;
					}
					GameObject gameObject = ((Component)val3).gameObject;
					if (gameObject.activeInHierarchy)
					{
						int layer = gameObject.layer;
						Camera worldCamera = val3.worldCamera;
						ManualLogSource log2 = Plugin.Log;
						val = new BepInExInfoLogInterpolatedStringHandler(39, 6, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("canvas '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Path(((Component)val3).transform));
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<RenderMode>(val3.renderMode);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("layer ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(layer);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LayerMask.LayerToName(layer));
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', ");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("camera ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)(object)worldCamera != (Object)null) ? ((Object)worldCamera).name : "none");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("order ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val3.sortingOrder);
						}
						log2.LogInfo(val);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("could not list the canvases: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
				}
				log3.LogWarning(val4);
			}
			DumpCheatMover();
		}

		private static void DumpCheatMover()
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				PlayerCharacter local = ThirdPersonCamera.Local;
				if ((Object)(object)local == (Object)null)
				{
					return;
				}
				PlayerCheater cheater = local.cheater;
				if (cheater == null)
				{
					Plugin.Log.LogInfo((object)"no PlayerCheater on the local player");
					return;
				}
				CameraCheatMover cameraCheatMover = cheater.cameraCheatMover;
				if ((Object)(object)cameraCheatMover == (Object)null)
				{
					Plugin.Log.LogInfo((object)"PlayerCheater is present but has no CameraCheatMover");
					return;
				}
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(86, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("the game's own CameraCheatMover is present: detached ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(cameraCheatMover._detached);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("speed ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(cameraCheatMover.movingSpeed, "0.##");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", sensitivity ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(cameraCheatMover.sensitivity, "0.##");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("maxPitch ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(cameraCheatMover.maxPitch, "0.##");
				}
				log.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not read the game's own camera cheat: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log2.LogInfo(val);
			}
		}

		private static string Path(Transform t)
		{
			StringBuilder stringBuilder = new StringBuilder(((Object)t).name);
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null)
			{
				stringBuilder.Insert(0, ((Object)parent).name + "/");
				parent = parent.parent;
			}
			return stringBuilder.ToString();
		}
	}
	internal sealed class HudElement
	{
		private struct Root
		{
			public Transform Transform;

			public Vector3 Scale;

			public CanvasGroup Group;

			public bool Added;

			public float Alpha;
		}

		private struct Tinted
		{
			public Graphic Graphic;

			public Color Original;
		}

		private static readonly List<Transform> Scratch = new List<Transform>();

		public readonly string Name;

		public ConfigEntry<bool> Hide;

		public ConfigEntry<bool> Tint;

		public ConfigEntry<float> Scale;

		public ConfigEntry<float> Opacity;

		public ConfigEntry<float> Red;

		public ConfigEntry<float> Green;

		public ConfigEntry<float> Blue;

		private readonly Func<IntPtr> _owner;

		private readonly Action<List<Transform>> _find;

		private readonly List<Root> _roots = new List<Root>();

		private readonly List<Tinted> _tinted = new List<Tinted>();

		private IntPtr _ownerPtr = IntPtr.Zero;

		private bool _touched;

		private bool _tinting;

		private bool _broken;

		private bool _reported;

		public bool Overridden
		{
			get
			{
				if (!Hide.Value && !Tint.Value && Scale.Value == 1f)
				{
					return Opacity.Value != 1f;
				}
				return true;
			}
		}

		public bool Found => _roots.Count > 0;

		public HudElement(string name, Func<IntPtr> owner, Action<List<Transform>> find)
		{
			Name = name;
			_owner = owner;
			_find = find;
		}

		public void Bind(ConfigFile cfg, string section, string what)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			Hide = cfg.Bind<bool>(section, "Hide", false, "Hide the " + what + " without hiding the rest of the HUD. This is the individual switch; the HUD keys hide everything at once.");
			Scale = cfg.Bind<float>(section, "Scale", 1f, new ConfigDescription("Size of the " + what + ". 1 is the size the game draws it at, and the scale multiplies whatever the game set, so a widget that was never square keeps its shape.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			Opacity = cfg.Bind<float>(section, "Opacity", 1f, new ConfigDescription("How solid the " + what + " is. 1 is untouched and 0 is invisible. Applied through a CanvasGroup, so it multiplies the fades the game does rather than overriding them.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Tint = cfg.Bind<bool>(section, "Tint", false, "Override the colour of the " + what + ". Off means it keeps the colour it shipped with. Only the red, green and blue are replaced — the transparency stays the game's, since that is what it animates.");
			Red = cfg.Bind<float>(section, "Red", 1f, new ConfigDescription("Red channel, 0-1. Only used when Tint is on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Green = cfg.Bind<float>(section, "Green", 1f, new ConfigDescription("Green channel, 0-1. Only used when Tint is on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Blue = cfg.Bind<float>(section, "Blue", 1f, new ConfigDescription("Blue channel, 0-1. Only used when Tint is on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		}

		public void Tick(bool resolve)
		{
			if (_broken)
			{
				return;
			}
			if (!Overridden)
			{
				if (_touched)
				{
					Restore();
				}
				return;
			}
			if (resolve)
			{
				Resolve();
			}
			if (_roots.Count != 0)
			{
				Apply();
			}
		}

		private void Resolve()
		{
			IntPtr intPtr;
			try
			{
				intPtr = _owner();
			}
			catch (Exception e)
			{
				Fail(e);
				return;
			}
			if (intPtr == IntPtr.Zero)
			{
				_roots.Clear();
				_tinted.Clear();
				_ownerPtr = IntPtr.Zero;
				_touched = false;
				_tinting = false;
			}
			else if (!(intPtr == _ownerPtr) || _roots.Count <= 0 || !((Object)(object)_roots[0].Transform != (Object)null))
			{
				Collect(intPtr);
			}
		}

		private void Collect(IntPtr owner)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			Restore();
			_roots.Clear();
			_tinted.Clear();
			_ownerPtr = owner;
			Scratch.Clear();
			try
			{
				_find(Scratch);
			}
			catch (Exception e)
			{
				Scratch.Clear();
				Fail(e);
				return;
			}
			for (int i = 0; i < Scratch.Count; i++)
			{
				Transform val = Scratch[i];
				if (!((Object)(object)val == (Object)null))
				{
					_roots.Add(new Root
					{
						Transform = val,
						Scale = val.localScale,
						Group = Group(val, out var added, out var alpha),
						Added = added,
						Alpha = alpha
					});
					CollectGraphics(val);
				}
			}
			Scratch.Clear();
			if (!_reported)
			{
				_reported = true;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(19, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_roots.Count);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" parts, ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_tinted.Count);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" graphics");
				}
				log.LogInfo(val2);
			}
		}

		private void CollectGraphics(Transform root)
		{
			//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)
			Il2CppReferenceArray<Component> componentsInChildren = ((Component)root).GetComponentsInChildren(Il2CppType.Of<Graphic>(), true);
			if (componentsInChildren == null)
			{
				return;
			}
			for (int i = 0; i < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; i++)
			{
				Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[i];
				Graphic val = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Graphic>() : null);
				if (!((Object)(object)val == (Object)null))
				{
					_tinted.Add(new Tinted
					{
						Graphic = val,
						Original = val.color
					});
				}
			}
		}

		private static CanvasGroup Group(Transform root, out bool added, out float alpha)
		{
			added = false;
			alpha = 1f;
			Component component = ((Component)root).GetComponent(Il2CppType.Of<CanvasGroup>());
			CanvasGroup val = (((Object)(object)component != (Object)null) ? ((Il2CppObjectBase)component).TryCast<CanvasGroup>() : null);
			if ((Object)(object)val != (Object)null)
			{
				alpha = val.alpha;
				return val;
			}
			Component val2 = ((Component)root).gameObject.AddComponent(Il2CppType.Of<CanvasGroup>());
			val = (((Object)(object)val2 != (Object)null) ? ((Il2CppObjectBase)val2).TryCast<CanvasGroup>() : null);
			added = (Object)(object)val != (Object)null;
			return val;
		}

		private void Apply()
		{
			//IL_0073: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			float value = Scale.Value;
			float num = (Hide.Value ? 0f : Mathf.Clamp01(Opacity.Value));
			bool flag = Tint.Value && !Hide.Value;
			for (int i = 0; i < _roots.Count; i++)
			{
				Root root = _roots[i];
				if (!((Object)(object)root.Transform == (Object)null))
				{
					Vector3 val = root.Scale * value;
					if (root.Transform.localScale != val)
					{
						root.Transform.localScale = val;
					}
					if ((Object)(object)root.Group != (Object)null && root.Group.alpha != num)
					{
						root.Group.alpha = num;
					}
				}
			}
			if (flag)
			{
				_tinting = true;
				float value2 = Red.Value;
				float value3 = Green.Value;
				float value4 = Blue.Value;
				for (int j = 0; j < _tinted.Count; j++)
				{
					Graphic graphic = _tinted[j].Graphic;
					if (!((Object)(object)graphic == (Object)null))
					{
						Color color = graphic.color;
						if (color.r != value2 || color.g != value3 || color.b != value4)
						{
							graphic.color = new Color(value2, value3, value4, color.a);
						}
					}
				}
			}
			else
			{
				Untint();
			}
			_touched = true;
		}

		public void Restore()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!_touched)
			{
				return;
			}
			_touched = false;
			for (int i = 0; i < _roots.Count; i++)
			{
				Root root = _roots[i];
				if ((Object)(object)root.Transform != (Object)null)
				{
					root.Transform.localScale = root.Scale;
				}
				if ((Object)(object)root.Group != (Object)null)
				{
					root.Group.alpha = (root.Added ? 1f : root.Alpha);
				}
			}
			Untint();
		}

		private void Untint()
		{
			//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)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!_tinting)
			{
				return;
			}
			_tinting = false;
			for (int i = 0; i < _tinted.Count; i++)
			{
				Graphic graphic = _tinted[i].Graphic;
				if (!((Object)(object)graphic == (Object)null))
				{
					Color original = _tinted[i].Original;
					graphic.color = new Color(original.r, original.g, original.b, graphic.color.a);
				}
			}
		}

		private void Fail(Exception e)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			_broken = true;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(37, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("cannot reach the ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", leaving it alone: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
			}
			log.LogWarning(val);
		}
	}
	internal static class HudStyle
	{
		private const float ResolveInterval = 1f;

		private const string ResizerGuid = "deck.bigwalk.crosshairresizer";

		public static readonly HudElement Crosshair = new HudElement("crosshair", CrosshairOwner, CrosshairRoots);

		public static readonly HudElement Backpack = new HudElement("backpack indicator", ArmHudOwner, BackpackRoots);

		public static readonly HudElement Belt = new HudElement("belt indicator", ArmHudOwner, BeltRoots);

		private static float _nextResolve;

		private static bool _touched;

		private static bool _checkedResizer;

		private static bool _resizer;

		public static bool CrosshairTaken
		{
			get
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Expected O, but got Unknown
				if (_checkedResizer)
				{
					return _resizer;
				}
				_checkedResizer = true;
				try
				{
					_resizer = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("deck.bigwalk.crosshairresizer");
					if (_resizer)
					{
						Plugin.Log.LogWarning((object)"Crosshair Resizer is installed and writes the same crosshair scale and colour, so the crosshair controls here are switched off. Delete BepInEx/plugins/CrosshairResizer.dll to use them — everything it did is in this mod's HUD tab.");
					}
				}
				catch (Exception ex)
				{
					_resizer = false;
					ManualLogSource log = Plugin.Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not check for Crosshair Resizer: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogInfo(val);
				}
				return _resizer;
			}
		}

		public static void Bind(ConfigFile cfg)
		{
			Crosshair.Bind(cfg, "Crosshair", "crosshair");
			Backpack.Bind(cfg, "Backpack", "backpack indicator");
			Belt.Bind(cfg, "Belt", "belt indicator");
		}

		public static void Tick()
		{
			bool flag = Crosshair.Overridden || Backpack.Overridden || Belt.Overridden;
			if (flag || _touched)
			{
				_touched = flag;
				bool resolve = false;
				float unscaledTime = Time.unscaledTime;
				if (unscaledTime >= _nextResolve)
				{
					_nextResolve = unscaledTime + 1f;
					resolve = true;
				}
				if (!CrosshairTaken)
				{
					Crosshair.Tick(resolve);
				}
				Backpack.Tick(resolve);
				Belt.Tick(resolve);
			}
		}

		public static void Restore()
		{
			Crosshair.Restore();
			Backpack.Restore();
			Belt.Restore();
			_touched = false;
		}

		private static IntPtr CrosshairOwner()
		{
			Crosshair instance = Crosshair.instance;
			if (instance == null)
			{
				return IntPtr.Zero;
			}
			return ((Il2CppObjectBase)instance).Pointer;
		}

		private static void CrosshairRoots(List<Transform> into)
		{
			Crosshair instance = Crosshair.instance;
			if (instance != null)
			{
				Add(into, instance.crosshairNormal);
				Add(into, instance.crosshairHolding);
				Add(into, (Transform)(object)instance.crosshairWindup);
			}
		}

		private static IntPtr ArmHudOwner()
		{
			ArmHud instance = ArmHud.instance;
			if (instance == null)
			{
				return IntPtr.Zero;
			}
			return ((Il2CppObjectBase)instance).Pointer;
		}

		private static void BackpackRoots(List<Transform> into)
		{
			ArmHud instance = ArmHud.instance;
			if (instance != null)
			{
				Add(into, instance.backpackEmpty);
				Add(into, instance.backpackFull);
			}
		}

		private static void BeltRoots(List<Transform> into)
		{
			ArmHud instance = ArmHud.instance;
			if (instance != null)
			{
				Add(into, instance.holsterEmpty);
				Add(into, instance.holsterFull);
			}
		}

		private static void Add(List<Transform> into, Transform root)
		{
			if ((Object)(object)root != (Object)null)
			{
				into.Add(root);
			}
		}
	}
	internal enum PanelTab
	{
		View,
		Freecam,
		Hud,
		Setup
	}
	internal static class Panels
	{
		private const float PreferredWidth = 560f;

		private const float MinimumWidth = 320f;

		private const float Gap = 10f;

		public static bool Open;

		public static PanelTab Tab;

		private static Vector2 _scroll;

		private static bool _ready;

		private static PanelTab _tabShown;

		private static HudPiece _pieceShown;

		private static bool _flyingShown;

		private static bool _crosshairMissing;

		private static bool _backpackMissing;

		private static bool _beltMissing;

		public static PanelTab TabShown => _tabShown;

		public static HudPiece PieceShown => _pieceShown;

		public static bool FlyingShown => _flyingShown;

		public static float Scale
		{
			get
			{
				float num = Mathf.Max(0.5f, (float)Screen.width / 340f);
				return Mathf.Clamp(Plugin.PanelScale.Value, 0.5f, num);
			}
		}

		public static bool Clamped => Plugin.PanelScale.Value > Scale + 0.01f;

		public static bool MissingShown(HudPiece piece)
		{
			return piece switch
			{
				HudPiece.Belt => _beltMissing, 
				HudPiece.Backpack => _backpackMissing, 
				_ => _crosshairMissing, 
			};
		}

		private static void Snapshot()
		{
			_ready = true;
			_tabShown = Tab;
			_pieceShown = FreecamPanel.Piece;
			_flyingShown = Freecam.Active;
			_crosshairMissing = Missing(HudStyle.Crosshair);
			_backpackMissing = Missing(HudStyle.Backpack);
			_beltMissing = Missing(HudStyle.Belt);
		}

		private static bool Missing(HudElement element)
		{
			if (!element.Found)
			{
				return element.Overridden;
			}
			return false;
		}

		public static void Closed()
		{
			_ready = false;
		}

		private static Rect Area()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			float scale = Scale;
			float num = Mathf.Clamp((float)Screen.width / scale - 20f, 320f, 560f);
			float num2 = Mathf.Max(140f, (float)Screen.height / scale - 20f);
			return new Rect(10f, 10f, num, num2);
		}

		public static void Draw()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_001c: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 8)
			{
				Snapshot();
			}
			else if (!_ready)
			{
				return;
			}
			Matrix4x4 matrix = GUI.matrix;
			float scale = Scale;
			GUI.matrix = Matrix4x4.Scale(new Vector3(scale, scale, 1f));
			Rect val = Area();
			GUILayout.BeginArea(val, GUI.skin.box);
			GUILayout.Label("BIG PERSON VIEW — settings", (Il2CppReferenceArray<GUILayoutOption>)null);
			TabBar();
			_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(((Rect)(ref val)).height - 130f) });
			switch (_tabShown)
			{
			case PanelTab.Freecam:
				FreecamPanel.Body();
				break;
			case PanelTab.Hud:
				FreecamPanel.HudBody();
				break;
			case PanelTab.Setup:
				SettingsPanel.SetupBody();
				break;
			default:
				SettingsPanel.ViewBody();
				break;
			}
			GUILayout.EndScrollView();
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Save to file", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				PanelWidgets.Save();
			}
			if (GUILayout.Button("Reload file", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				PanelWidgets.Reload();
			}
			GUILayout.EndHorizontal();
			GUILayout.Label((PanelWidgets.Status.Length > 0) ? PanelWidgets.Status : "changes apply now, and last the session", (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.EndArea();
			GUI.matrix = matrix;
		}

		private static void TabBar()
		{
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			Pick(PanelTab.View, "View");
			Pick(PanelTab.Freecam, "Freecam");
			Pick(PanelTab.Hud, "HUD");
			Pick(PanelTab.Setup, "Setup");
			GUILayout.EndHorizontal();
		}

		private static void Pick(PanelTab tab, string label)
		{
			//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)
			bool flag = Tab == tab;
			if (!(!GUILayout.Button(flag ? ("[" + label + "]") : label, (Il2CppReferenceArray<GUILayoutOption>)null) || flag))
			{
				Tab = tab;
				_scroll = Vector2.zero;
				PanelWidgets.Status = "";
			}
		}
	}
	internal static class PanelWidgets
	{
		public static string Status = "";

		public static void Section(string title, Action reset = null)
		{
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("— " + title + " —", (Il2CppReferenceArray<GUILayoutOption>)null);
			if (reset != null)
			{
				GUILayout.FlexibleSpace();
				if (GUILayout.Button("reset section", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }))
				{
					reset();
				}
			}
			GUILayout.EndHorizontal();
		}

		public static void Slider(ConfigEntry<float> entry, string label, float min, float max, string unit, int digits)
		{
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label(label + ": " + entry.Value.ToString("0." + new string('#', digits)) + unit, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) });
			float num = GUILayout.HorizontalSlider(entry.Value, min, max, Array.Empty<GUILayoutOption>());
			float num2 = Mathf.Pow(10f, (float)digits);
			num = Mathf.Round(num * num2) / num2;
			if (!Mathf.Approximately(num, entry.Value))
			{
				entry.Value = num;
			}
			float num3 = Default(entry);
			bool flag = !Mathf.Approximately(entry.Value, num3);
			if (GUILayout.Button(flag ? "↺" : "·", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }) && flag)
			{
				entry.Value = num3;
				Status = label + " back to " + num3.ToString("0." + new string('#', digits)) + unit;
			}
			GUILayout.EndHorizontal();
		}

		public static void Toggle(ConfigEntry<bool> entry, string label)
		{
			bool flag = GUILayout.Toggle(entry.Value, "  " + label, Array.Empty<GUILayoutOption>());
			if (flag != entry.Value)
			{
				entry.Value = flag;
			}
		}

		public static void ResetAll(string what, params ConfigEntry<float>[] entries)
		{
			foreach (ConfigEntry<float> obj in entries)
			{
				obj.Value = Default(obj);
			}
			Status = what + " back to defaults";
		}

		public static float Default(ConfigEntry<float> entry)
		{
			try
			{
				return Convert.ToSingle(((ConfigEntryBase)entry).DefaultValue);
			}
			catch (Exception)
			{
				return entry.Value;
			}
		}

		public static void Save()
		{
			try
			{
				Plugin.Cfg.Save();
				Status = "written to deck.bigwalk.thirdperson.cfg";
				Plugin.Log.LogInfo((object)"settings saved from the panel");
			}
			catch (Exception ex)
			{
				Status = "could not save: " + ex.Message;
			}
		}

		public static void Reload()
		{
			try
			{
				Plugin.Cfg.Reload();
				Status = "reloaded from the file, losing this session's changes";
				Plugin.Log.LogInfo((object)"settings reloaded from the file");
			}
			catch (Exception ex)
			{
				Status = "could not reload: " + ex.Message;
			}
		}
	}
	internal static class PlayerBody
	{
		private struct Part
		{
			public Renderer Renderer;

			public bool Enabled;

			public bool ForcedOff;

			public ShadowCastingMode Shadows;

			public bool LodManaged;
		}

		private static readonly List<Part> Woken = new List<Part>();

		private static readonly List<GameObject> Activated = new List<GameObject>();

		private static PlayerCharacter _player;

		private static bool _active;

		private static bool _torsoOverridden;

		private static bool _savedHideTorso;

		private static float _nextSweep;

		private static int _refreshes;

		private static float _refreshWindow;

		private static bool _refreshStorm;

		public static void ShowFull(PlayerCharacter pc)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			PlayerLooks looks = pc.looks;
			if (looks == null)
			{
				return;
			}
			bool flag = !_active;
			_player = pc;
			_active = true;
			float unscaledTime = Time.unscaledTime;
			if (!_torsoOverridden)
			{
				_savedHideTorso = looks.hideLocalTorso;
				_torsoOverridden = true;
				looks.hideLocalTorso = false;
			}
			bool flag2 = false;
			if ((int)looks.currentLookType != 1)
			{
				looks.currentLookType = (LookType)1;
				looks.RefreshLook();
				flag2 = !Counted(unscaledTime);
			}
			if (!(flag || flag2) && !(unscaledTime >= _nextSweep))
			{
				return;
			}
			_nextSweep = unscaledTime + 0.5f;
			int num = Sweep(looks);
			if (flag)
			{
				ManualLogSource log = Plugin.Log;
				bool flag3 = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag3);
				if (flag3)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("showing the full body, ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" renderers adjusted");
				}
				log.LogInfo(val);
			}
		}

		private static bool Counted(float now)
		{
			_refreshes++;
			if (now < _refreshWindow)
			{
				return _refreshStorm;
			}
			_refreshWindow = now + 1f;
			bool flag = _refreshes > 10;
			if (flag != _refreshStorm)
			{
				_refreshStorm = flag;
				Plugin.Log.LogInfo((object)(flag ? ($"something in this scene is resetting your look about {_refreshes} times a " + "second. Re-asserting it every frame as before, but the full-body sweep is dropping back to twice a second so it does not cost you frames.") : "your look has settled — sweeping on every change again."));
			}
			_refreshes = 0;
			return _refreshStorm;
		}

		public static void Restore()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (!_active)
			{
				return;
			}
			_active = false;
			_refreshes = 0;
			_refreshWindow = 0f;
			_refreshStorm = false;
			foreach (Part item in Woken)
			{
				Renderer renderer = item.Renderer;
				if (!((Object)(object)renderer == (Object)null))
				{
					if (!item.LodManaged)
					{
						renderer.enabled = item.Enabled;
					}
					renderer.forceRenderingOff = item.ForcedOff;
					renderer.shadowCastingMode = item.Shadows;
				}
			}
			Woken.Clear();
			foreach (GameObject item2 in Activated)
			{
				if ((Object)(object)item2 != (Object)null)
				{
					item2.SetActive(false);
				}
			}
			Activated.Clear();
			PlayerCharacter player = _player;
			_player = null;
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			PlayerLooks looks = player.looks;
			if (looks != null)
			{
				if (_torsoOverridden)
				{
					looks.hideLocalTorso = _savedHideTorso;
					_torsoOverridden = false;
				}
				looks.currentLookType = (LookType)0;
				looks.RefreshLook();
			}
		}

		private static int Sweep(PlayerLooks looks)
		{
			return Wake(looks.headRenderers) + Wake(looks.torsoRenderers) + Wake(looks.legsRenderers);
		}

		private static int Wake(Il2CppReferenceArray<LooksRenderer> parts)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Invalid comparison between Unknown and I4
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Invalid comparison between Unknown and I4
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			if (parts == null)
			{
				return 0;
			}
			int num = 0;
			bool flag = default(bool);
			for (int i = 0; i < ((Il2CppArrayBase<LooksRenderer>)(object)parts).Length; i++)
			{
				LooksRenderer val = ((Il2CppArrayBase<LooksRenderer>)(object)parts)[i];
				if (val == null)
				{
					continue;
				}
				Renderer renderer = val.renderer;
				if ((Object)(object)renderer == (Object)null)
				{
					continue;
				}
				if (val.local && !val.remote)
				{
					if (renderer.forceRenderingOff)
					{
						continue;
					}
					if (Remember(renderer, LodManaged(renderer)) && Plugin.DumpCameras.Value)
					{
						ManualLogSource log = Plugin.Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("hiding first-person part ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)renderer).gameObject).name);
						}
						log.LogInfo(val2);
					}
					renderer.forceRenderingOff = true;
					num++;
				}
				else
				{
					if (!val.remote)
					{
						continue;
					}
					GameObject gameObject = ((Component)renderer).gameObject;
					if (PlayerExtras.Named(((Object)gameObject).name))
					{
						continue;
					}
					if (!gameObject.activeSelf)
					{
						gameObject.SetActive(true);
						if (!Activated.Contains(gameObject))
						{
							Activated.Add(gameObject);
						}
						num++;
					}
					bool flag2 = LodManaged(renderer);
					if ((renderer.enabled || flag2) && !renderer.forceRenderingOff && (int)renderer.shadowCastingMode != 3)
					{
						continue;
					}
					if (Remember(renderer, flag2) && Plugin.DumpCameras.Value)
					{
						ManualLogSource log2 = Plugin.Log;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(53, 5, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("waking ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)gameObject).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": enabled ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(renderer.enabled);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ");
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("forceRenderingOff ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(renderer.forceRenderingOff);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ");
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("shadows ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<ShadowCastingMode>(renderer.shadowCastingMode);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", lod ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(flag2);
						}
						log2.LogInfo(val2);
					}
					if (!flag2)
					{
						renderer.enabled = true;
					}
					renderer.forceRenderingOff = false;
					if ((int)renderer.shadowCastingMode == 3)
					{
						renderer.shadowCastingMode = (ShadowCastingMode)1;
					}
					num++;
				}
			}
			return num;
		}

		private static bool LodManaged(Renderer renderer)
		{
			try
			{
				Component componentInParent = ((Component)renderer).GetComponentInParent(Il2CppType.Of<LODGroup>(), true);
				if ((Object)(object)componentInParent == (Object)null)
				{
					return false;
				}
				LODGroup val = ((Il2CppObjectBase)componentInParent).TryCast<LODGroup>();
				return (Object)(object)val == (Object)null || val.enabled;
			}
			catch (Exception)
			{
				return true;
			}
		}

		private static bool Remember(Renderer renderer, bool lodManaged)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			foreach (Part item in Woken)
			{
				if ((Object)(object)item.Renderer == (Object)(object)renderer)
				{
					return false;
				}
			}
			Woken.Add(new Part
			{
				Renderer = renderer,
				LodManaged = lodManaged,
				Enabled = renderer.enabled,
				ForcedOff = renderer.forceRenderingOff,
				Shadows = renderer.shadowCastingMode
			});
			return true;
		}

		public static void Report(PlayerCharacter pc)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			PlayerLooks looks = pc.looks;
			if (looks == null)
			{
				Plugin.Log.LogWarning((object)"no PlayerLooks to report on");
				return;
			}
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("look is ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<LookType>(looks.currentLookType);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", hideLocalTorso ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(looks.hideLocalTorso);
			}
			log.LogInfo(val);
			Report("head", looks.headRenderers);
			Report("torso", looks.torsoRenderers);
			Report("legs", looks.legsRenderers);
			ReportLodGroups(pc);
		}

		private static void ReportLodGroups(PlayerCharacter pc)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			try
			{
				Il2CppReferenceArray<Component> componentsInChildren = ((Component)pc).GetComponentsInChildren(Il2CppType.Of<LODGroup>(), true);
				if (componentsInChildren == null || ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length == 0)
				{
					Plugin.Log.LogInfo((object)"no LODGroups on the character");
					return;
				}
				StringBuilder stringBuilder = new StringBuilder("LODGroups:");
				for (int i = 0; i < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; i++)
				{
					Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[i];
					LODGroup val = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<LODGroup>() : null);
					if (!((Object)(object)val == (Object)null))
					{
						stringBuilder.Append(" " + ((Object)((Component)val).gameObject).name + "[" + (val.enabled ? "on" : "OFF") + " " + $"lods:{val.lodCount} size:{val.size:0.##}]");
					}
				}
				Plugin.Log.LogInfo((object)stringBuilder.ToString());
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("could not read LODGroups: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val2);
			}
		}

		private static void Report(string part, Il2CppReferenceArray<LooksRenderer> parts)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Invalid comparison between Unknown and I4
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			if (parts == null || ((Il2CppArrayBase<LooksRenderer>)(object)parts).Length == 0)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(part);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": no renderers listed");
				}
				log.LogInfo(val);
				return;
			}
			StringBuilder stringBuilder = new StringBuilder(part + ":");
			for (int i = 0; i < ((Il2CppArrayBase<LooksRenderer>)(object)parts).Length; i++)
			{
				LooksRenderer val2 = ((Il2CppArrayBase<LooksRenderer>)(object)parts)[i];
				if (val2 == null)
				{
					continue;
				}
				Renderer renderer = val2.renderer;
				if ((Object)(object)renderer == (Object)null)
				{
					stringBuilder.Append(" <no renderer>");
					continue;
				}
				GameObject gameObject = ((Component)renderer).gameObject;
				stringBuilder.Append(" " + ((Object)gameObject).name + "[" + (val2.local ? "L" : "-") + (val2.remote ? "R" : "-")).Append(renderer.enabled ? " on" : " OFF").Append(gameObject.activeInHierarchy ? " active" : " INACTIVE")
					.Append(renderer.isVisible ? " seen" : " unseen");
				if (renderer.forceRenderingOff)
				{
					stringBuilder.Append(" FORCED-OFF");
				}
				if ((int)renderer.shadowCastingMode != 1)
				{
					stringBuilder.Append($" shadows:{renderer.shadowCastingMode}");
				}
				Vector3 lossyScale = ((Component)renderer).transform.lossyScale;
				if (((Vector3)(ref lossyScale)).sqrMagnitude < 0.0001f)
				{
					stringBuilder.Append($" SCALE({lossyScale.x:0.###},{lossyScale.y:0.###},{lossyScale.z:0.###})");
				}
				Bounds bounds = renderer.bounds;
				Vector3 size = ((Bounds)(ref bounds)).size;
				stringBuilder.Append($" size({size.x:0.##},{size.y:0.##},{size.z:0.##})");
				Material sharedMaterial = renderer.sharedMaterial;
				if ((Object)(object)sharedMaterial == (Object)null)
				{
					stringBuilder.Append(" NO-MATERIAL");
				}
				else
				{
					Shader shader = sharedMaterial.shader;
					stringBuilder.Append(" mat:" + ((Object)sharedMaterial).name + "/" + (((Object)(object)shader != (Object)null) ? ((Object)shader).name : "no shader"));
				}
				SkinnedMeshRenderer val3 = ((Il2CppObjectBase)renderer).TryCast<SkinnedMeshRenderer>();
				if ((Object)(object)val3 != (Object)null)
				{
					Mesh sharedMesh = val3.sharedMesh;
					stringBuilder.Append(((Object)(object)sharedMesh == (Object)null) ? " NO-MESH" : $" mesh:{((Object)sharedMesh).name}({sharedMesh.vertexCount}v)");
				}
				stringBuilder.Append(']');
			}
			Plugin.Log.LogInfo((object)stringBuilder.ToString());
		}
	}
	internal static class PlayerExtras
	{
		private struct Part
		{
			public Renderer Renderer;

			public bool Enabled;

			public bool ForcedOff;

			public ShadowCastingMode Shadows;
		}

		private static readonly List<Part> Hidden = new List<Part>();

		private static readonly List<Transform> Helpers = new List<Transform>();

		private static readonly HashSet<IntPtr> Kit = new HashSet<IntPtr>();

		private static bool _kitUnknown;

		private static string _namesSource;

		private static string[] _names = new string[0];

		private static bool _active;

		private static float _nextSweep;

		private static bool _reported;

		public static void Hide(PlayerCharacter pc)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			if ((Object)(object)pc == (Object)null)
			{
				return;
			}
			bool flag = !_active;
			_active = true;
			if (!flag && Time.unscaledTime < _nextSweep)
			{
				return;
			}
			_nextSweep = Time.unscaledTime + 0.5f;
			int num = Sweep(pc);
			if (flag && !_reported)
			{
				_reported = true;
				ManualLogSource log = Plugin.Log;
				bool flag2 = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("hiding ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stray parts on your character");
				}
				log.LogInfo(val);
			}
		}

		public static void Restore()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!_active)
			{
				return;
			}
			_active = false;
			foreach (Part item in Hidden)
			{
				Renderer renderer = item.Renderer;
				if (!((Object)(object)renderer == (Object)null))
				{
					renderer.enabled = item.Enabled;
					renderer.forceRenderingOff = item.ForcedOff;
					renderer.shadowCastingMode = item.Shadows;
				}
			}
			Hidden.Clear();
		}

		private static int Sweep(PlayerCharacter pc)
		{
			int num = 0;
			if (Plugin.HideHelperParts.Value)
			{
				_kitUnknown = false;
				CollectKit(pc);
				if (!_kitUnknown)
				{
					Collect(pc);
					for (int i = 0; i < Helpers.Count; i++)
					{
						num += HideUnder(Helpers[i]);
					}
				}
			}
			string[] array = Names();
			if (array.Length == 0)
			{
				return num;
			}
			Il2CppReferenceArray<Component> componentsInChildren = ((Component)pc).GetComponentsInChildren(Il2CppType.Of<Renderer>(), true);
			if (componentsInChildren == null)
			{
				return num;
			}
			for (int j = 0; j < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; j++)
			{
				Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[j];
				Renderer val = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Renderer>() : null);
				if (!((Object)(object)val == (Object)null) && Named(((Object)((Component)val).gameObject).name, array))
				{
					num += Hide(val);
				}
			}
			return num;
		}

		private static void Collect(PlayerCharacter pc)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			Helpers.Clear();
			try
			{
				PlayerHands hands = pc.hands;
				if (hands != null)
				{
					Add(hands.grasper);
					Add(hands.grasperGuide);
				}
				PlayerArms arms = pc.arms;
				if (arms != null)
				{
					Add(arms.holdRaisedGuide);
					Add(arms.stretchTranform);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not read the arm helper objects: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
		}

		private static void Add(Transform helper)
		{
			if ((Object)(object)helper != (Object)null)
			{
				Helpers.Add(helper);
			}
		}

		private static int HideUnder(Transform root)
		{
			Il2CppReferenceArray<Component> componentsInChildren = ((Component)root).GetComponentsInChildren(Il2CppType.Of<Renderer>(), true);
			if (componentsInChildren == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; i++)
			{
				Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[i];
				Renderer val = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Renderer>() : null);
				if (!((Object)(object)val == (Object)null) && !Carried(val))
				{
					num += Hide(val);
				}
			}
			return num;
		}

		private static bool Carried(Renderer renderer)
		{
			return Kit.Contains(((Il2CppObjectBase)renderer).Pointer);
		}

		private static void CollectKit(PlayerCharacter pc)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			Kit.Clear();
			try
			{
				Il2CppReferenceArray<Component> componentsInChildren = ((Component)pc).GetComponentsInChildren(Il2CppType.Of<Prop>(), true);
				if (componentsInChildren == null)
				{
					return;
				}
				for (int i = 0; i < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; i++)
				{
					Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[i];
					Prop val = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Prop>() : null);
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					Il2CppReferenceArray<Renderer> renderers = val.renderers;
					if (renderers != null)
					{
						for (int j = 0; j < ((Il2CppArrayBase<Renderer>)(object)renderers).Length; j++)
						{
							if ((Object)(object)((Il2CppArrayBase<Renderer>)(object)renderers)[j] != (Object)null)
							{
								Kit.Add(((Il2CppObjectBase)((Il2CppArrayBase<Renderer>)(object)renderers)[j]).Pointer);
							}
						}
					}
					Il2CppReferenceArray<Component> componentsInChildren2 = ((Component)val).GetComponentsInChildren(Il2CppType.Of<Renderer>(), true);
					if (componentsInChildren2 == null)
					{
						continue;
					}
					for (int k = 0; k < ((Il2CppArrayBase<Component>)(object)componentsInChildren2).Length; k++)
					{
						Component obj2 = ((Il2CppArrayBase<Component>)(object)componentsInChildren2)[k];
						Renderer val2 = ((obj2 != null) ? ((Il2CppObjectBase)obj2).TryCast<Renderer>() : null);
						if ((Object)(object)val2 != (Object)null)
						{
							Kit.Add(((Il2CppObjectBase)val2).Pointer);
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(79, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("could not work out what you are carrying, so nothing will ");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("be hidden this pass: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val3);
				_kitUnknown = true;
			}
		}

		private static int Hide(Renderer renderer)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if ((Object)(object)renderer == (Object)null || renderer.forceRenderingOff)
			{
				return 0;
			}
			if (Remember(renderer))
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("hiding the stray '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)renderer).gameObject).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(under ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Owner(renderer));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
			}
			renderer.forceRenderingOff = true;
			return 1;
		}

		private static string Owner(Renderer renderer)
		{
			try
			{
				Transform parent = ((Component)renderer).transform.parent;
				return ((Object)(object)parent != (Object)null) ? ((Object)parent).name : "(no parent)";
			}
			catch (Exception)
			{
				return "(unknown)";
			}
		}

		private static bool Remember(Renderer renderer)
		{
			//IL_0070: 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)
			foreach (Part item in Hidden)
			{
				if ((Object)(object)item.Renderer == (Object)(object)renderer)
				{
					return false;
				}
			}
			Hidden.Add(new Part
			{
				Renderer = renderer,
				Enabled = renderer.enabled,
				ForcedOff = renderer.forceRenderingOff,
				Shadows = renderer.shadowCastingMode
			});
			return true;
		}

		private static string[] Names()
		{
			string text = Plugin.HiddenParts.Value ?? string.Empty;
			if (text == _namesSource)
			{
				return _names;
			}
			_namesSource = text;
			List<string> list = new List<string>();
			string[] array = text.Split(',');
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (text2.Length > 0)
				{
					list.Add(text2);
				}
			}
			_names = list.ToArray();
			return _names;
		}

		private static bool Named(string name, string[] names)
		{
			for (int i = 0; i < names.Length; i++)
			{
				if (name.IndexOf(names[i], StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		public static bool Named(string name)
		{
			return Named(name, Names());
		}

		public static void Report(PlayerCharacter pc)
		{
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: 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_0211: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				List<IntPtr> list = new List<IntPtr>();
				PlayerLooks looks = pc.looks;
				if (looks != null)
				{
					Note(list, looks.headRenderers);
					Note(list, looks.torsoRenderers);
					Note(list, looks.legsRenderers);
				}
				Il2CppReferenceArray<Component> componentsInChildren = ((Component)pc).GetComponentsInChildren(Il2CppType.Of<Prop>(), true);
				if (componentsInChildren != null)
				{
					for (int i = 0; i < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; i++)
					{
						Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[i];
						Prop val = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Prop>() : null);
						if ((Object)(object)val == (Object)null)
						{
							continue;
						}
						Il2CppReferenceArray<Component> componentsInChildren2 = ((Component)val).GetComponentsInChildren(Il2CppType.Of<Renderer>(), true);
						if (componentsInChildren2 == null)
						{
							continue;
						}
						for (int j = 0; j < ((Il2CppArrayBase<Component>)(object)componentsInChildren2).Length; j++)
						{
							Component obj2 = ((Il2CppArrayBase<Component>)(object)componentsInChildren2)[j];
							Renderer val2 = ((obj2 != null) ? ((Il2CppObjectBase)obj2).TryCast<Renderer>() : null);
							if ((Object)(object)val2 != (Object)null)
							{
								list.Add(((