Decompiled source of Alice v0.12.2

plugins/Alice.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Alice.Containers;
using Alice.Crafting;
using Alice.Link;
using Alice.Production;
using Alice.Reporting;
using Alice.UI;
using Alice.Vacuum;
using AliceLink;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SharedUI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: AssemblyCompany("Alice")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Alice - optional client companion for Wonderland servers (Alice in Wonderland: Alice is the client, Wonderland the server).")]
[assembly: AssemblyFileVersion("0.12.1.0")]
[assembly: AssemblyInformationalVersion("0.12.1")]
[assembly: AssemblyProduct("Alice")]
[assembly: AssemblyTitle("Alice")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.12.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SharedUI
{
	internal enum FrameStyle
	{
		Gilt,
		Runic,
		Serpent,
		Ironbound
	}
	internal struct ThemeOptions
	{
		public Color Metal;

		public bool DeriveTones;

		public Color Deep;

		public Color Bright;

		public Color Panel;

		public float PanelOpacity;

		public Color Text;

		public Color MutedText;

		public float Scale;

		public int BodyDelta;

		public int TitleDelta;

		public int SubTitleDelta;

		public int HeaderDelta;

		public int ButtonDelta;

		public int RowDelta;

		public int FooterDelta;

		public int FieldDelta;

		public FrameStyle Frame;

		public static ThemeOptions Default => new ThemeOptions
		{
			Metal = new Color(0.8f, 0.62f, 0.26f, 1f),
			DeriveTones = true,
			Deep = new Color(0.26f, 0.17f, 0.05f, 1f),
			Bright = new Color(1f, 0.94f, 0.72f, 1f),
			Panel = new Color(0.075f, 0.065f, 0.051f, 1f),
			PanelOpacity = 0.955f,
			Text = new Color(0.9f, 0.86f, 0.75f, 1f),
			MutedText = new Color(0.6f, 0.56f, 0.48f, 1f),
			Scale = 1f,
			BodyDelta = 0,
			TitleDelta = 0,
			SubTitleDelta = 0,
			HeaderDelta = 0,
			ButtonDelta = 0,
			RowDelta = 0,
			FooterDelta = 0,
			FieldDelta = 0,
			Frame = FrameStyle.Gilt
		};
	}
	internal static class GiltFrameTheme
	{
		private enum Edge
		{
			Top,
			Bottom,
			Left,
			Right
		}

		private sealed class Painter
		{
			public bool MirrorX;

			public bool MirrorY;

			public bool Transpose;

			private readonly int _w;

			private readonly int _h;

			private readonly float[] _a;

			private readonly float[] _z;

			public Painter(int w, int h)
			{
				_w = w;
				_h = h;
				_a = new float[w * h];
				_z = new float[w * h];
			}

			private void Put(float fx, float fy, float a, float z)
			{
				if (a <= 0f)
				{
					return;
				}
				if (Transpose)
				{
					float num = fx;
					fx = fy;
					fy = num;
				}
				int num2 = Mathf.RoundToInt(fx);
				int num3 = Mathf.RoundToInt(fy);
				if (MirrorX)
				{
					num2 = _w - 1 - num2;
				}
				if (MirrorY)
				{
					num3 = _h - 1 - num3;
				}
				if (num2 >= 0 && num3 >= 0 && num2 < _w && num3 < _h)
				{
					int num4 = num3 * _w + num2;
					if (a > _a[num4])
					{
						_a[num4] = a;
					}
					if (z > _z[num4])
					{
						_z[num4] = z;
					}
				}
			}

			public void Disc(float cx, float cy, float r)
			{
				if (r <= 0f)
				{
					return;
				}
				int num = Mathf.FloorToInt(cx - r - 1f);
				int num2 = Mathf.CeilToInt(cx + r + 1f);
				int num3 = Mathf.FloorToInt(cy - r - 1f);
				int num4 = Mathf.CeilToInt(cy + r + 1f);
				for (int i = num3; i <= num4; i++)
				{
					for (int j = num; j <= num2; j++)
					{
						float num5 = (float)j - cx;
						float num6 = (float)i - cy;
						float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6);
						float num8 = Mathf.Clamp01(r + 0.5f - num7);
						if (!(num8 <= 0f))
						{
							Put(j, i, num8, Mathf.Sqrt(Mathf.Max(0f, 1f - num7 / r * (num7 / r))));
						}
					}
				}
			}

			public void Lozenge(float cx, float cy, float r)
			{
				int num = Mathf.FloorToInt(cx - r - 1f);
				int num2 = Mathf.CeilToInt(cx + r + 1f);
				int num3 = Mathf.FloorToInt(cy - r - 1f);
				int num4 = Mathf.CeilToInt(cy + r + 1f);
				for (int i = num3; i <= num4; i++)
				{
					for (int j = num; j <= num2; j++)
					{
						float num5 = Mathf.Abs((float)j - cx) + Mathf.Abs((float)i - cy);
						float num6 = Mathf.Clamp01(r + 0.5f - num5);
						if (!(num6 <= 0f))
						{
							Put(j, i, num6, Mathf.Sqrt(Mathf.Max(0f, 1f - num5 / r * (num5 / r))));
						}
					}
				}
			}

			public void Taper(Vector2 a, Vector2 b, float w0, float w1)
			{
				//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_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				int num = Mathf.Max(8, Mathf.CeilToInt(Vector2.Distance(a, b) * 3f));
				for (int i = 0; i <= num; i++)
				{
					float num2 = (float)i / (float)num;
					Vector2 val = Vector2.Lerp(a, b, num2);
					Disc(val.x, val.y, Mathf.Lerp(w0, w1, num2));
				}
			}

			public void Bezier(Vector2 a, Vector2 b, Vector2 c, float w0, float w1)
			{
				//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_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_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: 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_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				int num = Mathf.Max(16, Mathf.CeilToInt((Vector2.Distance(a, b) + Vector2.Distance(b, c)) * 3f));
				for (int i = 0; i <= num; i++)
				{
					float num2 = (float)i / (float)num;
					float num3 = 1f - num2;
					Vector2 val = num3 * num3 * a + 2f * num3 * num2 * b + num2 * num2 * c;
					Disc(val.x, val.y, Mathf.Lerp(w0, w1, num2));
				}
			}

			public void Spiral(Vector2 eye, float r0, float growth, float t0, float t1, float phase, float w0, float w1, bool mirror = false)
			{
				//IL_005c: 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)
				int num = Mathf.Max(48, Mathf.CeilToInt((t1 - t0) * 40f));
				for (int i = 0; i <= num; i++)
				{
					float num2 = (float)i / (float)num;
					float num3 = Mathf.Lerp(t0, t1, num2);
					float num4 = r0 * Mathf.Exp(growth * num3);
					float num5 = num3 + phase;
					float num6 = Mathf.Cos(num5) * num4;
					float num7 = Mathf.Sin(num5) * num4;
					if (mirror)
					{
						num6 = 0f - num6;
					}
					Disc(eye.x + num6, eye.y + num7, Mathf.Lerp(w0, w1, num2));
				}
			}

			public void RailPixel(int x, int y, float d, float half)
			{
				float num = Mathf.Clamp01(half + 0.5f - d);
				if (!(num <= 0f))
				{
					Put(x, y, num, Mathf.Sqrt(Mathf.Max(0f, 1f - d / half * (d / half))));
				}
			}

			public void SquareElbow(float mid, float half, float centre)
			{
				for (int i = 0; i < _h; i++)
				{
					for (int j = 0; j < _w; j++)
					{
						float d = Mathf.Min(Mathf.Abs((float)j - mid), Mathf.Abs((float)i - mid));
						if (!((float)j > centre) || !((float)i > centre))
						{
							RailPixel(j, i, d, half);
						}
					}
				}
			}

			public void RailElbow(float mid, float half, float centre)
			{
				float num = centre - mid;
				for (int i = 0; i < _h; i++)
				{
					for (int j = 0; j < _w; j++)
					{
						float d;
						if (!((float)j <= centre) || !((float)i <= centre))
						{
							d = ((!((float)i <= centre)) ? ((!((float)j <= centre)) ? Mathf.Min(Mathf.Abs((float)i - mid), Mathf.Abs((float)j - mid)) : Mathf.Abs((float)j - mid)) : Mathf.Abs((float)i - mid));
						}
						else
						{
							float num2 = (float)j - centre;
							float num3 = (float)i - centre;
							d = Mathf.Abs(Mathf.Sqrt(num2 * num2 + num3 * num3) - num);
						}
						RailPixel(j, i, d, half);
					}
				}
			}

			public Texture2D Bake()
			{
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: 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_0108: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: 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_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val = New(_w, _h, (TextureWrapMode)1, (FilterMode)1);
				Color[] array = (Color[])(object)new Color[_w * _h];
				for (int i = 0; i < _h; i++)
				{
					for (int j = 0; j < _w; j++)
					{
						int num = i * _w + j;
						float num2 = _a[num];
						int num3 = (_h - 1 - i) * _w + j;
						if (num2 <= 0f)
						{
							array[num3] = Color.clear;
							continue;
						}
						float num4 = Z(j - 1, i) - Z(j + 1, i) + (Z(j, i - 1) - Z(j, i + 1));
						float num5 = Mathf.Clamp01(0.42f + 0.5f * num4 + 0.18f * _z[num]);
						Color val2 = ((num5 < 0.5f) ? Color.Lerp(GoldDeep, Gold, num5 * 2f) : Color.Lerp(Gold, GoldBright, (num5 - 0.5f) * 2f));
						array[num3] = new Color(val2.r, val2.g, val2.b, num2);
					}
				}
				val.SetPixels(array);
				val.Apply(false);
				return val;
			}

			private float Z(int x, int y)
			{
				return _z[Mathf.Clamp(y, 0, _h - 1) * _w + Mathf.Clamp(x, 0, _w - 1)];
			}
		}

		public static Color GoldDeep = new Color(0.26f, 0.17f, 0.05f, 1f);

		public static Color Gold = new Color(0.8f, 0.62f, 0.26f, 1f);

		public static Color GoldBright = new Color(1f, 0.94f, 0.72f, 1f);

		public static Color Parchment = new Color(0.9f, 0.86f, 0.75f, 1f);

		public static Color Muted = new Color(0.6f, 0.56f, 0.48f, 1f);

		private static ThemeOptions _bakedFrom = ThemeOptions.Default;

		private static bool _everBaked;

		private static int _appliedFrame = -1;

		private static bool _conflictLogged;

		private static readonly ManualLogSource Log = Logger.CreateLogSource("SharedUI.GiltFrameTheme");

		public const string HexMuted = "#9A9182";

		public const string HexLocked = "#E0736B";

		public const string HexOpen = "#87D278";

		public const float Band = 18f;

		public const float Pad = 22f;

		public static float TitleHeight = 54f;

		public static float FooterHeight = 30f;

		private static int _fontDelta;

		private static ThemeOptions _styledFrom = ThemeOptions.Default;

		private static bool _everStyled;

		private const int CornerTile = 84;

		private const float Overhang = 10f;

		private const float CornerExtent = 74f;

		private const int CrestW = 56;

		private const int CrestH = 34;

		private const float CrestOverhang = 8f;

		private const float OuterMid = 4.4f;

		private const float OuterHalf = 2.7f;

		private const float InnerMid = 12.4f;

		private const float InnerHalf = 1.6f;

		private const float BendCentre = 32f;

		public static GUIStyle Title;

		public static GUIStyle SubTitle;

		public static GUIStyle Header;

		public static GUIStyle Key;

		public static GUIStyle Value;

		public static GUIStyle Note;

		public static GUIStyle Footer;

		public static GUIStyle Button;

		public static GUIStyle Primary;

		public static GUIStyle Row;

		public static GUIStyle Field;

		public static GUIStyle ImageButton;

		private static Texture2D _railTop;

		private static Texture2D _railBottom;

		private static Texture2D _railLeft;

		private static Texture2D _railRight;

		private static Texture2D _cornerTL;

		private static Texture2D _cornerTR;

		private static Texture2D _cornerBL;

		private static Texture2D _cornerBR;

		private static Texture2D _crestTop;

		private static Texture2D _crestBottom;

		private static Texture2D _diamond;

		private static Texture2D _heart;

		private static Texture2D _dot;

		private static Texture2D _panel;

		private static Texture2D _white;

		private static Texture2D _btnNormal;

		private static Texture2D _btnHover;

		private static Texture2D _btnActive;

		private static Texture2D _rowNormal;

		private static Texture2D _rowHover;

		private static Texture2D _rowActive;

		private static Texture2D _selection;

		private static Texture2D _fieldTex;

		private static bool _railRepeats;

		private static float _railTileLength = 4f;

		public static float TextScale { get; private set; } = 1f;

		public static Color Metal(float alpha)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(Gold.r, Gold.g, Gold.b, alpha);
		}

		public static Color MetalBright(float alpha)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(GoldBright.r, GoldBright.g, GoldBright.b, alpha);
		}

		public static Color MetalDeep(float alpha)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return new Color(GoldDeep.r, GoldDeep.g, GoldDeep.b, alpha);
		}

		private static bool BakeInputsMatch(ThemeOptions o)
		{
			//IL_0020: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (_everBaked && o.Frame == _bakedFrom.Frame && o.Metal == _bakedFrom.Metal && o.DeriveTones == _bakedFrom.DeriveTones && (o.DeriveTones || (o.Deep == _bakedFrom.Deep && o.Bright == _bakedFrom.Bright)) && o.Panel == _bakedFrom.Panel)
			{
				return Mathf.Approximately(o.PanelOpacity, _bakedFrom.PanelOpacity);
			}
			return false;
		}

		private static bool StyleInputsMatch(ThemeOptions o)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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)
			if (_everStyled && Title != null && Mathf.Approximately(o.Scale, _styledFrom.Scale) && o.BodyDelta == _styledFrom.BodyDelta && o.TitleDelta == _styledFrom.TitleDelta && o.SubTitleDelta == _styledFrom.SubTitleDelta && o.HeaderDelta == _styledFrom.HeaderDelta && o.ButtonDelta == _styledFrom.ButtonDelta && o.RowDelta == _styledFrom.RowDelta && o.FooterDelta == _styledFrom.FooterDelta && o.FieldDelta == _styledFrom.FieldDelta && o.Text == _styledFrom.Text)
			{
				return o.MutedText == _styledFrom.MutedText;
			}
			return false;
		}

		public static float S(float v)
		{
			return Mathf.Round(v * TextScale);
		}

		public static void EnsureBuilt(Color goldColour, float textScale = 1f, int fontSizeDelta = 0, int headingDelta = 0)
		{
			//IL_0008: 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)
			ThemeOptions o = ThemeOptions.Default;
			o.Metal = goldColour;
			o.Scale = textScale;
			o.BodyDelta = fontSizeDelta;
			o.TitleDelta = headingDelta;
			o.SubTitleDelta = headingDelta;
			o.HeaderDelta = headingDelta;
			EnsureBuilt(o);
		}

		public static void EnsureBuilt(ThemeOptions o)
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_railTop != (Object)null && BakeInputsMatch(o) && StyleInputsMatch(o))
			{
				_appliedFrame = Time.frameCount;
				return;
			}
			if ((Object)(object)_railTop != (Object)null && _appliedFrame == Time.frameCount)
			{
				if (!_conflictLogged)
				{
					_conflictLogged = true;
					Log.LogWarning((object)("Two consumers of SharedUI.GiltFrameTheme asked for different values in the same " + $"frame (live: metal={_bakedFrom.Metal}, frame={_bakedFrom.Frame}, scale={TextScale}, " + $"delta={_fontDelta}; requested: metal={o.Metal}, frame={o.Frame}, scale={o.Scale}, " + $"delta={o.BodyDelta}). The theme is a single shared bake, so the first caller each " + "frame wins. Set the same UI theme values in every mod that uses this theme to resolve it."));
				}
				return;
			}
			if ((Object)(object)_railTop != (Object)null && !BakeInputsMatch(o))
			{
				DestroyTextures();
			}
			if ((Object)(object)_railTop != (Object)null)
			{
				if (!StyleInputsMatch(o))
				{
					BuildStyles(o);
				}
				_appliedFrame = Time.frameCount;
				return;
			}
			_bakedFrom = o;
			_everBaked = true;
			Gold = new Color(o.Metal.r, o.Metal.g, o.Metal.b, 1f);
			Parchment = o.Text;
			Muted = o.MutedText;
			if (!o.DeriveTones)
			{
				GoldDeep = o.Deep;
				GoldBright = o.Bright;
			}
			else if (Mathf.Approximately(Gold.r, 0.8f) && Mathf.Approximately(Gold.g, 0.62f) && Mathf.Approximately(Gold.b, 0.26f))
			{
				GoldDeep = new Color(0.26f, 0.17f, 0.05f, 1f);
				GoldBright = new Color(1f, 0.94f, 0.72f, 1f);
			}
			else
			{
				GoldDeep = new Color(Gold.r * 0.325f, Gold.g * 0.274f, Gold.b * 0.192f, 1f);
				GoldBright = Color.Lerp(Gold, Color.white, 0.72f);
			}
			_railTop = BuildRail(o.Frame, Edge.Top);
			_railBottom = BuildRail(o.Frame, Edge.Bottom);
			_railLeft = BuildRail(o.Frame, Edge.Left);
			_railRight = BuildRail(o.Frame, Edge.Right);
			_railRepeats = RailRepeats(o.Frame);
			_railTileLength = RailTile(o.Frame);
			if (_railRepeats)
			{
				((Texture)_railTop).wrapMode = (TextureWrapMode)0;
				((Texture)_railBottom).wrapMode = (TextureWrapMode)0;
				((Texture)_railLeft).wrapMode = (TextureWrapMode)0;
				((Texture)_railRight).wrapMode = (TextureWrapMode)0;
			}
			_cornerTL = BuildCorner(o.Frame, mirrorX: false, mirrorY: false);
			_cornerTR = BuildCorner(o.Frame, mirrorX: true, mirrorY: false);
			_cornerBL = BuildCorner(o.Frame, mirrorX: false, mirrorY: true);
			_cornerBR = BuildCorner(o.Frame, mirrorX: true, mirrorY: true);
			_crestTop = BuildCrest(o.Frame, flip: false);
			_crestBottom = BuildCrest(o.Frame, flip: true);
			_diamond = BuildDiamond(14);
			_heart = BuildHeart(28);
			_dot = BuildDot(24);
			_panel = BuildPanel(64, o.Panel, o.PanelOpacity);
			_white = BuildSolid(Color.white);
			_btnNormal = BuildPatch(Surface(o, 0.35f, 0.95f), GoldDeep);
			_btnHover = BuildPatch(Surface(o, 1.3f, 0.97f), Gold);
			_btnActive = BuildPatch(Surface(o, 2.6f, 0.98f), GoldBright);
			_rowNormal = BuildPatch(Color.clear, Color.clear);
			_rowHover = BuildPatch(new Color(Gold.r, Gold.g, Gold.b, 0.1f), new Color(Gold.r, Gold.g, Gold.b, 0.45f));
			_rowActive = BuildPatch(new Color(Gold.r, Gold.g, Gold.b, 0.2f), Gold);
			_selection = BuildSolid(new Color(Gold.r, Gold.g, Gold.b, 0.15f));
			_fieldTex = BuildPatch(Surface(o, -0.45f, 0.95f), GoldDeep);
			BuildStyles(o);
			_appliedFrame = Time.frameCount;
		}

		private static Color Surface(ThemeOptions o, float lift, float alpha)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0030: 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_0051: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Color panel = o.Panel;
			if (lift >= 0f)
			{
				float num = Mathf.Clamp01(lift * 0.25f);
				panel = Color.Lerp(panel * (1f + lift * 0.55f), o.Metal, num);
			}
			else
			{
				panel *= Mathf.Clamp01(1f + lift);
			}
			return new Color(Mathf.Clamp01(panel.r), Mathf.Clamp01(panel.g), Mathf.Clamp01(panel.b), alpha);
		}

		private static void DestroyTextures()
		{
			Texture2D[] array = (Texture2D[])(object)new Texture2D[23]
			{
				_railTop, _railBottom, _railLeft, _railRight, _cornerTL, _cornerTR, _cornerBL, _cornerBR, _crestTop, _crestBottom,
				_diamond, _heart, _panel, _white, _dot, _btnNormal, _btnHover, _btnActive, _rowNormal, _rowHover,
				_rowActive, _selection, _fieldTex
			};
			foreach (Texture2D val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			_railTop = (_railBottom = (_railLeft = (_railRight = null)));
			_cornerTL = (_cornerTR = (_cornerBL = (_cornerBR = null)));
			_crestTop = (_crestBottom = (_diamond = (_heart = (_dot = null))));
			_panel = (_white = null);
			_btnNormal = (_btnHover = (_btnActive = null));
			_rowNormal = (_rowHover = (_rowActive = (_selection = null)));
			_fieldTex = null;
			Title = null;
		}

		public static void DrawWindow(Rect win, string title)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			DrawPanelFill(win);
			DrawFrame(win);
			DrawShadowed(new Rect(((Rect)(ref win)).x + 74f, ((Rect)(ref win)).y + 18f + 8f, ((Rect)(ref win)).width - 148f, TitleHeight - 20f), (title ?? string.Empty).ToUpperInvariant(), Title);
			DrawRule(new Rect(((Rect)(ref win)).x + 18f + 22f, ((Rect)(ref win)).y + 18f + TitleHeight - 12f, ((Rect)(ref win)).width - 80f, 1f));
		}

		public static void DrawPanelFill(Rect win)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(((Rect)(ref win)).x + 1f, ((Rect)(ref win)).y + 1f, ((Rect)(ref win)).width - 2f, ((Rect)(ref win)).height - 2f), (Texture)(object)_panel, (ScaleMode)0);
		}

		public static Rect Body(Rect win)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref win)).x + 18f + 22f, ((Rect)(ref win)).y + 18f + TitleHeight, ((Rect)(ref win)).width - 80f, ((Rect)(ref win)).height - 36f - TitleHeight - FooterHeight);
		}

		public static Rect FooterLine(Rect win)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref win)).x + 18f + 22f, ((Rect)(ref win)).yMax - 18f - FooterHeight, ((Rect)(ref win)).width - 80f, S(18f));
		}

		public static void DrawFrame(Rect r)
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Rect)(ref r)).width - 148f;
			float num2 = ((Rect)(ref r)).height - 148f;
			if (_railRepeats)
			{
				float num3 = Mathf.Max(1f, _railTileLength);
				GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).y, num, 18f), (Texture)(object)_railTop, new Rect(0f, 0f, num / num3, 1f));
				GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).yMax - 18f, num, 18f), (Texture)(object)_railBottom, new Rect(0f, 0f, num / num3, 1f));
				GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railLeft, new Rect(0f, 0f, 1f, num2 / num3));
				GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).xMax - 18f, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railRight, new Rect(0f, 0f, 1f, num2 / num3));
			}
			else
			{
				GUI.DrawTexture(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).y, num, 18f), (Texture)(object)_railTop);
				GUI.DrawTexture(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).yMax - 18f, num, 18f), (Texture)(object)_railBottom);
				GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railLeft);
				GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - 18f, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railRight);
			}
			float num4 = 74f;
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 10f, ((Rect)(ref r)).y - 10f, 84f, 84f), (Texture)(object)_cornerTL);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - num4, ((Rect)(ref r)).y - 10f, 84f, 84f), (Texture)(object)_cornerTR);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 10f, ((Rect)(ref r)).yMax - num4, 84f, 84f), (Texture)(object)_cornerBL);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - num4, ((Rect)(ref r)).yMax - num4, 84f, 84f), (Texture)(object)_cornerBR);
			float num5 = ((Rect)(ref r)).center.x - 28f;
			GUI.DrawTexture(new Rect(num5, ((Rect)(ref r)).y - 8f, 56f, 34f), (Texture)(object)_crestTop);
			GUI.DrawTexture(new Rect(num5, ((Rect)(ref r)).yMax + 8f - 34f, 56f, 34f), (Texture)(object)_crestBottom);
			DrawOutline(new Rect(((Rect)(ref r)).x + 18f, ((Rect)(ref r)).y + 18f, ((Rect)(ref r)).width - 36f, ((Rect)(ref r)).height - 36f), new Color(Gold.r, Gold.g, Gold.b, 0.45f), 1f);
		}

		public static void DrawOutline(Rect r, Color c, float t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), (Texture)(object)_white);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), (Texture)(object)_white);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)_white);
			GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)_white);
			GUI.color = color;
		}

		public static void DrawFill(Rect r, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)_white);
			GUI.color = color;
		}

		public static void DrawInset(Rect r)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			DrawFill(r, new Color(0f, 0f, 0f, 0.45f));
			DrawOutline(r, new Color(Gold.r, Gold.g, Gold.b, 0.32f), 1f);
		}

		public static void DrawSelection(Rect r)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(r, (Texture)(object)_selection);
		}

		public static void DrawDot(Rect r, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)_dot, (ScaleMode)2);
			GUI.color = color;
		}

		public static void DrawHeartMark(Rect r, bool lit)
		{
			//IL_0000: 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_001c: 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)
			Color color = GUI.color;
			GUI.color = (Color)(lit ? Gold : new Color(0.75f, 0.75f, 0.75f, 0.28f));
			GUI.DrawTexture(r, (Texture)(object)_heart, (ScaleMode)2);
			GUI.color = color;
		}

		public static void DrawRule(Rect r)
		{
			//IL_0000: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			DrawFill(r, new Color(Gold.r, Gold.g, Gold.b, 0.4f));
			GUI.DrawTexture(new Rect(((Rect)(ref r)).center.x - 7f, ((Rect)(ref r)).y - 7f + 0.5f, 14f, 14f), (Texture)(object)_diamond);
		}

		public static void DrawShadowed(Rect r, string text, GUIStyle style)
		{
			//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)
			//IL_0032: 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_0076: 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)
			if (style != null && !string.IsNullOrEmpty(text))
			{
				Color textColor = style.normal.textColor;
				style.normal.textColor = new Color(0f, 0f, 0f, 0.7f);
				GUI.Label(new Rect(((Rect)(ref r)).x + 1.5f, ((Rect)(ref r)).y + 1.5f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style);
				style.normal.textColor = textColor;
				GUI.Label(r, text, style);
			}
		}

		private static void BuildStyles(ThemeOptions o)
		{
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Expected O, but got Unknown
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			TextScale = Mathf.Clamp(o.Scale, 0.6f, 3f);
			_fontDelta = Mathf.Clamp(o.BodyDelta, -6, 24);
			Parchment = o.Text;
			Muted = o.MutedText;
			int num = Mathf.Clamp(o.TitleDelta, -16, 32);
			int styleDelta = Mathf.Clamp(o.SubTitleDelta, -16, 32);
			int styleDelta2 = Mathf.Clamp(o.HeaderDelta, -16, 32);
			int styleDelta3 = Mathf.Clamp(o.ButtonDelta, -16, 32);
			int styleDelta4 = Mathf.Clamp(o.RowDelta, -16, 32);
			int num2 = Mathf.Clamp(o.FooterDelta, -16, 32);
			int styleDelta5 = Mathf.Clamp(o.FieldDelta, -16, 32);
			float num3 = Mathf.Max(0, _fontDelta);
			float num4 = Mathf.Max(num3, (float)Mathf.Max(0, _fontDelta + num));
			float num5 = Mathf.Max(num3, (float)Mathf.Max(0, _fontDelta + num2));
			TitleHeight = 26f + Mathf.Round(28f * TextScale) + Mathf.Round(num4 * 1.5f);
			FooterHeight = Mathf.Max(30f, Mathf.Round(30f * TextScale) + num5);
			Font font = FindFont();
			Title = Text(font, Pt(25, num), (FontStyle)1, GoldBright, (TextAnchor)4);
			SubTitle = Text(font, Pt(18, styleDelta), (FontStyle)1, Gold, (TextAnchor)3);
			Header = Text(font, Pt(13, styleDelta2), (FontStyle)1, Gold, (TextAnchor)3);
			Key = Text(font, Pt(13), (FontStyle)0, Muted, (TextAnchor)3);
			Value = Text(font, Pt(13), (FontStyle)1, Parchment, (TextAnchor)3);
			Note = Text(font, Pt(13), (FontStyle)2, Muted, (TextAnchor)4);
			Note.wordWrap = true;
			Footer = Text(font, Pt(11, num2), (FontStyle)0, Muted, (TextAnchor)4);
			Button = Patch(font, Pt(13, styleDelta3), (FontStyle)1, (TextAnchor)4, _btnNormal, _btnHover, _btnActive);
			Button.padding = new RectOffset(12, 12, 6, 6);
			Primary = Patch(font, Pt(16, styleDelta3), (FontStyle)1, (TextAnchor)4, _btnNormal, _btnHover, _btnActive);
			Primary.padding = new RectOffset(12, 12, 8, 8);
			Primary.normal.textColor = Gold;
			Row = Patch(font, Pt(14, styleDelta4), (FontStyle)0, (TextAnchor)3, _rowNormal, _rowHover, _rowActive);
			Row.padding = new RectOffset(12, 12, 4, 4);
			Row.normal.textColor = Parchment;
			ImageButton = Patch(font, Pt(11, styleDelta4), (FontStyle)0, (TextAnchor)7, _rowNormal, _rowHover, _rowActive);
			Field = new GUIStyle
			{
				font = font,
				fontSize = Pt(13, styleDelta5),
				alignment = (TextAnchor)3,
				padding = new RectOffset(8, 8, 4, 4),
				border = new RectOffset(3, 3, 3, 3),
				clipping = (TextClipping)1
			};
			Field.normal.background = _fieldTex;
			Field.focused.background = _fieldTex;
			Field.hover.background = _fieldTex;
			Field.active.background = _fieldTex;
			Field.normal.textColor = Parchment;
			Field.focused.textColor = GoldBright;
			Field.hover.textColor = Parchment;
			Field.active.textColor = Parchment;
			_styledFrom = o;
			_everStyled = true;
		}

		private static int Pt(int designSize, int styleDelta = 0)
		{
			return Mathf.Max(8, Mathf.RoundToInt((float)designSize * TextScale) + _fontDelta + styleDelta);
		}

		private static GUIStyle Text(Font font, int size, FontStyle fs, Color colour, TextAnchor anchor)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0014: 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_001b: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0044: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				font = font,
				fontSize = size,
				fontStyle = fs,
				alignment = anchor,
				richText = true,
				wordWrap = false,
				clipping = (TextClipping)1
			};
			val.normal.textColor = colour;
			return val;
		}

		private static GUIStyle Patch(Font font, int size, FontStyle fs, TextAnchor anchor, Texture2D normal, Texture2D hover, Texture2D active)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0014: 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_001b: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				font = font,
				fontSize = size,
				fontStyle = fs,
				alignment = anchor,
				richText = true,
				wordWrap = false,
				border = new RectOffset(3, 3, 3, 3),
				clipping = (TextClipping)1
			};
			val.normal.background = normal;
			val.hover.background = hover;
			val.active.background = active;
			val.focused.background = normal;
			val.normal.textColor = Parchment;
			val.hover.textColor = GoldBright;
			val.active.textColor = GoldBright;
			val.focused.textColor = Parchment;
			return val;
		}

		private static Font FindFont()
		{
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			string[] array2 = new string[3] { "AveriaSerifLibre", "Norsebold", "Norse" };
			foreach (string value in array2)
			{
				Font[] array3 = array;
				foreach (Font val in array3)
				{
					if ((Object)(object)val != (Object)null && ((Object)val).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return val;
					}
				}
			}
			return null;
		}

		private static int RailTile(FrameStyle style)
		{
			return style switch
			{
				FrameStyle.Serpent => 48, 
				FrameStyle.Ironbound => 40, 
				_ => 4, 
			};
		}

		private static bool RailRepeats(FrameStyle style)
		{
			return RailTile(style) > 4;
		}

		private static Texture2D BuildRail(FrameStyle style, Edge edge)
		{
			bool horizontal = edge == Edge.Top || edge == Edge.Bottom;
			int num = RailTile(style);
			int num2 = 18;
			int w = (horizontal ? num : num2);
			int h = (horizontal ? num2 : num);
			Painter p = new Painter(w, h)
			{
				MirrorY = (edge == Edge.Bottom),
				MirrorX = (edge == Edge.Right)
			};
			Action<float, float, float> action = delegate(float a, float ac, float r)
			{
				if (horizontal)
				{
					p.Disc(a, ac, r);
				}
				else
				{
					p.Disc(ac, a, r);
				}
			};
			switch (style)
			{
			case FrameStyle.Runic:
				RailProfile(p, horizontal, num, num2, 2f, 0.9f);
				RailProfile(p, horizontal, num, num2, 6.6f, 2.3f);
				RailProfile(p, horizontal, num, num2, 12.8f, 2.3f);
				break;
			case FrameStyle.Serpent:
			{
				for (int num3 = 0; num3 <= num * 3; num3++)
				{
					float num4 = (float)num3 / (float)(num * 3);
					float arg = num4 * (float)num;
					float num5 = Mathf.Sin(num4 * (float)Math.PI * 2f) * 3.6f;
					action(arg, 9f + num5, 2.3f);
					action(arg, 9f - num5, 2.3f);
				}
				break;
			}
			case FrameStyle.Ironbound:
				RailProfile(p, horizontal, num, num2, 2.4f, 1.3f);
				RailProfile(p, horizontal, num, num2, 9f, 5.2f);
				RailProfile(p, horizontal, num, num2, 15.6f, 1.3f);
				action((float)num * 0.5f, 9f, 3.1f);
				break;
			default:
				RailProfile(p, horizontal, num, num2, 4.4f, 2.7f);
				RailProfile(p, horizontal, num, num2, 12.4f, 1.6f);
				break;
			}
			return p.Bake();
		}

		private static void RailProfile(Painter p, bool horizontal, int along, int band, float mid, float half)
		{
			for (int i = 0; i < along; i++)
			{
				for (int j = 0; j < band; j++)
				{
					float d = Mathf.Abs((float)j - mid);
					if (horizontal)
					{
						p.RailPixel(i, j, d, half);
					}
					else
					{
						p.RailPixel(j, i, d, half);
					}
				}
			}
		}

		private static Texture2D BuildCorner(FrameStyle style, bool mirrorX, bool mirrorY)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			if (style != FrameStyle.Gilt)
			{
				return BuildCornerAlt(style, mirrorX, mirrorY);
			}
			Painter painter = new Painter(84, 84)
			{
				MirrorX = mirrorX,
				MirrorY = mirrorY
			};
			painter.RailElbow(14.4f, 2.7f, 32f);
			painter.RailElbow(22.4f, 1.6f, 32f);
			painter.Lozenge(11f, 11f, 4.5f);
			painter.Taper(new Vector2(13.5f, 13.5f), new Vector2(19.3f, 19.3f), 1.2f, 2.2f);
			painter.Lozenge(36f, 36f, 3.4f);
			for (int i = 0; i < 2; i++)
			{
				painter.Transpose = i == 1;
				painter.Taper(new Vector2(38.5f, 35f), new Vector2(47f, 32f), 1.4f, 0.45f);
				painter.Spiral(new Vector2(50f, 31f), 1.3f, 0.33f, 0f, 6.8f, 5.371f, 0.55f, 2.4f);
				painter.Bezier(new Vector2(56f, 36f), new Vector2(68f, 41f), new Vector2(78f, 30f), 2.2f, 0.35f);
				painter.Spiral(new Vector2(76f, 32f), 0.9f, 0.32f, 0f, 4.6f, 1f, 1.1f, 0.3f);
				painter.Disc(58f, 34f, 1.8f);
			}
			painter.Transpose = false;
			return painter.Bake();
		}

		private static Texture2D BuildCornerAlt(FrameStyle style, bool mirrorX, bool mirrorY)
		{
			//IL_0072: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			Painter painter = new Painter(84, 84)
			{
				MirrorX = mirrorX,
				MirrorY = mirrorY
			};
			switch (style)
			{
			case FrameStyle.Runic:
			{
				painter.SquareElbow(12f, 0.9f, 32f);
				painter.SquareElbow(16.6f, 2.3f, 32f);
				painter.SquareElbow(22.8f, 2.3f, 32f);
				painter.Taper(new Vector2(26f, 54f), new Vector2(54f, 26f), 1.9f, 1.9f);
				painter.Taper(new Vector2(30f, 30f), new Vector2(50f, 50f), 1.5f, 1.5f);
				painter.Lozenge(40f, 40f, 4.2f);
				for (int k = 0; k < 2; k++)
				{
					painter.Transpose = k == 1;
					painter.Disc(52f, 9.7f, 1.9f);
					painter.Disc(66f, 9.7f, 1.9f);
					painter.Disc(80f, 9.7f, 1.9f);
				}
				painter.Transpose = false;
				break;
			}
			case FrameStyle.Serpent:
			{
				painter.RailElbow(15.4f, 2.3f, 32f);
				painter.RailElbow(22.6f, 2.3f, 32f);
				painter.Lozenge(19f, 19f, 7.2f);
				painter.Taper(new Vector2(15f, 15f), new Vector2(6f, 6f), 3.4f, 1.1f);
				painter.Taper(new Vector2(23f, 14f), new Vector2(12f, 8f), 1.6f, 0.5f);
				painter.Taper(new Vector2(14f, 23f), new Vector2(8f, 12f), 1.6f, 0.5f);
				painter.Disc(24f, 16f, 1.7f);
				painter.Disc(16f, 24f, 1.7f);
				painter.Bezier(new Vector2(28f, 20f), new Vector2(24f, 24f), new Vector2(20f, 28f), 1.5f, 1.5f);
				for (int j = 0; j < 2; j++)
				{
					painter.Transpose = j == 1;
					painter.Bezier(new Vector2(34f, 30f), new Vector2(50f, 24f), new Vector2(64f, 33f), 2.3f, 2.3f);
					painter.Spiral(new Vector2(74f, 26f), 1.1f, 0.3f, 0f, 5f, 2.2f, 2.1f, 0.9f);
				}
				painter.Transpose = false;
				break;
			}
			default:
			{
				painter.SquareElbow(12.4f, 1.3f, 32f);
				painter.SquareElbow(19f, 5.2f, 32f);
				painter.SquareElbow(25.6f, 1.3f, 32f);
				painter.Disc(19f, 19f, 4.6f);
				painter.Disc(19f, 19f, 2f);
				for (int i = 0; i < 2; i++)
				{
					painter.Transpose = i == 1;
					painter.Disc(44f, 19f, 3.1f);
					painter.Disc(70f, 19f, 3.1f);
				}
				painter.Transpose = false;
				break;
			}
			}
			return painter.Bake();
		}

		private static Texture2D BuildCrest(FrameStyle style, bool flip)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			if (style != FrameStyle.Gilt)
			{
				return BuildCrestAlt(style, flip);
			}
			Painter painter = new Painter(56, 34);
			painter.MirrorY = flip;
			painter.Disc(28f, 2.5f, 1.8f);
			painter.Lozenge(28f, 9f, 6.5f);
			painter.Taper(new Vector2(28f, 14f), new Vector2(28f, 24f), 2.2f, 1.2f);
			painter.Spiral(new Vector2(17f, 25f), 1.2f, 0.33f, 0f, 5.4f, 2.6f, 2f, 0.35f);
			painter.Spiral(new Vector2(39f, 25f), 1.2f, 0.33f, 0f, 5.4f, 2.6f, 2f, 0.35f, mirror: true);
			painter.Bezier(new Vector2(23f, 19f), new Vector2(13f, 24f), new Vector2(4f, 16f), 1.6f, 0.3f);
			painter.Bezier(new Vector2(33f, 19f), new Vector2(43f, 24f), new Vector2(52f, 16f), 1.6f, 0.3f);
			painter.Disc(3f, 14f, 1.5f);
			painter.Disc(53f, 14f, 1.5f);
			return painter.Bake();
		}

		private static Texture2D BuildCrestAlt(FrameStyle style, bool flip)
		{
			//IL_0041: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			Painter painter = new Painter(56, 34)
			{
				MirrorY = flip
			};
			switch (style)
			{
			case FrameStyle.Runic:
				painter.Lozenge(28f, 8f, 6f);
				painter.Taper(new Vector2(28f, 13f), new Vector2(28f, 27f), 2f, 2f);
				painter.Taper(new Vector2(28f, 16f), new Vector2(17f, 25f), 1.7f, 1.1f);
				painter.Taper(new Vector2(28f, 16f), new Vector2(39f, 25f), 1.7f, 1.1f);
				painter.Disc(7f, 10f, 1.9f);
				painter.Disc(49f, 10f, 1.9f);
				break;
			case FrameStyle.Serpent:
				painter.Lozenge(28f, 11f, 5.2f);
				painter.Spiral(new Vector2(19f, 17f), 1.2f, 0.32f, 0f, 5.6f, 2.4f, 2.1f, 0.5f);
				painter.Spiral(new Vector2(37f, 17f), 1.2f, 0.32f, 0f, 5.6f, 2.4f, 2.1f, 0.5f, mirror: true);
				painter.Bezier(new Vector2(24f, 20f), new Vector2(12f, 26f), new Vector2(2f, 15f), 2f, 1f);
				painter.Bezier(new Vector2(32f, 20f), new Vector2(44f, 26f), new Vector2(54f, 15f), 2f, 1f);
				break;
			default:
				painter.Taper(new Vector2(3f, 12f), new Vector2(53f, 12f), 4.4f, 4.4f);
				painter.Disc(28f, 12f, 8.2f);
				painter.Disc(28f, 12f, 4.4f);
				painter.Disc(11f, 12f, 2.4f);
				painter.Disc(45f, 12f, 2.4f);
				painter.Disc(28f, 25f, 2.4f);
				break;
			}
			return painter.Bake();
		}

		private static Texture2D BuildDot(int size)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = New(size, size, (TextureWrapMode)1, (FilterMode)1);
			Color[] array = (Color[])(object)new Color[size * size];
			float num = (float)(size - 1) * 0.5f;
			float num2 = (float)size * 0.42f;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = 0f;
					for (int k = 0; k < 2; k++)
					{
						for (int l = 0; l < 2; l++)
						{
							float num4 = (float)j + ((float)l + 0.5f) * 0.5f - 0.5f - num;
							float num5 = (float)i + ((float)k + 0.5f) * 0.5f - 0.5f - num;
							if (Mathf.Sqrt(num4 * num4 + num5 * num5) <= num2)
							{
								num3 += 0.25f;
							}
						}
					}
					array[i * size + j] = new Color(1f, 1f, 1f, num3);
				}
			}
			val.SetPixels(array);
			val.Apply(false);
			return val;
		}

		private static Texture2D BuildDiamond(int size)
		{
			Painter painter = new Painter(size, size);
			float num = (float)(size - 1) * 0.5f;
			painter.Lozenge(num, num, (float)size * 0.36f);
			return painter.Bake();
		}

		private static Texture2D BuildHeart(int size)
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = New(size, size, (TextureWrapMode)1, (FilterMode)1);
			Color[] array = (Color[])(object)new Color[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = 0f;
					for (int k = 0; k < 2; k++)
					{
						for (int l = 0; l < 2; l++)
						{
							float num2 = (((float)j + ((float)l + 0.5f) * 0.5f) / (float)size - 0.5f) * 2.6f;
							float num3 = (((float)i + ((float)k + 0.5f) * 0.5f) / (float)size - 0.42f) * 2.9f;
							float num4 = num2 * num2 + num3 * num3 - 1f;
							if (num4 * num4 * num4 - num2 * num2 * num3 * num3 * num3 <= 0f)
							{
								num += 0.25f;
							}
						}
					}
					array[i * size + j] = new Color(1f, 1f, 1f, num);
				}
			}
			val.SetPixels(array);
			val.Apply(false);
			return val;
		}

		private static Texture2D BuildPanel(int size, Color colour, float opacity)
		{
			//IL_0085: 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_0097: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = New(size, size, (TextureWrapMode)1, (FilterMode)1);
			Color[] array = (Color[])(object)new Color[size * size];
			float num = (float)(size - 1) * 0.5f;
			float num2 = Mathf.Clamp01(opacity);
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = ((float)j - num) / num;
					float num4 = ((float)i - num) / num;
					float num5 = Mathf.Clamp01(1f - 0.55f * Mathf.Sqrt(0.6f * (num3 * num3 + num4 * num4)));
					float num6 = 0.73f + 0.27f * num5;
					array[i * size + j] = new Color(colour.r * num6, colour.g * num6, colour.b * num6, num2);
				}
			}
			val.SetPixels(array);
			val.Apply(false);
			return val;
		}

		private static Texture2D BuildPatch(Color fill, Color border)
		{
			//IL_0048: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = New(12, 12, (TextureWrapMode)1, (FilterMode)0);
			Color[] array = (Color[])(object)new Color[144];
			for (int i = 0; i < 12; i++)
			{
				for (int j = 0; j < 12; j++)
				{
					int num = Mathf.Min(Mathf.Min(j, i), Mathf.Min(11 - j, 11 - i));
					array[i * 12 + j] = ((num == 0) ? border : fill);
				}
			}
			val.SetPixels(array);
			val.Apply(false);
			return val;
		}

		private static Texture2D BuildSolid(Color c)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D obj = New(1, 1, (TextureWrapMode)1, (FilterMode)0);
			obj.SetPixel(0, 0, c);
			obj.Apply(false);
			return obj;
		}

		private static Texture2D New(int w, int h, TextureWrapMode wrap, FilterMode filter)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0020: Expected O, but got Unknown
			return new Texture2D(w, h, (TextureFormat)4, false)
			{
				wrapMode = wrap,
				filterMode = filter,
				hideFlags = (HideFlags)61
			};
		}
	}
	internal static class UIFocus
	{
		[HarmonyPatch]
		internal static class UIFocusPatch
		{
			private static readonly ManualLogSource Log = Logger.CreateLogSource("SharedUI.UIFocus");

			[HarmonyPatch(typeof(Chat), "HasFocus")]
			[HarmonyPostfix]
			private static void Chat_HasFocus_Postfix(ref bool __result)
			{
				try
				{
					if (HasTextFocus || BlocksGameInput)
					{
						__result = true;
					}
				}
				catch (Exception arg)
				{
					Log.LogError((object)string.Format("{0} failed (non-fatal, keyboard may leak into gameplay while a window is focused). Reason: {1}", "Chat_HasFocus_Postfix", arg));
				}
			}

			[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
			[HarmonyPrefix]
			private static bool GameCamera_UpdateMouseCapture_Prefix()
			{
				try
				{
					if (!WantsCursor)
					{
						return true;
					}
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
					return false;
				}
				catch (Exception arg)
				{
					Log.LogError((object)string.Format("{0} failed (non-fatal, falling back to vanilla cursor handling). Reason: {1}", "GameCamera_UpdateMouseCapture_Prefix", arg));
					return true;
				}
			}

			[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
			[HarmonyPostfix]
			[HarmonyPriority(800)]
			private static void GameCamera_UpdateMouseCapture_Postfix()
			{
				try
				{
					if (WantsCursor)
					{
						Cursor.lockState = (CursorLockMode)0;
						Cursor.visible = true;
					}
				}
				catch (Exception arg)
				{
					Log.LogError((object)string.Format("{0} failed (non-fatal, another mod's cursor handling may win this frame). Reason: {1}", "GameCamera_UpdateMouseCapture_Postfix", arg));
				}
			}
		}

		private static readonly HashSet<string> _cursorWindows = new HashSet<string>();

		private static readonly HashSet<string> _textFocusWindows = new HashSet<string>();

		private static readonly HashSet<string> _inputBlockWindows = new HashSet<string>();

		public static bool WantsCursor => _cursorWindows.Count > 0;

		public static bool HasTextFocus => _textFocusWindows.Count > 0;

		public static bool BlocksGameInput => _inputBlockWindows.Count > 0;

		public static void SetWantsCursor(string windowId, bool active)
		{
			if (active)
			{
				_cursorWindows.Add(windowId);
			}
			else
			{
				_cursorWindows.Remove(windowId);
			}
		}

		public static void SetHasTextFocus(string windowId, bool active)
		{
			if (active)
			{
				_textFocusWindows.Add(windowId);
			}
			else
			{
				_textFocusWindows.Remove(windowId);
			}
		}

		public static void SetBlocksGameInput(string windowId, bool active)
		{
			if (active)
			{
				_inputBlockWindows.Add(windowId);
			}
			else
			{
				_inputBlockWindows.Remove(windowId);
			}
		}
	}
}
namespace AliceLink
{
	public sealed class LinkFormatException : Exception
	{
		public LinkFormatException(string message)
			: base(message)
		{
		}
	}
	public static class LinkLimits
	{
		public const int MaxString = 512;

		public const int MaxPacket = 65536;

		public const int MaxList = 512;

		public const int MaxParamBlob = 32768;
	}
	public readonly struct ZdoRef : IEquatable<ZdoRef>
	{
		public readonly long User;

		public readonly uint Id;

		public bool IsNone
		{
			get
			{
				if (User == 0L)
				{
					return Id == 0;
				}
				return false;
			}
		}

		public ZdoRef(long user, uint id)
		{
			User = user;
			Id = id;
		}

		public bool Equals(ZdoRef other)
		{
			if (User == other.User)
			{
				return Id == other.Id;
			}
			return false;
		}

		public override bool Equals(object? obj)
		{
			if (obj is ZdoRef other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return ((int)(User ^ (User >> 32)) * 397) ^ (int)Id;
		}

		public override string ToString()
		{
			long user = User;
			string text = user.ToString();
			uint id = Id;
			return text + ":" + id;
		}

		public static bool operator ==(ZdoRef a, ZdoRef b)
		{
			return a.Equals(b);
		}

		public static bool operator !=(ZdoRef a, ZdoRef b)
		{
			return !a.Equals(b);
		}
	}
	public sealed class LinkWriter
	{
		private static readonly UTF8Encoding Utf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false);

		private byte[] _buf;

		private int _len;

		public int Length => _len;

		public LinkWriter(int capacity = 128)
		{
			_buf = new byte[Math.Max(16, capacity)];
		}

		public byte[] ToArray()
		{
			byte[] array = new byte[_len];
			Buffer.BlockCopy(_buf, 0, array, 0, _len);
			return array;
		}

		private void Ensure(int extra)
		{
			if (_len + extra > _buf.Length)
			{
				int num;
				for (num = _buf.Length * 2; num < _len + extra; num *= 2)
				{
				}
				Array.Resize(ref _buf, num);
			}
		}

		public LinkWriter U8(byte v)
		{
			Ensure(1);
			_buf[_len++] = v;
			return this;
		}

		public LinkWriter Bool(bool v)
		{
			return U8(v ? ((byte)1) : ((byte)0));
		}

		public LinkWriter U16(ushort v)
		{
			Ensure(2);
			_buf[_len++] = (byte)v;
			_buf[_len++] = (byte)(v >> 8);
			return this;
		}

		public LinkWriter U32(uint v)
		{
			Ensure(4);
			_buf[_len++] = (byte)v;
			_buf[_len++] = (byte)(v >> 8);
			_buf[_len++] = (byte)(v >> 16);
			_buf[_len++] = (byte)(v >> 24);
			return this;
		}

		public LinkWriter I32(int v)
		{
			return U32((uint)v);
		}

		public LinkWriter I64(long v)
		{
			Ensure(8);
			for (int i = 0; i < 8; i++)
			{
				_buf[_len++] = (byte)((ulong)v >> 8 * i);
			}
			return this;
		}

		public LinkWriter F32(float v)
		{
			byte[] bytes = BitConverter.GetBytes(v);
			if (!BitConverter.IsLittleEndian)
			{
				Array.Reverse((Array)bytes);
			}
			Ensure(4);
			Buffer.BlockCopy(bytes, 0, _buf, _len, 4);
			_len += 4;
			return this;
		}

		public LinkWriter Str(string? s, int maxBytes = 512)
		{
			byte[] bytes = Utf8.GetBytes(s ?? "");
			if (bytes.Length > maxBytes || bytes.Length > 65535)
			{
				throw new ArgumentException("string of " + bytes.Length + " bytes exceeds the limit of " + maxBytes);
			}
			U16((ushort)bytes.Length);
			Ensure(bytes.Length);
			Buffer.BlockCopy(bytes, 0, _buf, _len, bytes.Length);
			_len += bytes.Length;
			return this;
		}

		public LinkWriter Bytes(byte[] b)
		{
			U32((uint)b.Length);
			Ensure(b.Length);
			Buffer.BlockCopy(b, 0, _buf, _len, b.Length);
			_len += b.Length;
			return this;
		}

		public LinkWriter Raw(byte[] b)
		{
			Ensure(b.Length);
			Buffer.BlockCopy(b, 0, _buf, _len, b.Length);
			_len += b.Length;
			return this;
		}

		public LinkWriter Ref(ZdoRef r)
		{
			return I64(r.User).U32(r.Id);
		}

		public LinkWriter Vec3(float x, float y, float z)
		{
			return F32(x).F32(y).F32(z);
		}

		public LinkWriter Count(int n)
		{
			if (n < 0 || n > 512)
			{
				throw new ArgumentException("list of " + n + " elements exceeds the limit of " + 512);
			}
			return U16((ushort)n);
		}
	}
	public sealed class LinkReader
	{
		private static readonly UTF8Encoding StrictUtf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);

		private readonly byte[] _b;

		private readonly int _end;

		private int _p;

		public int Remaining => _end - _p;

		public LinkReader(byte[] data)
			: this(data, 0, (data != null) ? data.Length : 0)
		{
		}

		public LinkReader(byte[] data, int offset, int length)
		{
			if (data == null || offset < 0 || length < 0 || offset + length > data.Length)
			{
				throw new LinkFormatException("bad buffer");
			}
			if (length > 65536)
			{
				throw new LinkFormatException("message of " + length + " bytes exceeds the limit of " + 65536);
			}
			_b = data;
			_p = offset;
			_end = offset + length;
		}

		private void Need(int n)
		{
			if (n < 0 || n > _end - _p)
			{
				throw new LinkFormatException("truncated message (need " + n + ", have " + (_end - _p) + ")");
			}
		}

		public byte U8()
		{
			Need(1);
			return _b[_p++];
		}

		public bool Bool()
		{
			return U8() != 0;
		}

		public ushort U16()
		{
			Need(2);
			ushort result = (ushort)(_b[_p] | (_b[_p + 1] << 8));
			_p += 2;
			return result;
		}

		public uint U32()
		{
			Need(4);
			int result = _b[_p] | (_b[_p + 1] << 8) | (_b[_p + 2] << 16) | (_b[_p + 3] << 24);
			_p += 4;
			return (uint)result;
		}

		public int I32()
		{
			return (int)U32();
		}

		public long I64()
		{
			Need(8);
			ulong num = 0uL;
			for (int i = 0; i < 8; i++)
			{
				num |= (ulong)_b[_p + i] << 8 * i;
			}
			_p += 8;
			return (long)num;
		}

		public float F32()
		{
			Need(4);
			byte[] array = new byte[4];
			Buffer.BlockCopy(_b, _p, array, 0, 4);
			_p += 4;
			if (!BitConverter.IsLittleEndian)
			{
				Array.Reverse((Array)array);
			}
			return BitConverter.ToSingle(array, 0);
		}

		public string Str(int maxBytes = 512)
		{
			int num = U16();
			if (num > maxBytes)
			{
				throw new LinkFormatException("string of " + num + " bytes exceeds the limit of " + maxBytes);
			}
			Need(num);
			try
			{
				string result = StrictUtf8.GetString(_b, _p, num);
				_p += num;
				return result;
			}
			catch (ArgumentException)
			{
				throw new LinkFormatException("string is not valid UTF-8");
			}
		}

		public byte[] Bytes(int maxLen)
		{
			uint num = U32();
			if (num > (uint)maxLen)
			{
				throw new LinkFormatException("blob of " + num + " bytes exceeds the limit of " + maxLen);
			}
			Need((int)num);
			byte[] array = new byte[num];
			Buffer.BlockCopy(_b, _p, array, 0, (int)num);
			_p += (int)num;
			return array;
		}

		public ZdoRef Ref()
		{
			long user = I64();
			uint id = U32();
			return new ZdoRef(user, id);
		}

		public void Vec3(out float x, out float y, out float z)
		{
			x = F32();
			y = F32();
			z = F32();
		}

		public int Count(int max = 512)
		{
			int num = U16();
			if (num > max)
			{
				throw new LinkFormatException("list of " + num + " elements exceeds the limit of " + max);
			}
			return num;
		}

		public byte[] Rest()
		{
			byte[] array = new byte[_end - _p];
			Buffer.BlockCopy(_b, _p, array, 0, array.Length);
			_p = _end;
			return array;
		}
	}
	public static class LinkEnvelope
	{
		public static LinkWriter Begin(MsgKind kind)
		{
			return new LinkWriter().U8(161).U8((byte)kind);
		}

		public static LinkReader Open(byte[] data, out MsgKind kind)
		{
			LinkReader linkReader = new LinkReader(data);
			if (linkReader.Remaining < 2 || linkReader.U8() != 161)
			{
				throw new LinkFormatException("not an Alice message");
			}
			kind = (MsgKind)linkReader.U8();
			return linkReader;
		}

		public static byte[] EncodeAdvertise(AdvertiseMsg m)
		{
			LinkWriter linkWriter = Begin(MsgKind.Advertise);
			m.Write(linkWriter);
			return linkWriter.ToArray();
		}

		public static byte[] EncodeHello(HelloMsg m)
		{
			LinkWriter linkWriter = Begin(MsgKind.Hello);
			m.Write(linkWriter);
			return linkWriter.ToArray();
		}

		public static byte[] EncodeWelcome(WelcomeMsg m)
		{
			LinkWriter linkWriter = Begin(MsgKind.Welcome);
			m.Write(linkWriter);
			return linkWriter.ToArray();
		}

		public static byte[] EncodeRequest(uint id, Op op, Action<LinkWriter>? body = null)
		{
			LinkWriter linkWriter = Begin(MsgKind.Request).U32(id).U8((byte)op);
			body?.Invoke(linkWriter);
			return linkWriter.ToArray();
		}

		public static byte[] EncodeReply(uint id, Status status, Action<LinkWriter>? body = null)
		{
			LinkWriter linkWriter = Begin(MsgKind.Reply).U32(id).U8((byte)status);
			body?.Invoke(linkWriter);
			return linkWriter.ToArray();
		}

		public static byte[] EncodePush(PushEvent evt, Action<LinkWriter>? body = null)
		{
			LinkWriter linkWriter = Begin(MsgKind.Push).U8((byte)evt);
			body?.Invoke(linkWriter);
			return linkWriter.ToArray();
		}
	}
	public sealed class AdvertiseMsg
	{
		public ushort ProtoMin = 1;

		public ushort ProtoMax = 1;

		public string ServerVersion = "";

		public uint Nonce;

		public void Write(LinkWriter w)
		{
			w.U16(ProtoMin).U16(ProtoMax).Str(ServerVersion, 64)
				.U32(Nonce);
		}

		public static AdvertiseMsg Read(LinkReader r)
		{
			return new AdvertiseMsg
			{
				ProtoMin = r.U16(),
				ProtoMax = r.U16(),
				ServerVersion = r.Str(64),
				Nonce = r.U32()
			};
		}
	}
	public sealed class HelloMsg
	{
		public ushort ProtoMin = 1;

		public ushort ProtoMax = 1;

		public string ClientVersion = "";

		public Feature Features;

		public uint Nonce;

		public void Write(LinkWriter w)
		{
			w.U16(ProtoMin).U16(ProtoMax).Str(ClientVersion, 64)
				.U32((uint)Features)
				.U32(Nonce);
		}

		public static HelloMsg Read(LinkReader r)
		{
			return new HelloMsg
			{
				ProtoMin = r.U16(),
				ProtoMax = r.U16(),
				ClientVersion = r.Str(64),
				Features = (Feature)r.U32(),
				Nonce = r.U32()
			};
		}
	}
	public sealed class WelcomeMsg
	{
		public ushort Proto;

		public Feature Features;

		public ParamBag Params = new ParamBag();

		public void Write(LinkWriter w)
		{
			w.U16(Proto).U32((uint)Features);
			Params.Write(w);
		}

		public static WelcomeMsg Read(LinkReader r)
		{
			return new WelcomeMsg
			{
				Proto = r.U16(),
				Features = (Feature)r.U32(),
				Params = ParamBag.Read(r)
			};
		}
	}
	public readonly struct ContainerSpec
	{
		public readonly string Prefab;

		public readonly byte Width;

		public readonly byte Height;

		public ContainerSpec(string prefab, byte width, byte height)
		{
			Prefab = prefab;
			Width = width;
			Height = height;
		}
	}
	public sealed class ParamBag
	{
		private readonly SortedDictionary<byte, byte[]> _d = new SortedDictionary<byte, byte[]>();

		public int Count => _d.Count;

		public bool Has(ParamKey key)
		{
			return _d.ContainsKey((byte)key);
		}

		public ParamBag SetBlob(ParamKey key, byte[] blob)
		{
			if (blob.Length > 32768)
			{
				throw new ArgumentException("param " + key.ToString() + " of " + blob.Length + " bytes exceeds the limit of " + 32768);
			}
			_d[(byte)key] = blob;
			return this;
		}

		public ParamBag SetF32(ParamKey key, float v)
		{
			return SetBlob(key, new LinkWriter(4).F32(v).ToArray());
		}

		public ParamBag SetU16(ParamKey key, ushort v)
		{
			return SetBlob(key, new LinkWriter(2).U16(v).ToArray());
		}

		public float GetF32(ParamKey key, float fallback)
		{
			try
			{
				byte[] value;
				return (_d.TryGetValue((byte)key, out value) && value.Length >= 4) ? new LinkReader(value).F32() : fallback;
			}
			catch (LinkFormatException)
			{
				return fallback;
			}
		}

		public ushort GetU16(ParamKey key, ushort fallback)
		{
			try
			{
				byte[] value;
				return (_d.TryGetValue((byte)key, out value) && value.Length >= 2) ? new LinkReader(value).U16() : fallback;
			}
			catch (LinkFormatException)
			{
				return fallback;
			}
		}

		public ParamBag SetSpecs(IList<ContainerSpec> specs)
		{
			LinkWriter linkWriter = new LinkWriter(specs.Count * 24 + 4).Count(specs.Count);
			foreach (ContainerSpec spec in specs)
			{
				linkWriter.Str(spec.Prefab, 96).U8(spec.Width).U8(spec.Height);
			}
			return SetBlob(ParamKey.ContainerSpecs, linkWriter.ToArray());
		}

		public List<ContainerSpec> GetSpecs()
		{
			List<ContainerSpec> list = new List<ContainerSpec>();
			try
			{
				if (_d.TryGetValue(4, out byte[] value))
				{
					LinkReader linkReader = new LinkReader(value);
					int num = linkReader.Count();
					for (int i = 0; i < num; i++)
					{
						list.Add(new ContainerSpec(linkReader.Str(96), linkReader.U8(), linkReader.U8()));
					}
				}
			}
			catch (LinkFormatException)
			{
				list.Clear();
			}
			return list;
		}

		public void Write(LinkWriter w)
		{
			w.U16((ushort)_d.Count);
			foreach (KeyValuePair<byte, byte[]> item in _d)
			{
				w.U8(item.Key).Bytes(item.Value);
			}
		}

		public static ParamBag Read(LinkReader r)
		{
			ParamBag paramBag = new ParamBag();
			int num = r.U16();
			if (num > 255)
			{
				throw new LinkFormatException("param bag of " + num + " entries");
			}
			for (int i = 0; i < num; i++)
			{
				byte key = r.U8();
				paramBag._d[key] = r.Bytes(32768);
			}
			return paramBag;
		}
	}
	public sealed class StationStatus
	{
		public ZdoRef Id;

		public string Prefab = "";

		public StationKind Kind;

		public StationFlags Flags;

		public StationReason Reason;

		public ushort NoteAgeSeconds = ushort.MaxValue;

		public float X;

		public float Y;

		public float Z;

		public bool Enabled => (Flags & StationFlags.Enabled) != 0;

		public bool FuelOn => (Flags & StationFlags.FuelOn) != 0;

		public bool OreOn => (Flags & StationFlags.OreOn) != 0;

		public void Write(LinkWriter w)
		{
			w.Ref(Id).Str(Prefab, 96).U8((byte)Kind)
				.U8((byte)Flags)
				.U8((byte)Reason)
				.U16(NoteAgeSeconds)
				.Vec3(X, Y, Z);
		}

		public static StationStatus Read(LinkReader r)
		{
			StationStatus stationStatus = new StationStatus
			{
				Id = r.Ref(),
				Prefab = r.Str(96),
				Kind = (StationKind)r.U8(),
				Flags = (StationFlags)r.U8(),
				Reason = (StationReason)r.U8(),
				NoteAgeSeconds = r.U16()
			};
			r.Vec3(out stationStatus.X, out stationStatus.Y, out stationStatus.Z);
			return stationStatus;
		}

		public static void WriteList(LinkWriter w, IList<StationStatus> list)
		{
			w.Count(list.Count);
			foreach (StationStatus item in list)
			{
				item.Write(w);
			}
		}

		public static List<StationStatus> ReadList(LinkReader r)
		{
			int num = r.Count();
			List<StationStatus> list = new List<StationStatus>(num);
			for (int i = 0; i < num; i++)
			{
				list.Add(Read(r));
			}
			return list;
		}
	}
	public sealed class QueryStationsReq
	{
		public const byte ModeAround = 0;

		public const byte ModeIds = 1;

		public byte Mode;

		public float Radius;

		public List<ZdoRef> Ids = new List<ZdoRef>();

		public void Write(LinkWriter w)
		{
			w.U8(Mode).F32(Radius).Count(Ids.Count);
			foreach (ZdoRef id in Ids)
			{
				w.Ref(id);
			}
		}

		public static QueryStationsReq Read(LinkReader r)
		{
			QueryStationsReq queryStationsReq = new QueryStationsReq
			{
				Mode = r.U8(),
				Radius = r.F32()
			};
			int num = r.Count();
			for (int i = 0; i < num; i++)
			{
				queryStationsReq.Ids.Add(r.Ref());
			}
			return queryStationsReq;
		}
	}
	public sealed class SetStationPrefsReq
	{
		public ZdoRef Id;

		public StationFlags Mask;

		public StationFlags Values;

		public bool Toggle;

		public void Write(LinkWriter w)
		{
			w.Ref(Id).U8((byte)Mask).U8((byte)Values)
				.Bool(Toggle);
		}

		public static SetStationPrefsReq Read(LinkReader r)
		{
			return new SetStationPrefsReq
			{
				Id = r.Ref(),
				Mask = (StationFlags)r.U8(),
				Values = (StationFlags)r.U8(),
				Toggle = r.Bool()
			};
		}
	}
	public sealed class SetStationsInAreaReq
	{
		public AreaAction Action;

		public float Radius;

		public void Write(LinkWriter w)
		{
			w.U8((byte)Action).F32(Radius);
		}

		public static SetStationsInAreaReq Read(LinkReader r)
		{
			return new SetStationsInAreaReq
			{
				Action = (AreaAction)r.U8(),
				Radius = r.F32()
			};
		}
	}
	public sealed class OpenContainerReq
	{
		public ZdoRef Id;

		public void Write(LinkWriter w)
		{
			w.Ref(Id);
		}

		public static OpenContainerReq Read(LinkReader r)
		{
			return new OpenContainerReq
			{
				Id = r.Ref()
			};
		}
	}
	public sealed class CraftNeed
	{
		public const int MaxLines = 32;

		public string Item = "";

		public ushort Amount;

		public void Write(LinkWriter w)
		{
			w.Str(Item, 96).U16(Amount);
		}

		public static CraftNeed Read(LinkReader r)
		{
			return new CraftNeed
			{
				Item = r.Str(96),
				Amount = r.U16()
			};
		}

		public static void WriteList(LinkWriter w, IList<CraftNeed> list)
		{
			if (list.Count > 32)
			{
				throw new ArgumentException("craft list of " + list.Count + " lines exceeds the limit of " + 32);
			}
			w.Count(list.Count);
			foreach (CraftNeed item in list)
			{
				item.Write(w);
			}
		}

		public static List<CraftNeed> ReadList(LinkReader r)
		{
			int num = r.Count(32);
			List<CraftNeed> list = new List<CraftNeed>(num);
			for (int i = 0; i < num; i++)
			{
				list.Add(Read(r));
			}
			return list;
		}
	}
	public sealed class CraftReserveReq
	{
		public ZdoRef Station;

		public List<CraftNeed> Needs = new List<CraftNeed>();

		public CraftPurpose Purpose;

		public void Write(LinkWriter w)
		{
			w.Ref(Station);
			CraftNeed.WriteList(w, Needs);
			w.U8((byte)Purpose);
		}

		public static CraftReserveReq Read(LinkReader r)
		{
			return new CraftReserveReq
			{
				Station = r.Ref(),
				Needs = CraftNeed.ReadList(r),
				Purpose = (CraftPurpose)((r.Remaining > 0) ? r.U8() : 0)
			};
		}
	}
	public sealed class CraftReserveReply
	{
		public uint Id;

		public ushort ExpiresSeconds;

		public List<CraftNeed> Taken = new List<CraftNeed>();

		public void Write(LinkWriter w)
		{
			w.U32(Id).U16(ExpiresSeconds);
			CraftNeed.WriteList(w, Taken);
		}

		public static CraftReserveReply Read(LinkReader r)
		{
			return new CraftReserveReply
			{
				Id = r.U32(),
				ExpiresSeconds = r.U16(),
				Taken = CraftNeed.ReadList(r)
			};
		}
	}
	public sealed class CraftTicketReq
	{
		public uint Id;

		public void Write(LinkWriter w)
		{
			w.U32(Id);
		}

		public static CraftTicketReq Read(LinkReader r)
		{
			return new CraftTicketReq
			{
				Id = r.U32()
			};
		}
	}
	public sealed class ReleaseOfferEntry
	{
		public const int MaxPerMessage = 16;

		public uint OfferId;

		public ZdoRef Id;

		public void Write(LinkWriter w)
		{
			w.U32(OfferId).Ref(Id);
		}

		public static ReleaseOfferEntry Read(LinkReader r)
		{
			return new ReleaseOfferEntry
			{
				OfferId = r.U32(),
				Id = r.Ref()
			};
		}

		public static void WriteList(LinkWriter w, IList<ReleaseOfferEntry> list)
		{
			if (list.Count > 16)
			{
				throw new ArgumentException("release offer list of " + list.Count + " entries exceeds the limit of " + 16);
			}
			w.Count(list.Count);
			foreach (ReleaseOfferEntry item in list)
			{
				item.Write(w);
			}
		}

		public static List<ReleaseOfferEntry> ReadList(LinkReader r)
		{
			int num = r.Count(16);
			List<ReleaseOfferEntry> list = new List<ReleaseOfferEntry>(num);
			for (int i = 0; i < num; i++)
			{
				list.Add(Read(r));
			}
			return list;
		}
	}
	public sealed class ReleaseAnswerEntry
	{
		public const int MaxPerMessage = 16;

		public uint OfferId;

		public ZdoRef Id;

		public bool Released;

		public ushort OwnerRevision;

		public uint DataRevision;

		public ReleaseReason Reason;

		public void Write(LinkWriter w)
		{
			w.U32(OfferId).Ref(Id).Bool(Released)
				.U16(OwnerRevision)
				.U32(DataRevision)
				.U8((byte)Reason);
		}

		public static ReleaseAnswerEntry Read(LinkReader r)
		{
			return new ReleaseAnswerEntry
			{
				OfferId = r.U32(),
				Id = r.Ref(),
				Released = r.Bool(),
				OwnerRevision = r.U16(),
				DataRevision = r.U32(),
				Reason = (ReleaseReason)r.U8()
			};
		}

		public static void WriteList(LinkWriter w, IList<ReleaseAnswerEntry> list)
		{
			if (list.Count > 16)
			{
				throw new ArgumentException("release answer list of " + list.Count + " entries exceeds the limit of " + 16);
			}
			w.Count(list.Count);
			foreach (ReleaseAnswerEntry item in list)
			{
				item.Write(w);
			}
		}

		public static List<ReleaseAnswerEntry> ReadList(LinkReader r)
		{
			int num = r.Count(16);
			List<ReleaseAnswerEntry> list = new List<ReleaseAnswerEntry>(num);
			for (int i = 0; i < num; i++)
			{
				list.Add(Read(r));
			}
			return list;
		}
	}
	public sealed class VacuumNudgeReq
	{
		public const int MaxIds = 16;

		public List<ZdoRef> Ids = new List<ZdoRef>();

		public void Write(LinkWriter w)
		{
			if (Ids.Count > 16)
			{
				throw new ArgumentException("nudge of " + Ids.Count + " ids exceeds the limit of " + 16);
			}
			w.Count(Ids.Count);
			foreach (ZdoRef id in Ids)
			{
				w.Ref(id);
			}
		}

		public static VacuumNudgeReq Read(LinkReader r)
		{
			VacuumNudgeReq vacuumNudgeReq = new VacuumNudgeReq();
			int num = r.Count(16);
			for (int i = 0; i < num; i++)
			{
				vacuumNudgeReq.Ids.Add(r.Ref());
			}
			return vacuumNudgeReq;
		}
	}
	public sealed class VacuumNudgeReply
	{
		public byte Accepted;

		public void Write(LinkWriter w)
		{
			w.U8(Accepted);
		}

		public static VacuumNudgeReply Read(LinkReader r)
		{
			return new VacuumNudgeReply
			{
				Accepted = r.U8()
			};
		}
	}
	public sealed class ContainerPrefsMsg
	{
		public const int MaxFilterTokens = 32;

		public const int MaxTokenBytes = 96;

		public bool VacuumOn = true;

		public VacuumMode Mode;

		public float Radius;

		public List<string> Filter = new List<string>();

		public void Write(LinkWriter w)
		{
			if (Filter.Count > 32)
			{
				throw new ArgumentException("filter of " + Filter.Count + " tokens exceeds the limit of " + 32);
			}
			w.Bool(VacuumOn).U8((byte)Mode).F32(Radius)
				.Count(Filter.Count);
			foreach (string item in Filter)
			{
				w.Str(item, 96);
			}
		}

		public static ContainerPrefsMsg Read(LinkReader r)
		{
			ContainerPrefsMsg containerPrefsMsg = new ContainerPrefsMsg
			{
				VacuumOn = r.Bool(),
				Mode = (VacuumMode)r.U8(),
				Radius = r.F32()
			};
			int num = r.Count(32);
			for (int i = 0; i < num; i++)
			{
				containerPrefsMsg.Filter.Add(r.Str(96));
			}
			return containerPrefsMsg;
		}
	}
	public sealed class QueryContainerPrefsReq
	{
		public ZdoRef Id;

		public void Write(LinkWriter w)
		{
			w.Ref(Id);
		}

		public static QueryContainerPrefsReq Read(LinkReader r)
		{
			return new QueryContainerPrefsReq
			{
				Id = r.Ref()
			};
		}
	}
	public sealed class ContainerPrefsView
	{
		public bool CanEdit;

		public ContainerPrefsMsg Prefs = new ContainerPrefsMsg();

		public void Write(LinkWriter w)
		{
			w.Bool(CanEdit);
			Prefs.Write(w);
		}

		public static ContainerPrefsView Read(LinkReader r)
		{
			return new ContainerPrefsView
			{
				CanEdit = r.Bool(),
				Prefs = ContainerPrefsMsg.Read(r)
			};
		}
	}
	public sealed class SetContainerPrefsReq
	{
		public ZdoRef Id;

		public PrefsField Mask;

		public ContainerPrefsMsg Prefs = new ContainerPrefsMsg();

		public void Write(LinkWriter w)
		{
			w.Ref(Id).U8((byte)Mask);
			Prefs.Write(w);
		}

		public static SetContainerPrefsReq Read(LinkReader r)
		{
			return new SetContainerPrefsReq
			{
				Id = r.Ref(),
				Mask = (PrefsField)r.U8(),
				Prefs = ContainerPrefsMsg.Read(r)
			};
		}
	}
	public sealed class ContainerPrefsChangedMsg
	{
		public ZdoRef Id;

		public ContainerPrefsMsg Prefs = new ContainerPrefsMsg();

		public void Write(LinkWriter w)
		{
			w.Ref(Id);
			Prefs.Write(w);
		}

		public static ContainerPrefsChangedMsg Read(LinkReader r)
		{
			return new ContainerPrefsChangedMsg
			{
				Id = r.Ref(),
				Prefs = ContainerPrefsMsg.Read(r)
			};
		}
	}
	public sealed class ReportedStatDelta
	{
		public ReportedStat Stat;

		public uint Delta;

		public void Write(LinkWriter w)
		{
			w.U8((byte)Stat).U32(Delta);
		}

		public static ReportedStatDelta Read(LinkReader r)
		{
			return new ReportedStatDelta
			{
				Stat = (ReportedStat)r.U8(),
				Delta = r.U32()
			};
		}
	}
	public sealed class ReportStatsReq
	{
		public const int MaxStats = 8;

		public const int MaxSkillBytes = 32;

		public List<ReportedStatDelta> Deltas = new List<ReportedStatDelta>();

		public string TopSkill = "";

		public ushort TopSkillLevel;

		public ushort SkillLevelsSum;

		public void Write(LinkWriter w)
		{
			if (Deltas.Count > 8)
			{
				throw new ArgumentException("report of " + Deltas.Count + " stats exceeds the limit of " + 8);
			}
			w.U8((byte)Deltas.Count);
			foreach (ReportedStatDelta delta in Deltas)
			{
				delta.Write(w);
			}
			w.Str(TopSkill, 32).U16(TopSkillLevel).U16(SkillLevelsSum);
		}

		public static ReportStatsReq Read(LinkReader r)
		{
			ReportStatsReq reportStatsReq = new ReportStatsReq();
			int num = r.U8();
			if (num > 8)
			{
				throw new LinkFormatException("report of " + num + " stats exceeds the limit of " + 8);
			}
			for (int i = 0; i < num; i++)
			{
				reportStatsReq.Deltas.Add(ReportedStatDelta.Read(r));
			}
			reportStatsReq.TopSkill = r.Str(32);
			reportStatsReq.TopSkillLevel = r.U16();
			reportStatsReq.SkillLevelsSum = r.U16();
			return reportStatsReq;
		}
	}
	public sealed class VacuumMovedEntry
	{
		public const int MaxPerMessage = 8;

		public string Item = "";

		public ushort Amount;

		public int ChestPrefab;

		public byte DistanceMetres;

		public void Write(LinkWriter w)
		{
			w.Str(Item, 96).U16(Amount).I32(ChestPrefab)
				.U8(DistanceMetres);
		}

		public static VacuumMovedEntry Read(LinkReader r)
		{
			return new VacuumMovedEntry
			{
				Item = r.Str(96),
				Amount = r.U16(),
				ChestPrefab = r.I32(),
				DistanceMetres = r.U8()
			};
		}

		public static void WriteList(LinkWriter w, IList<VacuumMovedEntry> list)
		{
			if (list.Count > 8)
			{
				throw new ArgumentException("vacuum-moved list of " + list.Count + " entries exceeds the limit of " + 8);
			}
			w.Count(list.Count);
			foreach (VacuumMovedEntry item in list)
			{
				item.Write(w);
			}
		}

		public static List<VacuumMovedEntry> ReadList(LinkReader r)
		{
			int num = r.Count(8);
			List<VacuumMovedEntry> list = new List<VacuumMovedEntry>(num);
			for (int i = 0; i < num; i++)
			{
				list.Add(Read(r));
			}
			return list;
		}
	}
	public static class LinkProtocol
	{
		public const ushort Version = 1;

		public const ushort MinVersion = 1;

		public const string RpcToClient = "ALICE_S2C";

		public const string RpcToServer = "ALICE_C2S";

		public const byte Magic = 161;

		public static int Negotiate(int aMin, int aMax, int bMin, int bMax)
		{
			int num = Math.Max(aMin, bMin);
			int num2 = Math.Min(aMax, bMax);
			if (num2 < num || num2 <= 0)
			{
				return 0;
			}
			return num2;
		}
	}
	public enum MsgKind : byte
	{
		Advertise = 1,
		Welcome = 2,
		Reply = 3,
		Push = 4,
		Hello = 129,
		Request = 130
	}
	public enum Op : byte
	{
		QueryStations = 1,
		SetStationPrefs = 2,
		SetStationsInArea = 3,
		OpenContainer = 16,
		RecoverCache = 17,
		CraftReserve = 32,
		CraftCommit = 33,
		CraftCancel = 34,
		ReleaseAnswer = 48,
		VacuumNudge = 49,
		QueryContainerPrefs = 50,
		SetContainerPrefs = 51,
		ReportStats = 64,
		ClearReportedStats = 65
	}
	public enum Status : byte
	{
		Ok,
		Denied,
		Busy,
		OutOfRange,
		Insufficient,
		RateLimited,
		Disabled,
		BadRequest,
		Stale,
		NotFound
	}
	[Flags]
	public enum Feature : uint
	{
		None = 0u,
		Production = 1u,
		ContainerRows = 2u,
		ReliableOpen = 4u,
		CraftFromChests = 8u,
		VacuumCoop = 0x10u,
		ReportedStats = 0x20u,
		EnhancedChests = 0x40u,
		BuildFromChests = 0x80u
	}
	public enum CraftPurpose : byte
	{
		Craft,
		Upgrade,
		Build
	}
	public enum PushEvent : byte
	{
		Config = 1,
		StationChanged,
		ReleaseOffer,
		VacuumMoved,
		ContainerPrefsChanged
	}
	public enum ParamKey : byte
	{
		StationRange = 1,
		AreaRadiusMax,
		AreaMaxRows,
		ContainerSpecs,
		OpenRange,
		CraftRange,
		VacuumFlags,
		VacuumRadius,
		PrefsFilterMax,
		ReportMinSeconds
	}
	public enum ReportedStat : byte
	{
		Crafts = 1,
		Builds,
		Trees,
		BossLastHits,
		Kills,
		BossKills
	}
	[Flags]
	public enum VacuumFlag : ushort
	{
		None = 0,
		Release = 1,
		Nudge = 2,
		Prefs = 4,
		Toasts = 8
	}
	public enum ReleaseReason : byte
	{
		None,
		PlayerOnIt,
		Gone,
		NotOwner,
		Busy
	}
	public enum VacuumMode : byte
	{
		MatchOnly,
		Filter,
		CatchAll
	}
	[Flags]
	public enum PrefsField : byte
	{
		None = 0,
		Vacuum = 1,
		Mode = 2,
		Radius = 4,
		Filter = 8,
		All = 0xF
	}
	public enum StationKind : byte
	{
		Fireplace,
		Smelter,
		Kiln
	}
	[Flags]
	public enum StationFlags : byte
	{
		None = 0,
		Enabled = 1,
		FuelOn = 2,
		OreOn = 4,
		All = 7
	}
	public enum StationReason : byte
	{
		Unknown,
		Off,
		Fed,
		Full,
		NoFuelSource,
		NoInputSource,
		KilnFilter,
		OwnerBusy,
		Blocked
	}
	public enum AreaAction : byte
	{
		AllOff,
		AllOn,
		KilnsOff,
		KilnsOn
	}
}
namespace Alice
{
	internal static class AliceConfig
	{
		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<bool> VerboseLogging;

