Decompiled source of Buddy Up v0.2.0

BuddyUp.dll

Decompiled 20 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cinemachine;
using EZhex1991.EZSoftBone;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OnTogetherMods.Shared;
using PurrNet;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BuddyUp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+202da9e6c60ed49a1022f1cbb21327bfd75b6c45")]
[assembly: AssemblyProduct("BuddyUp")]
[assembly: AssemblyTitle("BuddyUp")]
[assembly: AssemblyVersion("0.2.0.0")]
[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 OnTogetherMods.Shared
{
	internal static class PanelStack
	{
		private const string TableKey = "OnTogetherMods.PanelStack.Panels";

		private const string HiddenKey = "OnTogetherMods.PanelStack.Hidden";

		private const string IconBarKey = "OnTogetherMods.IconBar.Rect";

		private const float Margin = 20f;

		private const float FromRight = 0.15f;

		private const float Gap = 10f;

		private const int WorldScene = 2;

		public const int PhotoModeOrder = 0;

		public const int EmoteSyncOrder = 10;

		public const int TeleportSpotsOrder = 20;

		public const int SongPlayerOrder = 30;

		public const int TraceOverlayOrder = 40;

		public const int NameDesignerOrder = 50;

		public const int CardDesignerOrder = 55;

		public const int OutfitSlotsOrder = 60;

		public const int DeskSwarmOrder = 70;

		public const int BuddyUpOrder = 75;

		public const int SessionManagerOrder = 80;

		public const int FocusAnywhereOrder = 90;

		public const int CardTableOrder = 95;

		public const int DoomTogetherOrder = 100;

		public const string CanvasPrefix = "OnTogetherMods ";

		private static int _hiddenFrame = -1;

		private static bool _gameUIHidden;

		private static FieldRef<UIManager, HideUIState> _eyeState;

		private static bool _eyeStateMissing;

		public static float Width => (float)Screen.width * 1080f / (float)Screen.height;

		public static bool Hidden
		{
			get
			{
				if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Hidden") is int num) || Time.frameCount > num)
				{
					return GameUIHidden;
				}
				return true;
			}
		}

		public static bool GameUIHidden
		{
			get
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: 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_0040: Invalid comparison between Unknown and I4
				int frameCount = Time.frameCount;
				if (_hiddenFrame != frameCount)
				{
					_hiddenFrame = frameCount;
					_gameUIHidden = false;
					Scene activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).buildIndex == 2)
					{
						UIManager i = MonoSingleton<UIManager>.I;
						_gameUIHidden = (Object)(object)i != (Object)null && (int)EyeState(i) > 0;
					}
				}
				return _gameUIHidden;
			}
		}

		public static bool IsModCanvas(Canvas canvas)
		{
			Canvas val = canvas;
			Transform parent = ((Component)canvas).transform.parent;
			while ((Object)(object)parent != (Object)null)
			{
				Canvas component = ((Component)parent).GetComponent<Canvas>();
				val = (((Object)(object)component != (Object)null) ? component : val);
				parent = parent.parent;
			}
			return ((Object)((Component)val).gameObject).name.StartsWith("OnTogetherMods ", StringComparison.Ordinal);
		}

		private static HideUIState EyeState(UIManager ui)
		{
			if (_eyeState == null && !_eyeStateMissing)
			{
				try
				{
					_eyeState = AccessTools.FieldRefAccess<UIManager, HideUIState>("_hideUIState");
				}
				catch (Exception)
				{
					_eyeStateMissing = true;
				}
			}
			if (_eyeState != null)
			{
				return _eyeState.Invoke(ui);
			}
			return (HideUIState)0;
		}

		public static void HideForCapture()
		{
			AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Hidden", Time.frameCount + 1);
		}

		public static Rect Place(string id, int order, Vector2 size)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			Hashtable hashtable = Panels();
			int frameCount = Time.frameCount;
			hashtable[id] = new double[3] { order, size.y, frameCount };
			float width = Width;
			float num = Mathf.Max(20f, width * 0.85f - size.x);
			float num2 = Bottom(num + size.x, frameCount) - size.y;
			foreach (DictionaryEntry item in hashtable)
			{
				string text = (string)item.Key;
				double[] array = (double[])item.Value;
				bool flag = (double)frameCount - array[2] <= 2.0;
				bool flag2 = array[0] < (double)order || (array[0] == (double)order && string.CompareOrdinal(text, id) < 0);
				if (text != id && flag && flag2)
				{
					num2 -= (float)array[1] + 10f;
				}
			}
			return new Rect(num, num2, size.x, size.y);
		}

		private static float Bottom(float windowRight, int frame)
		{
			float num = 1060f;
			if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array && (double)frame - array[4] <= 2.0)
			{
				float num2 = 1080f / (float)Screen.height;
				if (array[0] * (double)num2 < (double)(windowRight + 10f))
				{
					num = Mathf.Min(num, (float)array[1] * num2 - 10f);
				}
			}
			return num;
		}

		public static Matrix4x4 Begin(out float width)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.height / 1080f;
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			width = (float)Screen.width / num;
			return matrix;
		}

		public static void End(Matrix4x4 previous)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GUI.matrix = previous;
		}

		public static GUIStyle MakeStyle(TextAnchor alignment)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				alignment = alignment,
				fontSize = 15,
				richText = true,
				wordWrap = false,
				padding = new RectOffset(12, 12, 10, 10)
			};
			val.normal.textColor = Color.white;
			return val;
		}

		private static Hashtable Panels()
		{
			Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.PanelStack.Panels") as Hashtable;
			if (hashtable == null)
			{
				hashtable = new Hashtable();
				AppDomain.CurrentDomain.SetData("OnTogetherMods.PanelStack.Panels", hashtable);
			}
			return hashtable;
		}
	}
	internal static class IconBar
	{
		public enum State
		{
			Plain,
			Open,
			On,
			Off
		}

		public enum Click
		{
			None,
			Left,
			Right
		}

		private sealed class Item
		{
			public string Id;

			public object[] Entry;

			public double[] Numbers;

			public double Order;

			public double Slot;

			public bool Tucked;

			public Rect Rect;
		}

		private struct TrayLayout
		{
			public Rect Box;

			public Vector2 Grid;

			public int Columns;

			public float GridHeight;
		}

		private enum Target
		{
			None,
			Icon,
			TrayButton,
			Arrange,
			Reset,
			Done,
			Background
		}

		private struct Metrics
		{
			public float Unit;

			public int Art;

			public int Button;

			public int Gap;

			public int Margin;
		}

		private static class Patches
		{
			private static Action<InputManager, bool> _setMouse0Down;

			private static Action<InputManager, bool> _setMouse1;

			private static Action<InputManager, bool> _setMouse1Up;

			private static FieldRef<QuadPainterGPU, Vector2> _previousUV;

			private static bool _leftOnBar;

			private static bool _rightOnBar;

			public static void Apply(Harmony harmony)
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Expected O, but got Unknown
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Expected O, but got Unknown
				_setMouse0Down = Setter("IsMouseButton0Down");
				_setMouse1 = Setter("IsMouseButton1");
				_setMouse1Up = Setter("IsMouseButton1Up");
				harmony.Patch((MethodBase)AccessTools.Method(typeof(InputManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "InputPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				_previousUV = AccessTools.FieldRefAccess<QuadPainterGPU, Vector2>("previousUV");
				harmony.Patch((MethodBase)AccessTools.Method(typeof(QuadPainterGPU), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "PaintPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}

			private static void InputPostfix(InputManager __instance)
			{
				bool mouseOver = MouseOver;
				if (Input.GetMouseButtonDown(0))
				{
					_leftOnBar = mouseOver;
				}
				if (Input.GetMouseButtonDown(1))
				{
					_rightOnBar = mouseOver;
				}
				if (mouseOver)
				{
					_setMouse0Down(__instance, arg2: false);
				}
				if (_rightOnBar)
				{
					_setMouse1(__instance, arg2: false);
					_setMouse1Up(__instance, arg2: false);
				}
				if (!Input.GetMouseButton(0))
				{
					_leftOnBar = false;
				}
				if (!Input.GetMouseButton(1))
				{
					_rightOnBar = false;
				}
			}

			private static bool PaintPrefix(QuadPainterGPU __instance)
			{
				if (__instance.IsActive && (_leftOnBar || MouseOver))
				{
					_previousUV.Invoke(__instance).x = -1f;
					return false;
				}
				return true;
			}

			private static Action<InputManager, bool> Setter(string property)
			{
				return (Action<InputManager, bool>)Delegate.CreateDelegate(typeof(Action<InputManager, bool>), AccessTools.PropertySetter(typeof(InputManager), property));
			}
		}

		public const int PhotoModeOrder = 0;

		public const int EmoteSyncOrder = 10;

		public const int TeleportSpotsOrder = 20;

		public const int NameDesignerOrder = 30;

		public const int CardDesignerOrder = 32;

		public const int OutfitSlotsOrder = 35;

		public const int DeskSnapOrder = 40;

		public const int DeskSwarmOrder = 45;

		public const int BuddyUpOrder = 47;

		public const int FocusAnywhereOrder = 50;

		public const int SongPlayerOrder = 60;

		public const int TraceOverlayOrder = 70;

		public const int ChatRangeOrder = 80;

		public const int DoomTogetherOrder = 85;

		public const int CardTableOrder = 87;

		public const int QuickHideOrder = 90;

		public const int SessionManagerOrder = 95;

		private const int HostVersion = 2;

		private const string RectKey = "OnTogetherMods.IconBar.Rect";

		private const string TableKey = "OnTogetherMods.IconBar.Icons";

		private const string HiddenKey = "OnTogetherMods.IconBar.HiddenUntil";

		private const string EntriesKey = "OnTogetherMods.IconBar.Entries";

		private const string HostKey = "OnTogetherMods.IconBar.Host";

		private const string AreasKey = "OnTogetherMods.IconBar.Areas";

		private const string PatchedKey = "OnTogetherMods.IconBar.Patched2";

		private const int EntryNumbers = 0;

		private const int EntryPixels = 1;

		private const int EntryName = 2;

		private const int EntryHint = 3;

		private const int EntrySize = 4;

		private const int NumOrder = 0;

		private const int NumState = 1;

		private const int NumKey = 2;

		private const int NumFrame = 3;

		private const int NumClick = 4;

		private const int NumSize = 5;

		private const string TrayId = "~IconTray";

		private const double TrayOrder = 1000.0;

		private const string SaveFile = "IconRow.json";

		private const int WorldScene = 2;

		private const int HostDepth = -150;

		private const int TrayColumns = 5;

		private static readonly string[] TrayPixels = new string[16]
		{
			"......KKKK......", "..KK.KWWWGK.KK..", ".KWGKKWGGGKKWgK.", ".KGGGGGGGGGGGgK.", "..KWGGGGGGGGgK..", ".KKWGGGGGGGGgKK.", "KWWGGGGKKGGGGGgK", "KWGGGGK..KGGGGgK", "KWGGGGK..KGGGGgK", "KGGGGGGKKGGGGggK",
			".KKGGGGGGGGGgKK.", "..KGGGGGGGGGgK..", ".KGGGGGGGGGGggK.", ".KGgKKGGGgKKggK.", "..KK.KggggK.KK..", "......KKKK......"
		};

		private static readonly GUIContent ArrangeText = new GUIContent("Arrange icons");

		private static readonly GUIContent ResetText = new GUIContent("Reset");

		private static readonly GUIContent DoneText = new GUIContent("Done");

		private static readonly GUIContent EmptyText = new GUIContent("Nothing tucked away yet");

		private static readonly GUIContent DropText = new GUIContent("Drop icons here to tuck them away");

		private static readonly GUIContent HintText = new GUIContent("Drag icons to move them.\nClick one to tuck it away or put it back.");

		private static int _hostChecked = -1;

		private static bool _hostFailed;

		private static readonly Dictionary<string, Item> Items = new Dictionary<string, Item>();

		private static readonly List<Item> Live = new List<Item>();

		private static readonly List<Item> Older = new List<Item>();

		private static readonly List<Item> Unlisted = new List<Item>();

		private static readonly List<Item> Row = new List<Item>();

		private static readonly List<Item> Tray = new List<Item>();

		private static readonly List<string> RowIds = new List<string>();

		private static readonly List<string> TrayIds = new List<string>();

		private static readonly List<string> ShownRow = new List<string>();

		private static readonly List<string> ShownTray = new List<string>();

		private static readonly List<double> Slots = new List<double>();

		private static readonly List<object> Stale = new List<object>();

		private static readonly List<double> Areas = new List<double>();

		private static readonly Comparison<Item> ByOrder = (Item a, Item b) => (a.Order == b.Order) ? string.CompareOrdinal(a.Id, b.Id) : a.Order.CompareTo(b.Order);

		private static readonly Comparison<Item> BySlot = (Item a, Item b) => (a.Slot == b.Slot) ? string.CompareOrdinal(a.Id, b.Id) : a.Slot.CompareTo(b.Slot);

		private static List<string> _savedRow = new List<string>();

		private static List<string> _savedTray = new List<string>();

		private static bool _loaded;

		private static int _frame = -1;

		private static bool _dirty;

		private static bool _inWorld;

		private static bool _shown;

		private static Metrics _m;

		private static Rect _rowRect;

		private static Rect _rowBox;

		private static Rect _trayButton;

		private static bool _trayShown;

		private static TrayLayout _tray;

		private static Rect _emptyRect;

		private static Rect _hintRect;

		private static Rect _arrangeButton;

		private static Rect _resetButton;

		private static Rect _doneButton;

		private static bool _trayOpen;

		private static bool _arranging;

		private static Target _pressed;

		private static Item _pressedItem;

		private static int _pressedButton;

		private static Item _held;

		private static bool _dragging;

		private static Vector2 _pressedAt;

		private static Vector2 _grab;

		private static bool _dropInTray;

		private static int _dropIndex = -1;

		private static float _rowLeftWith;

		private static int _rowCountWith;

		private static TrayLayout _trayWith;

		private static int _trayCountWithout;

		private static GameObject _blocker;

		private static RectTransform _rowArea;

		private static RectTransform _trayArea;

		private static readonly Dictionary<char, Color32> Palette = new Dictionary<char, Color32>
		{
			{
				'K',
				new Color32((byte)42, (byte)36, (byte)51, byte.MaxValue)
			},
			{
				'W',
				new Color32((byte)247, (byte)243, (byte)234, byte.MaxValue)
			},
			{
				'G',
				new Color32((byte)201, (byte)198, (byte)207, byte.MaxValue)
			},
			{
				'g',
				new Color32((byte)143, (byte)138, (byte)153, byte.MaxValue)
			},
			{
				'D',
				new Color32((byte)87, (byte)82, (byte)95, byte.MaxValue)
			},
			{
				'B',
				new Color32((byte)168, (byte)107, (byte)60, byte.MaxValue)
			},
			{
				'b',
				new Color32((byte)217, (byte)160, (byte)102, byte.MaxValue)
			},
			{
				'd',
				new Color32((byte)110, (byte)67, (byte)37, byte.MaxValue)
			},
			{
				'R',
				new Color32((byte)224, (byte)90, (byte)90, byte.MaxValue)
			},
			{
				'r',
				new Color32((byte)168, (byte)58, (byte)70, byte.MaxValue)
			},
			{
				'p',
				new Color32((byte)246, (byte)165, (byte)165, byte.MaxValue)
			},
			{
				'Y',
				new Color32((byte)245, (byte)208, (byte)97, byte.MaxValue)
			},
			{
				'y',
				new Color32((byte)201, (byte)150, (byte)50, byte.MaxValue)
			},
			{
				'O',
				new Color32((byte)232, (byte)146, (byte)74, byte.MaxValue)
			},
			{
				'L',
				new Color32((byte)159, (byte)214, (byte)245, byte.MaxValue)
			},
			{
				'U',
				new Color32((byte)74, (byte)143, (byte)217, byte.MaxValue)
			},
			{
				'u',
				new Color32((byte)47, (byte)90, (byte)158, byte.MaxValue)
			},
			{
				'N',
				new Color32((byte)116, (byte)192, (byte)105, byte.MaxValue)
			},
			{
				'n',
				new Color32((byte)63, (byte)138, (byte)74, byte.MaxValue)
			},
			{
				'P',
				new Color32((byte)246, (byte)207, (byte)174, byte.MaxValue)
			},
			{
				'V',
				new Color32((byte)154, (byte)114, (byte)214, byte.MaxValue)
			},
			{
				'v',
				new Color32((byte)105, (byte)72, (byte)160, byte.MaxValue)
			},
			{
				'S',
				new Color32((byte)233, (byte)139, (byte)181, byte.MaxValue)
			},
			{
				'H',
				new Color32((byte)60, (byte)48, (byte)56, byte.MaxValue)
			}
		};

		private static readonly Color32 ButtonFill = new Color32((byte)28, (byte)26, (byte)34, (byte)200);

		private static readonly Color32 ButtonEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)30);

		private static readonly Color32 HoverFill = new Color32((byte)48, (byte)45, (byte)58, (byte)225);

		private static readonly Color32 HoverEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)80);

		private static readonly Color32 OpenFill = new Color32((byte)70, (byte)64, (byte)88, (byte)235);

		private static readonly Color32 OpenEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)150);

		private static readonly Color32 PanelFill = new Color32((byte)36, (byte)34, (byte)45, (byte)235);

		private static readonly Color32 PanelEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)60);

		private static readonly Color32 SlotFill = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)16);

		private static readonly Color32 SlotEdge = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)110);

		private static readonly Color32 DotFill = new Color32((byte)140, (byte)220, (byte)120, byte.MaxValue);

		private static readonly Color32 DotEdge = new Color32((byte)20, (byte)40, (byte)20, byte.MaxValue);

		private static readonly Dictionary<string[], Texture2D[]> Icons = new Dictionary<string[], Texture2D[]>();

		private static Texture2D _buttonTexture;

		private static Texture2D _hoverTexture;

		private static Texture2D _openTexture;

		private static Texture2D _panelTexture;

		private static Texture2D _slotTexture;

		private static Texture2D _dotTexture;

		private static GUIStyle _buttonStyle;

		private static GUIStyle _textButtonStyle;

		private static GUIStyle _labelStyle;

		private static GUIStyle _tipStyle;

		private static int _builtFor;

		private static bool RowHidden
		{
			get
			{
				if (AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.HiddenUntil") is int num)
				{
					return Time.frameCount <= num;
				}
				return false;
			}
		}

		public static bool MouseOver
		{
			get
			{
				//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_0008: 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_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				Vector3 mousePosition = Input.mousePosition;
				Vector2 point = default(Vector2);
				((Vector2)(ref point))..ctor(mousePosition.x, (float)Screen.height - mousePosition.y);
				AppDomain currentDomain = AppDomain.CurrentDomain;
				int frameCount = Time.frameCount;
				if (currentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array && array.Length >= 6 && array[5] >= 0.5 && (double)frameCount - array[4] <= 2.0 && Inside(array, 0, point))
				{
					return true;
				}
				if (currentDomain.GetData("OnTogetherMods.IconBar.Areas") is double[] array2 && array2.Length >= 1 && (double)frameCount - array2[0] <= 2.0)
				{
					for (int i = 1; i + 3 < array2.Length; i += 4)
					{
						if (Inside(array2, i, point))
						{
							return true;
						}
					}
				}
				return false;
			}
		}

		private static string SavePath => Path.Combine(Paths.ConfigPath, "IconRow.json");

		public static Click Draw(string id, int order, string[] pixels, State state, string name, KeyCode key, string hint = null)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			EnsureHost();
			object[] array = Entry(id);
			double[] array2 = (double[])array[0];
			array2[0] = order;
			array2[1] = (double)state;
			array2[2] = (double)key;
			array2[3] = Time.frameCount;
			array[1] = pixels;
			array[2] = name;
			array[3] = hint;
			double num = array2[4];
			if (num == 0.0)
			{
				return Click.None;
			}
			array2[4] = 0.0;
			if (num != 1.0)
			{
				return Click.Right;
			}
			return Click.Left;
		}

		public static void HideRow()
		{
			AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.HiddenUntil", Time.frameCount + 1);
		}

		public static string KeyText(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if ((int)key != 0)
			{
				return $" ({key})";
			}
			return "";
		}

		private static bool Inside(double[] r, int i, Vector2 point)
		{
			//IL_0000: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if ((double)point.x >= r[i] && (double)point.x < r[i] + r[i + 2] && (double)point.y >= r[i + 1])
			{
				return (double)point.y < r[i + 1] + r[i + 3];
			}
			return false;
		}

		private static object[] Entry(string id)
		{
			Hashtable hashtable = Table("OnTogetherMods.IconBar.Entries");
			if (hashtable[id] is object[] array && array.Length >= 4 && array[0] is double[] array2 && array2.Length >= 5)
			{
				return array;
			}
			return (object[])(hashtable[id] = new object[4]
			{
				new double[5],
				null,
				null,
				null
			});
		}

		private static Hashtable Table(string key)
		{
			Hashtable hashtable = AppDomain.CurrentDomain.GetData(key) as Hashtable;
			if (hashtable == null)
			{
				hashtable = new Hashtable();
				AppDomain.CurrentDomain.SetData(key, hashtable);
			}
			return hashtable;
		}

		private static void EnsureHost()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			int frameCount = Time.frameCount;
			if (_hostChecked == frameCount || _hostFailed)
			{
				return;
			}
			_hostChecked = frameCount;
			AppDomain currentDomain = AppDomain.CurrentDomain;
			if (currentDomain.GetData("OnTogetherMods.IconBar.Host") is object[] array && array.Length >= 2)
			{
				object obj = array[1];
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if (val != null && (Object)(object)val != (Object)null)
				{
					if (array[0] is int num && num >= 2)
					{
						return;
					}
					Object.Destroy((Object)(object)val);
				}
			}
			GameObject val2 = null;
			try
			{
				val2 = new GameObject("OnTogetherMods IconBar");
				Object.DontDestroyOnLoad((Object)(object)val2);
				val2.AddComponent<IconBarHost>();
				currentDomain.SetData("OnTogetherMods.IconBar.Host", new object[2] { 2, val2 });
			}
			catch (Exception arg)
			{
				_hostFailed = true;
				if ((Object)(object)val2 != (Object)null)
				{
					Object.Destroy((Object)(object)val2);
				}
				Debug.LogError((object)$"[OnTogetherMods] Couldn't set up the icon row: {arg}");
			}
		}

		internal static void HostGUI(GameObject self)
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected I4, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Host") is object[] array) || array.Length < 2 || array[1] != self)
			{
				Object.Destroy((Object)(object)self);
				return;
			}
			GUI.depth = -150;
			int controlID = GUIUtility.GetControlID((FocusType)2);
			Event current = Event.current;
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.identity;
			try
			{
				Prepare();
				if (!_shown)
				{
					if (GUIUtility.hotControl == controlID)
					{
						GUIUtility.hotControl = 0;
					}
					return;
				}
				EventType typeForControl = current.GetTypeForControl(controlID);
				switch ((int)typeForControl)
				{
				default:
					if ((int)typeForControl == 7)
					{
						Paint(controlID, current.mousePosition);
					}
					break;
				case 0:
					MouseDown(controlID, current);
					break;
				case 3:
					if (GUIUtility.hotControl == controlID)
					{
						Drag(current.mousePosition);
						current.Use();
					}
					break;
				case 1:
					if (GUIUtility.hotControl == controlID)
					{
						GUIUtility.hotControl = 0;
						current.Use();
						MouseUp(current);
					}
					break;
				case 2:
					break;
				}
			}
			finally
			{
				GUI.matrix = matrix;
			}
		}

		internal static void HostDestroyed()
		{
			Close();
		}

		private static void Prepare()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			int frameCount = Time.frameCount;
			if (_frame != frameCount)
			{
				_frame = frameCount;
				_dirty = true;
				Scene activeScene = SceneManager.GetActiveScene();
				_inWorld = ((Scene)(ref activeScene)).buildIndex == 2;
				_shown = false;
				if (_inWorld && !PanelStack.Hidden && !RowHidden)
				{
					TaskManager i = MonoSingleton<TaskManager>.I;
					_shown = (Object)(object)i != (Object)null && ((int)i.LockState == 0 || (int)i.LockState == 5);
				}
			}
			if (!_dirty)
			{
				return;
			}
			_dirty = false;
			if (!_inWorld)
			{
				Close();
				UpdateBlocker(shown: false);
				return;
			}
			if (!_loaded)
			{
				Load();
			}
			_m = Measure();
			BuildStyles(_m);
			Gather(frameCount);
			if (Live.Count == 0)
			{
				_shown = false;
			}
			if (!_shown)
			{
				Close();
			}
			Arrange();
			Layout();
			if (Live.Count > 0)
			{
				Publish(frameCount);
			}
			UpdateBlocker(_shown);
		}

		private static void Close()
		{
			_trayOpen = false;
			_arranging = false;
			_held = null;
			_dragging = false;
			_dropIndex = -1;
			_pressed = Target.None;
			_pressedItem = null;
		}

		private static void Gather(int frame)
		{
			Live.Clear();
			Older.Clear();
			foreach (DictionaryEntry item3 in Table("OnTogetherMods.IconBar.Entries"))
			{
				if (item3.Key is string id && item3.Value is object[] array && array.Length >= 4 && array[0] is double[] array2 && array2.Length >= 5)
				{
					if ((double)frame - array2[3] > 2.0)
					{
						array2[4] = 0.0;
						continue;
					}
					Item item = ItemFor(id);
					item.Entry = array;
					item.Numbers = array2;
					item.Order = array2[0];
					Live.Add(item);
				}
			}
			foreach (DictionaryEntry item4 in Table("OnTogetherMods.IconBar.Icons"))
			{
				if (item4.Key is string id2 && item4.Value is double[] array3 && array3.Length == 2 && (double)frame - array3[1] <= 2.0 && Find(Live, id2) == null)
				{
					Item item2 = ItemFor(id2);
					item2.Entry = null;
					item2.Numbers = null;
					item2.Order = array3[0];
					item2.Slot = array3[0];
					item2.Tucked = false;
					Older.Add(item2);
				}
			}
		}

		private static Item ItemFor(string id)
		{
			if (!Items.TryGetValue(id, out var value))
			{
				value = new Item
				{
					Id = id
				};
				Items[id] = value;
			}
			return value;
		}

		private static Item Find(List<Item> items, string id)
		{
			for (int i = 0; i < items.Count; i++)
			{
				if (items[i].Id == id)
				{
					return items[i];
				}
			}
			return null;
		}

		private static void Arrange()
		{
			TrayIds.Clear();
			RowIds.Clear();
			foreach (string item3 in _savedTray)
			{
				if (Find(Live, item3) != null && !TrayIds.Contains(item3))
				{
					TrayIds.Add(item3);
				}
			}
			foreach (string item4 in _savedRow)
			{
				if (Find(Live, item4) != null && !TrayIds.Contains(item4) && !RowIds.Contains(item4))
				{
					RowIds.Add(item4);
				}
			}
			Unlisted.Clear();
			foreach (Item item5 in Live)
			{
				if (!RowIds.Contains(item5.Id) && !TrayIds.Contains(item5.Id))
				{
					Unlisted.Add(item5);
				}
			}
			Unlisted.Sort(ByOrder);
			foreach (Item item6 in Unlisted)
			{
				InsertInPlace(RowIds, item6);
			}
			ShownRow.Clear();
			ShownRow.AddRange(RowIds);
			ShownTray.Clear();
			ShownTray.AddRange(TrayIds);
			if (_held != null && _dragging && _dropIndex >= 0 && Find(Live, _held.Id) != null)
			{
				ShownRow.Remove(_held.Id);
				ShownTray.Remove(_held.Id);
				List<string> list = (_dropInTray ? ShownTray : ShownRow);
				list.Insert(Mathf.Clamp(_dropIndex, 0, list.Count), _held.Id);
			}
			Slots.Clear();
			foreach (string item7 in ShownRow)
			{
				Slots.Add(Find(Live, item7).Order);
			}
			Slots.Sort();
			Row.Clear();
			for (int i = 0; i < ShownRow.Count; i++)
			{
				Item item = Find(Live, ShownRow[i]);
				double num = Slots[i];
				if (i > 0 && num <= Row[i - 1].Slot)
				{
					num = Row[i - 1].Slot + 0.001;
				}
				item.Slot = num;
				item.Tucked = false;
				Row.Add(item);
			}
			Row.AddRange(Older);
			Row.Sort(BySlot);
			Tray.Clear();
			foreach (string item8 in ShownTray)
			{
				Item item2 = Find(Live, item8);
				item2.Tucked = true;
				Tray.Add(item2);
			}
		}

		private static void InsertInPlace(List<string> ids, Item item)
		{
			for (int i = 0; i < ids.Count; i++)
			{
				Item item2 = Find(Live, ids[i]);
				if (item2 != null && ByOrder(item, item2) < 0)
				{
					ids.Insert(i, item.Id);
					return;
				}
			}
			ids.Add(item.Id);
		}

		private static void Layout()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			Metrics m = _m;
			int num = Row.Count + 1;
			int num2 = num * m.Button + (num - 1) * m.Gap;
			float num3 = Screen.width - m.Margin - num2;
			float num4 = Screen.height - m.Margin - m.Button;
			_rowRect = new Rect(num3, num4, (float)num2, (float)m.Button);
			for (int i = 0; i < Row.Count; i++)
			{
				Row[i].Rect = new Rect(num3 + (float)(i * (m.Button + m.Gap)), num4, (float)m.Button, (float)m.Button);
			}
			_trayButton = new Rect(num3 + (float)(Row.Count * (m.Button + m.Gap)), num4, (float)m.Button, (float)m.Button);
			float num5 = Mathf.Max(2, Mathf.RoundToInt((float)m.Gap / 2f));
			_rowBox = new Rect(((Rect)(ref _rowRect)).x - num5, ((Rect)(ref _rowRect)).y - num5, ((Rect)(ref _rowRect)).width + 2f * num5, ((Rect)(ref _rowRect)).height + 2f * num5);
			_trayShown = _shown && (_trayOpen || _arranging);
			if (_trayShown)
			{
				_tray = LayoutTray(Tray.Count);
				for (int j = 0; j < Tray.Count; j++)
				{
					Tray[j].Rect = new Rect(_tray.Grid.x + (float)(j % _tray.Columns * (m.Button + m.Gap)), _tray.Grid.y + (float)(j / _tray.Columns * (m.Button + m.Gap)), (float)m.Button, (float)m.Button);
				}
				LayoutTrayText();
			}
			if (_held != null)
			{
				bool flag = !_held.Tucked;
				_rowCountWith = Row.Count - (flag ? 1 : 0) + 1;
				int num6 = _rowCountWith + 1;
				_rowLeftWith = Screen.width - m.Margin - (num6 * m.Button + (num6 - 1) * m.Gap);
				_trayCountWithout = Tray.Count - ((!flag) ? 1 : 0);
				_trayWith = LayoutTray(_trayCountWithout + 1);
			}
		}

		private static TrayLayout LayoutTray(int icons)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			Metrics m = _m;
			int num = (_arranging ? 5 : Mathf.Clamp(icons, 1, 5));
			int num2 = (icons + num - 1) / num;
			if (_arranging)
			{
				num2 = Mathf.Max(1, num2);
			}
			float num3 = num * m.Button + (num - 1) * m.Gap;
			float num4 = ((num2 > 0) ? (num2 * m.Button + (num2 - 1) * m.Gap) : 0);
			Vector2 val = TrayTextSize(icons);
			float num5 = Mathf.Ceil(Mathf.Max(num3, val.x));
			float num6 = num5 + (float)(2 * m.Gap);
			float num7 = Mathf.Ceil(num4 + (float)((num4 > 0f) ? m.Gap : 0) + val.y + (float)(2 * m.Gap));
			Rect box = default(Rect);
			((Rect)(ref box))..ctor(((Rect)(ref _trayButton)).xMax - num6, ((Rect)(ref _rowRect)).y - (float)m.Gap - num7, num6, num7);
			return new TrayLayout
			{
				Box = box,
				Grid = new Vector2(((Rect)(ref box)).x + (float)m.Gap + Mathf.Floor((num5 - num3) / 2f), ((Rect)(ref box)).y + (float)m.Gap),
				Columns = num,
				GridHeight = num4
			};
		}

		private static Vector2 TrayTextSize(int icons)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			Metrics m = _m;
			if (_arranging)
			{
				Vector2 val = _labelStyle.CalcSize(HintText);
				Vector2 val2 = _textButtonStyle.CalcSize(ResetText);
				Vector2 val3 = _textButtonStyle.CalcSize(DoneText);
				float num = Mathf.Max(val2.y, val3.y);
				float num2 = ((icons == 0) ? _labelStyle.CalcSize(DropText).x : 0f);
				return new Vector2(Mathf.Max(new float[3]
				{
					val.x,
					val2.x + (float)(3 * m.Gap) + val3.x,
					num2
				}), val.y + (float)m.Gap + num);
			}
			Vector2 val4 = _textButtonStyle.CalcSize(ArrangeText);
			if (icons == 0)
			{
				Vector2 val5 = _labelStyle.CalcSize(EmptyText);
				return new Vector2(Mathf.Max(val4.x, val5.x), val5.y + (float)m.Gap + val4.y);
			}
			return val4;
		}

		private static void LayoutTrayText()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			Metrics m = _m;
			Rect box = _tray.Box;
			float num = ((Rect)(ref box)).x + (float)m.Gap;
			float num2 = ((Rect)(ref box)).width - (float)(2 * m.Gap);
			float num3 = _tray.Grid.y + ((_tray.GridHeight > 0f) ? (_tray.GridHeight + (float)m.Gap) : 0f);
			_emptyRect = default(Rect);
			_hintRect = default(Rect);
			_arrangeButton = default(Rect);
			_resetButton = default(Rect);
			_doneButton = default(Rect);
			if (_arranging)
			{
				if (Tray.Count == 0)
				{
					_emptyRect = new Rect(num, _tray.Grid.y, num2, _tray.GridHeight);
				}
				Vector2 val = _labelStyle.CalcSize(HintText);
				_hintRect = new Rect(num, num3, num2, val.y);
				num3 += val.y + (float)m.Gap;
				Vector2 val2 = _textButtonStyle.CalcSize(ResetText);
				Vector2 val3 = _textButtonStyle.CalcSize(DoneText);
				_resetButton = new Rect(num, num3, val2.x, val2.y);
				_doneButton = new Rect(((Rect)(ref box)).xMax - (float)m.Gap - val3.x, num3, val3.x, val3.y);
			}
			else
			{
				if (Tray.Count == 0)
				{
					Vector2 val4 = _labelStyle.CalcSize(EmptyText);
					_emptyRect = new Rect(num, num3, num2, val4.y);
					num3 += val4.y + (float)m.Gap;
				}
				Vector2 val5 = _textButtonStyle.CalcSize(ArrangeText);
				_arrangeButton = new Rect(((Rect)(ref box)).xMax - (float)m.Gap - val5.x, num3, val5.x, val5.y);
			}
		}

		private static void Publish(int frame)
		{
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			AppDomain currentDomain = AppDomain.CurrentDomain;
			Hashtable hashtable = Table("OnTogetherMods.IconBar.Icons");
			foreach (Item item in Row)
			{
				if (item.Entry != null)
				{
					Put(hashtable, item.Id, item.Slot, frame);
				}
			}
			Put(hashtable, "~IconTray", 1000.0, frame);
			Stale.Clear();
			foreach (DictionaryEntry item2 in hashtable)
			{
				if (item2.Value is double[] array && array.Length >= 3 && item2.Key is string text && text != "~IconTray" && (Find(Row, text) == null || Find(Row, text).Entry == null))
				{
					Stale.Add(item2.Key);
				}
			}
			foreach (object item3 in Stale)
			{
				hashtable.Remove(item3);
			}
			currentDomain.SetData("OnTogetherMods.IconBar.Rect", new double[6]
			{
				((Rect)(ref _rowRect)).x,
				((Rect)(ref _rowRect)).y,
				((Rect)(ref _rowRect)).width,
				((Rect)(ref _rowRect)).height,
				frame,
				_shown ? 1 : 0
			});
			Areas.Clear();
			Areas.Add(frame);
			if (_trayShown)
			{
				AddArea(_tray.Box);
			}
			if (_shown && _arranging)
			{
				AddArea(_rowBox);
			}
			currentDomain.SetData("OnTogetherMods.IconBar.Areas", Areas.ToArray());
		}

		private static void Put(Hashtable table, string id, double slot, int frame)
		{
			if (table[id] is double[] array && array.Length >= 3)
			{
				array[0] = slot;
				array[1] = frame;
				return;
			}
			table[id] = new double[3] { slot, frame, 1.0 };
		}

		private static void AddArea(Rect rect)
		{
			Areas.Add(((Rect)(ref rect)).x);
			Areas.Add(((Rect)(ref rect)).y);
			Areas.Add(((Rect)(ref rect)).width);
			Areas.Add(((Rect)(ref rect)).height);
		}

		private static void MouseDown(int control, Event e)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (e.button != 0 && e.button != 1)
			{
				return;
			}
			Vector2 mousePosition = e.mousePosition;
			Item item;
			Target target = HitTest(mousePosition, out item);
			if (target == Target.None)
			{
				if (_trayOpen || _arranging)
				{
					_trayOpen = false;
					_arranging = false;
					_dirty = true;
				}
				return;
			}
			GUIUtility.hotControl = control;
			e.Use();
			_pressed = Target.None;
			_pressedItem = null;
			if (_arranging && target == Target.Icon)
			{
				if (e.button == 0)
				{
					_held = item;
					_dragging = false;
					_dropIndex = -1;
					_pressedAt = mousePosition;
					_grab = mousePosition - ((Rect)(ref item.Rect)).position;
				}
			}
			else
			{
				_pressed = target;
				_pressedItem = item;
				_pressedButton = e.button;
			}
		}

		private static void Drag(Vector2 mouse)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (_held == null)
			{
				return;
			}
			if (!_dragging)
			{
				float num = Mathf.Max(3f, 4f * _m.Unit);
				Vector2 val = mouse - _pressedAt;
				if (((Vector2)(ref val)).sqrMagnitude < num * num)
				{
					return;
				}
				_dragging = true;
				_dirty = true;
			}
			FindDrop(mouse, out var inTray, out var index);
			if (inTray != _dropInTray || index != _dropIndex)
			{
				_dropInTray = inTray;
				_dropIndex = index;
				_dirty = true;
			}
		}

		private static void FindDrop(Vector2 mouse, out bool inTray, out int index)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			Metrics m = _m;
			float num = m.Button + m.Gap;
			Rect box = _trayWith.Box;
			((Rect)(ref box))..ctor(((Rect)(ref box)).x - (float)m.Gap, ((Rect)(ref box)).y - (float)m.Gap, ((Rect)(ref box)).width + (float)(2 * m.Gap), ((Rect)(ref box)).height + (float)(2 * m.Gap));
			if (((Rect)(ref box)).Contains(mouse))
			{
				inTray = true;
				int num2 = Mathf.Clamp(Mathf.FloorToInt((mouse.x - _trayWith.Grid.x + (float)m.Gap / 2f) / num), 0, _trayWith.Columns - 1);
				int num3 = Mathf.Max(0, Mathf.FloorToInt((mouse.y - _trayWith.Grid.y + (float)m.Gap / 2f) / num));
				index = Mathf.Clamp(num3 * _trayWith.Columns + num2, 0, _trayCountWithout);
				return;
			}
			inTray = false;
			if (mouse.y >= ((Rect)(ref _rowRect)).y - (float)m.Button / 2f && mouse.x >= _rowLeftWith - (float)m.Button)
			{
				int place = Mathf.Clamp(Mathf.FloorToInt((mouse.x - _rowLeftWith + (float)m.Gap / 2f) / num), 0, _rowCountWith - 1);
				index = MovableBefore(place);
			}
			else
			{
				index = -1;
			}
		}

		private static int MovableBefore(int place)
		{
			int num = 0;
			int num2 = 0;
			foreach (Item item in Row)
			{
				if (item != _held)
				{
					if (num2++ >= place)
					{
						break;
					}
					if (item.Entry != null)
					{
						num++;
					}
				}
			}
			return num;
		}

		private static void MouseUp(Event e)
		{
			//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_009c: 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)
			Vector2 mousePosition = e.mousePosition;
			if (_held != null)
			{
				Item held = _held;
				bool dragging = _dragging;
				bool dropInTray = _dropInTray;
				int dropIndex = _dropIndex;
				_held = null;
				_dragging = false;
				_dropIndex = -1;
				_dirty = true;
				if (dragging)
				{
					if (dropIndex >= 0)
					{
						Move(held, dropInTray, dropIndex);
					}
				}
				else if (e.button == 0 && ((Rect)(ref held.Rect)).Contains(mousePosition))
				{
					Toggle(held);
				}
				return;
			}
			Target pressed = _pressed;
			Item pressedItem = _pressedItem;
			int pressedButton = _pressedButton;
			_pressed = Target.None;
			_pressedItem = null;
			if (pressed == Target.None || e.button != pressedButton || HitTest(mousePosition, out var item) != pressed || item != pressedItem)
			{
				return;
			}
			switch (pressed)
			{
			case Target.Icon:
				pressedItem.Numbers[4] = ((pressedButton == 0) ? 1 : 2);
				if (pressedItem.Tucked)
				{
					_trayOpen = false;
				}
				break;
			case Target.TrayButton:
				if (_arranging)
				{
					_arranging = false;
					_trayOpen = false;
				}
				else if (pressedButton == 1)
				{
					_arranging = true;
					_trayOpen = true;
				}
				else
				{
					_trayOpen = !_trayOpen;
				}
				break;
			case Target.Arrange:
				_arranging = true;
				_trayOpen = true;
				break;
			case Target.Done:
				_arranging = false;
				break;
			case Target.Reset:
				Reset();
				break;
			}
			_dirty = true;
		}

		private static Target HitTest(Vector2 mouse, out Item item)
		{
			//IL_00ab: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			item = null;
			if (_trayShown && ((Rect)(ref _tray.Box)).Contains(mouse))
			{
				if (_arranging)
				{
					if (((Rect)(ref _resetButton)).Contains(mouse))
					{
						return Target.Reset;
					}
					if (((Rect)(ref _doneButton)).Contains(mouse))
					{
						return Target.Done;
					}
				}
				else if (((Rect)(ref _arrangeButton)).Contains(mouse))
				{
					return Target.Arrange;
				}
				foreach (Item item2 in Tray)
				{
					if (item2 != _held && ((Rect)(ref item2.Rect)).Contains(mouse))
					{
						item = item2;
						return Target.Icon;
					}
				}
				return Target.Background;
			}
			if (((Rect)(ref _trayButton)).Contains(mouse))
			{
				return Target.TrayButton;
			}
			foreach (Item item3 in Row)
			{
				if (item3 != _held && ((Rect)(ref item3.Rect)).Contains(mouse))
				{
					if (item3.Entry == null)
					{
						return _arranging ? Target.Background : Target.None;
					}
					item = item3;
					return Target.Icon;
				}
			}
			if (_arranging && ((Rect)(ref _rowBox)).Contains(mouse))
			{
				return Target.Background;
			}
			return Target.None;
		}

		private static void Move(Item item, bool intoTray, int index)
		{
			List<string> list = new List<string>(RowIds);
			List<string> list2 = new List<string>(TrayIds);
			list.Remove(item.Id);
			list2.Remove(item.Id);
			List<string> list3 = (intoTray ? list2 : list);
			list3.Insert(Mathf.Clamp(index, 0, list3.Count), item.Id);
			Commit(list, list2);
		}

		private static void Toggle(Item item)
		{
			List<string> list = new List<string>(RowIds);
			List<string> list2 = new List<string>(TrayIds);
			if (list2.Remove(item.Id))
			{
				InsertInPlace(list, item);
			}
			else
			{
				list.Remove(item.Id);
				list2.Add(item.Id);
			}
			Commit(list, list2);
		}

		private static void Commit(List<string> row, List<string> tray)
		{
			_savedRow = KeepMissing(row, _savedRow, tray);
			_savedTray = KeepMissing(tray, _savedTray, row);
			Save();
			_dirty = true;
		}

		private static List<string> KeepMissing(List<string> shown, List<string> saved, List<string> other)
		{
			List<string> list = new List<string>(shown);
			for (int i = 0; i < saved.Count; i++)
			{
				string text = saved[i];
				if (list.Contains(text) || other.Contains(text) || Find(Live, text) != null)
				{
					continue;
				}
				int index = 0;
				for (int num = i - 1; num >= 0; num--)
				{
					int num2 = list.IndexOf(saved[num]);
					if (num2 >= 0)
					{
						index = num2 + 1;
						break;
					}
				}
				list.Insert(index, text);
			}
			return list;
		}

		private static void Reset()
		{
			_savedRow = new List<string>();
			_savedTray = new List<string>();
			string savePath = SavePath;
			try
			{
				if (File.Exists(savePath))
				{
					File.Delete(savePath);
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[OnTogetherMods] Couldn't delete " + savePath + ": " + ex.Message));
			}
			_dirty = true;
		}

		private static void Load()
		{
			_loaded = true;
			_savedRow = new List<string>();
			_savedTray = new List<string>();
			string savePath = SavePath;
			try
			{
				if (File.Exists(savePath))
				{
					JObject obj = JObject.Parse(File.ReadAllText(savePath));
					ReadIds(obj["Row"], _savedRow);
					ReadIds(obj["Tray"], _savedTray);
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[OnTogetherMods] Couldn't read " + savePath + ", so the icons are in their usual order: " + ex.Message));
			}
		}

		private static void ReadIds(JToken token, List<string> into)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			JArray val = (JArray)(object)((token is JArray) ? token : null);
			if (val == null)
			{
				return;
			}
			foreach (JToken item in val)
			{
				if ((int)item.Type == 8 && !into.Contains((string)item))
				{
					into.Add((string)item);
				}
			}
		}

		private static void Save()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0038: 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_0054: Expected O, but got Unknown
			//IL_0055: Expected O, but got Unknown
			string savePath = SavePath;
			try
			{
				JObject val = new JObject { ["Version"] = JToken.op_Implicit(1) };
				object[] array = _savedRow.ToArray();
				val["Row"] = (JToken)new JArray(array);
				array = _savedTray.ToArray();
				val["Tray"] = (JToken)new JArray(array);
				JObject val2 = val;
				string text = savePath + ".tmp";
				File.WriteAllText(text, ((JToken)val2).ToString((Formatting)1, Array.Empty<JsonConverter>()));
				if (File.Exists(savePath))
				{
					File.Delete(savePath);
				}
				File.Move(text, savePath);
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[OnTogetherMods] Couldn't save " + savePath + ": " + ex.Message));
			}
		}

		private static void Paint(int control, Vector2 mouse)
		{
			//IL_001f: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			Metrics m = _m;
			bool flag = GUIUtility.hotControl == 0;
			bool mine = GUIUtility.hotControl == control;
			if (_arranging)
			{
				PaintBox(_rowBox, _slotTexture);
			}
			foreach (Item item2 in Row)
			{
				if (item2.Entry != null)
				{
					PaintItem(item2, mouse, flag, mine, m);
				}
			}
			PaintTrayButton(mouse, flag, mine, m);
			if (_trayShown)
			{
				PaintBox(_tray.Box, _panelTexture);
				foreach (Item item3 in Tray)
				{
					PaintItem(item3, mouse, flag, mine, m);
				}
				if (((Rect)(ref _emptyRect)).width > 0f)
				{
					_labelStyle.Draw(_emptyRect, _arranging ? DropText : EmptyText, false, false, false, false);
				}
				if (_arranging)
				{
					_labelStyle.Draw(_hintRect, HintText, false, false, false, false);
					PaintTextButton(_resetButton, ResetText, Target.Reset, mouse, flag, mine);
					PaintTextButton(_doneButton, DoneText, Target.Done, mouse, flag, mine);
				}
				else
				{
					PaintTextButton(_arrangeButton, ArrangeText, Target.Arrange, mouse, flag, mine);
				}
			}
			if (_held != null && _dragging)
			{
				PaintIcon(new Rect(mouse.x - _grab.x, mouse.y - _grab.y, (float)m.Button, (float)m.Button), Pixels(_held), StateOf(_held), _openTexture, m);
				return;
			}
			Item item;
			Target target = HitTest(mouse, out item);
			if (target == Target.Icon && (flag || _pressedItem == item || _held == item))
			{
				DrawTooltip(item.Rect, m, ItemTooltip(item));
			}
			else if (target == Target.TrayButton && (flag || _pressed == Target.TrayButton))
			{
				DrawTooltip(_trayButton, m, TrayTooltip());
			}
		}

		private static void PaintItem(Item item, Vector2 mouse, bool idle, bool mine, Metrics m)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (item == _held && _dragging)
			{
				PaintBox(item.Rect, _slotTexture);
				return;
			}
			State state = StateOf(item);
			bool flag = mine && (_pressedItem == item || _held == item);
			bool flag2 = ((Rect)(ref item.Rect)).Contains(mouse) && (idle || flag);
			Texture2D back = ((state == State.Open || (flag && flag2)) ? _openTexture : (flag2 ? _hoverTexture : _buttonTexture));
			PaintIcon(item.Rect, Pixels(item), state, back, m);
		}

		private static void PaintTrayButton(Vector2 mouse, bool idle, bool mine, Metrics m)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			bool flag = mine && _pressed == Target.TrayButton;
			bool flag2 = ((Rect)(ref _trayButton)).Contains(mouse) && (idle || flag);
			Texture2D back = ((_trayShown || (flag && flag2)) ? _openTexture : (flag2 ? _hoverTexture : _buttonTexture));
			State state = State.Plain;
			foreach (Item item in Tray)
			{
				if (StateOf(item) == State.On)
				{
					state = State.On;
				}
			}
			PaintIcon(_trayButton, TrayPixels, state, back, m);
		}

		private static void PaintBox(Rect rect, Texture2D texture)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			_buttonStyle.normal.background = texture;
			_buttonStyle.Draw(rect, false, false, false, false);
		}

		private static void PaintIcon(Rect rect, string[] pixels, State state, Texture2D back, Metrics m)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			PaintBox(rect, back);
			if (pixels != null)
			{
				Texture2D[] array = IconTextures(pixels);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + (((Rect)(ref rect)).width - (float)m.Art) / 2f, ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - (float)m.Art) / 2f, (float)m.Art, (float)m.Art), (Texture)(object)((state == State.Off) ? array[1] : array[0]));
			}
			if (state == State.On)
			{
				float num = Mathf.Max(1, Mathf.RoundToInt(2f * m.Unit));
				float num2 = ((Texture)_dotTexture).width;
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - num - num2, ((Rect)(ref rect)).yMax - num - num2, num2, num2), (Texture)(object)_dotTexture);
			}
		}

		private static void PaintTextButton(Rect rect, GUIContent text, Target target, Vector2 mouse, bool idle, bool mine)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			bool flag = mine && _pressed == target;
			bool flag2 = ((Rect)(ref rect)).Contains(mouse) && (idle || flag);
			_textButtonStyle.normal.background = ((flag && flag2) ? _openTexture : (flag2 ? _hoverTexture : _buttonTexture));
			_textButtonStyle.Draw(rect, text, false, false, false, false);
		}

		private static string[] Pixels(Item item)
		{
			object[] entry = item.Entry;
			return ((entry != null) ? entry[1] : null) as string[];
		}

		private static State StateOf(Item item)
		{
			if (item.Numbers == null)
			{
				return State.Plain;
			}
			return (State)item.Numbers[1];
		}

		private static string ItemTooltip(Item item)
		{
			string text = (item.Entry[2] as string) ?? item.Id;
			if (_arranging)
			{
				return text + (item.Tucked ? "\nClick to put it back in the row, or drag it" : "\nClick to tuck it away, or drag it");
			}
			return Tooltip(StateOf(item), text, (KeyCode)(int)item.Numbers[2], item.Entry[3] as string);
		}

		private static string TrayTooltip()
		{
			if (_arranging)
			{
				return "Icon tray\nClick: done arranging";
			}
			string text = ((Tray.Count > 0) ? $": {Tray.Count} tucked away" : "");
			return "Icon tray" + text + "\nRight-click: arrange the icons";
		}

		private static string Tooltip(State state, string name, KeyCode key, string hint)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			string text = name + KeyText(key);
			switch (state)
			{
			case State.On:
				text += ": on";
				break;
			case State.Off:
				text += ": off";
				break;
			}
			if (hint == null)
			{
				return text;
			}
			return text + "\n" + hint;
		}

		private static void DrawTooltip(Rect icon, Metrics m, string text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			GUIContent val = new GUIContent(text);
			Vector2 val2 = _tipStyle.CalcSize(val);
			float num = Mathf.Clamp(((Rect)(ref icon)).center.x - val2.x / 2f, (float)m.Margin, Mathf.Max((float)m.Margin, (float)(Screen.width - m.Margin) - val2.x));
			float num2 = Mathf.Max(0f, ((Rect)(ref icon)).y - (float)m.Gap - val2.y);
			_tipStyle.Draw(new Rect(Mathf.Round(num), Mathf.Round(num2), val2.x, val2.y), val, false, false, false, false);
		}

		private static Metrics Measure()
		{
			float num = (float)Screen.height / 1080f;
			int num2 = Mathf.Max(1, Mathf.RoundToInt(2f * num));
			int num3 = Mathf.Max(2, Mathf.RoundToInt(4f * num));
			return new Metrics
			{
				Unit = num,
				Art = 16 * num2,
				Button = 16 * num2 + 2 * num3,
				Gap = Mathf.Max(2, Mathf.RoundToInt(6f * num)),
				Margin = Mathf.RoundToInt(20f * num)
			};
		}

		private static void UpdateBlocker(bool shown)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_blocker == (Object)null)
			{
				if (!shown || !(AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Host") is object[] array) || array.Length < 2)
				{
					return;
				}
				object obj = array[1];
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if (val == null || (Object)(object)val == (Object)null)
				{
					return;
				}
				_blocker = CreateBlocker(val.transform);
			}
			if (shown)
			{
				PlaceArea(_rowArea, _arranging ? _rowBox : _rowRect, on: true);
				PlaceArea(_trayArea, _tray.Box, _trayShown);
			}
			if (_blocker.activeSelf != shown)
			{
				_blocker.SetActive(shown);
			}
		}

		private static void PlaceArea(RectTransform area, Rect rect, bool on)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)area).gameObject.activeSelf != on)
			{
				((Component)area).gameObject.SetActive(on);
			}
			if (on)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(((Rect)(ref rect)).x, (float)Screen.height - ((Rect)(ref rect)).yMax);
				if (area.anchoredPosition != val)
				{
					area.anchoredPosition = val;
				}
				if (area.sizeDelta != ((Rect)(ref rect)).size)
				{
					area.sizeDelta = ((Rect)(ref rect)).size;
				}
			}
		}

		private static GameObject CreateBlocker(Transform parent)
		{
			//IL_0005: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0067: Expected O, but got Unknown
			GameObject val = new GameObject("OnTogetherMods IconBar ClickBlocker");
			val.transform.SetParent(parent, false);
			Canvas obj = val.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32767;
			val.AddComponent<GraphicRaycaster>();
			_rowArea = AddArea(val.transform, "Row");
			_trayArea = AddArea(val.transform, "Tray");
			val.SetActive(false);
			return val;
		}

		private static RectTransform AddArea(Transform parent, string name)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			((Graphic)val.GetComponent<Image>()).color = Color.clear;
			RectTransform val2 = (RectTransform)val.transform;
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.zero;
			val2.pivot = Vector2.zero;
			return val2;
		}

		public static void Patch()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			AppDomain currentDomain = AppDomain.CurrentDomain;
			if (currentDomain.GetData("OnTogetherMods.IconBar.Patched2") != null)
			{
				return;
			}
			currentDomain.SetData("OnTogetherMods.IconBar.Patched2", true);
			try
			{
				Patches.Apply(new Harmony("nelphei.ontogether.iconbar.v2"));
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[OnTogetherMods] Icon bar patches failed, so clicks on it may reach the game: {arg}");
			}
		}

		private static Texture2D[] IconTextures(string[] pixels)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (Icons.TryGetValue(pixels, out var value) && (Object)(object)value[0] != (Object)null && (Object)(object)value[1] != (Object)null)
			{
				return value;
			}
			Color32[] array = (Color32[])(object)new Color32[256];
			Color32[] array2 = (Color32[])(object)new Color32[256];
			for (int i = 0; i < 16; i++)
			{
				string text = ((i < pixels.Length) ? pixels[i] : "");
				for (int j = 0; j < 16; j++)
				{
					char key = ((text != null && j < text.Length) ? text[j] : '.');
					Color32 value2;
					Color32 val = (Color32)(Palette.TryGetValue(key, out value2) ? value2 : new Color32((byte)0, (byte)0, (byte)0, (byte)0));
					int num = (15 - i) * 16 + j;
					array[num] = val;
					byte b = (byte)Mathf.RoundToInt(0.3f * (float)(int)val.r + 0.59f * (float)(int)val.g + 0.11f * (float)(int)val.b);
					array2[num] = new Color32(b, b, b, (byte)((float)(int)val.a * 0.45f));
				}
			}
			value = (Texture2D[])(object)new Texture2D[2]
			{
				NewTexture(16, 16, array, (FilterMode)0),
				NewTexture(16, 16, array2, (FilterMode)0)
			};
			Icons[pixels] = value;
			return value;
		}

		private static void BuildStyles(Metrics m)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_018f: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: 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_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Expected O, but got Unknown
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			if (_builtFor != Screen.height || _buttonStyle == null || !((Object)(object)_buttonTexture != (Object)null) || !((Object)(object)_dotTexture != (Object)null) || !((Object)(object)_panelTexture != (Object)null) || !((Object)(object)_slotTexture != (Object)null))
			{
				_builtFor = Screen.height;
				int num = Mathf.Max(2, Mathf.RoundToInt(6f * m.Unit));
				Destroy(_buttonTexture);
				Destroy(_hoverTexture);
				Destroy(_openTexture);
				Destroy(_panelTexture);
				Destroy(_slotTexture);
				Destroy(_dotTexture);
				_buttonTexture = RoundedBox(num, ButtonFill, ButtonEdge);
				_hoverTexture = RoundedBox(num, HoverFill, HoverEdge);
				_openTexture = RoundedBox(num, OpenFill, OpenEdge);
				_panelTexture = RoundedBox(num, PanelFill, PanelEdge);
				_slotTexture = RoundedBox(num, SlotFill, SlotEdge);
				int num2 = Mathf.Max(2, Mathf.RoundToInt(3f * m.Unit));
				_dotTexture = RoundedBox(num2, DotFill, DotEdge, 2 * num2);
				int num3 = num + 1;
				int fontSize = Mathf.Max(8, Mathf.RoundToInt(15f * m.Unit));
				int fontSize2 = Mathf.Max(8, Mathf.RoundToInt(14f * m.Unit));
				_buttonStyle = new GUIStyle
				{
					border = new RectOffset(num3, num3, num3, num3)
				};
				_textButtonStyle = new GUIStyle
				{
					border = new RectOffset(num3, num3, num3, num3),
					padding = new RectOffset(Mathf.RoundToInt(12f * m.Unit), Mathf.RoundToInt(12f * m.Unit), Mathf.RoundToInt(5f * m.Unit), Mathf.RoundToInt(5f * m.Unit)),
					fontSize = fontSize2,
					alignment = (TextAnchor)4,
					wordWrap = false,
					richText = false
				};
				_textButtonStyle.normal.textColor = Color.white;
				_labelStyle = new GUIStyle
				{
					fontSize = fontSize2,
					alignment = (TextAnchor)4,
					wordWrap = false,
					richText = false
				};
				_labelStyle.normal.textColor = new Color(1f, 1f, 1f, 0.8f);
				_tipStyle = new GUIStyle
				{
					border = new RectOffset(num3, num3, num3, num3),
					padding = new RectOffset(Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(10f * m.Unit), Mathf.RoundToInt(6f * m.Unit), Mathf.RoundToInt(6f * m.Unit)),
					fontSize = fontSize,
					alignment = (TextAnchor)3,
					wordWrap = false,
					richText = false
				};
				_tipStyle.normal.background = _hoverTexture;
				_tipStyle.normal.textColor = Color.white;
			}
		}

		private static Texture2D RoundedBox(int radius, Color32 fill, Color32 edge, int size = 0)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (size <= 0)
			{
				size = 2 * radius + 4;
			}
			Color32[] array = (Color32[])(object)new Color32[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = (float)j + 0.5f;
					float num2 = (float)i + 0.5f;
					float num3 = Mathf.Max(Mathf.Max((float)radius - num, num - (float)(size - radius)), 0f);
					float num4 = Mathf.Max(Mathf.Max((float)radius - num2, num2 - (float)(size - radius)), 0f);
					float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4) - (float)radius;
					float num6 = Mathf.Clamp01(0.5f - num5);
					Color val = Color.Lerp(Color32.op_Implicit(fill), Color32.op_Implicit(edge), Mathf.Clamp01(num5 + 1.5f));
					val.a *= num6;
					array[i * size + j] = Color32.op_Implicit(val);
				}
			}
			return NewTexture(size, size, array, (FilterMode)1);
		}

		private static Texture2D NewTexture(int width, int height, Color32[] pixels, FilterMode filter)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0010: 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_001f: 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_002f: Expected O, but got Unknown
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false)
			{
				filterMode = filter,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
			val.SetPixels32(pixels);
			val.Apply(false, true);
			return val;
		}

		private static void Destroy(Texture2D texture)
		{
			if ((Object)(object)texture != (Object)null)
			{
				Object.Destroy((Object)(object)texture);
			}
		}
	}
	internal sealed class IconBarHost : MonoBehaviour
	{
		private void OnGUI()
		{
			IconBar.HostGUI(((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			IconBar.HostDestroyed();
		}
	}
	internal sealed class ClickBlocker
	{
		private readonly GameObject _root;

		private readonly RectTransform _area;

		public ClickBlocker(string name)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject(name);
			Object.DontDestroyOnLoad((Object)(object)_root);
			Canvas obj = _root.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32767;
			_root.AddComponent<GraphicRaycaster>();
			GameObject val = new GameObject("Area", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(_root.transform, false);
			((Graphic)val.GetComponent<Image>()).color = Color.clear;
			_area = (RectTransform)val.transform;
			_area.anchorMin = Vector2.zero;
			_area.anchorMax = Vector2.zero;
			_area.pivot = Vector2.zero;
			_root.SetActive(false);
		}

		public void Update(bool shown, Rect screenRect)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_root == (Object)null))
			{
				if (shown)
				{
					_area.anchoredPosition = new Vector2(((Rect)(ref screenRect)).x, (float)Screen.height - ((Rect)(ref screenRect)).yMax);
					_area.sizeDelta = ((Rect)(ref screenRect)).size;
				}
				if (_root.activeSelf != shown)
				{
					_root.SetActive(shown);
				}
			}
		}

		public void Destroy()
		{
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
		}

		public static bool MouseIn(Rect screenRect)
		{
			//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_0008: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 mousePosition = Input.mousePosition;
			return ((Rect)(ref screenRect)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y));
		}
	}
	internal sealed class TextBox
	{
		public const float FontSize = 18f;

		private static readonly RectOffset Padding = new RectOffset(12, 12, 10, 10);

		private static Sprite _boxSprite;

		private static bool _lookedForBox;

		private readonly string _name;

		private readonly TextAlignmentOptions _alignment;

		private GameObject _root;

		private RectTransform _box;

		private TextMeshProUGUI _text;

		private int _drawnFrame = -100;

		private string _measured;

		private TMP_FontAsset _measuredFont;

		private Vector2 _measuredSize;

		public TMP_FontAsset Font { get; set; }

		public TextBox(string name, TextAlignmentOptions alignment)
		{
			//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)
			_name = name;
			_alignment = alignment;
		}

		public Vector2 Measure(string text)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			Prepare();
			if (text != _measured || (Object)(object)((TMP_Text)_text).font != (Object)(object)_measuredFont)
			{
				Vector2 preferredValues = ((TMP_Text)_text).GetPreferredValues(text);
				_measuredSize = new Vector2(Mathf.Ceil(preferredValues.x) + (float)Padding.horizontal, Mathf.Ceil(preferredValues.y) + (float)Padding.vertical);
				_measured = text;
				_measuredFont = ((TMP_Text)_text).font;
			}
			return _measuredSize;
		}

		public void Draw(Rect rect, string text)
		{
			//IL_003a: 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)
			Prepare();
			if (((TMP_Text)_text).text != text)
			{
				((TMP_Text)_text).text = text;
			}
			_box.anchoredPosition = new Vector2(((Rect)(ref rect)).x, 0f - ((Rect)(ref rect)).y);
			_box.sizeDelta = ((Rect)(ref rect)).size;
			_drawnFrame = Time.frameCount;
		}

		public void LateUpdate()
		{
			if (!((Object)(object)_root == (Object)null))
			{
				bool flag = Time.frameCount - _drawnFrame <= 1 && !PanelStack.Hidden;
				if (_root.activeSelf != flag)
				{
					_root.SetActive(flag);
				}
			}
		}

		public void Destroy()
		{
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
		}

		private void Prepare()
		{
			if ((Object)(object)_root == (Object)null)
			{
				Build();
			}
			TMP_FontAsset val = (((Object)(object)Font != (Object)null) ? Font : PlayerNames.NameTagFont());
			if ((Object)(object)val != (Object)null && (Object)(object)((TMP_Text)_text).font != (Object)(object)val)
			{
				((TMP_Text)_text).font = val;
			}
			if (!_root.activeSelf && !PanelStack.Hidden)
			{
				_root.SetActive(true);
			}
		}

		private void Build()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject("OnTogetherMods " + _name);
			Object.DontDestroyOnLoad((Object)(object)_root);
			Canvas obj = _root.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32766;
			CanvasScaler obj2 = _root.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.screenMatchMode = (ScreenMatchMode)0;
			obj2.matchWidthOrHeight = 1f;
			GameObject val = new GameObject("Box", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(_root.transform, false);
			_box = (RectTransform)val.transform;
			RectTransform box = _box;
			RectTransform box2 = _box;
			RectTransform box3 = _box;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, 1f);
			box3.pivot = val2;
			Vector2 anchorMin = (box2.anchorMax = val2);
			box.anchorMin = anchorMin;
			Image component = val.GetComponent<Image>();
			((Graphic)component).raycastTarget = false;
			Sprite val4 = BoxSprite();
			if ((Object)(object)val4 != (Object)null)
			{
				component.sprite = val4;
				component.type = (Type)1;
			}
			else
			{
				((Graphic)component).color = new Color(0f, 0f, 0f, 0.65f);
			}
			GameObject val5 = new GameObject("Text", new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer)
			});
			val5.transform.SetParent(val.transform, false);
			RectTransform val6 = (RectTransform)val5.transform;
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = Vector2.one;
			val6.offsetMin = new Vector2((float)Padding.left, (float)Padding.bottom);
			val6.offsetMax = new Vector2((float)(-Padding.right), (float)(-Padding.top));
			_text = val5.AddComponent<TextMeshProUGUI>();
			((Graphic)_text).raycastTarget = false;
			((TMP_Text)_text).richText = true;
			((TMP_Text)_text).fontSize = 18f;
			((Graphic)_text).color = Color.white;
			((TMP_Text)_text).alignment = _alignment;
			((TMP_Text)_text).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)_text).overflowMode = (TextOverflowModes)0;
			_root.SetActive(false);
		}

		private static Sprite BoxSprite()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (!_lookedForBox)
			{
				_lookedForBox = true;
				GUIStyle box = GUI.skin.box;
				Texture2D background = box.normal.background;
				if ((Object)(object)background != (Object)null)
				{
					RectOffset border = box.border;
					_boxSprite = Sprite.Create(background, new Rect(0f, 0f, (float)((Texture)background).width, (float)((Texture)background).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)border.left, (float)border.bottom, (float)border.right, (float)border.top));
				}
			}
			return _boxSprite;
		}
	}
	internal static class PlayerNames
	{
		private static readonly HashSet<string> Closable = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
		{
			"color", "b", "i", "u", "s", "size", "font", "font-weight", "material", "mark",
			"gradient", "cspace", "mspace", "voffset", "alpha", "indent", "line-height", "line-indent", "align", "rotate",
			"lowercase", "uppercase", "allcaps", "smallcaps", "sup", "sub", "width", "margin", "nobr", "link",
			"style", "noparse"
		};

		private static readonly Regex Tag = new Regex("<(/?)(#|[A-Za-z][\\w-]*)[^<>]*>");

		private static TMP_FontAsset _font;

		private static float _nextFontLookup;

		public static string Of(PlayerController player)
		{
			string text = (((Object)(object)player != (Object)null && (Object)(object)player.PlayerNameText != (Object)null) ? ((TMP_Text)player.PlayerNameText).text : null);
			if (!string.IsNullOrWhiteSpace(text))
			{
				return ForText(text.Trim());
			}
			return null;
		}

		public static string Plain(string name)
		{
			return name.Replace("<", "‹");
		}

		public static string WithoutTags(string name)
		{
			return Tag.Replace(name, "");
		}

		public static string ForText(string name)
		{
			List<string> list = new List<string>();
			bool flag = false;
			foreach (Match item in Tag.Matches(name))
			{
				string text = ((item.Groups[2].Value == "#") ? "color" : item.Groups[2].Value.ToLowerInvariant());
				bool flag2 = item.Groups[1].Value == "/";
				if (!Closable.Contains(text) || (flag && (!flag2 || !(text == "noparse"))))
				{
					continue;
				}
				if (flag2)
				{
					int num = list.LastIndexOf(text);
					if (num >= 0)
					{
						list.RemoveAt(num);
					}
				}
				else
				{
					list.Add(text);
				}
				flag = list.Contains("noparse");
			}
			StringBuilder stringBuilder = new StringBuilder(name);
			for (int num2 = list.Count - 1; num2 >= 0; num2--)
			{
				stringBuilder.Append("</").Append(list[num2]).Append('>');
			}
			return stringBuilder.ToString();
		}

		public static TMP_FontAsset NameTagFont()
		{
			if ((Object)(object)_font == (Object)null && Time.unscaledTime >= _nextFontLookup)
			{
				_nextFontLookup = Time.unscaledTime + 1f;
				PlayerController val = Object.FindAnyObjectByType<PlayerController>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.PlayerNameText != (Object)null)
				{
					_font = ((TMP_Text)val.PlayerNameText).font;
				}
			}
			return _font;
		}
	}
}
namespace BuddyUp
{
	internal static class AreaExits
	{
		public static HashSet<Collider> At(PlayerFocusController me, Vector3 position)
		{
			//IL_001f: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Collider> hashSet = new HashSet<Collider>();
			CharacterController component = ((Component)me).GetComponent<CharacterController>();
			if ((Object)(object)component == (Object)null)
			{
				return hashSet;
			}
			float radius = component.radius;
			Vector3 val = position + component.center;
			float num = Mathf.Max(0f, component.height / 2f - radius);
			Collider[] array = Physics.OverlapCapsule(val + Vector3.up * num, val - Vector3.up * num, radius, -1, (QueryTriggerInteraction)2);
			foreach (Collider val2 in array)
			{
				if (val2.isTrigger && (Object)(object)((Component)val2).GetComponentInParent<PlayerController>() == (Object)null)
				{
					hashSet.Add(val2);
				}
			}
			return hashSet;
		}

		public static void LeaveOld(PlayerFocusController me, HashSet<Collider> before)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (before == null || before.Count == 0)
			{
				return;
			}
			HashSet<Collider> hashSet =