Decompiled source of Overlay Core Module v2.0.1

Overlay.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using DunGen.Generation;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Overlay.Internal;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Michael")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("One in-game window dock that any mod can register into.")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+615bce4ae0bb6fec2350b40b97bd1db923e2326c")]
[assembly: AssemblyProduct("Overlay")]
[assembly: AssemblyTitle("Overlay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
internal static class LCMPluginInfo
{
	public const string PLUGIN_GUID = "Michael.LethalCompany.Overlay";

	public const string PLUGIN_NAME = "Overlay";

	public const string PLUGIN_VERSION = "2.0.36";
}
namespace Overlay
{
	public enum AlertTone
	{
		None,
		Bad,
		Normal
	}
	public sealed class Alert
	{
		public string Module { get; }

		public string Info { get; internal set; }

		public AlertTone Tone { get; }

		public string Tag { get; }

		public string Subject { get; }

		public string Kind { get; }

		public string TagLine
		{
			get
			{
				bool flag = !string.IsNullOrEmpty(Subject);
				bool flag2 = !string.IsNullOrEmpty(Kind);
				if (flag && flag2)
				{
					return "[" + Subject + "]  [" + Kind + "]";
				}
				if (flag)
				{
					return "[" + Subject + "]";
				}
				return flag2 ? ("[" + Kind + "]") : null;
			}
		}

		internal int Count { get; set; }

		internal bool IsStatic { get; set; }

		internal bool AnimateDots { get; set; }

		internal float Seconds { get; set; }

		internal Alert(string module, string info, AlertTone tone, string tag = null)
		{
			Module = (string.IsNullOrEmpty(module) ? "MOD" : module);
			Info = info ?? string.Empty;
			Tone = tone;
			Tag = tag ?? string.Empty;
			Count = 1;
			Subject = string.Empty;
			Kind = string.Empty;
		}

		internal Alert(string module, string info, AlertTone tone, string subject, string kind)
			: this(module, info, tone, Compose(subject, kind))
		{
			Subject = subject ?? string.Empty;
			Kind = kind ?? string.Empty;
		}

		private static string Compose(string subject, string kind)
		{
			return subject + "|" + kind;
		}
	}
	public static class Alerts
	{
		public static Alert Showing => AlertHost.Showing;

		public static int Queued => AlertHost.Queued;

		public static StaticAlert Static(string module, string info, AlertTone tone = AlertTone.Normal, bool animateDots = false)
		{
			return AlertHost.RaiseStatic(module, info, tone, animateDots);
		}

		public static void Raise(string module, string info)
		{
			Raise(module, info, AlertTone.Normal);
		}

		public static void Raise(string module, string info, AlertTone tone)
		{
			AlertHost.Raise(new Alert(module, info, tone));
		}

		public static void Raise(string module, string info, AlertTone tone, string tag)
		{
			AlertHost.Raise(new Alert(module, info, tone, tag));
		}

		public static void Raise(string module, string info, AlertTone tone, string subject, string kind)
		{
			AlertHost.Raise(new Alert(module, info, tone, subject, kind));
		}

		public static void ClearForSubject(string subject)
		{
			if (!string.IsNullOrEmpty(subject))
			{
				AlertHost.ClearByTag(subject + "|", exact: false);
			}
		}

		public static bool IsMuted(string module)
		{
			return AlertHost.IsMuted(module);
		}

		public static void Mute(string module, bool muted)
		{
			AlertHost.SetMuted(module, muted);
		}

		public static string[] Senders()
		{
			return AlertHost.Senders();
		}

		public static void Clear()
		{
			AlertHost.Clear();
		}

		public static void ClearByTag(string tag, bool exact = true)
		{
			AlertHost.ClearByTag(tag, exact);
		}

		internal static string[] ToArray(IEnumerable<string> names)
		{
			List<string> list = new List<string>();
			foreach (string name in names)
			{
				list.Add(name);
			}
			list.Sort(StringComparer.OrdinalIgnoreCase);
			return list.ToArray();
		}
	}
	public sealed class StaticAlert
	{
		private readonly Alert _alert;

		public bool Active => AlertHost.StaticActive(_alert);

		internal StaticAlert(Alert alert)
		{
			_alert = alert;
		}

		public void Update(string info)
		{
			AlertHost.UpdateStatic(_alert, info);
		}

		public void Deload()
		{
			AlertHost.DeloadStatic(_alert);
		}
	}
	public static class Dock
	{
		private static readonly List<OverlayPanel> Panels = new List<OverlayPanel>();

		private static readonly object Gate = new object();

		internal static int Version { get; private set; }

		public static bool IsAvailable => (Object)(object)DockHost.Instance != (Object)null;

		public static bool IsOpen => (Object)(object)DockHost.Instance != (Object)null && DockHost.Instance.IsOpen;

		public static OverlayPanel ActivePanel => ((Object)(object)DockHost.Instance == (Object)null) ? null : DockHost.Instance.ActivePanel;

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static OverlayPanel Register(string title)
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			return Register(title, PluginGuid(callingAssembly), callingAssembly);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static OverlayPanel Register(string title, string ownerGuid)
		{
			return Register(title, ownerGuid, Assembly.GetCallingAssembly());
		}

		private static OverlayPanel Register(string title, string ownerGuid, Assembly owner)
		{
			lock (Gate)
			{
				OverlayPanel overlayPanel = Find(title);
				if (overlayPanel != null)
				{
					OverlayPlugin.Log.LogInfo((object)("[Dock] " + ownerGuid + " asked for the panel \"" + title + "\" again - handing back the one that exists."));
					return overlayPanel;
				}
				OverlayPanel overlayPanel2 = new OverlayPanel(title, ownerGuid, owner);
				Panels.Add(overlayPanel2);
				Version++;
				OverlayPlugin.Log.LogInfo((object)("[Dock] Registered the panel \"" + overlayPanel2.Title + "\" for " + ownerGuid + "."));
				return overlayPanel2;
			}
		}

		public static bool Unregister(OverlayPanel panel)
		{
			if (panel == null)
			{
				return false;
			}
			lock (Gate)
			{
				if (!Panels.Remove(panel))
				{
					return false;
				}
				Version++;
				OverlayPlugin.Log.LogInfo((object)("[Dock] Unregistered the panel \"" + panel.Title + "\"."));
				return true;
			}
		}

		public static OverlayPanel[] All()
		{
			lock (Gate)
			{
				return Panels.ToArray();
			}
		}

		public static OverlayPanel Find(string title)
		{
			lock (Gate)
			{
				for (int i = 0; i < Panels.Count; i++)
				{
					if (string.Equals(Panels[i].Title, title, StringComparison.OrdinalIgnoreCase))
					{
						return Panels[i];
					}
				}
			}
			return null;
		}

		public static bool Show(OverlayPanel panel)
		{
			return (Object)(object)DockHost.Instance != (Object)null && DockHost.Instance.Show(panel);
		}

		public static void Open()
		{
			if ((Object)(object)DockHost.Instance != (Object)null)
			{
				DockHost.Instance.SetOpen(open: true, "api");
			}
		}

		public static void Close()
		{
			if ((Object)(object)DockHost.Instance != (Object)null)
			{
				DockHost.Instance.SetOpen(open: false, "api");
			}
		}

		public static void Toggle()
		{
			if ((Object)(object)DockHost.Instance != (Object)null)
			{
				DockHost.Instance.SetOpen(!DockHost.Instance.IsOpen, "api");
			}
		}

		public static void Toast(string message)
		{
			if ((Object)(object)DockHost.Instance != (Object)null)
			{
				DockHost.Instance.Toast(message);
			}
		}

		public static void Alert(string module, string info, AlertTone tone = AlertTone.Normal)
		{
			Alerts.Raise(module, info, tone);
		}

		public static string ToggleKeyName()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			string text = GameKeybind.Name();
			return string.IsNullOrEmpty(text) ? ((object)OverlayConfig.ToggleKey()/*cast due to .constrained prefix*/).ToString() : text;
		}

		internal static void NotifyWindowsChanged()
		{
			lock (Gate)
			{
				Version++;
			}
		}

		private static string PluginGuid(Assembly caller)
		{
			try
			{
				Type[] types = caller.GetTypes();
				foreach (Type type in types)
				{
					object[] customAttributes = type.GetCustomAttributes(inherit: false);
					foreach (object obj in customAttributes)
					{
						if (!(obj.GetType().Name != "BepInPlugin"))
						{
							PropertyInfo property = obj.GetType().GetProperty("GUID");
							object obj2 = ((property == null) ? null : property.GetValue(obj, null));
							if (obj2 is string { Length: >0 } text)
							{
								return text;
							}
						}
					}
				}
				return caller.GetName().Name;
			}
			catch (Exception)
			{
				return "an unidentified mod";
			}
		}
	}
	public static class Network
	{
		public const string Module = "NETWORK ALERT";

		public static bool Enabled
		{
			get
			{
				return OverlayConfig.NetworkAlerts();
			}
			set
			{
				NetworkLink.SetEnabled(value);
			}
		}

		public static bool CanChangeEnabled => NetworkLink.CanChangeEnabled;

		public static bool ReceiveMapGenerationData
		{
			get
			{
				return OverlayConfig.ReceiveMapGenerationData();
			}
			set
			{
				OverlayConfig.SetReceiveMapGenerationData(value);
			}
		}

		public static bool SendMapGenerationData
		{
			get
			{
				return OverlayConfig.SendMapGenerationData();
			}
			set
			{
				OverlayConfig.SetSendMapGenerationData(value);
			}
		}

		public static bool Live => NetworkLink.Live;

		public static bool IsHost => NetworkLink.IsServer;

		public static string Version => NetworkLink.OurVersion;

		public static string HostVersion => NetworkLink.HostVersion;

		public static event Action<CompanySale> CompanySaleReceived;

		public static event Action<Quota> QuotaReceived;

		public static event Action<Weather> WeatherReceived;

		public static event Action<PlayerNames> PlayerNamesReceived;

		public static event Action<PlayerSlotRepair> PlayerSlotRepairReceived;

		public static event Action<GenerationData> GenerationDataReceived;

		public static event Action<DungeonSize> DungeonSizeReceived;

		public static event Action<ObjectSync> ObjectSyncReceived;

		public static event Action MapGenerationAccepted;

		public static event Action MapGenerationRejected;

		public static event Action<ulong> MapGenerationRequested;

		public static ulong[] Clients()
		{
			return NetworkLink.Clients();
		}

		public static string VersionOf(ulong clientId)
		{
			return NetworkLink.VersionOf(clientId);
		}

		public static bool Send(ulong clientId, string info, AlertTone tone = AlertTone.Normal, string subject = null, string kind = null)
		{
			return NetworkLink.SendAlert(clientId, info, tone, subject, kind);
		}

		public static int Broadcast(string info, AlertTone tone = AlertTone.Normal, string subject = null, string kind = null)
		{
			return NetworkLink.BroadcastAlert(info, tone, subject, kind);
		}

		public static bool RequestMapGenerationData()
		{
			return NetworkLink.RequestMapGenerationData();
		}

		public static bool SendCompanySale(ulong clientId, string itemName, int price)
		{
			return NetworkLink.SendCompanySale(clientId, itemName, price);
		}

		public static int BroadcastCompanySale(string itemName, int price)
		{
			return NetworkLink.BroadcastCompanySale(itemName, price);
		}

		public static bool SendQuota(ulong clientId, int amount)
		{
			return NetworkLink.SendQuota(clientId, amount);
		}

		public static int BroadcastQuota(int amount)
		{
			return NetworkLink.BroadcastQuota(amount);
		}

		public static bool SendWeather(ulong clientId, int weather)
		{
			return NetworkLink.SendWeather(clientId, weather);
		}

		public static int BroadcastWeather(int weather)
		{
			return NetworkLink.BroadcastWeather(weather);
		}

		public static bool SendPlayerNames(ulong clientId, string[] names)
		{
			return NetworkLink.SendPlayerNames(clientId, names);
		}

		public static int BroadcastPlayerNames(string[] names)
		{
			return NetworkLink.BroadcastPlayerNames(names);
		}

		public static bool SendPlayerSlotRepair(ulong clientId, int slot)
		{
			return NetworkLink.SendPlayerSlotRepair(clientId, slot);
		}

		public static bool SendGenerationData(ulong clientId, byte[] data)
		{
			return NetworkLink.SendGenerationData(clientId, data);
		}

		public static int BroadcastGenerationData(byte[] data)
		{
			return NetworkLink.BroadcastGenerationData(data);
		}

		public static bool SendDungeonSize(ulong clientId, float size)
		{
			return NetworkLink.SendDungeonSize(clientId, size);
		}

		public static int BroadcastDungeonSize(float size)
		{
			return NetworkLink.BroadcastDungeonSize(size);
		}

		public static bool SendObjectSync(ulong clientId, string prefabName, Vector3 position, Quaternion rotation, Vector3 scale)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return NetworkLink.SendObjectSync(clientId, prefabName, position, rotation, scale);
		}

		public static int BroadcastObjectSync(string prefabName, Vector3 position, Quaternion rotation, Vector3 scale)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			return NetworkLink.BroadcastObjectSync(prefabName, position, rotation, scale);
		}

		internal static void RaiseCompanySale(string itemName, int price)
		{
			Network.CompanySaleReceived?.Invoke(new CompanySale(itemName, price));
		}

		internal static void RaiseQuota(int amount)
		{
			Network.QuotaReceived?.Invoke(new Quota(amount));
		}

		internal static void RaiseWeather(int weather)
		{
			Network.WeatherReceived?.Invoke(new Weather(weather));
		}

		internal static void RaisePlayerNames(string[] names)
		{
			Network.PlayerNamesReceived?.Invoke(new PlayerNames(names));
		}

		internal static void RaisePlayerSlotRepair(int slot)
		{
			Network.PlayerSlotRepairReceived?.Invoke(new PlayerSlotRepair(slot));
		}

		internal static void RaiseGenerationData(byte[] data)
		{
			Network.GenerationDataReceived?.Invoke(new GenerationData(data));
		}

		internal static void RaiseDungeonSize(float size)
		{
			Network.DungeonSizeReceived?.Invoke(new DungeonSize(size));
		}

		internal static void RaiseObjectSync(string prefabName, Vector3 position, Quaternion rotation, Vector3 scale)
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			Network.ObjectSyncReceived?.Invoke(new ObjectSync(prefabName, position, rotation, scale));
		}

		internal static void RaiseMapGenerationAccepted()
		{
			Network.MapGenerationAccepted?.Invoke();
		}

		internal static void RaiseMapGenerationRejected()
		{
			Network.MapGenerationRejected?.Invoke();
		}

		internal static void RaiseMapGenerationRequested(ulong clientId)
		{
			Network.MapGenerationRequested?.Invoke(clientId);
		}
	}
	public struct CompanySale
	{
		public string ItemName { get; }

		public int Price { get; }

		public CompanySale(string itemName, int price)
		{
			ItemName = itemName;
			Price = price;
		}
	}
	public struct Quota
	{
		public int Amount { get; }

		public Quota(int amount)
		{
			Amount = amount;
		}
	}
	public struct Weather
	{
		public int Value { get; }

		public Weather(int value)
		{
			Value = value;
		}
	}
	public struct PlayerNames
	{
		public string[] Names { get; }

		public PlayerNames(string[] names)
		{
			Names = names;
		}
	}
	public struct PlayerSlotRepair
	{
		public int Slot { get; }

		public PlayerSlotRepair(int slot)
		{
			Slot = slot;
		}
	}
	public struct GenerationData
	{
		public byte[] Data { get; }

		public GenerationData(byte[] data)
		{
			Data = data;
		}
	}
	public struct DungeonSize
	{
		public float Value { get; }

		public DungeonSize(float value)
		{
			Value = value;
		}
	}
	public struct ObjectSync
	{
		public string PrefabName { get; }

		public Vector3 Position { get; }

		public Quaternion Rotation { get; }

		public Vector3 Scale { get; }

		public ObjectSync(string prefabName, Vector3 position, Quaternion rotation, Vector3 scale)
		{
			//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_0011: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			PrefabName = prefabName;
			Position = position;
			Rotation = rotation;
			Scale = scale;
		}
	}
	public static class OverlayColorPicker
	{
		private const int WheelSize = 196;

		private const float MinWheel = 96f;

		private static readonly Dictionary<OverlayPanel, OverlayWindow> Windows = new Dictionary<OverlayPanel, OverlayWindow>();

		private static OverlayWindow _current;

		private static Action<Color> _chosen;

		private static string _label = "Colour";

		private static float _hue;

		private static float _saturation;

		private static float _value = 1f;

		private static float _alpha = 1f;

		private static string _hex = string.Empty;

		private static bool _typing;

		private static Texture2D _wheel;

		private static float _wheelValue = -1f;

		private static float ChosenWidth => Mathf.Max(54f, OverlayStyles.Measure("CHOSEN", OverlayStyles.ColumnHeader));

		private static float HexWidth => Mathf.Max(118f, OverlayStyles.Measure("#FFFFFFFF", OverlayStyles.Field) + 12f);

		private static float UseWidth => OverlayStyles.ButtonWidth("USE");

		private static float ColumnWidth => ChosenWidth + HexWidth + UseWidth + 12f;

		public static bool IsOpen => _current != null && _current.Open;

		public static bool Swatch(Rect rect, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			bool result = OverlayStyles.Press(rect, GUIContent.none, OverlayStyles.SmallButton);
			OverlayStyles.DrawBox(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, ((Rect)(ref rect)).height - 4f), color, OverlayStyles.Border);
			return result;
		}

		public static void Swatch(Rect rect, string label, Color color, Action<Color> chosen)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			if (Swatch(rect, color))
			{
				Pick(label, color, chosen);
			}
		}

		public static void Pick(string label, Color start, Action<Color> chosen)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			_label = (string.IsNullOrEmpty(label) ? "Colour" : label);
			_chosen = chosen;
			SetColor(start);
			_typing = false;
			OverlayWindow overlayWindow = WindowFor(Dock.ActivePanel);
			if (overlayWindow != null)
			{
				_current = overlayWindow;
				overlayWindow.Focus();
			}
		}

		public static void Cancel()
		{
			_chosen = null;
			if (_current != null)
			{
				_current.Open = false;
			}
			_current = null;
		}

		private static OverlayWindow WindowFor(OverlayPanel panel)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (panel == null)
			{
				return null;
			}
			if (Windows.TryGetValue(panel, out var value) && value != null)
			{
				return value;
			}
			value = panel.AddWindow("COLOUR", Draw, null, new Rect(170f, 160f, 520f, 420f));
			value.Listed = false;
			value.Subtitle = () => _label;
			Windows[panel] = value;
			return value;
		}

		private static void SetColor(Color color)
		{
			//IL_0001: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			Color.RGBToHSV(color, ref _hue, ref _saturation, ref _value);
			_alpha = color.a;
			_hex = ThemeSpec.Write(Current());
		}

		private static Color Current()
		{
			//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_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_0026: Unknown result type (might be due to invalid IL or missing references)
			Color result = Color.HSVToRGB(_hue, _saturation, _value);
			result.a = _alpha;
			return result;
		}

		private static void Draw(Rect content)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			float rowHeight = OverlayStyles.RowHeight;
			bool flag = TakeEnter();
			float columnWidth = ColumnWidth;
			float num = Mathf.Min(196f, Mathf.Min(((Rect)(ref content)).width - columnWidth - 12f, ((Rect)(ref content)).height - rowHeight * 3f));
			num = Mathf.Max(96f, num);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((Rect)(ref content)).x, ((Rect)(ref content)).y, num, num);
			DrawWheel(rect);
			float num2 = ((Rect)(ref rect)).xMax + 12f;
			float num3 = Mathf.Max(120f, ((Rect)(ref content)).xMax - num2);
			float y = ((Rect)(ref content)).y;
			GUI.Label(new Rect(num2, y, num3, rowHeight), "BRIGHTNESS", OverlayStyles.ColumnHeader);
			y += rowHeight;
			_value = OverlayStyles.Slider(new Rect(num2, y, num3, rowHeight), _value, 0f, 1f);
			y += rowHeight + 4f;
			GUI.Label(new Rect(num2, y, num3, rowHeight), "OPACITY", OverlayStyles.ColumnHeader);
			y += rowHeight;
			_alpha = OverlayStyles.Slider(new Rect(num2, y, num3, rowHeight), _alpha, 0f, 1f);
			y += rowHeight + 8f;
			bool flag2 = DrawChosenAndHex(num2, ref y, num3, rowHeight);
			float y2 = Mathf.Max(((Rect)(ref rect)).yMax, ((Rect)(ref content)).y + rowHeight * 8f) + 8f;
			y2 = DrawRecent(content, y2, rowHeight);
			DrawActions(content, y2, rowHeight, flag || flag2);
			if (_current != null)
			{
				float num4 = Mathf.Max(96f, rowHeight * 8f);
				float num5 = rowHeight + Mathf.Min(rowHeight + 6f, 30f) + 6f;
				float num6 = rowHeight * 2f + 2f;
				_current.FitContent(108f + columnWidth, num4 + 8f + num5 + num6);
			}
		}

		private static bool TakeEnter()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			Event current = Event.current;
			if ((int)current.type != 4)
			{
				return false;
			}
			if ((int)current.keyCode != 13 && (int)current.keyCode != 271)
			{
				return false;
			}
			current.Use();
			return true;
		}

		private static void DrawWheel(Rect rect)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			EnsureWheel();
			GUI.DrawTexture(rect, (Texture)(object)_wheel, (ScaleMode)2);
			Vector2 center = ((Rect)(ref rect)).center;
			float num = Mathf.Min(((Rect)(ref rect)).width, ((Rect)(ref rect)).height) / 2f;
			Event current = Event.current;
			Vector2 val = current.mousePosition - center;
			bool flag = ((Vector2)(ref val)).sqrMagnitude <= num * num;
			if (((int)current.type == 0 || (int)current.type == 3) && current.button == 0 && flag)
			{
				Vector2 val2 = current.mousePosition - center;
				float num2 = Mathf.Atan2(0f - val2.y, val2.x);
				_hue = Mathf.Repeat(num2 / (MathF.PI * 2f), 1f);
				_saturation = Mathf.Clamp01(((Vector2)(ref val2)).magnitude / num);
				_typing = false;
				_hex = ThemeSpec.Write(Current());
				current.Use();
			}
			float num3 = _hue * MathF.PI * 2f;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(center.x + Mathf.Cos(num3) * _saturation * num, center.y - Mathf.Sin(num3) * _saturation * num);
			Rect val4 = default(Rect);
			((Rect)(ref val4))..ctor(val3.x - 5f, val3.y - 5f, 10f, 10f);
			OverlayStyles.Fill(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width, 1f), Color.white);
			OverlayStyles.Fill(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).yMax - 1f, ((Rect)(ref val4)).width, 1f), Color.white);
			OverlayStyles.Fill(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y, 1f, ((Rect)(ref val4)).height), Color.white);
			OverlayStyles.Fill(new Rect(((Rect)(ref val4)).xMax - 1f, ((Rect)(ref val4)).y, 1f, ((Rect)(ref val4)).height), Color.white);
		}

		private static void EnsureWheel()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0071: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_wheel != (Object)null && Mathf.Abs(_wheelValue - _value) < 0.02f)
			{
				return;
			}
			if ((Object)(object)_wheel == (Object)null)
			{
				_wheel = new Texture2D(196, 196, (TextureFormat)4, false)
				{
					hideFlags = (HideFlags)61,
					filterMode = (FilterMode)1,
					wrapMode = (TextureWrapMode)1
				};
			}
			_wheelValue = _value;
			Color[] array = (Color[])(object)new Color[38416];
			float num = 98f;
			for (int i = 0; i < 196; i++)
			{
				for (int j = 0; j < 196; j++)
				{
					float num2 = (float)j + 0.5f - num;
					float num3 = (float)i + 0.5f - num;
					float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
					if (num4 > num)
					{
						array[i * 196 + j] = Color.clear;
						continue;
					}
					float num5 = Mathf.Repeat(Mathf.Atan2(num3, num2) / (MathF.PI * 2f), 1f);
					Color val = Color.HSVToRGB(num5, Mathf.Clamp01(num4 / num), _value);
					val.a = Mathf.Clamp01(num - num4);
					array[i * 196 + j] = val;
				}
			}
			_wheel.SetPixels(array);
			_wheel.Apply();
		}

		private static bool DrawChosenAndHex(float x, ref float y, float width, float row)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			float useWidth = UseWidth;
			float chosenWidth = ChosenWidth;
			float num = Mathf.Max(90f, width - chosenWidth - useWidth - 12f);
			GUI.Label(new Rect(x, y, chosenWidth, row), "CHOSEN", OverlayStyles.ColumnHeader);
			GUI.Label(new Rect(x + chosenWidth + 6f, y, num, row), "HEX", OverlayStyles.ColumnHeader);
			y += row;
			OverlayStyles.DrawBox(new Rect(x, y, chosenWidth, row), Current(), OverlayStyles.Border);
			if (!_typing)
			{
				_hex = ThemeSpec.Write(Current());
			}
			string text = GUI.TextField(new Rect(x + chosenWidth + 6f, y, num, row), _hex ?? string.Empty, ThemeSpec.Read(_hex).HasValue ? OverlayStyles.Field : OverlayStyles.FieldInvalid);
			if (text != _hex)
			{
				_hex = text;
				_typing = true;
				Color? val = ThemeSpec.Read(text);
				if (val.HasValue)
				{
					Color value = val.Value;
					Color.RGBToHSV(value, ref _hue, ref _saturation, ref _value);
					_alpha = value.a;
				}
			}
			bool result = OverlayStyles.Press(new Rect(x + chosenWidth + num + 12f, y, useWidth, row), "USE", OverlayStyles.Button);
			y += row + 8f;
			return result;
		}

		private static float DrawRecent(Rect content, float y, float row)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(((Rect)(ref content)).x, y, ((Rect)(ref content)).width, row), "RECENT", OverlayStyles.ColumnHeader);
			y += row;
			Color[] array = OverlayConfig.RecentColors();
			if (array.Length == 0)
			{
				GUI.Label(new Rect(((Rect)(ref content)).x, y, ((Rect)(ref content)).width, row), "Colours you choose here are kept, ten at a time.", OverlayStyles.LabelMuted);
				return y + row + 6f;
			}
			float num = Mathf.Min(row + 6f, (((Rect)(ref content)).width - 90f) / 10f);
			for (int i = 0; i < array.Length; i++)
			{
				if (Swatch(new Rect(((Rect)(ref content)).x + (float)i * (num + 4f), y, num, num), array[i]))
				{
					SetColor(array[i]);
					_typing = false;
				}
			}
			return y + num + 6f;
		}

		private static void DrawActions(Rect content, float y, float row, bool accept)
		{
			//IL_0011: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			GUI.Label(new Rect(((Rect)(ref content)).x, y, ((Rect)(ref content)).width, row), "USE or Enter takes it for " + _label + ".", OverlayStyles.LabelMuted);
			y += row + 2f;
			float num = Mathf.Max(OverlayStyles.ControlWidth, OverlayStyles.ButtonWidth("CANCEL", OverlayStyles.DangerButton));
			if (OverlayStyles.Press(new Rect(((Rect)(ref content)).x, y, num, row), "CANCEL", OverlayStyles.DangerButton))
			{
				Cancel();
			}
			else if (accept)
			{
				Color val = Current();
				Action<Color> chosen = _chosen;
				OverlayConfig.RememberColor(val);
				Cancel();
				chosen?.Invoke(val);
				Dock.Toast(_label + " is " + ThemeSpec.Write(val));
			}
		}
	}
	public sealed class OverlayColumns
	{
		private readonly string[] _headers;

		private readonly float[] _widths;

		private readonly float[] _minimums;

		public int Count => _headers.Length;

		public int Stretch { get; set; }

		public float Total
		{
			get
			{
				float num = 0f;
				for (int i = 0; i < _widths.Length; i++)
				{
					num += Width(i);
				}
				return num;
			}
		}

		public OverlayColumns(params string[] headers)
		{
			_headers = headers ?? new string[0];
			_widths = new float[_headers.Length];
			_minimums = new float[_headers.Length];
		}

		public void SetMinimum(int column, float width)
		{
			if (column >= 0 && column < _minimums.Length)
			{
				_minimums[column] = width;
			}
		}

		public void Measure(int column, string text, GUIStyle style = null)
		{
			if (column >= 0 && column < _widths.Length && !string.IsNullOrEmpty(text))
			{
				float num = OverlayStyles.Measure(text, style ?? OverlayStyles.Label) + OverlayStyles.CellPadding * 2f;
				if (num > _widths[column])
				{
					_widths[column] = num;
				}
			}
		}

		public void Reset()
		{
			for (int i = 0; i < _widths.Length; i++)
			{
				_widths[i] = 0f;
			}
		}

		public float Width(int column)
		{
			if (column < 0 || column >= _widths.Length)
			{
				return 0f;
			}
			float num = OverlayStyles.Measure(_headers[column], OverlayStyles.ColumnHeader) + OverlayStyles.CellPadding * 2f;
			return Mathf.Max(Mathf.Max(_widths[column], _minimums[column]), num);
		}

		public void Fit(OverlayWindow window, float extra = 0f)
		{
			window?.FitContentWidth(Total + extra);
		}

		public Rect Cell(Rect row, int column)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (column < 0 || column >= _widths.Length)
			{
				return new Rect(((Rect)(ref row)).x, ((Rect)(ref row)).y, 0f, ((Rect)(ref row)).height);
			}
			float num = ((Rect)(ref row)).width - Total;
			float num2 = ((Rect)(ref row)).x;
			for (int i = 0; i < column; i++)
			{
				num2 += Width(i) + ((i == Stretch) ? num : 0f);
			}
			float num3 = Width(column) + ((column == Stretch) ? num : 0f);
			float cellPadding = OverlayStyles.CellPadding;
			return new Rect(num2 + cellPadding, ((Rect)(ref row)).y, Mathf.Max(0f, num3 - cellPadding * 2f), ((Rect)(ref row)).height);
		}

		public void DrawHeaders(Rect row)
		{
			//IL_0007: 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)
			for (int i = 0; i < _headers.Length; i++)
			{
				GUI.Label(Cell(row, i), _headers[i], OverlayStyles.ColumnHeader);
			}
		}

		public void DrawCell(Rect row, int column, string text, GUIStyle style = null)
		{
			//IL_0018: 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)
			GUIStyle val = style ?? OverlayStyles.Label;
			Measure(column, text, val);
			GUI.Label(Cell(row, column), text, val);
		}
	}
	public static class OverlayIcons
	{
		public const int RecommendedSize = 64;

		public const string FolderName = "icons";

		private static readonly Dictionary<string, Texture2D> Loaded = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> Created = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static Texture2D _blank;

		public static Texture2D FromFile(string path)
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			try
			{
				if (string.IsNullOrEmpty(path) || !File.Exists(path))
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					hideFlags = (HideFlags)61,
					wrapMode = (TextureWrapMode)1
				};
				if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
				{
					Object.Destroy((Object)(object)val);
					return null;
				}
				((Texture)val).filterMode = (FilterMode)1;
				return val;
			}
			catch (Exception ex)
			{
				OverlayPlugin.Log.LogWarning((object)("[Dock] Failed to load the icon " + path + ": " + ex.Message));
				return null;
			}
		}

		public static Texture2D Blank()
		{
			//IL_001f: 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_002d: 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_0042: Expected O, but got Unknown
			if ((Object)(object)_blank != (Object)null)
			{
				return _blank;
			}
			_blank = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61,
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1
			};
			Color32[] pixels = (Color32[])(object)new Color32[4096];
			_blank.SetPixels32(pixels);
			_blank.Apply();
			return _blank;
		}

		public static int Reload()
		{
			int count = Loaded.Count;
			foreach (KeyValuePair<string, Texture2D> item in Loaded)
			{
				if ((Object)(object)item.Value != (Object)null && (Object)(object)item.Value != (Object)(object)_blank)
				{
					Object.Destroy((Object)(object)item.Value);
				}
			}
			Loaded.Clear();
			Created.Clear();
			OverlayPlugin.Log.LogInfo((object)$"[Dock] Dropped {count} icon(s) - they will be read off disk again.");
			return count;
		}

		internal static Texture2D For(OverlayWindow window)
		{
			if ((Object)(object)window.Icon != (Object)null)
			{
				return window.Icon;
			}
			string text = PathFor(window);
			if (text == null)
			{
				return Blank();
			}
			if (Loaded.TryGetValue(text, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = FromFile(text);
			if ((Object)(object)value == (Object)null)
			{
				WriteBlank(text);
				value = Blank();
			}
			else
			{
				OverlayPlugin.Log.LogInfo((object)("[Dock] Icon: " + text));
			}
			Loaded[text] = value;
			return value;
		}

		private static string PathFor(OverlayWindow window)
		{
			try
			{
				Assembly ownerAssembly = window.Panel.OwnerAssembly;
				string text = ((ownerAssembly == null) ? null : Path.GetDirectoryName(ownerAssembly.Location));
				if (string.IsNullOrEmpty(text))
				{
					return null;
				}
				string text2 = (string.IsNullOrEmpty(window.IconFile) ? Slug(window.Title) : window.IconFile);
				if (string.IsNullOrEmpty(text2))
				{
					return null;
				}
				if (!text2.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
				{
					text2 += ".png";
				}
				return Path.Combine(Path.Combine(text, "icons"), text2);
			}
			catch (Exception ex)
			{
				OverlayPlugin.Log.LogWarning((object)("[Dock] Could not work out where \"" + window.Title + "\" keeps its icon: " + ex.Message));
				return null;
			}
		}

		private static string Slug(string title)
		{
			if (string.IsNullOrEmpty(title))
			{
				return null;
			}
			StringBuilder stringBuilder = new StringBuilder(title.Length);
			bool flag = false;
			for (int i = 0; i < title.Length; i++)
			{
				char c = char.ToLowerInvariant(title[i]);
				if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
				{
					stringBuilder.Append(c);
					flag = false;
				}
				else if (!flag && stringBuilder.Length > 0)
				{
					stringBuilder.Append('-');
					flag = true;
				}
			}
			return stringBuilder.ToString().TrimEnd('-');
		}

		private static void WriteBlank(string path)
		{
			if (!Created.Add(path))
			{
				return;
			}
			try
			{
				string directoryName = Path.GetDirectoryName(path);
				if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName))
				{
					Directory.CreateDirectory(directoryName);
				}
				File.WriteAllBytes(path, ImageConversion.EncodeToPNG(Blank()));
				OverlayPlugin.Log.LogInfo((object)$"[Dock] No icon at {path} - wrote a blank {64}x{64} one. Draw over it to give the window an icon.");
			}
			catch (Exception ex)
			{
				OverlayPlugin.Log.LogWarning((object)("[Dock] Could not write a blank icon at " + path + ": " + ex.Message));
			}
		}
	}
	public abstract class OverlayNode
	{
		private readonly List<OverlayNode> _pool = new List<OverlayNode>();

		private int _next;

		private float _spacing = -1f;

		internal OverlayLayout Root;

		internal OverlayNode Child;

		internal bool Live;

		public OverlayNode Parent { get; internal set; }

		public Rect Rect { get; internal set; }

		public float NeedWidth { get; internal set; }

		public float NeedHeight { get; internal set; }

		public float UsedWidth { get; internal set; }

		public float UsedHeight { get; internal set; }

		public float Spacing
		{
			get
			{
				return (_spacing < 0f) ? OverlayStyles.Gap : _spacing;
			}
			set
			{
				_spacing = value;
			}
		}

		public OverlayWindow Window => (Root == null) ? null : Root.Owner;

		protected abstract Rect Place(float width, float height, bool fill);

		internal abstract Rect Region();

		internal abstract void Absorb(OverlayNode child);

		protected virtual void Sealed()
		{
		}

		public Rect Take(float width, float height, bool fill = false)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			CloseChild();
			return Place(width, height, fill);
		}

		public void Close()
		{
			if (Live)
			{
				CloseChild();
				Live = false;
				Sealed();
				if (Parent != null)
				{
					Parent.Absorb(this);
				}
			}
		}

		public void Label(string text, GUIStyle style = null)
		{
			//IL_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = style ?? OverlayStyles.Label;
			Vector2 val2 = OverlayStyles.MeasureSize(text, val);
			Rect val3 = Take(val2.x, Mathf.Max(OverlayStyles.RowHeight, val2.y));
			GUI.Label(val3, text, val);
		}

		public float Paragraph(string text, GUIStyle style = null)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text))
			{
				return 0f;
			}
			float controlWidth = OverlayStyles.ControlWidth;
			Rect rect = Rect;
			float width = Mathf.Max(controlWidth, ((Rect)(ref rect)).width);
			float num = OverlayStyles.TextHeight(text, width, style);
			Rect rect2 = Take(0f, num);
			OverlayStyles.Paragraph(rect2, text, style);
			return num;
		}

		public bool Button(string label, GUIStyle style = null)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			GUIStyle style2 = style ?? OverlayStyles.Button;
			float width = OverlayStyles.ButtonWidth(label, style2);
			Rect rect = Take(width, OverlayStyles.RowHeight);
			return OverlayStyles.Press(OverlayStyles.Fit(rect, label, style2), label, style2);
		}

		public bool Choice(string label, bool active)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle style = (active ? OverlayStyles.ButtonActive : OverlayStyles.Button);
			float width = OverlayStyles.ButtonWidth(label, style);
			return OverlayStyles.Choice(Take(width, OverlayStyles.RowHeight), label, active);
		}

		public bool Toggle(bool on, string onText = "ON", string offText = "OFF")
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			float width = OverlayStyles.ToggleWidth(onText, offText);
			return OverlayStyles.Toggle(Take(width, OverlayStyles.RowHeight), on, onText, offText);
		}

		public float Slider(float value, float min, float max)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			float width = OverlayStyles.ControlWidth * 2f;
			return OverlayStyles.Slider(Take(width, OverlayStyles.RowHeight, fill: true), value, min, max);
		}

		public float SliderField(string key, float value, float min, float max, string format = "0.##")
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			float width = OverlayStyles.ControlWidth * 2f + OverlayStyles.FieldWidth(max.ToString(format)) + Spacing;
			return OverlayStyles.SliderField(Take(width, OverlayStyles.RowHeight, fill: true), key, value, min, max, format);
		}

		public float NumberField(string key, float value, float min, float max, string format = "0.##")
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			float width = OverlayStyles.FieldWidth(max.ToString(format));
			return OverlayStyles.NumberField(Take(width, OverlayStyles.RowHeight), key, value, min, max, format);
		}

		public string TextField(string text, string sample = null, bool fill = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			string text2 = text ?? string.Empty;
			float width = OverlayStyles.FieldWidth(sample ?? text2);
			Rect rect = Take(width, OverlayStyles.RowHeight, fill);
			return GUI.TextField(OverlayStyles.Fit(rect, text2, OverlayStyles.Field), text2, OverlayStyles.Field);
		}

		public void Space(float height = 0f)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			Take(0f, (height > 0f) ? height : OverlayStyles.Gap);
		}

		public void Rule()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Rect rect = Take(0f, Mathf.Max(1f, OverlayStyles.WindowBorderThickness));
			OverlayStyles.Fill(rect, OverlayStyles.Border);
		}

		internal void CloseChild()
		{
			if (Child != null && Child.Live)
			{
				Child.Close();
			}
			Child = null;
		}

		internal void Adopt(OverlayNode child)
		{
			CloseChild();
			child.Parent = this;
			child.Root = Root;
			Child = child;
		}

		internal T Fetch<T>() where T : OverlayNode, new()
		{
			while (_next < _pool.Count)
			{
				if (_pool[_next].GetType() == typeof(T))
				{
					T result = (T)_pool[_next];
					_next++;
					return result;
				}
				_pool.RemoveAt(_next);
			}
			T val = new T();
			_pool.Add(val);
			_next++;
			return val;
		}

		internal void ResetPool()
		{
			_next = 0;
		}
	}
	public class OverlayBox : OverlayNode
	{
		private bool _horizontal;

		private float _cursor;

		private bool _first;

		private int _stretched;

		private int _lastStretched;

		private float _lastNeedWidth;

		public bool Horizontal => _horizontal;

		public OverlayBox Column()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			OverlayBox overlayBox = Fetch<OverlayBox>();
			Adopt(overlayBox);
			overlayBox.Start(Region(), horizontal: false);
			return overlayBox;
		}

		public OverlayBox Row()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			OverlayBox overlayBox = Fetch<OverlayBox>();
			Adopt(overlayBox);
			overlayBox.Start(Region(), horizontal: true);
			return overlayBox;
		}

		public OverlayTable Table(params string[] headers)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			OverlayTable overlayTable = Fetch<OverlayTable>();
			Adopt(overlayTable);
			overlayTable.Start(Region(), headers ?? Array.Empty<string>());
			return overlayTable;
		}

		public OverlayScroll Scroll(string key = null, float leaveBelow = 0f)
		{
			//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_0061: Unknown result type (might be due to invalid IL or missing references)
			OverlayScroll overlayScroll = Fetch<OverlayScroll>();
			Adopt(overlayScroll);
			Rect area = Region();
			if (leaveBelow > 0f && !Horizontal)
			{
				((Rect)(ref area))..ctor(((Rect)(ref area)).x, ((Rect)(ref area)).y, ((Rect)(ref area)).width, Mathf.Max(OverlayStyles.RowHeight, ((Rect)(ref area)).height - leaveBelow));
			}
			overlayScroll.StartScroll(area, key);
			return overlayScroll;
		}

		public void Spring()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (_horizontal)
			{
				float num = Slack();
				_stretched++;
				_cursor += (_first ? 0f : base.Spacing) + num;
				_first = false;
				float cursor = _cursor;
				Rect rect = base.Rect;
				base.UsedWidth = cursor - ((Rect)(ref rect)).x;
			}
		}

		public bool Toggle(string label, bool on, string onText = "ON", string offText = "OFF", GUIStyle style = null)
		{
			//IL_002f: 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_0060: 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)
			GUIStyle val = style ?? OverlayStyles.Label;
			float num = OverlayStyles.ToggleWidth(onText, offText);
			float num2 = OverlayStyles.Measure(label, val);
			Rect row = Take(num2 + base.Spacing + num, OverlayStyles.RowHeight, fill: true);
			GUI.Label(new Rect(((Rect)(ref row)).x, ((Rect)(ref row)).y, Mathf.Max(num2, ((Rect)(ref row)).width - num - base.Spacing), ((Rect)(ref row)).height), label, val);
			return OverlayStyles.Toggle(row, on, onText, offText);
		}

		public bool Button(string label, string action, GUIStyle style = null)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = style ?? OverlayStyles.Label;
			float num = OverlayStyles.ButtonWidth(action);
			float num2 = OverlayStyles.Measure(label, val);
			Rect val2 = Take(num2 + base.Spacing + num, OverlayStyles.RowHeight, fill: true);
			GUI.Label(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, Mathf.Max(num2, ((Rect)(ref val2)).width - num - base.Spacing), ((Rect)(ref val2)).height), label, val);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((Rect)(ref val2)).xMax - num, ((Rect)(ref val2)).y + 1f, num, ((Rect)(ref val2)).height - 3f);
			return OverlayStyles.Press(OverlayStyles.Fit(rect, action, OverlayStyles.Button, fromRight: true), action, OverlayStyles.Button);
		}

		public float Slider(string label, string key, float value, float min, float max, string format = "0.##", GUIStyle style = null)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			GUIStyle val = style ?? OverlayStyles.Label;
			float num = OverlayStyles.ControlWidth * 2f + OverlayStyles.FieldWidth(max.ToString(format)) + base.Spacing;
			float num2 = OverlayStyles.Measure(label, val);
			Rect val2 = Take(num2 + base.Spacing + num, OverlayStyles.RowHeight, fill: true);
			GUI.Label(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, Mathf.Max(num2, ((Rect)(ref val2)).width - num - base.Spacing), ((Rect)(ref val2)).height), label, val);
			float num3 = Mathf.Max(num, ((Rect)(ref val2)).width - num2 - base.Spacing);
			return OverlayStyles.SliderField(new Rect(((Rect)(ref val2)).xMax - num3, ((Rect)(ref val2)).y, num3, ((Rect)(ref val2)).height), key, value, min, max, format);
		}

		public string Field(string label, string text, string sample = null, GUIStyle style = null)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = style ?? OverlayStyles.Label;
			string text2 = text ?? string.Empty;
			float num = OverlayStyles.FieldWidth(sample ?? text2);
			float num2 = OverlayStyles.Measure(label, val);
			Rect val2 = Take(num2 + base.Spacing + num, OverlayStyles.RowHeight, fill: true);
			GUI.Label(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, Mathf.Max(num2, ((Rect)(ref val2)).width - num - base.Spacing), ((Rect)(ref val2)).height), label, val);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((Rect)(ref val2)).xMax - num, ((Rect)(ref val2)).y, num, ((Rect)(ref val2)).height);
			return GUI.TextField(OverlayStyles.Fit(rect, text2, OverlayStyles.Field, fromRight: true), text2, OverlayStyles.Field);
		}

		internal void Start(Rect rect, bool horizontal)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			base.Rect = rect;
			_horizontal = horizontal;
			_cursor = (horizontal ? ((Rect)(ref rect)).x : ((Rect)(ref rect)).y);
			_first = true;
			_stretched = 0;
			base.NeedWidth = 0f;
			base.NeedHeight = 0f;
			base.UsedWidth = 0f;
			base.UsedHeight = 0f;
			Live = true;
			Child = null;
			ResetPool();
		}

		protected override Rect Place(float width, float height, bool fill)
		{
			//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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			float num = (_first ? 0f : base.Spacing);
			_first = false;
			Rect rect;
			Rect result = default(Rect);
			if (_horizontal)
			{
				float num2 = _cursor + num;
				float num3 = width;
				if (fill)
				{
					num3 += Slack();
					_stretched++;
				}
				rect = base.Rect;
				float y = ((Rect)(ref rect)).y;
				float num4 = num3;
				float num5;
				if (!(height > 0f))
				{
					rect = base.Rect;
					num5 = ((Rect)(ref rect)).height;
				}
				else
				{
					num5 = height;
				}
				((Rect)(ref result))..ctor(num2, y, num4, num5);
				_cursor = num2 + num3;
				base.NeedWidth += num + width;
				base.NeedHeight = Mathf.Max(base.NeedHeight, ((Rect)(ref result)).height);
			}
			else
			{
				float num6 = _cursor + num;
				rect = base.Rect;
				float x = ((Rect)(ref rect)).x;
				rect = base.Rect;
				((Rect)(ref result))..ctor(x, num6, Mathf.Max(width, ((Rect)(ref rect)).width), height);
				_cursor = num6 + height;
				base.NeedWidth = Mathf.Max(base.NeedWidth, width);
				base.NeedHeight += num + height;
			}
			float usedWidth;
			if (!_horizontal)
			{
				usedWidth = Mathf.Max(base.UsedWidth, ((Rect)(ref result)).width);
			}
			else
			{
				float cursor = _cursor;
				rect = base.Rect;
				usedWidth = cursor - ((Rect)(ref rect)).x;
			}
			base.UsedWidth = usedWidth;
			float usedHeight;
			if (!_horizontal)
			{
				float cursor2 = _cursor;
				rect = base.Rect;
				usedHeight = cursor2 - ((Rect)(ref rect)).y;
			}
			else
			{
				usedHeight = Mathf.Max(base.UsedHeight, ((Rect)(ref result)).height);
			}
			base.UsedHeight = usedHeight;
			return result;
		}

		internal override Rect Region()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			float num = (_first ? 0f : base.Spacing);
			Rect rect;
			Rect result;
			if (!_horizontal)
			{
				rect = base.Rect;
				float x = ((Rect)(ref rect)).x;
				float num2 = _cursor + num;
				rect = base.Rect;
				float width = ((Rect)(ref rect)).width;
				rect = base.Rect;
				result = new Rect(x, num2, width, Mathf.Max(0f, ((Rect)(ref rect)).yMax - _cursor - num));
			}
			else
			{
				float num3 = _cursor + num;
				rect = base.Rect;
				float y = ((Rect)(ref rect)).y;
				rect = base.Rect;
				float num4 = Mathf.Max(0f, ((Rect)(ref rect)).xMax - _cursor - num);
				rect = base.Rect;
				result = new Rect(num3, y, num4, ((Rect)(ref rect)).height);
			}
			return result;
		}

		internal override void Absorb(OverlayNode child)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			float num = (_first ? 0f : base.Spacing);
			_first = false;
			if (_horizontal)
			{
				_cursor += num + child.UsedWidth;
				base.NeedWidth += num + child.NeedWidth;
				base.NeedHeight = Mathf.Max(base.NeedHeight, child.NeedHeight);
			}
			else
			{
				_cursor += num + child.UsedHeight;
				base.NeedWidth = Mathf.Max(base.NeedWidth, child.NeedWidth);
				base.NeedHeight += num + child.NeedHeight;
			}
			float usedWidth;
			Rect rect;
			if (!_horizontal)
			{
				usedWidth = Mathf.Max(base.UsedWidth, child.UsedWidth);
			}
			else
			{
				float cursor = _cursor;
				rect = base.Rect;
				usedWidth = cursor - ((Rect)(ref rect)).x;
			}
			base.UsedWidth = usedWidth;
			float usedHeight;
			if (!_horizontal)
			{
				float cursor2 = _cursor;
				rect = base.Rect;
				usedHeight = cursor2 - ((Rect)(ref rect)).y;
			}
			else
			{
				usedHeight = Mathf.Max(base.UsedHeight, child.UsedHeight);
			}
			base.UsedHeight = usedHeight;
		}

		protected override void Sealed()
		{
			_lastNeedWidth = base.NeedWidth;
			_lastStretched = _stretched;
		}

		private float Slack()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			float result;
			if (_lastStretched <= 0)
			{
				result = 0f;
			}
			else
			{
				Rect rect = base.Rect;
				result = Mathf.Max(0f, ((Rect)(ref rect)).width - _lastNeedWidth) / (float)_lastStretched;
			}
			return result;
		}
	}
	public sealed class OverlayScroll : OverlayBox
	{
		private Rect _area;

		private float _content;

		private Vector2 _scroll;

		public float BarWidth { get; set; } = 14f;

		public float ViewHeight => ((Rect)(ref _area)).height;

		public int FirstRow(float step)
		{
			return (!(step <= 0f)) ? Mathf.Max(0, Mathf.FloorToInt(_scroll.y / step) - 1) : 0;
		}

		public int RowsShown(float step)
		{
			return (!(step <= 0f)) ? (Mathf.CeilToInt(((Rect)(ref _area)).height / step) + 3) : 0;
		}

		public void SkipRows(int rows, float step)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (rows > 0 && step > 0f)
			{
				Take(0f, (float)rows * step);
			}
		}

		internal void StartScroll(Rect area, string key)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			_area = area;
			float num = Mathf.Max(OverlayStyles.ControlWidth, ((Rect)(ref area)).width - BarWidth);
			float num2 = Mathf.Max(_content, ((Rect)(ref area)).height);
			Vector2 val = ((Root == null) ? Vector2.zero : Root.ScrollOf(key));
			val = (_scroll = GUI.BeginScrollView(area, val, new Rect(0f, 0f, num, num2)));
			if (Root != null)
			{
				Root.SetScroll(key, val);
			}
			Start(new Rect(0f, 0f, num, num2), horizontal: false);
		}

		protected override void Sealed()
		{
			base.Sealed();
			GUI.EndScrollView();
			_content = base.NeedHeight;
			base.NeedWidth += BarWidth;
			base.NeedHeight = 0f;
			base.UsedWidth = ((Rect)(ref _area)).width;
			base.UsedHeight = ((Rect)(ref _area)).height;
		}
	}
	public sealed class OverlayTable : OverlayNode
	{
		private static readonly string[] None = new string[0];

		private readonly List<float> _heights = new List<float>();

		private string[] _headers = None;

		private float[] _widths = new float[0];

		private float[] _minimums = new float[0];

		private int _generation = -1;

		private int _index;

		private float _cursor;

		private bool _first;

		public int Stretch { get; set; }

		public bool Striped { get; set; } = true;

		public bool ShowHeaders { get; set; } = true;

		public int Count => _headers.Length;

		public float Total
		{
			get
			{
				float num = 0f;
				for (int i = 0; i < _widths.Length; i++)
				{
					num += Width(i);
				}
				return num;
			}
		}

		public float Width(int column)
		{
			if (column < 0 || column >= _widths.Length)
			{
				return 0f;
			}
			float num = ((ShowHeaders && !string.IsNullOrEmpty(_headers[column])) ? (OverlayStyles.Measure(_headers[column], OverlayStyles.ColumnHeader) + OverlayStyles.CellPadding * 2f) : 0f);
			return Mathf.Max(Mathf.Max(_widths[column], _minimums[column]), num);
		}

		public void SetMinimum(int column, float width)
		{
			if (column >= 0 && column < _minimums.Length)
			{
				_minimums[column] = width;
			}
		}

		public void Reset()
		{
			for (int i = 0; i < _widths.Length; i++)
			{
				_widths[i] = 0f;
			}
			_heights.Clear();
		}

		public OverlayRow Row()
		{
			//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_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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			OverlayRow overlayRow = Fetch<OverlayRow>();
			Adopt(overlayRow);
			float num = (_first ? 0f : base.Spacing);
			_first = false;
			float num2 = HeightAt(_index);
			Rect rect = base.Rect;
			float x = ((Rect)(ref rect)).x;
			float num3 = _cursor + num;
			rect = base.Rect;
			Rect rect2 = default(Rect);
			((Rect)(ref rect2))..ctor(x, num3, ((Rect)(ref rect)).width, num2);
			if (Striped && (_index & 1) == 1)
			{
				OverlayStyles.Fill(rect2, OverlayStyles.RowFace);
			}
			_cursor = ((Rect)(ref rect2)).y;
			overlayRow.Start(this, _index, rect2);
			_index++;
			return overlayRow;
		}

		public Rect CellRect(Rect row, int column)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (column < 0 || column >= _widths.Length)
			{
				return new Rect(((Rect)(ref row)).x, ((Rect)(ref row)).y, 0f, ((Rect)(ref row)).height);
			}
			float num = ((Rect)(ref row)).width - Total;
			float num2 = ((Rect)(ref row)).x;
			for (int i = 0; i < column; i++)
			{
				num2 += Width(i) + ((i == Stretch) ? num : 0f);
			}
			float num3 = Width(column) + ((column == Stretch) ? num : 0f);
			float cellPadding = OverlayStyles.CellPadding;
			return new Rect(num2 + cellPadding, ((Rect)(ref row)).y, Mathf.Max(0f, num3 - cellPadding * 2f), ((Rect)(ref row)).height);
		}

		internal void Start(Rect rect, string[] headers)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			headers = headers ?? None;
			if (headers.Length != _widths.Length)
			{
				_widths = new float[headers.Length];
				_minimums = new float[headers.Length];
				_heights.Clear();
			}
			_headers = headers;
			if (_generation != OverlayStyles.Generation)
			{
				_generation = OverlayStyles.Generation;
				Reset();
			}
			base.Rect = rect;
			_cursor = ((Rect)(ref rect)).y;
			_index = 0;
			_first = true;
			base.NeedWidth = 0f;
			base.NeedHeight = 0f;
			base.UsedWidth = ((Rect)(ref rect)).width;
			base.UsedHeight = 0f;
			Live = true;
			Child = null;
			ResetPool();
			if (ShowHeaders && _headers.Length != 0)
			{
				DrawHeaders();
			}
		}

		internal void Measure(int column, float contentWidth)
		{
			if (column >= 0 && column < _widths.Length)
			{
				float num = contentWidth + OverlayStyles.CellPadding * 2f;
				if (num > _widths[column])
				{
					_widths[column] = num;
				}
			}
		}

		internal void RowNeeds(int index, float height)
		{
			while (_heights.Count <= index)
			{
				_heights.Add(OverlayStyles.RowHeight);
			}
			if (height > _heights[index])
			{
				_heights[index] = height;
			}
		}

		protected override Rect Place(float width, float height, bool fill)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			return Row().Take(width, height, fill);
		}

		internal override Rect Region()
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = base.Rect;
			float x = ((Rect)(ref rect)).x;
			float cursor = _cursor;
			rect = base.Rect;
			float width = ((Rect)(ref rect)).width;
			rect = base.Rect;
			return new Rect(x, cursor, width, Mathf.Max(0f, ((Rect)(ref rect)).yMax - _cursor));
		}

		internal override void Absorb(OverlayNode child)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			_cursor += child.UsedHeight;
			float cursor = _cursor;
			Rect rect = base.Rect;
			base.UsedHeight = cursor - ((Rect)(ref rect)).y;
		}

		protected override void Sealed()
		{
			//IL_001d: 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)
			base.NeedWidth = Total;
			base.NeedHeight = base.UsedHeight;
			Rect rect = base.Rect;
			base.UsedWidth = ((Rect)(ref rect)).width;
		}

		private void DrawHeaders()
		{
			//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_0018: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0099: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = base.Rect;
			float x = ((Rect)(ref rect)).x;
			float cursor = _cursor;
			rect = base.Rect;
			Rect row = default(Rect);
			((Rect)(ref row))..ctor(x, cursor, ((Rect)(ref rect)).width, OverlayStyles.RowHeight);
			for (int i = 0; i < _headers.Length; i++)
			{
				GUI.Label(CellRect(row, i), _headers[i], OverlayStyles.ColumnHeader);
			}
			float num = Mathf.Max(1f, OverlayStyles.WindowBorderThickness);
			rect = base.Rect;
			float x2 = ((Rect)(ref rect)).x;
			float yMax = ((Rect)(ref row)).yMax;
			rect = base.Rect;
			OverlayStyles.Fill(new Rect(x2, yMax, ((Rect)(ref rect)).width, num), OverlayStyles.Border);
			_cursor = ((Rect)(ref row)).yMax + num;
			_first = false;
			float cursor2 = _cursor;
			rect = base.Rect;
			base.UsedHeight = cursor2 - ((Rect)(ref rect)).y;
		}

		private float HeightAt(int index)
		{
			while (_heights.Count <= index)
			{
				_heights.Add(OverlayStyles.RowHeight);
			}
			return Mathf.Max(OverlayStyles.RowHeight, _heights[index]);
		}
	}
	public sealed class OverlayRow : OverlayNode
	{
		private OverlayTable _table;

		private int _index;

		private int _column;

		public OverlayTable Table => _table;

		public int Index => _index;

		public OverlayCell Cell(int column)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			OverlayCell overlayCell = Fetch<OverlayCell>();
			Adopt(overlayCell);
			_column = column + 1;
			overlayCell.Start(_table, base.Rect, column);
			return overlayCell;
		}

		public OverlayCell Cell()
		{
			return Cell(_column);
		}

		public void Label(int column, string text, GUIStyle style = null)
		{
			Cell(column).Label(text, style);
		}

		public bool Button(int column, string label, GUIStyle style = null)
		{
			return Cell(column).Button(label, style);
		}

		public bool Toggle(int column, bool on, string onText = "ON", string offText = "OFF")
		{
			return Cell(column).Toggle(on, onText, offText);
		}

		public float Slider(int column, string key, float value, float min, float max, string format = "0.##")
		{
			return Cell(column).SliderField(key, value, min, max, format);
		}

		public string TextField(int column, string text, string sample = null)
		{
			return Cell(column).TextField(text, sample);
		}

		internal void Start(OverlayTable table, int index, Rect rect)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			_table = table;
			_index = index;
			_column = 0;
			base.Rect = rect;
			base.NeedWidth = 0f;
			base.NeedHeight = OverlayStyles.RowHeight;
			base.UsedWidth = ((Rect)(ref rect)).width;
			base.UsedHeight = ((Rect)(ref rect)).height;
			Live = true;
			Child = null;
			ResetPool();
		}

		protected override Rect Place(float width, float height, bool fill)
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			return Cell(_column).Take(width, height, fill);
		}

		internal override Rect Region()
		{
			//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_000a: Unknown result type (might be due to invalid IL or missing references)
			return base.Rect;
		}

		internal override void Absorb(OverlayNode child)
		{
			base.NeedHeight = Mathf.Max(base.NeedHeight, child.NeedHeight);
		}

		protected override void Sealed()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			_table.RowNeeds(_index, base.NeedHeight);
			Rect rect = base.Rect;
			base.UsedHeight = Mathf.Max(((Rect)(ref rect)).height, base.NeedHeight);
		}
	}
	public sealed class OverlayCell : OverlayNode
	{
		private OverlayTable _table;

		private Rect _row;

		private int _column;

		private float _cursor;

		private float _content;

		private bool _first;

		public int Column => _column;

		internal void Start(OverlayTable table, Rect row, int column)
		{
			//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_002a: 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_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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			_table = table;
			_row = row;
			_column = column;
			_content = 0f;
			_first = true;
			base.Rect = table.CellRect(row, column);
			Rect rect = base.Rect;
			_cursor = ((Rect)(ref rect)).x;
			base.NeedWidth = 0f;
			base.NeedHeight = OverlayStyles.RowHeight;
			rect = base.Rect;
			base.UsedWidth = ((Rect)(ref rect)).width;
			rect = base.Rect;
			base.UsedHeight = ((Rect)(ref rect)).height;
			Live = true;
			Child = null;
			ResetPool();
		}

		protected override Rect Place(float width, float height, bool fill)
		{
			//IL_004e: 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_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_0099: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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)
			float num = (_first ? 0f : base.Spacing);
			_first = false;
			_content += num + width;
			_table.Measure(_column, _content);
			base.Rect = _table.CellRect(_row, _column);
			float num2 = _cursor + num;
			_cursor = num2 + width;
			Rect rect;
			float num3;
			if (!(height > 0f))
			{
				rect = base.Rect;
				num3 = ((Rect)(ref rect)).height;
			}
			else
			{
				num3 = height;
			}
			float num4 = num3;
			float num5;
			if (!fill)
			{
				num5 = width;
			}
			else
			{
				rect = base.Rect;
				num5 = Mathf.Max(width, ((Rect)(ref rect)).xMax - num2);
			}
			float num6 = num5;
			base.NeedWidth = _content;
			base.NeedHeight = Mathf.Max(base.NeedHeight, num4);
			float cursor = _cursor;
			rect = base.Rect;
			base.UsedWidth = cursor - ((Rect)(ref rect)).x;
			base.UsedHeight = Mathf.Max(base.UsedHeight, num4);
			rect = base.Rect;
			return new Rect(num2, ((Rect)(ref rect)).y, num6, num4);
		}

		internal override Rect Region()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			float cursor = _cursor;
			Rect rect = base.Rect;
			float y = ((Rect)(ref rect)).y;
			rect = base.Rect;
			float num = Mathf.Max(0f, ((Rect)(ref rect)).xMax - _cursor);
			rect = base.Rect;
			return new Rect(cursor, y, num, ((Rect)(ref rect)).height);
		}

		internal override void Absorb(OverlayNode child)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			_content += child.NeedWidth;
			_table.Measure(_column, _content);
			_cursor += child.UsedWidth;
			base.NeedWidth = _content;
			base.NeedHeight = Mathf.Max(base.NeedHeight, child.NeedHeight);
			float cursor = _cursor;
			Rect rect = base.Rect;
			base.UsedWidth = cursor - ((Rect)(ref rect)).x;
			base.UsedHeight = Mathf.Max(base.UsedHeight, child.UsedHeight);
		}
	}
	public sealed class OverlayLayout : OverlayBox
	{
		private readonly Dictionary<string, Vector2> _scrolls = new Dictionary<string, Vector2>();

		internal OverlayWindow Owner;

		internal void StartFrame(OverlayWindow window, Rect content)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			Owner = window;
			Root = this;
			base.Parent = null;
			Start(content, horizontal: false);
		}

		internal void Finish()
		{
			Close();
			if (Owner != null)
			{
				Owner.FitContent(base.NeedWidth, base.NeedHeight);
			}
		}

		internal Vector2 ScrollOf(string key)
		{
			//IL_0040: 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_0021: 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_0041: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(key))
			{
				return (Owner == null) ? Vector2.zero : Owner.Scroll;
			}
			Vector2 value;
			return _scrolls.TryGetValue(key, out value) ? value : Vector2.zero;
		}

		internal void SetScroll(string key, Vector2 scroll)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(key))
			{
				if (Owner != null)
				{
					Owner.Scroll = scroll;
				}
			}
			else
			{
				_scrolls[key] = scroll;
			}
		}
	}
	public sealed class OverlayPanel
	{
		private readonly List<OverlayWindow> _windows = new List<OverlayWindow>();

		public string Title { get; set; }

		public string OwnerGuid { get; }

		public Assembly OwnerAssembly { get; }

		public int Order { get; set; }

		public bool Enabled { get; set; } = true;

		public Func<string> Unavailable { get; set; }

		public IList<OverlayWindow> Windows => _windows;

		internal OverlayPanel(string title, string ownerGuid, Assembly ownerAssembly)
		{
			Title = (string.IsNullOrEmpty(title) ? "MOD" : title);
			OwnerGuid = ownerGuid;
			OwnerAssembly = ownerAssembly;
		}

		internal bool IsListed()
		{
			return Enabled;
		}

		internal string UnavailableReason()
		{
			if (Unavailable == null)
			{
				return null;
			}
			try
			{
				string text = Unavailable();
				return string.IsNullOrEmpty(text) ? null : text;
			}
			catch (Exception ex)
			{
				OverlayPlugin.Log.LogWarning((object)("[Dock] The availability check for \"" + Title + "\" threw and has been dropped: " + ex.Message));
				Unavailable = null;
				return null;
			}
		}

		internal bool IsUsable()
		{
			return Enabled && UnavailableReason() == null;
		}

		public OverlayWindow AddWindow(string title, Action<Rect> draw)
		{
			OverlayWindow overlayWindow = new OverlayWindow(this, title, draw);
			_windows.Add(overlayWindow);
			Dock.NotifyWindowsChanged();
			return overlayWindow;
		}

		public OverlayWindow AddWindow(string title, Action<Rect> draw, string iconFile, Rect defaultRect)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			OverlayWindow overlayWindow = AddWindow(title, draw);
			overlayWindow.IconFile = iconFile;
			overlayWindow.DefaultRect = defaultRect;
			return overlayWindow;
		}

		public bool RemoveWindow(OverlayWindow window)
		{
			bool flag = _windows.Remove(window);
			if (flag)
			{
				Dock.NotifyWindowsChanged();
			}
			return flag;
		}

		public OverlayWindow Window(string title)
		{
			for (int i = 0; i < _windows.Count; i++)
			{
				if (_windows[i].Title == title)
				{
					return _windows[i];
				}
			}
			return null;
		}
	}
	[BepInPlugin("Michael.LethalCompany.Overlay", "Overlay", "2.0.36")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class OverlayPlugin : BaseUnityPlugin
	{
		private static readonly object NetworkLogGate = new object();

		internal static ManualLogSource Log { get; private set; } = new ManualLogSource("Overlay");

		internal static void NetworkLog(string message)
		{
			Log.LogInfo((object)message);
			try
			{
				lock (NetworkLogGate)
				{
					File.AppendAllText(Path.Combine(Paths.BepInExRootPath, "Overlay.log"), $"[{DateTime.Now:MM-dd HH:mm:ss.fff}] {message}{Environment.NewLine}");
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("[Network] Could not write Overlay.log: " + ex.Message));
			}
		}

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			OverlayConfig.Init((BaseUnityPlugin)(object)this);
			DockHost.Attach();
			SettingsPanel.Register();
			DungeonMapSync.Initialize();
			try
			{
				Harmony val = new Harmony("Michael.LethalCompany.Overlay");
				val.PatchAll(typeof(LifecyclePatch));
				val.PatchAll(typeof(GenerationNoticePatch));
				val.PatchAll(typeof(GameplaySyncPatch));
				val.PatchAll(typeof(DungeonMapSyncPatch));
				InputBlockPatch.Apply(val);
			}
			catch (Exception arg)
			{
				Log.LogWarning((object)$"[Dock] Could not install the patches: {arg}");
			}
			Log.LogInfo((object)string.Format("Overlay {0} ready. {1} panel(s) registered so far.", "2.0.36", Dock.All().Length));
		}

		private void Update()
		{
			GameplaySync.Tick();
			FriendsLobbyWindow.Tick();
		}
	}
	public static class OverlaySounds
	{
		public const string FolderName = "sounds";

		public static readonly string[] Extensions = new string[3] { ".wav", ".ogg", ".mp3" };

		private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> Loading = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, string> Problems = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private static AudioSource _source;

		public static string Folder
		{
			get
			{
				try
				{
					string directoryName = Path.GetDirectoryName(typeof(OverlaySounds).Assembly.Location);
					return string.IsNullOrEmpty(directoryName) ? null : Path.Combine(directoryName, "sounds");
				}
				catch (Exception)
				{
					return null;
				}
			}
		}

		public static void Play(string name, string fallback, float volume)
		{
			if (volume <= 0f)
			{
				return;
			}
			AudioClip val = Resolve(name);
			if ((Object)(object)val == (Object)null && !string.Equals(name, fallback, StringComparison.OrdinalIgnoreCase))
			{
				val = Resolve(fallback);
			}
			if (!((Object)(object)val == (Object)null))
			{
				AudioSource val2 = Source();
				if ((Object)(object)val2 != (Object)null)
				{
					val2.PlayOneShot(val, Mathf.Clamp(volume, 0f, 2f));
				}
			}
		}

		public static void Prepare(string name)
		{
			Resolve(name);
		}

		public static string Problem(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			string value;
			return Problems.TryGetValue(name, out value) ? value : null;
		}

		public static int Reload()
		{
			int count = Clips.Count;
			foreach (KeyValuePair<string, AudioClip> clip in Clips)
			{
				if ((Object)(object)clip.Value != (Object)null)
				{
					Object.Destroy((Object)(object)clip.Value);
				}
			}
			Clips.Clear();
			Loading.Clear();
			Problems.Clear();
			OverlayPlugin.Log.LogInfo((object)$"[Dock] Dropped {count} sound(s) - they will be read off disk again.");
			return count;
		}

		private static AudioClip Resolve(string name)
		{
			//IL_009d: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Invalid comparison between Unknown and I4
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			if (Clips.TryGetValue(name, out var value))
			{
				return value;
			}
			if (!Loading.Add(name))
			{
				return null;
			}
			string text = PathFor(name);
			if (text == null)
			{
				Fail(name, "there is no sounds folder beside Overlay");
				return null;
			}
			if (!File.Exists(text))
			{
				Fail(name, "no file called " + name + " in the sounds folder");
				return null;
			}
			AudioType val = TypeOf(text);
			if ((int)val == 0)
			{
				Fail(name, Path.GetExtension(text) + " is not a sound the game can play - use WAV, OGG or MP3");
				return null;
			}
			DockHost.Run(Load(name, text, val));
			return null;
		}

		private static IEnumerator Load(string name, string path, AudioType type)
		{
			//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)
			string uri;
			try
			{
				uri = new Uri(path).AbsoluteUri;
			}
			catch (Exception ex)
			{
				Exception ex2 = ex;
				Fail(name, ex2.Message);
				yield break;
			}
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(uri, type);
			try
			{
				yield return request.SendWebRequest();
				if ((int)request.result != 1)
				{
					Fail(name, request.error ?? "it could not be read");
					yield break;
				}
				AudioClip clip = DownloadHandlerAudioClip.GetContent(request);
				if ((Object)(object)clip == (Object)null || (int)clip.loadState == 3)
				{
					Fail(name, "it is not a sound the game can play");
					yield break;
				}
				((Object)clip).hideFlags = (HideFlags)61;
				Loading.Remove(name);
				Clips[name] = clip;
				Problems.Remove(name);
				OverlayPlugin.Log.LogInfo((