Decompiled source of Desk Snap v0.2.1

DeskSnap.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 EZhex1991.EZSoftBone;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OnTogetherMods.Shared;
using PurrNet;
using TMPro;
using UnityEngine;
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("DeskSnap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1+622bd7ccbb267719684ff770ce18e1834dc51b45")]
[assembly: AssemblyProduct("DeskSnap")]
[assembly: AssemblyTitle("DeskSnap")]
[assembly: AssemblyVersion("0.2.1.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 string CanvasPrefix = "OnTogetherMods ";

		private static int _deskFrame = -1;

		private static bool _desk;

		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 InDeskMode;
				}
				return true;
			}
		}

		public static bool InDeskMode
		{
			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 (_deskFrame != frameCount)
				{
					_deskFrame = frameCount;
					_desk = false;
					Scene activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).buildIndex == 2)
					{
						OverlayManager i = MonoSingleton<OverlayManager>.I;
						_desk = (Object)(object)i != (Object)null && (int)i.ResolutionMode == 3;
					}
				}
				return _desk;
			}
		}

		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);
		}

		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 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 DeskSnapOrder = 40;

		public const int FocusAnywhereOrder = 50;

		public const int SongPlayerOrder = 60;

		public const int TraceOverlayOrder = 70;

		public const int ChatRangeOrder = 80;

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

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

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

		private const string BlockerKey = "OnTogetherMods.IconBar.Blocker";

		private const string BlockerFrameKey = "OnTogetherMods.IconBar.BlockerFrame";

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

		private const int WorldScene = 2;

		private const int TooltipDepth = -100;

		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 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 _dotTexture;

		private static GUIStyle _buttonStyle;

		private static GUIStyle _tipStyle;

		private static int _builtFor;

		private static int _cachedFrame = -1;

		private static bool _inWorld;

		private static bool _visible;

		private static int _pressedButton;

		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_003d: 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_005c: 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_006f: Unknown result type (might be due to invalid IL or missing references)
				if (!(AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || array[5] < 0.5 || (double)Time.frameCount - array[4] > 2.0)
				{
					return false;
				}
				Vector3 mousePosition = Input.mousePosition;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor((float)array[0], (float)array[1], (float)array[2], (float)array[3]);
				return ((Rect)(ref val)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y));
			}
		}

		public static Click Draw(string id, int order, string[] pixels, State state, string name, KeyCode key, string hint = null)
		{
			//IL_0086: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			int controlID = GUIUtility.GetControlID((FocusType)2);
			Event current = Event.current;
			Refresh();
			if (!_inWorld)
			{
				Hide(controlID, current);
				UpdateBlocker(shown: false, default(Rect));
				return Click.None;
			}
			Rect bar;
			Metrics m;
			Rect icon = Place(id, order, out bar, out m);
			Share(bar);
			UpdateBlocker(_visible, bar);
			if (!_visible)
			{
				Hide(controlID, current);
				return Click.None;
			}
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.identity;
			try
			{
				return Handle(controlID, current, icon, m, pixels, state, name, key, hint);
			}
			finally
			{
				GUI.matrix = matrix;
			}
		}

		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 Click Handle(int control, Event e, Rect icon, Metrics m, string[] pixels, State state, string name, KeyCode key, string hint)
		{
			//IL_0003: 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_0015: 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_002c: Expected I4, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ((Rect)(ref icon)).Contains(e.mousePosition);
			EventType typeForControl = e.GetTypeForControl(control);
			switch ((int)typeForControl)
			{
			default:
			{
				if ((int)typeForControl != 7)
				{
					break;
				}
				BuildStyles(m);
				bool flag2 = GUIUtility.hotControl == control;
				_buttonStyle.normal.background = ((state == State.Open || (flag2 && flag)) ? _openTexture : (flag ? _hoverTexture : _buttonTexture));
				_buttonStyle.Draw(icon, false, false, false, false);
				Texture2D[] array = IconTextures(pixels);
				GUI.DrawTexture(new Rect(((Rect)(ref icon)).x + (((Rect)(ref icon)).width - (float)m.Art) / 2f, ((Rect)(ref icon)).y + (((Rect)(ref icon)).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 icon)).xMax - num - num2, ((Rect)(ref icon)).yMax - num - num2, num2, num2), (Texture)(object)_dotTexture);
				}
				int num3;
				if (flag)
				{
					num3 = ((GUIUtility.hotControl == 0 || flag2) ? 1 : 0);
					if (num3 != 0)
					{
						DrawTooltip(icon, m, Tooltip(state, name, key, hint));
					}
				}
				else
				{
					num3 = 0;
				}
				GUI.depth = ((num3 != 0) ? (-100) : 0);
				break;
			}
			case 0:
				if (flag && (e.button == 0 || e.button == 1))
				{
					GUIUtility.hotControl = control;
					_pressedButton = e.button;
					e.Use();
				}
				break;
			case 3:
				if (GUIUtility.hotControl == control)
				{
					e.Use();
				}
				break;
			case 1:
				if (GUIUtility.hotControl != control)
				{
					break;
				}
				GUIUtility.hotControl = 0;
				e.Use();
				if (flag && e.button == _pressedButton)
				{
					if (e.button != 0)
					{
						return Click.Right;
					}
					return Click.Left;
				}
				break;
			case 2:
				break;
			}
			return Click.None;
		}

		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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			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 = ((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 void Hide(int control, Event e)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			if (GUIUtility.hotControl == control)
			{
				GUIUtility.hotControl = 0;
			}
			if ((int)e.type == 7)
			{
				GUI.depth = 0;
			}
		}

		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 Rect Place(string id, int order, out Rect bar, out Metrics m)
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			Hashtable hashtable = Table();
			int frameCount = Time.frameCount;
			if (hashtable[id] is double[] array)
			{
				array[0] = order;
				array[1] = frameCount;
			}
			else
			{
				hashtable[id] = new double[2] { order, frameCount };
			}
			int num = 0;
			int num2 = 0;
			foreach (DictionaryEntry item in hashtable)
			{
				string text = (string)item.Key;
				double[] array2 = (double[])item.Value;
				if (!((double)frameCount - array2[1] > 2.0))
				{
					num2++;
					if (text != id && (array2[0] < (double)order || (array2[0] == (double)order && string.CompareOrdinal(text, id) < 0)))
					{
						num++;
					}
				}
			}
			m = Measure();
			int num3 = num2 * m.Button + (num2 - 1) * m.Gap;
			int num4 = Screen.width - m.Margin - num3;
			int num5 = Screen.height - m.Margin - m.Button;
			bar = new Rect((float)num4, (float)num5, (float)num3, (float)m.Button);
			return new Rect((float)(num4 + num * (m.Button + m.Gap)), (float)num5, (float)m.Button, (float)m.Button);
		}

		private static void Share(Rect bar)
		{
			AppDomain currentDomain = AppDomain.CurrentDomain;
			int frameCount = Time.frameCount;
			if (!(currentDomain.GetData("OnTogetherMods.IconBar.Rect") is double[] array) || (int)array[4] != frameCount || !(array[2] >= (double)((Rect)(ref bar)).width))
			{
				currentDomain.SetData("OnTogetherMods.IconBar.Rect", new double[6]
				{
					((Rect)(ref bar)).x,
					((Rect)(ref bar)).y,
					((Rect)(ref bar)).width,
					((Rect)(ref bar)).height,
					frameCount,
					_visible ? 1 : 0
				});
			}
		}

		private static Hashtable Table()
		{
			Hashtable hashtable = AppDomain.CurrentDomain.GetData("OnTogetherMods.IconBar.Icons") as Hashtable;
			if (hashtable == null)
			{
				hashtable = new Hashtable();
				AppDomain.CurrentDomain.SetData("OnTogetherMods.IconBar.Icons", hashtable);
			}
			return hashtable;
		}

		private static void Refresh()
		{
			//IL_0015: 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_0055: 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_0063: Invalid comparison between Unknown and I4
			int frameCount = Time.frameCount;
			if (_cachedFrame != frameCount)
			{
				_cachedFrame = frameCount;
				Scene activeScene = SceneManager.GetActiveScene();
				_inWorld = ((Scene)(ref activeScene)).buildIndex == 2;
				_visible = false;
				if (_inWorld && !PanelStack.Hidden && !RowHidden)
				{
					TaskManager i = MonoSingleton<TaskManager>.I;
					_visible = (Object)(object)i != (Object)null && ((int)i.LockState == 0 || (int)i.LockState == 5);
				}
			}
		}

		private static void UpdateBlocker(bool shown, Rect bar)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00a4: 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_00bd: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			AppDomain currentDomain = AppDomain.CurrentDomain;
			int frameCount = Time.frameCount;
			if (currentDomain.GetData("OnTogetherMods.IconBar.BlockerFrame") is int num && num == frameCount)
			{
				return;
			}
			currentDomain.SetData("OnTogetherMods.IconBar.BlockerFrame", frameCount);
			object? data = currentDomain.GetData("OnTogetherMods.IconBar.Blocker");
			GameObject val = (GameObject)((data is GameObject) ? data : null);
			if ((Object)(object)val == (Object)null)
			{
				if (!shown)
				{
					return;
				}
				val = CreateBlocker();
				currentDomain.SetData("OnTogetherMods.IconBar.Blocker", val);
			}
			if (shown)
			{
				RectTransform val2 = (RectTransform)val.transform.GetChild(0);
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(((Rect)(ref bar)).x, (float)Screen.height - ((Rect)(ref bar)).yMax);
				if (val2.anchoredPosition != val3)
				{
					val2.anchoredPosition = val3;
				}
				if (val2.sizeDelta != ((Rect)(ref bar)).size)
				{
					val2.sizeDelta = ((Rect)(ref bar)).size;
				}
			}
			if (val.activeSelf != shown)
			{
				val.SetActive(shown);
			}
		}

		private static GameObject CreateBlocker()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0061: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OnTogetherMods IconBar ClickBlocker");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas obj = val.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32767;
			val.AddComponent<GraphicRaycaster>();
			GameObject val2 = new GameObject("Area", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val2.transform.SetParent(val.transform, false);
			((Graphic)val2.GetComponent<Image>()).color = Color.clear;
			RectTransform val3 = (RectTransform)val2.transform;
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.zero;
			val3.pivot = Vector2.zero;
			val.SetActive(false);
			return val;
		}

		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.Patched") != null)
			{
				return;
			}
			currentDomain.SetData("OnTogetherMods.IconBar.Patched", true);
			try
			{
				Patches.Apply(new Harmony("nelphei.ontogether.iconbar"));
			}
			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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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)
			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 = ((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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0105: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01bd: 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))
			{
				_builtFor = Screen.height;
				int num = Mathf.Max(2, Mathf.RoundToInt(6f * m.Unit));
				Destroy(_buttonTexture);
				Destroy(_hoverTexture);
				Destroy(_openTexture);
				Destroy(_dotTexture);
				_buttonTexture = RoundedBox(num, ButtonFill, ButtonEdge);
				_hoverTexture = RoundedBox(num, HoverFill, HoverEdge);
				_openTexture = RoundedBox(num, OpenFill, OpenEdge);
				int num2 = Mathf.Max(2, Mathf.RoundToInt(3f * m.Unit));
				_dotTexture = RoundedBox(num2, DotFill, DotEdge, 2 * num2);
				int num3 = num + 1;
				_buttonStyle = new GUIStyle
				{
					border = new RectOffset(num3, num3, num3, num3)
				};
				_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 = Mathf.Max(8, Mathf.RoundToInt(15f * m.Unit)),
					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 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 DeskSnap
{
	internal struct Span
	{
		public float Left;

		public float Right;

		public float Back;

		public float Front;

		public float Width => Right - Left;

		public override string ToString()
		{
			return $"left {Left:0.00}, right {Right:0.00}, back {Back:0.00}, front {Front:0.00}";
		}
	}
	internal sealed class Seat
	{
		public PlayerFocusController Player;

		public Vector3 Position;

		public Quaternion Facing;

		public Span Span;

		public string Name => Game.NameOf(Player);
	}
	internal static class Desks
	{
		private static readonly Span Fallback = new Span
		{
			Left = -0.6f,
			Right = 0.6f,
			Back = -0.5f,
			Front = 0.8f
		};

		private static readonly HashSet<int> DeskAnims = new HashSet<int>();

		private static readonly HashSet<int> NoDeskAnims = new HashSet<int>();

		private static float _animsReadAt = -100f;

		public static Quaternion FacingOf(Transform t)
		{
			//IL_0006: 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)
			return Quaternion.Euler(0f, t.eulerAngles.y, 0f);
		}

		public static List<Seat> OthersAtDesks(PlayerFocusController me)
		{
			//IL_0047: 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_0058: 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)
			List<Seat> list = new List<Seat>();
			PlayerFocusController[] array = Object.FindObjectsByType<PlayerFocusController>((FindObjectsSortMode)0);
			foreach (PlayerFocusController val in array)
			{
				if (!((Object)(object)val == (Object)(object)me) && ((Component)val).gameObject.activeInHierarchy && IsAtFreeDesk(val))
				{
					list.Add(new Seat
					{
						Player = val,
						Position = ((Component)val).transform.position,
						Facing = FacingOf(((Component)val).transform),
						Span = Measure(val)
					});
				}
			}
			return list;
		}

		public static bool IsAtFreeDesk(PlayerFocusController player)
		{
			if (Game.IsAtSeatSpot(player))
			{
				return false;
			}
			GameObject val = Game.Desk.Invoke(player);
			bool result = (Object)(object)val != (Object)null && val.activeSelf;
			Animator val2 = Game.AnimatorOf(player);
			if ((Object)(object)val2 == (Object)null)
			{
				return result;
			}
			ReadAnims();
			int integer = val2.GetInteger(Game.AnimStateParam);
			if (DeskAnims.Contains(integer))
			{
				return true;
			}
			if (NoDeskAnims.Contains(integer))
			{
				return false;
			}
			return result;
		}

		public static Span Measure(PlayerFocusController player)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_0176: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Game.Desk.Invoke(player);
			if ((Object)(object)val == (Object)null)
			{
				return Fallback;
			}
			Transform transform = ((Component)player).transform;
			Quaternion val2 = FacingOf(transform);
			Vector3 val3 = val2 * Vector3.right;
			Vector3 val4 = val2 * Vector3.forward;
			Vector3 position = transform.position;
			bool value = Plugin.Settings.DebugLog.Value;
			Span span = new Span
			{
				Left = float.MaxValue,
				Right = float.MinValue,
				Back = float.MaxValue,
				Front = float.MinValue
			};
			bool flag = false;
			MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
			Vector3 val7 = default(Vector3);
			foreach (MeshRenderer val5 in componentsInChildren)
			{
				if (!((Renderer)val5).enabled || !IsShown(((Component)val5).transform, val.transform))
				{
					continue;
				}
				MeshFilter component = ((Component)val5).GetComponent<MeshFilter>();
				Mesh val6 = (((Object)(object)component != (Object)null) ? component.sharedMesh : null);
				if (!((Object)(object)val6 == (Object)null))
				{
					Bounds bounds = val6.bounds;
					Matrix4x4 localToWorldMatrix = ((Component)val5).transform.localToWorldMatrix;
					float num = float.MaxValue;
					float num2 = float.MinValue;
					for (int j = 0; j < 8; j++)
					{
						((Vector3)(ref val7))..ctor(((j & 1) == 0) ? (-1f) : 1f, ((j & 2) == 0) ? (-1f) : 1f, ((j & 4) == 0) ? (-1f) : 1f);
						Vector3 val8 = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, val7)) - position;
						float num3 = Vector3.Dot(val8, val3);
						float num4 = Vector3.Dot(val8, val4);
						num = Mathf.Min(num, num3);
						num2 = Mathf.Max(num2, num3);
						span.Back = Mathf.Min(span.Back, num4);
						span.Front = Mathf.Max(span.Front, num4);
					}
					span.Left = Mathf.Min(span.Left, num);
					span.Right = Mathf.Max(span.Right, num2);
					flag = true;
					if (value)
					{
						Plugin.Log.LogInfo((object)$"  {Game.NameOf(player)}'s desk part {((Object)val5).name}: {num:0.00} to {num2:0.00} across.");
					}
				}
			}
			if (!flag || span.Width < 0.2f || span.Width > 6f || span.Front - span.Back > 6f)
			{
				if (value)
				{
					Plugin.Log.LogInfo((object)("Couldn't measure " + Game.NameOf(player) + "'s desk, so using the usual size."));
				}
				return Fallback;
			}
			if (value)
			{
				Plugin.Log.LogInfo((object)$"{Game.NameOf(player)}'s desk: {span}.");
			}
			return span;
		}

		private static bool IsShown(Transform t, Transform desk)
		{
			while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)desk)
			{
				if (!((Component)t).gameObject.activeSelf)
				{
					return false;
				}
				t = t.parent;
			}
			return true;
		}

		private static void ReadAnims()
		{
			if (Time.unscaledTime - _animsReadAt < 5f)
			{
				return;
			}
			_animsReadAt = Time.unscaledTime;
			DeskAnims.Clear();
			NoDeskAnims.Clear();
			GameSettings i = ScriptableSingleton<GameSettings>.I;
			List<int> list = (((Object)(object)i != (Object)null) ? Game.LandAnims.Invoke(i) : null);
			List<bool> list2 = (((Object)(object)i != (Object)null) ? Game.LandIsDesk.Invoke(i) : null);
			if (list == null || list2 == null)
			{
				return;
			}
			HashSet<int> hashSet = new HashSet<int>();
			for (int j = 0; j < list.Count && j < list2.Count; j++)
			{
				HashSet<int> obj = (list2[j] ? DeskAnims : NoDeskAnims);
				if ((list2[j] ? NoDeskAnims : DeskAnims).Contains(list[j]))
				{
					hashSet.Add(list[j]);
				}
				obj.Add(list[j]);
			}
			DeskAnims.ExceptWith(hashSet);
			NoDeskAnims.ExceptWith(hashSet);
		}
	}
	internal static class Game
	{
		private const string EmoteSyncGuid = "nelphei.ontogether.emotesync";

		public static readonly int AnimStateParam = Animator.StringToHash("AnimState");

		public static readonly FieldRef<PlayerFocusController, GameObject> Desk = AccessTools.FieldRefAccess<PlayerFocusController, GameObject>("_desk");

		public static readonly FieldRef<PlayerFocusController, Vector3> PreFocusPosition = AccessTools.FieldRefAccess<PlayerFocusController, Vector3>("_preFocusPosition");

		public static readonly FieldRef<PlayerFocusController, Quaternion> PreFocusRotation = AccessTools.FieldRefAccess<PlayerFocusController, Quaternion>("_preFocusRotation");

		public static readonly FieldRef<PlayerFocusController, FocusAreaController> ActiveFocusArea = AccessTools.FieldRefAccess<PlayerFocusController, FocusAreaController>("_activeFocusAreaController");

		private static readonly FieldRef<PlayerAnimationController, Animator> AnimatorField = AccessTools.FieldRefAccess<PlayerAnimationController, Animator>("_animator");

		public static readonly FieldRef<GameSettings, List<int>> LandAnims = AccessTools.FieldRefAccess<GameSettings, List<int>>("_animationStates");

		public static readonly FieldRef<GameSettings, List<bool>> LandIsDesk = AccessTools.FieldRefAccess<GameSettings, List<bool>>("_isDesk");

		private static Func<bool> _emoteSyncJoining;

		private static bool _lookedForEmoteSync;

		public static bool IsAtOwnDesk(PlayerFocusController me)
		{
			if ((Object)(object)me != (Object)null && me.IsFocus && me.IsDesk)
			{
				return IsFreeFocus(me);
			}
			return false;
		}

		public static bool IsFreeFocus(PlayerFocusController me)
		{
			if ((Object)(object)me.CurrentFocusAreaController == (Object)null)
			{
				return (Object)(object)ActiveFocusArea.Invoke(me) == (Object)null;
			}
			return false;
		}

		public static bool EmoteSyncJoining()
		{
			if (!_lookedForEmoteSync)
			{
				_lookedForEmoteSync = true;
				if (Chainloader.PluginInfos.TryGetValue("nelphei.ontogether.emotesync", out var value) && (Object)(object)value.Instance != (Object)null)
				{
					Type type = ((object)value.Instance).GetType().Assembly.GetType("EmoteSync.FocusJoin");
					MethodInfo methodInfo = ((type != null) ? AccessTools.PropertyGetter(type, "Joining") : null);
					if (methodInfo != null)
					{
						_emoteSyncJoining = (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), methodInfo);
					}
				}
				if (Plugin.Settings.DebugLog.Value)
				{
					Plugin.Log.LogInfo((object)((_emoteSyncJoining != null) ? "Found Emote Sync: desks snap after its focus joins too." : "Emote Sync isn't installed (or is too old), so only your own picks are checked for joins."));
				}
			}
			if (_emoteSyncJoining != null)
			{
				return _emoteSyncJoining();
			}
			return false;
		}

		public static bool IsAtSeatSpot(PlayerFocusController player)
		{
			FocusAreaManager i = NetworkSingleton<FocusAreaManager>.I;
			NetworkTransform component = ((Component)player).GetComponent<NetworkTransform>();
			if ((Object)(object)i == (Object)null || (Object)(object)component == (Object)null || i.NetworkTransforms == null || i.AreaIndexes == null)
			{
				return false;
			}
			int num = i.NetworkTransforms.IndexOf(component);
			if (num >= 0 && num < i.AreaIndexes.Count)
			{
				return i.AreaIndexes[num] >= 0;
			}
			return false;
		}

		public static Animator AnimatorOf(PlayerFocusController player)
		{
			PlayerAnimationController val = ((Component)player).GetComponent<PlayerAnimationController>() ?? ((Component)player).GetComponentInChildren<PlayerAnimationController>() ?? ((Component)player).GetComponentInParent<PlayerAnimationController>();
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return AnimatorField.Invoke(val);
		}

		public static string NameOf(PlayerFocusController player)
		{
			PlayerController component = ((Component)player).GetComponent<PlayerController>();
			string text = (((Object)(object)component != (Object)null && (Object)(object)component.PlayerNameText != (Object)null) ? ((TMP_Text)component.PlayerNameText).text : null);
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text.Trim();
			}
			return "your friend";
		}

		public static ulong IdOf(PlayerFocusController player)
		{
			//IL_0015: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			PlayerID? owner = ((NetworkIdentity)player).owner;
			if (!owner.HasValue)
			{
				return 0uL;
			}
			PlayerID value = owner.Value;
			return ((PlayerID)(ref value)).id.value;
		}

		public static void MoveSeated(PlayerFocusController me, Vector3 position, Quaternion rotation)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_002e: 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)
			((Component)me).transform.SetPositionAndRotation(position, rotation);
			Physics.SyncTransforms();
			PreFocusPosition.Invoke(me) = position;
			PreFocusRotation.Invoke(me) = rotation;
			ResetTail(me);
		}

		private static void ResetTail(PlayerFocusController me)
		{
			PlayerCustomizationController component = ((Component)me).GetComponent<PlayerCustomizationController>();
			if (!((Object)(object)component == (Object)null) && component.OutfitMeshRenderers.TryGetValue((OutfitType)8, out var value) && !((Object)(object)value == (Object)null) && !((Object)(object)((Component)value).transform.parent == (Object)null))
			{
				EZSoftBone component2 = ((Component)((Component)value).transform.parent).GetComponent<EZSoftBone>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.SetRestState();
				}
			}
		}
	}
	internal static class Icon
	{
		public static readonly string[] Pixels = new string[16]
		{
			"................", "................", "..KKKKKKK.......", "..KLLUUUK..N.N..", "..KLUUUUK..NNN..", "..KUUUUUK...n...", "..KKKKKKK.KOOOK.", ".....D.....KOK..", "KKKKKKKKKKKKKKKK", "KbbbbbbbbbbbbbbK",
			"KKKKKKKKKKKKKKKK", ".KBK.....KBBBBK.", ".KBK.....KBddBK.", ".KBK.....KBBBBK.", ".KBK.....KBddBK.", ".KKK.....KKKKKK."
		};
	}
	[HarmonyPatch(typeof(PlayerFocusController), "SetFocus")]
	internal static class SetFocusPatch
	{
		private static void Postfix(PlayerFocusController __instance)
		{
			try
			{
				SnapController.Instance?.OnFocusPicked(__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
			}
		}
	}
	[BepInPlugin("nelphei.ontogether.desksnap", "Desk Snap", "0.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "nelphei.ontogether.desksnap";

		public const string PluginName = "Desk Snap";

		public const string PluginVersion = "0.2.1";

		internal static ManualLogSource Log;

		internal static Settings Settings;

		private GameObject _host;

		private void Awake()
		{
			//IL_0020: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Settings = new Settings(((BaseUnityPlugin)this).Config);
			new Harmony("nelphei.ontogether.desksnap").PatchAll();
			IconBar.Patch();
			_host = new GameObject("DeskSnap");
			((Object)_host).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)_host);
			_host.AddComponent<SnapController>();
			Log.LogInfo((object)("Desk Snap 0.2.1 loaded. Snapping is " + (Settings.Enabled.Value ? "on" : "off") + "; " + $"press {Settings.ToggleKey.Value} to turn it on or off."));
		}

		private void OnDestroy()
		{
			if ((Object)(object)_host != (Object)null)
			{
				Object.Destroy((Object)(object)_host);
			}
		}
	}
	internal struct Placement
	{
		public Vector3 Position;

		public Quaternion Facing;

		public Seat Neighbour;
	}
	internal static class Row
	{
		private const float MaxSink = 0.15f;

		private const int MaxChain = 8;

		private const float Overlap = 0.05f;

		private static int _mask;

		private static int Mask
		{
			get
			{
				if (_mask == 0)
				{
					_mask = ~LayerMask.GetMask(new string[8] { "Ignore Raycast", "Player", "Water", "Area", "AreaTrigger", "Customization", "IsGroundedChecker", "DeskRender" });
				}
				return _mask;
			}
		}

		public static bool TryPlace(Seat target, int side, Span mine, List<Seat> seats, float gap, out Placement placement, out string why)
		{
			why = null;
			int[] array = new int[2]
			{
				side,
				-side
			};
			foreach (int side2 in array)
			{
				if (TryPlaceOnSide(target, side2, mine, seats, gap, out placement, out var why2))
				{
					return true;
				}
				why = why ?? why2;
			}
			placement = default(Placement);
			return false;
		}

		private static bool TryPlaceOnSide(Seat target, int side, Span mine, List<Seat> seats, float gap, out Placement placement, out string why)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0015: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			placement = default(Placement);
			Quaternion facing = target.Facing;
			Vector3 val = facing * Vector3.right;
			HashSet<Seat> hashSet = new HashSet<Seat> { target };
			Seat seat = target;
			for (int i = 0; i < 8; i++)
			{
				float num = ((side > 0) ? (seat.Span.Right + gap - mine.Left) : (seat.Span.Left - gap - mine.Right));
				Vector3 spot = seat.Position + val * num;
				Seat seat2 = OccupantAt(spot, facing, mine, seats, hashSet);
				if (seat2 != null)
				{
					hashSet.Add(seat2);
					seat = seat2;
					continue;
				}
				if (!Fits(spot, facing, seat, mine, out var placed, out why))
				{
					return false;
				}
				placement = new Placement
				{
					Position = placed,
					Facing = facing,
					Neighbour = seat
				};
				return true;
			}
			why = "the row is full";
			return false;
		}

		public static bool Overlaps(Vector3 spot, Quaternion facing, Span mine, Seat other)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			float across;
			return OverlapWith(spot, facing, mine, other, out across) > 0.05f;
		}

		private static float OverlapWith(Vector3 spot, Quaternion facing, Span mine, Seat other, out float across)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = other.Position - spot;
			across = Vector3.Dot(val, facing * Vector3.right);
			if (Mathf.Abs(Vector3.Dot(val, facing * Vector3.forward)) > 1f || Mathf.Abs(val.y) > 1f)
			{
				return 0f;
			}
			return Mathf.Min(mine.Right, across + other.Span.Right) - Mathf.Max(mine.Left, across + other.Span.Left);
		}

		private static Seat OccupantAt(Vector3 spot, Quaternion facing, Span mine, List<Seat> seats, HashSet<Seat> passed)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Seat result = null;
			float num = float.MaxValue;
			foreach (Seat seat in seats)
			{
				if (!passed.Contains(seat) && OverlapWith(spot, facing, mine, seat, out var across) > 0.05f && Mathf.Abs(across) < num)
				{
					result = seat;
					num = Mathf.Abs(across);
				}
			}
			return result;
		}

		private static bool Fits(Vector3 spot, Quaternion facing, Seat neighbour, Span mine, out Vector3 placed, out string why)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0090: 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_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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			placed = new Vector3(spot.x, neighbour.Position.y, spot.z);
			if (Ground(placed + Vector3.up * 0.15f, 0.45f, 0f, out var _))
			{
				why = "the ground is higher there";
				return false;
			}
			Vector3 val = neighbour.Position + Vector3.up * 0.9f;
			Vector3 to = placed + Vector3.up * 0.9f;
			if (Blocked(val, to))
			{
				why = "something's in the way";
				return false;
			}
			Vector3 val2 = placed + facing * new Vector3((mine.Left + mine.Right) / 2f, 0.65f, (mine.Back + mine.Front) / 2f);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(Mathf.Max(0.05f, mine.Width / 2f - 0.05f), 0.35f, Mathf.Max(0.05f, (mine.Front - mine.Back) / 2f - 0.05f));
			Collider[] array = Physics.OverlapBox(val2, val3, facing, Mask, (QueryTriggerInteraction)1);
			foreach (Collider val4 in array)
			{
				if (!IsIgnored(val4))
				{
					if (Plugin.Settings.DebugLog.Value)
					{
						Plugin.Log.LogInfo((object)("No room for the desk: " + ((Object)val4).name + " is there."));
					}
					why = "something's in the way";
					return false;
				}
			}
			why = null;
			return true;
		}

		private static bool Ground(Vector3 at, float up, float down, out float y)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			y = 0f;
			float num = float.MaxValue;
			RaycastHit[] array = Physics.RaycastAll(at + Vector3.up * up, Vector3.down, up + down, Mask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (((RaycastHit)(ref val)).distance < num && !IsIgnored(((RaycastHit)(ref val)).collider))
				{
					num = ((RaycastHit)(ref val)).distance;
					y = ((RaycastHit)(ref val)).point.y;
				}
			}
			return num < float.MaxValue;
		}

		private static bool Blocked(Vector3 from, Vector3 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			RaycastHit[] array = Physics.RaycastAll(from, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, Mask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				if (!IsIgnored(((RaycastHit)(ref val2)).collider))
				{
					if (Plugin.Settings.DebugLog.Value)
					{
						Plugin.Log.LogInfo((object)("Between the desks: " + ((Object)((RaycastHit)(ref val2)).collider).name + "."));
					}
					return true;
				}
			}
			return false;
		}

		private static bool IsIgnored(Collider collider)
		{
			if (!((Object)(object)((Component)collider).GetComponentInParent<PlayerController>() != (Object)null))
			{
				return (Object)(object)((Component)collider).GetComponentInParent<PetController>() != (Object)null;
			}
			return true;
		}
	}
	internal sealed class Settings
	{
		public readonly ConfigEntry<KeyCode> ToggleKey;

		public readonly ConfigEntry<bool> Enabled;

		public readonly ConfigEntry<float> Gap;

		public readonly ConfigEntry<float> Range;

		public readonly ConfigEntry<bool> ShowNotices;

		public readonly ConfigEntry<bool> ShowIcon;

		public readonly ConfigEntry<bool> DebugLog;

		public Settings(ConfigFile config)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			ToggleKey = config.Bind<KeyCode>("Keys", "ToggleKey", (KeyCode)284, "Turns snapping on and off. If you're sitting at your desk, turning it on snaps you next to a friend's desk right away, and turning it off moves you back to where you sat down.");
			Enabled = config.Bind<bool>("Snap", "Enabled", true, "When you sit down at your desk near a friend's desk, move yours into line beside it, facing the same way. ToggleKey changes this, and it's remembered between games.");
			Gap = config.Bind<float>("Snap", "Gap", 0.03f, new ConfigDescription("Space between the two desks, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>()));
			Range = config.Bind<float>("Snap", "Range", 3f, new ConfigDescription("How close to a friend you need to sit (in metres) for your desk to snap next to theirs.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			ShowNotices = config.Bind<bool>("Display", "ShowNotices", true, "Show a short message at the top of the screen when your desk snaps or you press ToggleKey.");
			ShowIcon = config.Bind<bool>("Display", "ShowIcon", true, "Show a desk icon in the row of mod icons at the bottom-right, with a green dot while snapping is on. Clicking it does what ToggleKey does.");
			DebugLog = config.Bind<bool>("Debug", "DebugLog", false, "Write desk sizes, targets and why a snap didn't happen to the BepInEx log.");
		}
	}
	internal enum SnapResult
	{
		Snapped,
		AlreadyThere,
		NoDesk,
		NoRoom
	}
	internal sealed class SnapController : MonoBehaviour
	{
		private const float JoinWaitSeconds = 3f;

		private const float SettleSeconds = 3f;

		private const float CheckEvery = 0.2f;

		private const int MaxResettles = 3;

		private PlayerFocusController _me;

		private bool _sitting;

		private Vector3 _sitPosition;

		private Quaternion _sitRotation;

		private bool _snapped;

		private PlayerFocusController _neighbour;

		private float _joinUntil;

		private float _settleUntil;

		private int _resettles;

		private float _nextCheck;

		private readonly Dictionary<PlayerFocusController, float> _firstSeen = new Dictionary<PlayerFocusController, float>();

		private readonly TextBox _noticeBox = new TextBox("DeskSnap Notice", (TextAlignmentOptions)514);

		private string _notice;

		private float _noticeUntil;

		private bool _iconClicked;

		public static SnapController Instance { get; private set; }

		private static Settings S => Plugin.Settings;

		private void Awake()
		{
			Instance = this;
		}

		private void OnDestroy()
		{
			_noticeBox.Destroy();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public void OnFocusPicked(PlayerFocusController focus)
		{
			//IL_0054: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			TextChannelManager i = NetworkSingleton<TextChannelManager>.I;
			if ((Object)(object)i == (Object)null || (Object)(object)focus != (Object)(object)i.MainFocusController || !focus.IsFocus)
			{
				return;
			}
			if (!_sitting || !((Object)(object)_me == (Object)(object)focus))
			{
				_me = focus;
				_sitting = true;
				_sitPosition = ((Component)focus).transform.position;
				_sitRotation = ((Component)focus).transform.rotation;
				_snapped = false;
				_neighbour = null;
				_firstSeen.Clear();
			}
			_joinUntil = 0f;
			_settleUntil = 0f;
			if (!S.Enabled.Value || _snapped || !Game.IsAtOwnDesk(focus))
			{
				return;
			}
			bool flag = Game.EmoteSyncJoining();
			if (TrySnap(flag, out var message) == SnapResult.NoDesk)
			{
				if (flag)
				{
					_joinUntil = Time.unscaledTime + 3f;
					_nextCheck = Time.unscaledTime + 0.2f;
				}
			}
			else if (message != null)
			{
				Notice(message);
			}
		}

		private void LateUpdate()
		{
			_noticeBox.LateUpdate();
		}

		private void Update()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			bool iconClicked = _iconClicked;
			_iconClicked = false;
			if ((Input.GetKeyDown(S.ToggleKey.Value) && !IsTyping()) || iconClicked)
			{
				Toggle();
			}
			if (!_sitting)
			{
				return;
			}
			if ((Object)(object)_me == (Object)null || !_me.IsFocus)
			{
				ClearSit();
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextCheck || (unscaledTime >= _joinUntil && unscaledTime >= _settleUntil))
			{
				return;
			}
			_nextCheck = unscaledTime + 0.2f;
			if (!_snapped && unscaledTime < _joinUntil)
			{
				string message;
				if (!S.Enabled.Value || !Game.IsAtOwnDesk(_me))
				{
					_joinUntil = 0f;
				}
				else if (TrySnap(preferFirstOut: true, out message) != SnapResult.NoDesk)
				{
					_joinUntil = 0f;
					if (message != null)
					{
						Notice(message);
					}
				}
			}
			else if (_snapped && unscaledTime < _settleUntil)
			{
				Settle();
			}
		}

		private void Toggle()
		{
			//IL_0080: 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)
			bool flag = !S.Enabled.Value;
			S.Enabled.Value = flag;
			_joinUntil = 0f;
			_settleUntil = 0f;
			bool flag2 = _sitting && (Object)(object)_me != (Object)null && _me.IsFocus && Game.IsFreeFocus(_me);
			if (!flag)
			{
				if (flag2 && _snapped)
				{
					Game.MoveSeated(_me, _sitPosition, _sitRotation);
					_snapped = false;
					_neighbour = null;
					Notice("Desk Snap off. You're back where you sat down.");
				}
				else
				{
					Notice("Desk Snap off");
				}
			}
			else if (flag2 && !_snapped && Game.IsAtOwnDesk(_me))
			{
				string message;
				SnapResult snapResult = TrySnap(preferFirstOut: false, out message);
				Notice((snapResult == SnapResult.AlreadyThere || message == null) ? "Desk Snap on" : ("Desk Snap on. " + message));
			}
			else
			{
				Notice("Desk Snap on. Sit at your desk near a friend's desk to line up beside it.");
			}
		}

		private SnapResult TrySnap(bool preferFirstOut, out string message)
		{
			//IL_008c: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			message = null;
			float unscaledTime = Time.unscaledTime;
			List<Seat> list = Desks.OthersAtDesks(_me);
			foreach (Seat item in list)
			{
				if (!_firstSeen.ContainsKey(item.Player))
				{
					_firstSeen[item.Player] = unscaledTime;
				}
			}
			float range = S.Range.Value;
			Vector3 from = _sitPosition;
			List<Seat> list2 = list.Where((Seat s) => Distance(s) <= range && Mathf.Abs(s.Position.y - from.y) < 2f).ToList();
			if (list2.Count == 0)
			{
				message = $"No other desk within {range:0.#} m";
				if (S.DebugLog.Value)
				{
					Plugin.Log.LogInfo((object)$"No desk to snap to ({list.Count} other desks out, none within {range:0.#} m).");
				}
				return SnapResult.NoDesk;
			}
			Seat seat = (preferFirstOut ? list2.OrderBy((Seat s) => _firstSeen[s.Player]).ThenBy(Distance).First() : list2.OrderBy(Distance).First());
			Span mine = Desks.Measure(_me);
			Vector3 val = seat.Facing * Vector3.right;
			int side = ((Vector3.Dot(from - seat.Position, val) >= 0f) ? 1 : (-1));
			if (!Row.TryPlace(seat, side, mine, list, S.Gap.Value, out var placement, out var why))
			{
				message = "No room next to " + PlayerNames.ForText(seat.Name) + "'s desk: " + why;
				Plugin.Log.LogInfo((object)("No room next to " + seat.Name + "'s desk: " + why + "."));
				return SnapResult.NoRoom;
			}
			return MoveTo(placement, out message);
			float Distance(Seat seat2)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: 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_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val2 = seat2.Position - from;
				Vector2 val3 = new Vector2(val2.x, val2.z);
				return ((Vector2)(ref val3)).magnitude;
			}
		}

		private SnapResult MoveTo(Placement place, out string message)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)_me).transform;
			_neighbour = place.Neighbour.Player;
			Vector3 val = transform.position - place.Position;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0004f && Quaternion.Angle(transform.rotation, place.Facing) < 1f)
			{
				_snapped = true;
				message = null;
				return SnapResult.AlreadyThere;
			}
			float num = Vector3.Distance(transform.position, place.Position);
			Game.MoveSeated(_me, place.Position, place.Facing);
			_snapped = true;
			_settleUntil = Time.unscaledTime + 3f;
			_nextCheck = Time.unscaledTime + 0.2f;
			string name = place.Neighbour.Name;
			message = $"Snapped next to {PlayerNames.ForText(name)}'s desk. Press {S.ToggleKey.Value} to turn snapping off.";
			Plugin.Log.LogInfo((object)$"Snapped next to {name}'s desk (moved {num:0.00} m).");
			return SnapResult.Snapped;
		}

		private void Settle()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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)
			Transform t = ((Component)_me).transform;
			Span mine = Desks.Measure(_me);
			List<Seat> list = Desks.OthersAtDesks(_me);
			Seat seat = list.FirstOrDefault((Seat s) => (Object)(object)s.Player == (Object)(object)_neighbour);
			Seat seat2 = list.FirstOrDefault((Seat s) => (Object)(object)s.Player != (Object)(object)_neighbour && Row.Overlaps(t.position, Desks.FacingOf(t), mine, s));
			if (seat2 == null || seat == null || Game.IdOf(_me) <= Game.IdOf(seat2.Player) || _resettles >= 3)
			{
				return;
			}
			_resettles++;
			Plugin.Log.LogInfo((object)(seat2.Name + " snapped into the same spot, so moving along the row."));
			int side = ((Vector3.Dot(t.position - seat.Position, seat.Facing * Vector3.right) >= 0f) ? 1 : (-1));
			if (Row.TryPlace(seat, side, mine, list, S.Gap.Value, out var placement, out var why))
			{
				MoveTo(placement, out var message);
				if (message != null)
				{
					Notice(message);
				}
			}
			else
			{
				Plugin.Log.LogInfo((object)("Couldn't move along: " + why + "."));
			}
		}

		private void ClearSit()
		{
			_sitting = false;
			_snapped = false;
			_neighbour = null;
			_joinUntil = 0f;
			_settleUntil = 0f;
			_resettles = 0;
			_firstSeen.Clear();
		}

		private static bool IsTyping()
		{
			TaskManager i = MonoSingleton<TaskManager>.I;
			if ((Object)(object)i != (Object)null)
			{
				return i.IsWriting;
			}
			return false;
		}

		private void Notice(string text)
		{
			if (S.ShowNotices.Value)
			{
				_notice = text;
				_noticeUntil = Time.unscaledTime + 3f;
			}
		}

		private void OnGUI()
		{
			//IL_0041: 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_0084: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (S.ShowIcon.Value && IconBar.Draw("DeskSnap", 40, Icon.Pixels, S.Enabled.Value ? IconBar.State.On : IconBar.State.Off, "Desk Snap", S.ToggleKey.Value) == IconBar.Click.Left)
			{
				_iconClicked = true;
			}
			if (_notice != null && !(Time.unscaledTime >= _noticeUntil) && !PanelStack.Hidden)
			{
				Vector2 val = _noticeBox.Measure(_notice);
				_noticeBox.Draw(new Rect((PanelStack.Width - val.x) / 2f, 140f, val.x, val.y), _notice);
			}
		}
	}
}