		public static ConfigEntry<bool> ProductionEnabled;

		public static ConfigEntry<bool> ShowStationStatus;

		public static ConfigEntry<KeyboardShortcut> ToggleStationKey;

		public static ConfigEntry<KeyboardShortcut> ToggleFuelKey;

		public static ConfigEntry<KeyboardShortcut> ToggleOreKey;

		public static ConfigEntry<KeyboardShortcut> AllOffKey;

		public static ConfigEntry<KeyboardShortcut> AllOnKey;

		public static ConfigEntry<float> BulkRadius;

		public static ConfigEntry<bool> GrowContainerRows;

		public static ConfigEntry<bool> ReliableOpen;

		public static ConfigEntry<bool> CraftFromChests;

		public static ConfigEntry<bool> BuildFromChests;

		public static ConfigEntry<bool> SaveAfterChestCraft;

		public static ConfigEntry<KeyboardShortcut> ProductionPanelKey;

		public static ConfigEntry<float> PanelRadius;

		public static ConfigEntry<float> PanelScale;

		public static ConfigEntry<bool> VacuumCooperation;

		public static ConfigEntry<bool> VacuumNudge;

		public static ConfigEntry<bool> VacuumToasts;

		public static ConfigEntry<KeyboardShortcut> ChestSettingsKey;

		public static ConfigEntry<ShareMode> ShareStats;

		public static ConfigEntry<string> ReportedStatsServers;

		public static ConfigEntry<string> ReportedStatsSent;

		public static void Bind(ConfigFile cfg)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Expected O, but got Unknown
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			Enabled = cfg.Bind<bool>("1 - General", "Enabled", true, "Master switch. Off = Alice does nothing at all and the game behaves exactly as vanilla. Read once at start-up: changing it needs a restart of the game. Alice also does nothing on a server that is not running Wonderland with its Alice link on, whatever this says.");
			VerboseLogging = cfg.Bind<bool>("1 - General", "VerboseLogging", false, "Log every link message and decision to the BepInEx log. Off by default; turn it on when reporting a problem.");
			ProductionEnabled = cfg.Bind<bool>("2 - Production", "ProductionEnabled", true, "Show the auto-supply status of fireplaces, smelters and kilns when you look at them, and let you switch them with the keys below.");
			ShowStationStatus = cfg.Bind<bool>("2 - Production", "ShowStationStatus", true, "Add a line to a station's hover text saying whether the server's auto-supply is on and what it last did.");
			ToggleStationKey = cfg.Bind<KeyboardShortcut>("2 - Production", "ToggleStationKey", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "While looking at a s