Decompiled source of Item Debug v1.1.4

BepInEx/plugins/Item_Debug/GearDebug.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;

[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("GearDebug")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Debug panel for equipping Big Walk props and recolouring your character in a solo game")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion("1.1.4")]
[assembly: AssemblyProduct("GearDebug")]
[assembly: AssemblyTitle("GearDebug")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.4.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 GearDebug
{
	internal static class CharacterColour
	{
		public static Color Custom = new Color(1f, 0.35f, 0.1f);

		public static bool PaintHead = true;

		public static bool PaintTorso = true;

		public static bool PaintLegs = true;

		public static bool Keep;

		public static bool Cycling;

		public static bool CyclePerPart = true;

		public static string RepaintError;

		private static float _nextRepaint;

		private static IntPtr _paletteFrom;

		private static Color[] _swatches = Array.Empty<Color>();

		private static bool[] _locked = Array.Empty<bool>();

		private static int _rememberedFor;

		private static int _headWas;

		private static int _torsoWas;

		private static int _legsWas;

		public static bool Painting;

		public static Color? NoseColour;

		private static MaterialPropertyBlock _noseBlock;

		private static MaterialPropertyBlock _block;

		private static int _colourId = -1;

		private static string _colourProperty;

		private static readonly HashSet<string> _shadersSeen = new HashSet<string>(StringComparer.Ordinal);

		public static int PaletteCount => _swatches.Length;

		public static bool Remembered => _rememberedFor != 0;

		public static Color Swatch(int id)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (id < 0 || id >= _swatches.Length)
			{
				return Color.grey;
			}
			return _swatches[id];
		}

		public static bool Locked(int id)
		{
			if (id >= 0 && id < _locked.Length)
			{
				return _locked[id];
			}
			return false;
		}

		public static void ReadPalette(PlayerCharacter pc)
		{
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			object obj;
			if (pc == null)
			{
				obj = null;
			}
			else
			{
				PlayerLooks looks = pc.looks;
				obj = ((looks != null) ? looks.lookSet : null);
			}
			PlayerLookSet val = (PlayerLookSet)obj;
			if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == _paletteFrom)
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				Il2CppStructArray<LookColor> colors = val.colors;
				int num = ((Il2CppArrayBase<LookColor>)(object)colors)?.Length ?? 0;
				Color[] array = (Color[])(object)new Color[num];
				bool[] array2 = new bool[num];
				for (int i = 0; i < num; i++)
				{
					LookColor val2 = ((Il2CppArrayBase<LookColor>)(object)colors)[i];
					array[i] = val2.color;
					array2[i] = val2.rewardOnly;
				}
				_swatches = array;
				_locked = array2;
				_paletteFrom = ((Il2CppObjectBase)val).Pointer;
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("palette: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" colours, ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(Count(array2));
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" of them reward-only");
				}
				log.LogInfo(val3);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("could not read the colour palette: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val4);
			}
		}

		private static int Count(bool[] flags)
		{
			int num = 0;
			for (int i = 0; i < flags.Length; i++)
			{
				if (flags[i])
				{
					num++;
				}
			}
			return num;
		}

		public static int Current(PlayerCharacter pc, LookPart part)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return (((pc != null) ? pc.looks : null) == null) ? (-1) : pc.looks.GetLookId(part);
			}
			catch (Exception)
			{
				return -1;
			}
		}

		public static string SetFromPalette(PlayerCharacter pc, LookPart part, int id)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			PlayerLooks val = ((pc != null) ? pc.looks : null);
			if (val == null)
			{
				return "no player to recolour";
			}
			if (id < 0 || id >= _swatches.Length)
			{
				return $"there is no colour {id} in the palette";
			}
			Remember(pc, val);
			string text = SetLive(val, pc, part, id);
			string text2;
			try
			{
				if (NetworkServer.active)
				{
					val.ServerSaveLook(part, id);
					text2 = "saved";
				}
				else
				{
					PlayerNetworking playerNetworking = pc.playerNetworking;
					if ((Object)(object)playerNetworking != (Object)null)
					{
						playerNetworking.CmdChangeLook(id, part);
						text2 = "asked the host";
					}
					else
					{
						text2 = "local only";
					}
				}
			}
			catch (Exception ex)
			{
				text2 = "local only";
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("the look change was refused (");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("), painting locally instead");
				}
				log.LogInfo(val2);
			}
			string text3 = Paint(val, part, Colour(val, id));
			if (text3 != null)
			{
				return text3;
			}
			if ((int)part == 0)
			{
				NoseColour = Colour(val, id).color;
			}
			string text4 = $"{Name(part)} is now colour {id} ({text2}, {text})";
			Plugin.Log.LogInfo((object)text4);
			return null;
		}

		private static string SetLive(PlayerLooks looks, PlayerCharacter pc, LookPart part, int id)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			try
			{
				int num = (((int)part == 0) ? id : Current(pc, (LookPart)0));
				int num2 = (((int)part == 1) ? id : Current(pc, (LookPart)1));
				int num3 = (((int)part == 2) ? id : Current(pc, (LookPart)2));
				if (num < 0 || num2 < 0 || num3 < 0)
				{
					return "not worn — the game will not say what the other parts are wearing";
				}
				looks.SetAllLooks(num, num2, num3);
				return "worn";
			}
			catch (Exception ex)
			{
				return "not worn: " + ex.Message;
			}
		}

		public static string SetWholeBody(PlayerCharacter pc, int id)
		{
			return SetFromPalette(pc, (LookPart)0, id) ?? SetFromPalette(pc, (LookPart)1, id) ?? SetFromPalette(pc, (LookPart)2, id);
		}

		public static int CurrentWholeBody(PlayerCharacter pc)
		{
			int num = Current(pc, (LookPart)0);
			int num2 = Current(pc, (LookPart)1);
			int num3 = Current(pc, (LookPart)2);
			if (num < 0 || num != num2 || num != num3)
			{
				return -1;
			}
			return num;
		}

		private static LookColor Colour(PlayerLooks looks, int id)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return looks.GetColor(id);
			}
			catch (Exception)
			{
				return new LookColor
				{
					color = Swatch(id)
				};
			}
		}

		public static string PaintCustom(PlayerCharacter pc)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			PlayerLooks val = ((pc != null) ? pc.looks : null);
			if (val == null)
			{
				return "no player to recolour";
			}
			if (!PaintHead && !PaintTorso && !PaintLegs)
			{
				return "tick a part to paint first";
			}
			Remember(pc, val);
			string text = Apply(val);
			if (text != null)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(49, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("painting failed, so the colour will not be kept: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
				}
				log.LogWarning(val2);
				return text;
			}
			RepaintError = null;
			Keep = true;
			_nextRepaint = Time.unscaledTime + Interval();
			return null;
		}

		public static Color ColourFor(LookPart part)
		{
			//IL_0007: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!Cycling)
			{
				return Custom;
			}
			float num = Mathf.Max(0.05f, Plugin.CycleSeconds.Value);
			float num2 = Time.unscaledTime / num;
			if (CyclePerPart)
			{
				num2 += Phase(part);
			}
			num2 -= Mathf.Floor(num2);
			return Color.HSVToRGB(num2, Mathf.Clamp01(Plugin.CycleSaturation.Value), Mathf.Clamp01(Plugin.CycleBrightness.Value));
		}

		private static float Phase(LookPart part)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)part != 1)
			{
				if ((int)part == 2)
				{
					return 2f / 3f;
				}
				return 0f;
			}
			return 1f / 3f;
		}

		private static float Interval()
		{
			if (!Cycling)
			{
				return Mathf.Max(0f, Plugin.RepaintInterval.Value);
			}
			float value = Plugin.CycleFps.Value;
			if (!(value <= 0f))
			{
				return 1f / value;
			}
			return 0f;
		}

		public static void Reassert(PlayerLooks looks)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			if ((!Keep && !Cycling) || RepaintError != null || looks == null)
			{
				return;
			}
			string text = Apply(looks);
			if (text != null)
			{
				RepaintError = text;
				Keep = false;
				Cycling = false;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(20, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("stopped repainting: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				}
				log.LogWarning(val);
			}
		}

		public static void Repaint(PlayerCharacter pc)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			if ((!Keep && !Cycling) || RepaintError != null)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextRepaint)
			{
				return;
			}
			_nextRepaint = unscaledTime + Interval();
			PlayerLooks val;
			bool flag = default(bool);
			try
			{
				val = (((Object)(object)pc == (Object)null) ? null : pc.looks);
			}
			catch (Exception ex)
			{
				RepaintError = "the character being repainted has gone: " + ex.GetType().Name;
				Keep = false;
				Cycling = false;
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(20, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("stopped repainting: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(RepaintError);
				}
				log.LogWarning(val2);
				return;
			}
			if (val == null)
			{
				return;
			}
			string text = Apply(val);
			if (text != null)
			{
				RepaintError = text;
				Keep = false;
				Cycling = false;
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(20, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("stopped repainting: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
				}
				log2.LogWarning(val2);
			}
		}

		private static string Apply(PlayerLooks looks)
		{
			if (PaintHead)
			{
				string text = Paint(looks, (LookPart)0);
				if (text != null)
				{
					return text;
				}
			}
			if (PaintTorso)
			{
				string text2 = Paint(looks, (LookPart)1);
				if (text2 != null)
				{
					return text2;
				}
			}
			if (PaintLegs)
			{
				string text3 = Paint(looks, (LookPart)2);
				if (text3 != null)
				{
					return text3;
				}
			}
			return null;
		}

		private static string Paint(PlayerLooks looks, LookPart part)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0064: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			Color val = ColourFor(part);
			if ((int)part == 0)
			{
				NoseColour = val;
			}
			try
			{
				Il2CppReferenceArray<LooksRenderer> val2 = Renderers(looks, part);
				if (val2 == null)
				{
					return "the game lists no " + Name(part) + " renderers";
				}
				if (_colourId < 0)
				{
					_colourId = Shader.PropertyToID(PlayerLooks.lookColorPropertyName);
				}
				if (_block == null)
				{
					_block = new MaterialPropertyBlock();
				}
				for (int i = 0; i < ((Il2CppArrayBase<LooksRenderer>)(object)val2).Length; i++)
				{
					LooksRenderer val3 = ((Il2CppArrayBase<LooksRenderer>)(object)val2)[i];
					if (val3 != null)
					{
						Renderer renderer = val3.renderer;
						if (!((Object)(object)renderer == (Object)null))
						{
							renderer.GetPropertyBlock(_block);
							_block.SetColor(_colourId, val);
							renderer.SetPropertyBlock(_block);
						}
					}
				}
				return null;
			}
			catch (Exception ex)
			{
				return "could not colour the " + Name(part) + ": " + ex.GetType().Name + ": " + ex.Message;
			}
		}

		public static string SetCycling(PlayerCharacter pc, bool on)
		{
			Cycling = on;
			RepaintError = null;
			if (on)
			{
				return PaintCustom(pc);
			}
			PlayerLooks val = ((pc != null) ? pc.looks : null);
			if (val != null)
			{
				return Apply(val);
			}
			return null;
		}

		public static void PaintNose(PlayerLips lips)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!NoseColour.HasValue || lips == null)
			{
				return;
			}
			try
			{
				if (_colourId < 0)
				{
					_colourId = Shader.PropertyToID(PlayerLooks.lookColorPropertyName);
				}
				if (_noseBlock == null)
				{
					_noseBlock = new MaterialPropertyBlock();
				}
				Il2CppReferenceArray<PropertyBlockHelper> propertyBlockHelpers = lips.propertyBlockHelpers;
				if (propertyBlockHelpers == null)
				{
					return;
				}
				Color value = NoseColour.Value;
				for (int i = 0; i < ((Il2CppArrayBase<PropertyBlockHelper>)(object)propertyBlockHelpers).Length; i++)
				{
					PropertyBlockHelper obj = ((Il2CppArrayBase<PropertyBlockHelper>)(object)propertyBlockHelpers)[i];
					Renderer val = ((obj != null) ? obj.targetRenderer : null);
					if (!((Object)(object)val == (Object)null))
					{
						val.GetPropertyBlock(_noseBlock);
						_noseBlock.SetColor(_colourId, value);
						val.SetPropertyBlock(_noseBlock);
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private static string Paint(PlayerLooks looks, LookPart part, LookColor colour)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Il2CppReferenceArray<LooksRenderer> val = Renderers(looks, part);
				if (val == null)
				{
					return "the game lists no " + Name(part) + " renderers";
				}
				Painting = true;
				looks.SetColor(val, colour);
				return null;
			}
			catch (Exception ex)
			{
				return "could not colour the " + Name(part) + ": " + ex.Message;
			}
			finally
			{
				Painting = false;
			}
		}

		private static Il2CppReferenceArray<LooksRenderer> Renderers(PlayerLooks looks, LookPart part)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)part != 1)
			{
				if ((int)part == 2)
				{
					return looks.legsRenderers;
				}
				return looks.headRenderers;
			}
			return looks.torsoRenderers;
		}

		public static string PutThemBack(PlayerCharacter pc)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			if ((Object)(object)pc == (Object)null)
			{
				return "no player to recolour";
			}
			if (!Is(pc, _rememberedFor))
			{
				return "nothing to put back";
			}
			Keep = false;
			string text = SetFromPalette(pc, (LookPart)0, _headWas) ?? SetFromPalette(pc, (LookPart)1, _torsoWas) ?? SetFromPalette(pc, (LookPart)2, _legsWas);
			if (text != null)
			{
				return text;
			}
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("put the colours back to ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_headWas);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_torsoWas);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_legsWas);
			}
			log.LogInfo(val);
			return null;
		}

		public static int Random(PlayerCharacter pc)
		{
			try
			{
				PlayerLooks val = ((pc != null) ? pc.looks : null);
				if (val != null)
				{
					return val.GetRandomLookId();
				}
			}
			catch (Exception)
			{
			}
			if (_swatches.Length == 0)
			{
				return -1;
			}
			for (int i = 0; i < 20; i++)
			{
				int num = Random.Range(0, _swatches.Length);
				if (!Locked(num))
				{
					return num;
				}
			}
			return 0;
		}

		public static PlayerCharacter Mine()
		{
			try
			{
				PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
				if ((Object)(object)localPlayerCharacter != (Object)null)
				{
					return localPlayerCharacter;
				}
			}
			catch (Exception)
			{
			}
			return GearPanel.Player;
		}

		private static int Id(PlayerCharacter pc)
		{
			try
			{
				return (!((Object)(object)pc == (Object)null)) ? ((Object)pc).GetInstanceID() : 0;
			}
			catch (Exception)
			{
				return 0;
			}
		}

		private static bool Is(PlayerCharacter pc, int id)
		{
			if (id == 0)
			{
				return false;
			}
			return Id(pc) == id;
		}

		private static void Remember(PlayerCharacter pc, PlayerLooks looks)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			if (Is(pc, _rememberedFor))
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				_headWas = looks.GetLookId((LookPart)0);
				_torsoWas = looks.GetLookId((LookPart)1);
				_legsWas = looks.GetLookId((LookPart)2);
				_rememberedFor = Id(pc);
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("colours before anything was changed: head ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_headWas);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("torso ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_torsoWas);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", legs ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_legsWas);
				}
				log.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(70, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("could not read the current look ids, so there is nothing to ");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("put back: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val2);
			}
		}

		public static string Name(LookPart part)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)part != 1)
			{
				if ((int)part == 2)
				{
					return "legs";
				}
				return "head";
			}
			return "torso";
		}

		public static void Report(PlayerCharacter pc)
		{
			//IL_003f: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007f: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			PlayerLooks val = ((pc != null) ? pc.looks : null);
			if (val == null)
			{
				Plugin.Log.LogInfo((object)"colours: no PlayerLooks on this character");
				return;
			}
			ReadPalette(pc);
			LookPart[] array = (LookPart[])(object)new LookPart[3]
			{
				default(LookPart),
				(LookPart)1,
				(LookPart)2
			};
			foreach (LookPart part in array)
			{
				int num = Current(pc, part);
				Color val2 = Swatch(num);
				Plugin.Log.LogInfo((object)($"colour {Name(part)}: look id {num} " + $"rgb({val2.r:0.##}, {val2.g:0.##}, {val2.b:0.##})" + (Locked(num) ? " reward-only" : "")));
			}
			if (Cycling)
			{
				Plugin.Log.LogInfo((object)($"hue cycling: {Plugin.CycleSeconds.Value:0.##}s a turn, " + (CyclePerPart ? "parts a third apart" : "all parts together") + $", {Plugin.CycleFps.Value:0} paints a second"));
			}
			else if (Keep)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("free colour is being kept: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("rgb(");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(Custom.r, "0.##");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(Custom.g, "0.##");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(Custom.b, "0.##");
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
				}
				log.LogInfo(val3);
			}
			Parts(val);
		}

		private static void Parts(PlayerLooks looks)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			_colourProperty = null;
			bool flag = default(bool);
			try
			{
				_colourProperty = PlayerLooks.lookColorPropertyName;
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(83, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("the look colour is written to shader property ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_colourProperty);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (speechlessness '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(PlayerLooks.speechlessnessPropertyName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("rewardness '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(PlayerLooks.rewardnessPropertyName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("')");
				}
				log.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not read which shader property the colour goes to: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log2.LogInfo(val);
			}
			_shadersSeen.Clear();
			Part(looks, (LookPart)0, looks.headRenderers);
			Part(looks, (LookPart)1, looks.torsoRenderers);
			Part(looks, (LookPart)2, looks.legsRenderers);
			_shadersSeen.Clear();
		}

		private static void Describe(Material material)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Shader shader;
			try
			{
				shader = material.shader;
				if ((Object)(object)shader == (Object)null || !_shadersSeen.Add(((Object)shader).name))
				{
					return;
				}
			}
			catch (Exception)
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				int propertyCount = shader.GetPropertyCount();
				StringBuilder stringBuilder = new StringBuilder();
				for (int i = 0; i < propertyCount; i++)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append(", ");
					}
					stringBuilder.Append(shader.GetPropertyName(i)).Append('(').Append(shader.GetPropertyType(i))
						.Append(')');
				}
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("  shader '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)shader).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' takes ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(propertyCount);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<StringBuilder>(stringBuilder);
				}
				log.LogInfo(val);
			}
			catch (Exception ex2)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("  shader '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)shader).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': could not list its properties: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
				}
				log2.LogInfo(val);
			}
		}

		private static string Takes(Material material)
		{
			if (_colourProperty == null)
			{
				return "";
			}
			try
			{
				return material.HasProperty(_colourProperty) ? "" : ("  <- NO '" + _colourProperty + "' PROPERTY, the look colour cannot reach this");
			}
			catch (Exception)
			{
				return "";
			}
		}

		private static void Part(PlayerLooks looks, LookPart part, Il2CppReferenceArray<LooksRenderer> list)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (list == null)
			{
				ManualLogSource log = Plugin.Log;
				val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(part));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": no renderer list");
				}
				log.LogInfo(val);
				return;
			}
			ManualLogSource log2 = Plugin.Log;
			val = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("--- ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(part));
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(((Il2CppArrayBase<LooksRenderer>)(object)list).Length);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" renderers the colour is written to ---");
			}
			log2.LogInfo(val);
			for (int i = 0; i < ((Il2CppArrayBase<LooksRenderer>)(object)list).Length; i++)
			{
				LooksRenderer val2 = ((Il2CppArrayBase<LooksRenderer>)(object)list)[i];
				if (val2 == null)
				{
					continue;
				}
				Renderer renderer = val2.renderer;
				if ((Object)(object)renderer == (Object)null)
				{
					ManualLogSource log3 = Plugin.Log;
					val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("  [");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(i);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] (no renderer) local=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(val2.local);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" remote=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(val2.remote);
					}
					log3.LogInfo(val);
					continue;
				}
				string text = "?";
				string text2 = "";
				Material val3 = null;
				try
				{
					Material sharedMaterial = renderer.sharedMaterial;
					if ((Object)(object)sharedMaterial == (Object)null)
					{
						text = "(none)";
					}
					else
					{
						Shader shader = sharedMaterial.shader;
						text = (((Object)(object)shader == (Object)null) ? ((Object)sharedMaterial).name : (((Object)sharedMaterial).name + " shader:'" + ((Object)shader).name + "'"));
						text2 = Takes(sharedMaterial);
						val3 = sharedMaterial;
					}
				}
				catch (Exception)
				{
				}
				string text3 = "";
				try
				{
					Component componentInParent = ((Component)renderer).GetComponentInParent(Il2CppType.Of<LODGroup>(), true);
					if ((Object)(object)componentInParent != (Object)null)
					{
						LODGroup val4 = ((Il2CppObjectBase)componentInParent).TryCast<LODGroup>();
						text3 = " LODGROUP('" + ((Object)componentInParent.gameObject).name + "'" + (((Object)(object)val4 != (Object)null) ? $", {val4.lodCount} levels, enabled={val4.enabled}" : "") + ")";
					}
				}
				catch (Exception)
				{
					text3 = " LODGROUP(?)";
				}
				ManualLogSource log4 = Plugin.Log;
				val = new BepInExInfoLogInterpolatedStringHandler(58, 11, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("  [");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(i);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)renderer).gameObject).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' local=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(val2.local);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" remote=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(val2.remote);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mat:");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" enabled=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(renderer.enabled);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" forceOff=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(renderer.forceRenderingOff);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" active=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(((Component)renderer).gameObject.activeInHierarchy);
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text3);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Path(((Component)renderer).transform));
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
				}
				log4.LogInfo(val);
				if ((Object)(object)val3 != (Object)null)
				{
					Describe(val3);
				}
			}
		}

		private static string Path(Transform t)
		{
			string text = ((Object)t).name;
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}
	}
	internal enum GearTab
	{
		Gear,
		Colour
	}
	internal static class GearPanel
	{
		private struct Entry
		{
			public Prop Prop;

			public string Name;

			public string Search;

			public float Distance;
		}

		private struct PropRow
		{
			public Prop Prop;

			public string Text;
		}

		private struct SlotRow
		{
			public PropHome Home;

			public string Text;
		}

		private static readonly List<Entry> Props = new List<Entry>();

		private static readonly List<PropHome> Homes = new List<PropHome>();

		private static PlayerCharacter _player;

		private static Prop _picked;

		private static string _filter = "";

		private static string _status = "";

		private static GearTab _tab = GearTab.Gear;

		private static LookPart _part = (LookPart)0;

		private static bool _whole;

		private static Vector2 _homeScroll;

		private static Vector2 _propScroll;

		private static Vector2 _colourScroll;

		private static bool _rowsDirty = true;

		private static float _nextRebuild;

		private static string _rowFilter;

		private const float RebuildInterval = 0.5f;

		private static bool _ready;

		private static float _scale = 1.6f;

		private static float _height = 600f;

		private static GearTab _drawTab;

		private static bool _havePlayer;

		private static SlotRow[] _slotRows = Array.Empty<SlotRow>();

		private static PropRow[] _propRows = Array.Empty<PropRow>();

		private static int _matched;

		private static bool _crowded;

		private static int _palette;

		private static bool _repaintFailed;

		private static int _curHead = -1;

		private static int _curTorso = -1;

		private static int _curLegs = -1;

		private const float Width = 560f;

		private const int PerRow = 8;

		private const float SwatchWidth = 58f;

		private const float SwatchHeight = 34f;

		private static GUILayoutOption[] _swatchSize;

		private static GUILayoutOption[] _slotsHigh;

		private static GUILayoutOption[] _propsHigh;

		private static GUILayoutOption[] _filterWide;

		private static GUILayoutOption[] _paintLabel;

		private static GUILayoutOption[] _channelLabel;

		private static Texture2D _white;

		public static PlayerCharacter Player => _player;

		private static void Sizes()
		{
			if (_swatchSize == null)
			{
				_swatchSize = (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(58f),
					GUILayout.Height(34f)
				};
				_slotsHigh = (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(180f) };
				_propsHigh = (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(320f) };
				_filterWide = (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) };
				_paintLabel = (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) };
				_channelLabel = (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) };
			}
		}

		public static void Refresh()
		{
			_player = FindPlayer();
			if ((Object)(object)_player == (Object)null)
			{
				_status = "no local player yet — load into a game first";
				_rowsDirty = true;
				Homes.Clear();
				Props.Clear();
			}
			else
			{
				FindHomes(_player);
				FindProps(_player);
				CharacterColour.ReadPalette(_player);
				_status = $"{Homes.Count} slots on you, {Props.Count} props in the world";
			}
		}

		private static void Snapshot()
		{
			_ready = true;
			float num = Mathf.Max(0.5f, Plugin.Scale.Value);
			float num2 = Mathf.Max(0.5f, (float)Screen.width / 600f);
			_scale = Mathf.Min(num, num2);
			_height = (float)Screen.height / _scale - 20f;
			_drawTab = _tab;
			_repaintFailed = CharacterColour.RepaintError != null;
			_palette = CharacterColour.PaletteCount;
			bool flag = (Object)(object)_player != (Object)null;
			if (flag != _havePlayer)
			{
				_havePlayer = flag;
				_rowsDirty = true;
			}
			if (_drawTab == GearTab.Colour && _havePlayer)
			{
				_curHead = CharacterColour.Current(_player, (LookPart)0);
				_curTorso = CharacterColour.Current(_player, (LookPart)1);
				_curLegs = CharacterColour.Current(_player, (LookPart)2);
			}
			float unscaledTime = Time.unscaledTime;
			if (_rowsDirty || !string.Equals(_filter, _rowFilter, StringComparison.Ordinal) || unscaledTime >= _nextRebuild)
			{
				_rowsDirty = false;
				_rowFilter = _filter;
				_nextRebuild = unscaledTime + 0.5f;
				BuildSlotRows();
				BuildPropRows();
			}
		}

		private static void BuildSlotRows()
		{
			if (!_havePlayer)
			{
				_slotRows = Array.Empty<SlotRow>();
				return;
			}
			List<SlotRow> list = new List<SlotRow>(Homes.Count);
			foreach (PropHome home in Homes)
			{
				if (!((Object)(object)home == (Object)null))
				{
					Prop pinnedProp = home.pinnedProp;
					list.Add(new SlotRow
					{
						Home = home,
						Text = Label(home) + " — " + (((Object)(object)pinnedProp == (Object)null) ? "empty" : ("'" + Name(pinnedProp) + "'"))
					});
				}
			}
			_slotRows = list.ToArray();
		}

		private static void BuildPropRows()
		{
			_matched = 0;
			_crowded = false;
			if (!_havePlayer)
			{
				_propRows = Array.Empty<PropRow>();
				return;
			}
			string text = (_filter ?? "").Trim().ToLowerInvariant();
			int num = Mathf.Max(1, Plugin.ListLimit.Value);
			List<PropRow> list = new List<PropRow>(Mathf.Min(num, Props.Count));
			foreach (Entry prop in Props)
			{
				if (!((Object)(object)prop.Prop == (Object)null) && (text.Length <= 0 || prop.Search.IndexOf(text, StringComparison.Ordinal) >= 0))
				{
					_matched++;
					if (list.Count < num)
					{
						list.Add(new PropRow
						{
							Prop = prop.Prop,
							Text = $"{prop.Name}  {prop.Distance:0}m"
						});
					}
				}
			}
			_propRows = list.ToArray();
			_crowded = _matched > list.Count;
		}

		public static void Closed()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			_ready = false;
			_player = null;
			try
			{
				ConfigFile cfg = Plugin.Cfg;
				if (cfg != null)
				{
					cfg.Save();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not save the config: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
		}

		public static void Draw()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_007f: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Sizes();
			if ((int)Event.current.type == 8)
			{
				Snapshot();
			}
			else if (!_ready)
			{
				return;
			}
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(_scale, _scale, 1f));
			GUILayout.BeginArea(new Rect(10f, 10f, 560f, _height), GUI.skin.box);
			try
			{
				Body();
			}
			finally
			{
				GUI.enabled = true;
				GUILayout.EndArea();
				GUI.matrix = matrix;
			}
		}

		private static void Body()
		{
			GUILayout.Label("GEAR DEBUG", (Il2CppReferenceArray<GUILayoutOption>)null);
			TabBar();
			if (!_havePlayer)
			{
				GUILayout.Label((_status.Length > 0) ? _status : "not looked yet", (Il2CppReferenceArray<GUILayoutOption>)null);
				if (GUILayout.Button("Look for the player", (Il2CppReferenceArray<GUILayoutOption>)null))
				{
					Refresh();
				}
				return;
			}
			if (_drawTab == GearTab.Colour)
			{
				ColourBody();
			}
			else
			{
				GearBody();
			}
			GUILayout.Space(6f);
			GUILayout.Label(_status, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Refresh", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				Refresh();
			}
			if (GUILayout.Button("Log a report", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				Report();
			}
			GUILayout.EndHorizontal();
		}

		private static void TabBar()
		{
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			Pick(GearTab.Gear, "Gear");
			Pick(GearTab.Colour, "Colour");
			GUILayout.EndHorizontal();
		}

		private static void Pick(GearTab tab, string label)
		{
			bool flag = _tab == tab;
			if (!(!GUILayout.Button(flag ? ("[" + label + "]") : label, (Il2CppReferenceArray<GUILayoutOption>)null) || flag))
			{
				_tab = tab;
				_status = "";
			}
		}

		private static void GearBody()
		{
			DrawSlots();
			DrawProps();
		}

		private static void DrawSlots()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Space(6f);
			GUILayout.Label($"Slots on your character ({_slotRows.Length})", (Il2CppReferenceArray<GUILayoutOption>)null);
			_homeScroll = GUILayout.BeginScrollView(_homeScroll, _slotsHigh);
			SlotRow[] slotRows = _slotRows;
			for (int i = 0; i < slotRows.Length; i++)
			{
				SlotRow slotRow = slotRows[i];
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.Label(slotRow.Text, (Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.FlexibleSpace();
				if (GUILayout.Button("Fill", (Il2CppReferenceArray<GUILayoutOption>)null))
				{
					Pin(slotRow.Home);
				}
				if (GUILayout.Button("Clear", (Il2CppReferenceArray<GUILayoutOption>)null))
				{
					Unpin(slotRow.Home);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
		}

		private static void DrawProps()
		{
			//IL_0087: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Space(6f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Props in the world  filter:", (Il2CppReferenceArray<GUILayoutOption>)null);
			_filter = GUILayout.TextField(_filter ?? "", _filterWide);
			if (GUILayout.Button("x", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				_filter = "";
			}
			GUILayout.EndHorizontal();
			GUILayout.Label(((Object)(object)_picked == (Object)null) ? "nothing picked yet" : ("picked: '" + Name(_picked) + "'"), (Il2CppReferenceArray<GUILayoutOption>)null);
			_propScroll = GUILayout.BeginScrollView(_propScroll, _propsHigh);
			PropRow[] propRows = _propRows;
			for (int i = 0; i < propRows.Length; i++)
			{
				PropRow propRow = propRows[i];
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.Label(propRow.Text, (Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.FlexibleSpace();
				if (GUILayout.Button("Pick", (Il2CppReferenceArray<GUILayoutOption>)null))
				{
					Pick(propRow.Prop);
				}
				if (GUILayout.Button("Hold", (Il2CppReferenceArray<GUILayoutOption>)null))
				{
					Hold(propRow.Prop);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
			if (_crowded)
			{
				GUILayout.Label($"showing {_propRows.Length} of {_matched} matches — " + "narrow the filter to see the rest", (Il2CppReferenceArray<GUILayoutOption>)null);
			}
		}

		private static void ColourBody()
		{
			//IL_0000: 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)
			_colourScroll = GUILayout.BeginScrollView(_colourScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			try
			{
				ColourControls();
			}
			finally
			{
				GUILayout.EndScrollView();
			}
		}

		private static void ColourControls()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Space(6f);
			GUILayout.Label("— The game's palette —", (Il2CppReferenceArray<GUILayoutOption>)null);
			PartBar();
			int current = ((!_whole) ? (((int)_part == 1) ? _curTorso : (((int)_part == 2) ? _curLegs : _curHead)) : ((_curHead >= 0 && _curHead == _curTorso && _curHead == _curLegs) ? _curHead : (-1)));
			GUILayout.Label(Wearing(current), (Il2CppReferenceArray<GUILayoutOption>)null);
			Swatches(current);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Random each part", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				RandomAll();
			}
			GUI.enabled = CharacterColour.Remembered;
			if (GUILayout.Button("Put them back", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				Say(CharacterColour.PutThemBack(_player), "colours put back");
			}
			GUI.enabled = true;
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			GUILayout.Label("— Any colour at all —", (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("Paint:", _paintLabel);
			CharacterColour.PaintHead = GUILayout.Toggle(CharacterColour.PaintHead, " head ", Array.Empty<GUILayoutOption>());
			CharacterColour.PaintTorso = GUILayout.Toggle(CharacterColour.PaintTorso, " torso ", Array.Empty<GUILayoutOption>());
			CharacterColour.PaintLegs = GUILayout.Toggle(CharacterColour.PaintLegs, " legs ", Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			Color custom = CharacterColour.Custom;
			custom.r = Channel("Red", custom.r);
			custom.g = Channel("Green", custom.g);
			custom.b = Channel("Blue", custom.b);
			CharacterColour.Custom = custom;
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			Preset("White", Color.white);
			Preset("Black", new Color(0.05f, 0.05f, 0.05f));
			Preset("Red", new Color(0.9f, 0.1f, 0.1f));
			Preset("Green", new Color(0.15f, 0.8f, 0.2f));
			Preset("Blue", new Color(0.15f, 0.35f, 0.95f));
			Preset("Pink", new Color(1f, 0.4f, 0.75f));
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Paint it", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				Say(CharacterColour.PaintCustom(_player), "painted, and keeping it");
			}
			bool flag = GUILayout.Toggle(CharacterColour.Keep, "  Keep it painted", Array.Empty<GUILayoutOption>());
			if (flag != CharacterColour.Keep)
			{
				CharacterColour.Keep = flag;
				CharacterColour.RepaintError = null;
				if (flag)
				{
					Say(CharacterColour.PaintCustom(_player), "keeping it painted");
				}
				else
				{
					_status = "stopped repainting";
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.Label("A free colour is yours alone and is not saved. It is put back the moment", (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("anything repaints you, so painting one turns Keep it painted on for you.", (Il2CppReferenceArray<GUILayoutOption>)null);
			Rainbow();
			if (_repaintFailed)
			{
				GUILayout.Label("repainting stopped: " + CharacterColour.RepaintError, (Il2CppReferenceArray<GUILayoutOption>)null);
			}
		}

		private static void Rainbow()
		{
			GUILayout.Space(8f);
			GUILayout.Label("— Rainbow —", (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			bool flag = GUILayout.Toggle(CharacterColour.Cycling, "  Cycle the hue", Array.Empty<GUILayoutOption>());
			if (flag != CharacterColour.Cycling)
			{
				Say(CharacterColour.SetCycling(_player, flag), flag ? "cycling the hue" : "stopped cycling");
			}
			bool flag2 = GUILayout.Toggle(CharacterColour.CyclePerPart, "  parts offset", Array.Empty<GUILayoutOption>());
			if (flag2 != CharacterColour.CyclePerPart)
			{
				CharacterColour.CyclePerPart = flag2;
				_status = (flag2 ? "each part a third of the wheel apart" : "the whole body as one");
			}
			GUILayout.EndHorizontal();
			float value = Plugin.CycleSeconds.Value;
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label($"Speed: {value:0.0}s a turn", _paintLabel);
			float num = GUILayout.HorizontalSlider(20f - Mathf.Clamp(value, 0.5f, 20f), 0f, 19.5f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			float num2 = 20f - num;
			if (Mathf.Abs(num2 - value) > 0.01f)
			{
				Plugin.CycleSeconds.Value = num2;
			}
			GUILayout.Label("Local and unsaved like any free colour — nobody else sees it.", (Il2CppReferenceArray<GUILayoutOption>)null);
		}

		private static string Wearing(int current)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!_whole)
			{
				if (current >= 0)
				{
					return $"{CharacterColour.Name(_part)}: colour #{current} of {_palette}" + (CharacterColour.Locked(current) ? "  (reward-only)" : "");
				}
				return CharacterColour.Name(_part) + ": the game will not say which colour it is wearing";
			}
			if (current >= 0)
			{
				return $"whole body: colour #{current} of {_palette}";
			}
			return $"whole body: mixed — head #{_curHead}, torso #{_curTorso}, legs #{_curLegs}";
		}

		private static void PartBar()
		{
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			PartPick((LookPart)0, "Head");
			PartPick((LookPart)1, "Torso");
			PartPick((LookPart)2, "Legs");
			bool whole = _whole;
			if (GUILayout.Button(whole ? "[Whole body]" : "Whole body", (Il2CppReferenceArray<GUILayoutOption>)null) && !whole)
			{
				_whole = true;
				_status = "";
			}
			GUILayout.EndHorizontal();
		}

		private static void PartPick(LookPart part, string label)
		{
			//IL_0007: 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_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)
			bool flag = !_whole && _part == part;
			if (!(!GUILayout.Button(flag ? ("[" + label + "]") : label, (Il2CppReferenceArray<GUILayoutOption>)null) || flag))
			{
				_part = part;
				_whole = false;
				_status = "";
			}
		}

		private static void Swatches(int current)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (_palette == 0)
			{
				GUILayout.Label("no palette yet — press Refresh once you are in a game", (Il2CppReferenceArray<GUILayoutOption>)null);
				return;
			}
			for (int i = 0; i < _palette; i += 8)
			{
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				for (int j = i; j < i + 8 && j < _palette; j++)
				{
					bool num = GUILayout.Button("", _swatchSize);
					Fill(GUILayoutUtility.GetLastRect(), j, j == current);
					if (num)
					{
						Set(j);
					}
				}
				GUILayout.EndHorizontal();
			}
		}

		private static void Fill(Rect cell, int id, bool current)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type == 7)
			{
				Color val = CharacterColour.Swatch(id);
				val.a = 1f;
				Color color = GUI.color;
				if (_white == null)
				{
					_white = Texture2D.whiteTexture;
				}
				if (current)
				{
					GUI.color = Color.white;
					GUI.DrawTexture(Inset(cell, 2f), (Texture)(object)_white);
				}
				GUI.color = val;
				GUI.DrawTexture(Inset(cell, current ? 5f : 3f), (Texture)(object)_white);
				if (CharacterColour.Locked(id))
				{
					GUI.color = ((0.299f * val.r + 0.587f * val.g + 0.114f * val.b > 0.55f) ? Color.black : Color.white);
					GUI.Label(Inset(cell, 5f), "*");
				}
				GUI.color = color;
			}
		}

		private static Rect Inset(Rect r, float by)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref r)).x + by, ((Rect)(ref r)).y + by, Mathf.Max(0f, ((Rect)(ref r)).width - 2f * by), Mathf.Max(0f, ((Rect)(ref r)).height - 2f * by));
		}

		private static float Channel(string label, float value)
		{
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label($"{label}: {value:0.##}", _channelLabel);
			float result = GUILayout.HorizontalSlider(value, 0f, 1f, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			return result;
		}

		private static void Preset(string label, Color colour)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = colour;
			bool num = GUILayout.Button(label, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUI.backgroundColor = backgroundColor;
			if (num)
			{
				CharacterColour.Custom = colour;
				Say(CharacterColour.PaintCustom(_player), "painted " + label.ToLowerInvariant() + ", and keeping it");
			}
		}

		private static void Set(int id)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (id < 0)
			{
				_status = "the game has no colour to give";
			}
			else if (_whole)
			{
				Say(CharacterColour.SetWholeBody(_player, id), $"all of you is colour #{id}");
			}
			else
			{
				Say(CharacterColour.SetFromPalette(_player, _part, id), $"{CharacterColour.Name(_part)} set to colour #{id}");
			}
		}

		private static void RandomAll()
		{
			Say(CharacterColour.SetFromPalette(_player, (LookPart)0, CharacterColour.Random(_player)) ?? CharacterColour.SetFromPalette(_player, (LookPart)1, CharacterColour.Random(_player)) ?? CharacterColour.SetFromPalette(_player, (LookPart)2, CharacterColour.Random(_player)), "randomised");
		}

		private static void Say(string failed, string good)
		{
			_status = failed ?? good;
		}

		private static void Pick(Prop prop)
		{
			_picked = prop;
			_status = "picked '" + Name(prop) + "'";
		}

		private static void Pin(PropHome home)
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if ((Object)(object)_picked == (Object)null)
			{
				_status = "pick a prop from the list below first";
				return;
			}
			string text = GearBlocked();
			bool flag = default(bool);
			if (text != null)
			{
				_status = text;
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(16, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("refused to pin: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				}
				log.LogWarning(val);
				return;
			}
			if (!Ours(_picked))
			{
				_status = "'" + Name(_picked) + "' belongs to another player — pick something else";
				return;
			}
			try
			{
				if (IsServer())
				{
					_picked.ServerSetPinned(home);
					_status = "pinned '" + Name(_picked) + "' into " + Label(home);
				}
				else
				{
					_picked.PredictivelyPlaceInHome(home);
					Command(home, _picked);
					_status = "asked the server to put '" + Name(_picked) + "' into " + Label(home);
				}
				Plugin.Log.LogInfo((object)_status);
				FindHomes(_player);
			}
			catch (Exception ex)
			{
				_status = "could not pin: " + ex.Message;
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(16, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("pinning failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log2.LogWarning(val);
			}
		}

		private static void Command(PropHome home, Prop prop)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerCharacter player = _player;
				PlayerNetworking val = ((player != null) ? player.playerNetworking : null);
				if (!((Object)(object)val == (Object)null))
				{
					val.CmdPlaceInHome(prop, home.shellReference);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("the server was not asked to confirm the pin: " + ex.Message + ". It will revert on the next update from the host."));
			}
		}

		private static bool Ours(Prop prop)
		{
			try
			{
				PlayerCharacter exclusiveHolder = prop.exclusiveHolder;
				if ((Object)(object)exclusiveHolder == (Object)null)
				{
					return true;
				}
				if ((Object)(object)_player == (Object)null)
				{
					return false;
				}
				return ((Object)exclusiveHolder).GetInstanceID() == ((Object)_player).GetInstanceID();
			}
			catch (Exception)
			{
				return true;
			}
		}

		private static void Unpin(PropHome home)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			Prop pinnedProp = home.pinnedProp;
			if ((Object)(object)pinnedProp == (Object)null)
			{
				_status = Label(home) + " is already empty";
				return;
			}
			string text = GearBlocked();
			if (text != null)
			{
				_status = text;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("refused to clear a slot: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				}
				log.LogWarning(val);
				return;
			}
			if (!IsServer())
			{
				_status = "only the host can take a prop out of a slot";
				return;
			}
			try
			{
				pinnedProp.ServerSetUnpinned();
				_status = "took '" + Name(pinnedProp) + "' out of " + Label(home);
				Plugin.Log.LogInfo((object)_status);
				FindHomes(_player);
			}
			catch (Exception ex)
			{
				_status = "could not clear " + Label(home) + ": " + ex.Message;
			}
		}

		private static void Hold(Prop prop)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			string text = GearBlocked();
			if (text != null)
			{
				_status = text;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(24, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("refused to hold a prop: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				}
				log.LogWarning(val);
				return;
			}
			if (!Ours(prop))
			{
				_status = "'" + Name(prop) + "' is in another player's hands";
				return;
			}
			try
			{
				prop.SetHeld(_player);
				_status = "holding '" + Name(prop) + "' (local only — the server is not told)";
				Plugin.Log.LogInfo((object)_status);
			}
			catch (Exception ex)
			{
				_status = "could not hold '" + Name(prop) + "': " + ex.Message;
			}
		}

		private static string Label(PropHome home)
		{
			PlayerCharacter player = _player;
			PlayerRegistry val = ((player != null) ? player.registry : null);
			if (val != null)
			{
				if ((Object)(object)home == (Object)(object)val.backpackPocket)
				{
					return "BACKPACK";
				}
				if ((Object)(object)home == (Object)(object)val.holsterPocket)
				{
					return "BELT (holster)";
				}
				if ((Object)(object)home == (Object)(object)val.blindfoldPocket)
				{
					return "BLINDFOLD";
				}
			}
			return ((Object)home).name + (home.isInventory ? " (inventory)" : "");
		}

		private unsafe static string Name(Prop prop)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Object)prop).name ?? "?";
			SaveablePropName saveablePropName = prop.saveablePropName;
			if ((int)saveablePropName == 0)
			{
				return text;
			}
			string text2 = ((object)(*(SaveablePropName*)(&saveablePropName))/*cast due to .constrained prefix*/).ToString();
			if (text.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return text;
			}
			return text + " [" + text2 + "]";
		}

		public static PlayerCharacter FindPlayer()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			try
			{
				PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
				if ((Object)(object)localPlayerCharacter != (Object)null)
				{
					return localPlayerCharacter;
				}
			}
			catch (Exception)
			{
			}
			try
			{
				Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Il2CppType.Of<PlayerCharacter>());
				if (val == null)
				{
					return null;
				}
				for (int i = 0; i < ((Il2CppArrayBase<Object>)(object)val).Length; i++)
				{
					Object obj = ((Il2CppArrayBase<Object>)(object)val)[i];
					PlayerCharacter val2 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<PlayerCharacter>() : null);
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					try
					{
						if (((NetworkBehaviour)val2).isLocalPlayer)
						{
							return val2;
						}
					}
					catch (Exception)
					{
					}
				}
				return null;
			}
			catch (Exception ex3)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("could not find the player: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex3.Message);
				}
				log.LogWarning(val3);
				return null;
			}
		}

		private static bool IsServer()
		{
			try
			{
				return NetworkServer.active;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static int Players()
		{
			try
			{
				return PlayerCharacter.allPlayerCharacters?.Count ?? 0;
			}
			catch (Exception)
			{
				return 0;
			}
		}

		private static string GearBlocked()
		{
			int num = Players();
			if (num > 1)
			{
				return $"there are {num} characters in this game — pinning is networked and saved, " + "so it is refused in company. Use it in a solo game.";
			}
			return null;
		}

		private static void FindHomes(PlayerCharacter pc)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			_rowsDirty = true;
			Homes.Clear();
			if ((Object)(object)pc == (Object)null)
			{
				return;
			}
			PlayerRegistry registry = pc.registry;
			if (registry != null)
			{
				Add(registry.backpackPocket);
				Add(registry.holsterPocket);
				Add(registry.blindfoldPocket);
			}
			try
			{
				Il2CppReferenceArray<Component> componentsInChildren = ((Component)pc).GetComponentsInChildren(Il2CppType.Of<PropHome>(), true);
				if (componentsInChildren != null)
				{
					for (int i = 0; i < ((Il2CppArrayBase<Component>)(object)componentsInChildren).Length; i++)
					{
						Component obj = ((Il2CppArrayBase<Component>)(object)componentsInChildren)[i];
						Add((obj != null) ? ((Il2CppObjectBase)obj).TryCast<PropHome>() : null);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not list your slots: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
		}

		private static void Add(PropHome home)
		{
			if ((Object)(object)home == (Object)null)
			{
				return;
			}
			foreach (PropHome home2 in Homes)
			{
				if ((Object)(object)home2 == (Object)(object)home)
				{
					return;
				}
			}
			Homes.Add(home);
		}

		private static void FindProps(PlayerCharacter pc)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			_rowsDirty = true;
			Props.Clear();
			Vector3 position = ((Component)pc).transform.position;
			bool flag = default(bool);
			try
			{
				List<Prop> allProps = Prop.allProps;
				if (allProps != null)
				{
					for (int i = 0; i < allProps.Count; i++)
					{
						Record(allProps[i], position);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Prop.allProps did not work (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), sweeping the scene instead");
				}
				log.LogInfo(val);
			}
			if (Props.Count == 0)
			{
				try
				{
					Il2CppReferenceArray<Object> val2 = Object.FindObjectsOfType(Il2CppType.Of<Prop>());
					if (val2 != null)
					{
						for (int j = 0; j < ((Il2CppArrayBase<Object>)(object)val2).Length; j++)
						{
							Object obj = ((Il2CppArrayBase<Object>)(object)val2)[j];
							Record((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Prop>() : null, position);
						}
					}
				}
				catch (Exception ex2)
				{
					ManualLogSource log2 = Plugin.Log;
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("could not list the world's props: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message);
					}
					log2.LogWarning(val3);
				}
			}
			Props.Sort((Entry a, Entry b) => a.Distance.CompareTo(b.Distance));
		}

		private static void Record(Prop prop, Vector3 here)
		{
			//IL_0043: 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)
			if (!((Object)(object)prop == (Object)null))
			{
				string text = Name(prop);
				Props.Add(new Entry
				{
					Prop = prop,
					Name = text,
					Search = text.ToLowerInvariant(),
					Distance = Vector3.Distance(((Component)prop).transform.position, here)
				});
			}
		}

		public static void ReportNow()
		{
			if ((Object)(object)_player == (Object)null)
			{
				_player = FindPlayer();
			}
			Report();
		}

		private static void Report()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if ((Object)(object)_player == (Object)null)
			{
				Plugin.Log.LogInfo((object)"no player to report on");
				return;
			}
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("--- gear on '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)_player).name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ---");
			}
			log.LogInfo(val);
			PlayerRegistry registry = _player.registry;
			if (registry != null)
			{
				MeshRenderer fakeHolster = registry.fakeHolster;
				Plugin.Log.LogInfo((object)(((Object)(object)fakeHolster == (Object)null) ? "fakeHolster: none" : ("fakeHolster: '" + ((Object)((Component)fakeHolster).gameObject).name + "' under " + Path(((Component)fakeHolster).transform) + ", " + $"enabled {((Renderer)fakeHolster).enabled}, active {((Component)fakeHolster).gameObject.activeInHierarchy}")));
			}
			foreach (PropHome home in Homes)
			{
				if ((Object)(object)home == (Object)null)
				{
					continue;
				}
				Prop pinnedProp = home.pinnedProp;
				StringBuilder stringBuilder = new StringBuilder(Label(home)).Append(" at ").Append(Path(((Component)home).transform)).Append(((Object)(object)home.hideForLocalPlayer != (Object)null) ? " HIDDEN-FOR-LOCAL" : "");
				if ((Object)(object)pinnedProp == (Object)null)
				{
					stringBuilder.Append(" — empty");
				}
				else
				{
					stringBuilder.Append(" — holding '" + Name(pinnedProp) + "'");
					if ((Object)(object)pinnedProp.locallyHiddenForPlayer != (Object)null)
					{
						stringBuilder.Append(" LOCALLY-HIDDEN");
					}
				}
				Plugin.Log.LogInfo((object)stringBuilder.ToString());
			}
			CharacterColour.Report(_player);
			_status = "written to BepInEx/LogOutput.log";
		}

		private static string Path(Transform t)
		{
			string text = ((Object)t).name;
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}
	}
	[HarmonyPatch]
	internal static class LooksPatches
	{
		private static bool _inside;

		private static readonly HashSet<string> Fired = new HashSet<string>(StringComparer.Ordinal);

		private static string _lastLine;

		private static int _lastFrame = -1;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLooks), "RefreshLook")]
		private static void AfterRefreshLook(PlayerLooks __instance)
		{
			Handle(__instance, "RefreshLook");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLooks), "SetBodyToLocalMode")]
		private static void AfterLocalMode(PlayerLooks __instance)
		{
			Handle(__instance, "SetBodyToLocalMode");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLooks), "SetBodyToLocalModeInitial")]
		private static void AfterLocalModeInitial(PlayerLooks __instance)
		{
			Handle(__instance, "SetBodyToLocalModeInitial");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLooks), "SetBodyToRemoteMode")]
		private static void AfterRemoteMode(PlayerLooks __instance)
		{
			Handle(__instance, "SetBodyToRemoteMode");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLooks), "LoadOne")]
		private static void AfterLoadOne(PlayerLooks __instance)
		{
			Handle(__instance, "LoadOne");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLooks), "SetAllLooks")]
		private static void AfterSetAllLooks(PlayerLooks __instance)
		{
			Handle(__instance, "SetAllLooks");
		}

		private static void Handle(PlayerLooks looks, string method)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			bool flag = CharacterColour.Keep || CharacterColour.Cycling;
			if ((!flag && !Plugin.LogRepaints.Value) || _inside)
			{
				return;
			}
			try
			{
				bool flag2 = Ours(looks);
				Trace(method, looks, flag2);
				if (flag2 && flag)
				{
					_inside = true;
					CharacterColour.Reassert(looks);
				}
			}
			catch (Exception ex)
			{
				CharacterColour.Keep = false;
				CharacterColour.Cycling = false;
				CharacterColour.RepaintError = ex.Message;
				ManualLogSource log = Plugin.Log;
				bool flag3 = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(56, 1, ref flag3);
				if (flag3)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("stopped repainting after a failure inside a look patch: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogWarning(val);
			}
			finally
			{
				_inside = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerLips), "UpdateNoseVisuals")]
		private static void AfterNoseVisuals(PlayerLips __instance)
		{
			if (!CharacterColour.NoseColour.HasValue)
			{
				return;
			}
			try
			{
				if (Fired.Add("UpdateNoseVisuals") && Plugin.LogRepaints.Value)
				{
					Plugin.Log.LogInfo((object)"repaint: UpdateNoseVisuals fired — the nose can be coloured");
				}
				if (OursByCharacter(__instance))
				{
					CharacterColour.PaintNose(__instance);
				}
			}
			catch (Exception)
			{
			}
		}

		private static bool OursByCharacter(PlayerLips lips)
		{
			try
			{
				PlayerCharacter playerCharacter = lips.playerCharacter;
				PlayerCharacter val = CharacterColour.Mine();
				return (Object)(object)playerCharacter != (Object)null && (Object)(object)val != (Object)null && ((Object)playerCharacter).GetInstanceID() == ((Object)val).GetInstanceID();
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static void Trace(string method, PlayerLooks looks, bool ours)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.LogRepaints.Value)
			{
				return;
			}
			bool flag = Fired.Add(method);
			if (flag || ours)
			{
				string arg = "";
				string text;
				try
				{
					text = $"{looks.GetLookId((LookPart)0)}/" + $"{looks.GetLookId((LookPart)1)}/" + $"{looks.GetLookId((LookPart)2)}";
					arg = $", look type {looks.currentLookType}, hideLocalTorso {looks.hideLocalTorso}";
				}
				catch (Exception ex)
				{
					text = "unreadable (" + ex.GetType().Name + ")";
				}
				string text2 = method + " " + text;
				int frameCount = Time.frameCount;
				if (flag || frameCount != _lastFrame || !string.Equals(text2, _lastLine, StringComparison.Ordinal))
				{
					_lastLine = text2;
					_lastFrame = frameCount;
					Plugin.Log.LogInfo((object)("repaint: " + method + " on " + (ours ? "your character" : "someone else") + ", " + $"look ids now {text}{arg}, keep={CharacterColour.Keep} " + $"cycling={CharacterColour.Cycling}" + (flag ? "  (first time this fired)" : "")));
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerLooks), "SetColor")]
		private static void BeforeSetColor(Il2CppReferenceArray<LooksRenderer> looksRenderers, LookColor lookColor)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			if (!Plugin.LogRepaints.Value || CharacterColour.Painting)
			{
				return;
			}
			try
			{
				Color color = lookColor.color;
				int num = ((Il2CppArrayBase<LooksRenderer>)(object)looksRenderers)?.Length ?? 0;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 5, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("the game painted ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" renderers ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("rgb(");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(color.r, "0.##");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(color.g, "0.##");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(color.b, "0.##");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") on frame ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Time.frameCount);
				}
				log.LogInfo(val);
			}
			catch (Exception)
			{
			}
		}

		private static bool Ours(PlayerLooks looks)
		{
			if (looks == null)
			{
				return false;
			}
			try
			{
				PlayerCharacter val = CharacterColour.Mine();
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				PlayerLooks looks2 = val.looks;
				return looks2 != null && ((Il2CppObjectBase)looks2).Pointer == ((Il2CppObjectBase)looks).Pointer;
			}
			catch (Exception)
			{
				return false;
			}
		}
	}
	[BepInPlugin("deck.bigwalk.geardebug", "Gear Debug", "1.1.4")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "deck.bigwalk.geardebug";

		public static ManualLogSource Log;

		public static ConfigEntry<string> ToggleKeys;

		public static ConfigEntry<string> ReportKeys;

		public static ConfigEntry<bool> FreeCursor;

		public static ConfigEntry<int> ListLimit;

		public static ConfigEntry<float> Scale;

		public static ConfigEntry<float> RepaintInterval;

		public static ConfigEntry<float> CycleSeconds;

		public static ConfigEntry<float> CycleFps;

		public static ConfigEntry<float> CycleSaturation;

		public static ConfigEntry<float> CycleBrightness;

		public static ConfigEntry<bool> LogRepaints;

		public static ConfigEntry<bool> LogKeys;

		public static ConfigFile Cfg;

		public override void Load()
		{
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			Cfg = ((BasePlugin)this).Config;
			((BasePlugin)this).Config.SaveOnConfigSet = false;
			ToggleKeys = ((BasePlugin)this).Config.Bind<string>("Input", "ToggleKeys", "Quote,F9", "Comma-separated keys that open and close the panel. Several are listed because Steam swallows the function keys before the game sees them on some setups — whichever one arrives wins. Any KeyCode name works, including JoystickButton0..19 for a pad.");
			ReportKeys = ((BasePlugin)this).Config.Bind<string>("Input", "ReportKeys", "F10,Period", "Comma-separated keys that write the report to the log, with or without the panel open. The button for it sits at the bottom of the panel and can end up below the edge of the screen on a small display, which is exactly when a report is wanted.");
			FreeCursor = ((BasePlugin)this).Config.Bind<bool>("Input", "FreeCursor", true, "Release the mouse cursor while the panel is open, so the buttons can be clicked. The game still reads the mouse for looking around, so expect the camera to turn while you aim at a button.");
			ListLimit = ((BasePlugin)this).Config.Bind<int>("General", "ListLimit", 60, "How many props to show at once. Big Walk's world holds thousands, so type in the filter box to narrow it down rather than raising this.");
			Scale = ((BasePlugin)this).Config.Bind<float>("General", "Scale", 1.6f, "How much to magnify the panel. Unity's built-in debug UI draws at a fixed pixel size, which is unreadable on a handheld screen.");
			RepaintInterval = ((BasePlugin)this).Config.Bind<float>("General", "RepaintInterval", 1f, "Seconds between re-applying a free colour while 'Keep it painted' is on. This is now only a backstop: the repaints that matter — changing view, a body swap, the game's own refresh — are caught as they happen, so the colour no longer waits for this clock. Lower it only if a colour still comes back late; 0 means every frame.");
			CycleSeconds = ((BasePlugin)this).Config.Bind<float>("Colour", "CycleSeconds", 6f, "Seconds for one full turn around the hue wheel while 'Rainbow' is on. Lower is faster.");
			CycleFps = ((BasePlugin)this).Config.Bind<float>("Colour", "CycleFps", 30f, "How many times a second a running rainbow repaints. Each paint pushes a colour through every renderer on your body, so this is capped well under the frame rate — 30 already looks continuous. 0 means every frame.");
			CycleSaturation = ((BasePlugin)this).Config.Bind<float>("Colour", "CycleSaturation", 1f, "How strong the rainbow colours are, 0 grey to 1 vivid.");
			CycleBrightness = ((BasePlugin)this).Config.Bind<float>("Colour", "CycleBrightness", 1f, "How bright the rainbow colours are, 0 black to 1 full.");
			LogRepaints = ((BasePlugin)this).Config.Bind<bool>("Debug", "LogRepaints", false, "Log each time the game repaints your character, with the look ids it holds at that moment, and every colour the game writes. Off by default — it is chatty. Turn it on if a colour will not stay: it tells apart a colour that was painted over, one whose look id never changed, and a repaint hook that never fires, which need different fixes and look identical from inside the game.");
			LogKeys = ((BasePlugin)this).Config.Bind<bool>("Debug", "LogKeys", false, "Log every key and pad button press, to find one this machine actually delivers.");
			bool flag = default(bool);
			try
			{
				new Harmony("deck.bigwalk.geardebug").PatchAll(typeof(LooksPatches));
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(105, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not hook the game's repaints, so a free colour will only be ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("put back on the RepaintInterval clock: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			ClassInjector.RegisterTypeInIl2Cpp<GearDebugRuntime>();
			GameObject val2 = new GameObject("GearDebugRuntime")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val2);
			val2.AddComponent<GearDebugRuntime>();
			((BasePlugin)this).Config.Save();
			ManualLogSource log2 = Log;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(76, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Gear Debug loaded. Any of [");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ToggleKeys.Value);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] opens the panel, ");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ReportKeys.Value);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] writes a report without it.");
			}
			log2.LogInfo(val3);
		}
	}
	public class GearDebugRuntime : MonoBehaviour
	{
		private static KeyCode[] _allKeys;

		private bool _open;

		private bool _inputDead;

		private CursorLockMode _lockWas;

		private bool _cursorWas;

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

		private void Update()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			if (_inputDead)
			{
				return;
			}
			try
			{
				if (Plugin.LogKeys.Value)
				{
					LogPressedKeys();
				}
				if (KeyList.AnyDown(Plugin.ReportKeys.Value))
				{
					GearPanel.ReportNow();
				}
				if (KeyList.AnyDown(Plugin.ToggleKeys.Value))
				{
					_open = !_open;
					if (_open)
					{
						GearPanel.Refresh();
					}
					else
					{
						GearPanel.Closed();
					}
					Cursor(_open);
					Plugin.Log.LogInfo((object)(_open ? "panel open" : "panel closed"));
				}
			}
			catch (Exception ex)
			{
				_inputDead = true;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(62, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("keyboard input is unavailable, so the panel cannot be opened: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private void LateUpdate()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			if (!CharacterColour.Keep && !CharacterColour.Cycling)
			{
				return;
			}
			try
			{
				CharacterColour.Repaint(CharacterColour.Mine());
			}
			catch (Exception ex)
			{
				CharacterColour.Keep = false;
				CharacterColour.RepaintError = ex.Message;
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("stopped repainting after an unexpected failure: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogWarning(val);
			}
		}

		private unsafe static void LogPressedKeys()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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
			//IL_004b: 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_0049: Invalid comparison between Unknown and I4
			if (!Input.anyKeyDown)
			{
				return;
			}
			if (_allKeys == null)
			{
				_allKeys = (KeyCode[])Enum.GetValues(typeof(KeyCode));
			}
			string text = null;
			KeyCode[] allKeys = _allKeys;
			for (int i = 0; i < allKeys.Length; i++)
			{
				KeyCode val = allKeys[i];
				if ((int)val != 0 && ((int)val < 323 || (int)val > 329) && Input.GetKeyDown(val))
				{
					text = ((text == null) ? ((object)(*(KeyCode*)(&val))/*cast due to .constrained prefix*/).ToString() : (text + ", " + ((object)(*(KeyCode*)(&val))/*cast due to .constrained prefix*/).ToString()));
				}
			}
			if (text != null)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("key down: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
				}
				log.LogInfo(val2);
			}
		}

		private void Cursor(bool free)
		{
			//IL_0028: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.FreeCursor.Value)
			{
				if (free)
				{
					_lockWas = Cursor.lockState;
					_cursorWas = Cursor.visible;
				}
				else
				{
					Cursor.lockState = _lockWas;
					Cursor.visible = _cursorWas;
				}
			}
		}

		private void OnGUI()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			if (!_open)
			{
				return;
			}
			if (Plugin.FreeCursor.Value)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			try
			{
				GearPanel.Draw();
			}
			catch (Exception ex)
			{
				_open = false;
				Cursor(free: false);
				GearPanel.Closed();
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("the panel threw, closing it: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}
	}
	internal static class KeyList
	{
		private static readonly Dictionary<string, KeyCode[]> Parsed = new Dictionary<string, KeyCode[]>();

		public static bool AnyDown(string spec)
		{
			KeyCode[] array = Parse(spec);
			for (int i = 0; i < array.Length; i++)
			{
				if (Input.GetKeyDown(array[i]))
				{
					return true;
				}
			}
			return false;
		}

		private static KeyCode[] Parse(string spec)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0050: 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)
			if (spec == null)
			{
				spec = string.Empty;
			}
			if (Parsed.TryGetValue(spec, out var value))
			{
				return value;
			}
			List<KeyCode> list = new List<KeyCode>();
			string[] array = spec.Split(',');
			bool flag = default(bool);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length == 0)
				{
					continue;
				}
				if (Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result) && (int)result != 0)
				{
					list.Add(result);
					continue;
				}
				ManualLogSource log = Plugin.Log;