Decompiled source of WhipItUp v1.0.1

WhipItUp/WhipItUp.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Kydl.Common;
using Kydl.Ui;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.TextCore.Text;
using UnityEngine.UIElements;
using WhipItUp.Sounds;
using WhipItUp.Ui;
using WhipItUp.Weapons;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Kydl.Ui
{
	internal static class UiControls
	{
		private const float ItemHeight = 40f;

		private const float ListMax = 400f;

		private static readonly string[] Palette = new string[14]
		{
			"#FFFFFF", "#000000", "#E8D5A9", "#FFB85C", "#C0392B", "#E67E22", "#F1C40F", "#2ECC71", "#1ABC9C", "#00FFFF",
			"#3498DB", "#9B59B6", "#FF33FF", "#7F8C8D"
		};

		internal static Button Button(string text, Action onClick, bool primary = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0042: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0152: 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)
			Button b = new Button((Action)delegate
			{
				UiLog.Verbose("Ui: button '" + text + "' pressed");
				onClick?.Invoke();
			})
			{
				text = text
			};
			Color bg = (primary ? UiKit.GoldDim : UiKit.PanelLight);
			Color hot = (primary ? UiKit.Gold : UiKit.PanelHover);
			((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(bg);
			((VisualElement)b).style.color = StyleColor.op_Implicit(primary ? UiKit.OnDark : UiKit.Text);
			((VisualElement)b).style.fontSize = StyleLength.op_Implicit(21f);
			UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border);
			UiKit.Radius((VisualElement)(object)b, 4f);
			UiKit.Pad((VisualElement)(object)b, 6f, 14f);
			((VisualElement)b).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)b).style.marginLeft = StyleLength.op_Implicit(3f);
			((VisualElement)b).style.marginRight = StyleLength.op_Implicit(3f);
			((VisualElement)b).style.marginTop = StyleLength.op_Implicit(3f);
			((VisualElement)b).style.marginBottom = StyleLength.op_Implicit(3f);
			UiKit.Fade((VisualElement)(object)b, "background-color");
			((CallbackEventHandler)b).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(hot);
			}, (TrickleDown)0);
			((CallbackEventHandler)b).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(bg);
			}, (TrickleDown)0);
			return b;
		}

		internal static Button Field(string text, Action onClick)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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)
			Button b = new Button((Action)delegate
			{
				UiLog.Verbose("Ui: field '" + text + "' opened");
				onClick?.Invoke();
			})
			{
				text = text
			};
			((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			((VisualElement)b).style.color = StyleColor.op_Implicit(UiKit.Gold);
			((VisualElement)b).style.fontSize = StyleLength.op_Implicit(22f);
			UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border);
			UiKit.Radius((VisualElement)(object)b, 4f);
			UiKit.Pad((VisualElement)(object)b, 5f, 10f);
			((VisualElement)b).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
			((VisualElement)b).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)b).style.marginLeft = StyleLength.op_Implicit(0f);
			((VisualElement)b).style.marginRight = StyleLength.op_Implicit(0f);
			UiKit.Fade((VisualElement)(object)b, "border-top-color", "border-bottom-color", "border-left-color", "border-right-color");
			((CallbackEventHandler)b).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Gold);
			}, (TrickleDown)0);
			((CallbackEventHandler)b).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border);
			}, (TrickleDown)0);
			return b;
		}

		internal static VisualElement Heading(string text)
		{
			//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_0010: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00b2: 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_00c4: Expected O, but got Unknown
			VisualElement val = new VisualElement();
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.marginTop = StyleLength.op_Implicit(16f);
			val.style.marginBottom = StyleLength.op_Implicit(6f);
			Label val2 = UiKit.Label(text.ToUpperInvariant(), 24f, UiKit.Gold, title: true);
			((VisualElement)val2).style.letterSpacing = StyleLength.op_Implicit(1.5f);
			val.Add((VisualElement)(object)val2);
			VisualElement val3 = new VisualElement();
			val3.style.height = StyleLength.op_Implicit(1f);
			val3.style.backgroundColor = StyleColor.op_Implicit(UiKit.Border);
			val3.style.marginTop = StyleLength.op_Implicit(4f);
			val.Add(val3);
			return val;
		}

		internal static Label Note(string text)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			Label obj = UiKit.Label(text, 18f, UiKit.TextDim);
			((VisualElement)obj).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0);
			((VisualElement)obj).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)obj).style.marginTop = StyleLength.op_Implicit(2f);
			((VisualElement)obj).style.marginBottom = StyleLength.op_Implicit(2f);
			return obj;
		}

		internal static VisualElement Row(string label, VisualElement control)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_003c: 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_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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.marginTop = StyleLength.op_Implicit(4f);
			val.style.marginBottom = StyleLength.op_Implicit(4f);
			Label val2 = UiKit.Label(label, 22f, UiKit.Text);
			((VisualElement)val2).style.width = StyleLength.op_Implicit(170f);
			((VisualElement)val2).style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add((VisualElement)(object)val2);
			control.style.flexGrow = StyleFloat.op_Implicit(1f);
			control.style.flexShrink = StyleFloat.op_Implicit(1f);
			val.Add(control);
			return val;
		}

		internal static VisualElement Line(params VisualElement[] items)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			foreach (VisualElement val2 in items)
			{
				val.Add(val2);
			}
			return val;
		}

		internal static TextField TextField(string value, int maxLength, Action<string> changed)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0029: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00ae: Expected O, but got Unknown
			TextField val = new TextField();
			((BaseField<string>)val).value = value ?? "";
			((TextInputBaseField<string>)val).maxLength = maxLength;
			((VisualElement)val).style.marginLeft = StyleLength.op_Implicit(0f);
			((VisualElement)val).style.marginRight = StyleLength.op_Implicit(0f);
			((VisualElement)val).style.marginTop = StyleLength.op_Implicit(0f);
			((VisualElement)val).style.marginBottom = StyleLength.op_Implicit(0f);
			((VisualElement)val).style.flexShrink = StyleFloat.op_Implicit(0f);
			StyleInput(val, 22);
			INotifyValueChangedExtensions.RegisterValueChangedCallback<string>((INotifyValueChanged<string>)val, (EventCallback<ChangeEvent<string>>)delegate(ChangeEvent<string> e)
			{
				changed?.Invoke(e.newValue);
			});
			return val;
		}

		private static void StyleInput(TextField f, int size)
		{
			//IL_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			VisualElement input = (VisualElement)(((object)UQueryExtensions.Q((VisualElement)(object)f, (string)null, TextField.inputUssClassName)) ?? ((object)f));
			input.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			input.style.color = StyleColor.op_Implicit(UiKit.Gold);
			input.style.fontSize = StyleLength.op_Implicit((float)size);
			UiKit.Borders(input, 1f, UiKit.Border);
			UiKit.Radius(input, 4f);
			UiKit.Pad(input, 5f, 8f);
			input.style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
			((CallbackEventHandler)f).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders(input, 1f, UiKit.Gold);
			}, (TrickleDown)0);
			((CallbackEventHandler)f).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders(input, 1f, UiKit.Border);
			}, (TrickleDown)0);
		}

		internal static VisualElement Toggle(string text, bool on, Action<bool> changed)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0032: 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_0062: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_018c: Expected O, but got Unknown
			//IL_01a4: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			VisualElement row = new VisualElement();
			row.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			row.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			row.style.flexShrink = StyleFloat.op_Implicit(0f);
			UiKit.Pad(row, 5f, 8f);
			UiKit.Radius(row, 4f);
			row.style.marginRight = StyleLength.op_Implicit(6f);
			UiKit.Fade(row, "background-color");
			VisualElement sw = new VisualElement();
			sw.pickingMode = (PickingMode)1;
			sw.style.width = StyleLength.op_Implicit(44f);
			sw.style.height = StyleLength.op_Implicit(22f);
			sw.style.flexShrink = StyleFloat.op_Implicit(0f);
			sw.style.marginRight = StyleLength.op_Implicit(8f);
			UiKit.Radius(sw, 11f);
			UiKit.Borders(sw, 1f, UiKit.Border);
			UiKit.Fade(sw, "background-color");
			VisualElement knob = new VisualElement();
			knob.pickingMode = (PickingMode)1;
			knob.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			knob.style.top = StyleLength.op_Implicit(2f);
			knob.style.width = StyleLength.op_Implicit(16f);
			knob.style.height = StyleLength.op_Implicit(16f);
			UiKit.Radius(knob, 8f);
			UiKit.Fade(knob, "left", "background-color");
			sw.Add(knob);
			row.Add(sw);
			row.Add((VisualElement)(object)UiKit.Label(text, 22f, UiKit.Text));
			((CallbackEventHandler)row).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				row.style.backgroundColor = StyleColor.op_Implicit(UiKit.PanelLight);
			}, (TrickleDown)0);
			((CallbackEventHandler)row).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				row.style.backgroundColor = StyleColor.op_Implicit(Color.clear);
			}, (TrickleDown)0);
			((CallbackEventHandler)row).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0)
				{
					on = !on;
					Show();
					UiLog.Verbose("Ui: switch '" + text + "' " + (on ? "on" : "off"));
					changed?.Invoke(on);
				}
			}, (TrickleDown)0);
			Show();
			return row;
			void Show()
			{
				//IL_001a: 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_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: 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_006b: Unknown result type (might be due to invalid IL or missing references)
				sw.style.backgroundColor = StyleColor.op_Implicit(on ? UiKit.GoldDim : UiKit.Track);
				knob.style.left = StyleLength.op_Implicit((float)(on ? 24 : 2));
				knob.style.backgroundColor = StyleColor.op_Implicit(on ? UiKit.Gold : UiKit.TextDim);
			}
		}

		internal static VisualElement Slider(float min, float max, float value, string format, Action<float> changed)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_008f: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_02f5: Expected O, but got Unknown
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Expected O, but got Unknown
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.minHeight = StyleLength.op_Implicit(34f);
			VisualElement hit = new VisualElement();
			hit.style.flexGrow = StyleFloat.op_Implicit(1f);
			hit.style.height = StyleLength.op_Implicit(24f);
			hit.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
			hit.style.marginRight = StyleLength.op_Implicit(10f);
			VisualElement val2 = new VisualElement();
			val2.pickingMode = (PickingMode)1;
			val2.style.height = StyleLength.op_Implicit(6f);
			UiKit.Radius(val2, 3f);
			val2.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			UiKit.Borders(val2, 1f, UiKit.Border);
			hit.Add(val2);
			VisualElement fill = new VisualElement();
			fill.pickingMode = (PickingMode)1;
			fill.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			fill.style.left = StyleLength.op_Implicit(0f);
			fill.style.top = StyleLength.op_Implicit(0f);
			fill.style.bottom = StyleLength.op_Implicit(0f);
			fill.style.backgroundColor = StyleColor.op_Implicit(UiKit.GoldDim);
			UiKit.Radius(fill, 3f);
			val2.Add(fill);
			VisualElement handle = new VisualElement();
			handle.pickingMode = (PickingMode)1;
			handle.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			handle.style.top = StyleLength.op_Implicit(4f);
			handle.style.width = StyleLength.op_Implicit(16f);
			handle.style.height = StyleLength.op_Implicit(16f);
			handle.style.marginLeft = StyleLength.op_Implicit(-8f);
			UiKit.Radius(handle, 8f);
			handle.style.backgroundColor = StyleColor.op_Implicit(UiKit.Gold);
			UiKit.Borders(handle, 1f, UiKit.OnDark);
			hit.Add(handle);
			val.Add(hit);
			TextField val3 = new TextField();
			((TextInputBaseField<string>)val3).maxLength = 8;
			TextField input = val3;
			((VisualElement)input).style.width = StyleLength.op_Implicit(80f);
			((VisualElement)input).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)input).style.marginLeft = StyleLength.op_Implicit(0f);
			((VisualElement)input).style.marginRight = StyleLength.op_Implicit(0f);
			((VisualElement)input).style.marginTop = StyleLength.op_Implicit(0f);
			((VisualElement)input).style.marginBottom = StyleLength.op_Implicit(0f);
			StyleInput(input, 19);
			val.Add((VisualElement)(object)input);
			float v = Mathf.Clamp(value, min, max);
			bool editing = false;
			((CallbackEventHandler)hit).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				PointerCaptureHelper.CapturePointer((IEventHandler)(object)hit, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId);
				FromX(((PointerEventBase<PointerDownEvent>)(object)e).localPosition.x);
				((EventBase)e).StopPropagation();
			}, (TrickleDown)0);
			((CallbackEventHandler)hit).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent e)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)hit, ((PointerEventBase<PointerMoveEvent>)(object)e).pointerId))
				{
					FromX(((PointerEventBase<PointerMoveEvent>)(object)e).localPosition.x);
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)hit).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate(PointerUpEvent e)
			{
				if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)hit, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId))
				{
					PointerCaptureHelper.ReleasePointer((IEventHandler)(object)hit, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId);
					UiLog.Verbose("Ui: slider set to " + v.ToString(format));
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)input).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate
			{
				editing = true;
			}, (TrickleDown)0);
			((CallbackEventHandler)input).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate
			{
				editing = false;
				Commit();
			}, (TrickleDown)0);
			((CallbackEventHandler)input).RegisterCallback<KeyDownEvent>((EventCallback<KeyDownEvent>)delegate(KeyDownEvent e)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and I4
				if ((int)((KeyboardEventBase<KeyDownEvent>)(object)e).keyCode == 13 || (int)((KeyboardEventBase<KeyDownEvent>)(object)e).keyCode == 271)
				{
					((EventBase)e).StopPropagation();
					editing = false;
					Commit();
					((Focusable)input).Blur();
				}
			}, (TrickleDown)0);
			Show();
			return val;
			void Commit()
			{
				if (float.TryParse((((BaseField<string>)(object)input).value ?? "").Trim().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					Set(result, "typed");
					UiLog.Verbose("Ui: slider typed " + v.ToString(format));
				}
				else
				{
					UiLog.Verbose("Ui: slider input '" + ((BaseField<string>)(object)input).value + "' is not a number, kept " + v.ToString(format));
					Show();
				}
			}
			void FromX(float x)
			{
				float width = hit.resolvedStyle.width;
				if (width > 1f)
				{
					Set(Mathf.Lerp(min, max, Mathf.Clamp01(x / width)), "drag");
				}
			}
			void Set(float nv, string how)
			{
				v = Mathf.Clamp(nv, min, max);
				Show();
				changed?.Invoke(v);
			}
			void Show()
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				float num = ((max > min) ? Mathf.InverseLerp(min, max, v) : 0f);
				fill.style.width = StyleLength.op_Implicit(Length.Percent(num * 100f));
				handle.style.left = StyleLength.op_Implicit(Length.Percent(num * 100f));
				if (!editing)
				{
					((BaseField<string>)(object)input).SetValueWithoutNotify(v.ToString(format));
				}
			}
		}

		internal static Button Dropdown(IList<string> options, string current, Func<string, string> label, Action<string> chosen)
		{
			Button b = null;
			string cur = current;
			VisualElement openList = null;
			b = Field(label(current) + "  ▾", delegate
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Expected O, but got Unknown
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: 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_029f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0298: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
				VisualElement root = UiKit.Root;
				if (root != null)
				{
					VisualElement shade = new VisualElement
					{
						name = "kydl-dropdown"
					};
					shade.style.position = StyleEnum<Position>.op_Implicit((Position)1);
					shade.style.left = StyleLength.op_Implicit(0f);
					shade.style.top = StyleLength.op_Implicit(0f);
					shade.style.right = StyleLength.op_Implicit(0f);
					shade.style.bottom = StyleLength.op_Implicit(0f);
					shade.style.backgroundColor = StyleColor.op_Implicit(new Color(0f, 0f, 0f, 0.35f));
					VisualElement val = new VisualElement();
					Rect worldBound = ((VisualElement)b).worldBound;
					float num = Mathf.Min(400f, (float)options.Count * 40f + 12f);
					float num2 = ((Rect)(ref worldBound)).yMax + num;
					Rect layout = root.layout;
					float num3 = ((num2 > ((Rect)(ref layout)).height) ? Mathf.Max(0f, ((Rect)(ref worldBound)).yMin - num) : (((Rect)(ref worldBound)).yMax + 2f));
					val.style.position = StyleEnum<Position>.op_Implicit((Position)1);
					val.style.left = StyleLength.op_Implicit(((Rect)(ref worldBound)).xMin);
					val.style.top = StyleLength.op_Implicit(num3);
					val.style.width = StyleLength.op_Implicit(Mathf.Max(((Rect)(ref worldBound)).width, 260f));
					val.style.height = StyleLength.op_Implicit(num);
					val.style.backgroundColor = StyleColor.op_Implicit(new Color(UiKit.Panel.r, UiKit.Panel.g, UiKit.Panel.b, 1f));
					UiKit.Borders(val, 1f, UiKit.Gold);
					UiKit.Radius(val, 6f);
					UiKit.Pad(val, 4f, 4f);
					UiScroll uiScroll = new UiScroll("drop-down");
					val.Add(uiScroll.Root);
					foreach (string option in options)
					{
						string opt = option;
						Label item = UiKit.Label(label(opt), 22f, (opt == cur) ? UiKit.Gold : UiKit.Text);
						((VisualElement)item).pickingMode = (PickingMode)0;
						((VisualElement)item).style.height = StyleLength.op_Implicit(36f);
						((VisualElement)item).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
						((VisualElement)item).style.flexShrink = StyleFloat.op_Implicit(0f);
						UiKit.Pad((VisualElement)(object)item, 0f, 10f);
						UiKit.Radius((VisualElement)(object)item, 4f);
						UiKit.Fade((VisualElement)(object)item, "background-color");
						((CallbackEventHandler)item).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
						{
							//IL_000b: Unknown result type (might be due to invalid IL or missing references)
							//IL_0010: Unknown result type (might be due to invalid IL or missing references)
							((VisualElement)item).style.backgroundColor = StyleColor.op_Implicit(UiKit.PanelHover);
						}, (TrickleDown)0);
						((CallbackEventHandler)item).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
						{
							//IL_000b: Unknown result type (might be due to invalid IL or missing references)
							//IL_0010: Unknown result type (might be due to invalid IL or missing references)
							((VisualElement)item).style.backgroundColor = StyleColor.op_Implicit(Color.clear);
						}, (TrickleDown)0);
						((CallbackEventHandler)item).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
						{
							if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0)
							{
								cur = opt;
								((TextElement)b).text = label(opt) + "  ▾";
								shade.RemoveFromHierarchy();
								UiLog.Verbose("Ui: drop-down chose '" + opt + "'");
								chosen?.Invoke(opt);
							}
						}, (TrickleDown)0);
						uiScroll.Content.Add((VisualElement)(object)item);
					}
					((CallbackEventHandler)shade).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
					{
						if ((object)((EventBase)e).target == shade)
						{
							shade.RemoveFromHierarchy();
							UiLog.Verbose("Ui: drop-down closed without a choice");
						}
					}, (TrickleDown)0);
					shade.Add(val);
					root.Add(shade);
					openList = shade;
					int num4 = options.IndexOf(cur);
					if (num4 > 3)
					{
						uiScroll.ScrollTo((float)(num4 - 3) * 40f);
					}
					UiLog.Verbose("Ui: drop-down opened with " + options.Count + " option(s), current '" + cur + "'");
				}
			});
			((CallbackEventHandler)b).RegisterCallback<DetachFromPanelEvent>((EventCallback<DetachFromPanelEvent>)delegate
			{
				VisualElement val = openList;
				openList = null;
				if (val != null && val.parent != null)
				{
					val.RemoveFromHierarchy();
					UiLog.Verbose("Ui: drop-down closed because its field left the panel");
				}
			}, (TrickleDown)0);
			return b;
		}

		internal static VisualElement ColorPicker(string hex, Action<string> changed, out Action<string> set)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001e: 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_0055: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement();
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			Color c = default(Color);
			if (!ColorUtility.TryParseHtmlString(hex ?? "#FFFFFF", ref c))
			{
				c = Color.white;
			}
			VisualElement preview = new VisualElement();
			preview.style.height = StyleLength.op_Implicit(26f);
			UiKit.Radius(preview, 4f);
			UiKit.Borders(preview, 1f, UiKit.Border);
			val.Add(preview);
			VisualElement val2 = new VisualElement();
			val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val2.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1);
			val2.style.flexShrink = StyleFloat.op_Implicit(0f);
			val2.style.marginTop = StyleLength.op_Implicit(8f);
			val2.style.marginBottom = StyleLength.op_Implicit(4f);
			val.Add(val2);
			VisualElement sliders = new VisualElement();
			sliders.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add(sliders);
			TextField field = null;
			string[] palette = Palette;
			Color pc = default(Color);
			foreach (string obj in palette)
			{
				ColorUtility.TryParseHtmlString(obj, ref pc);
				VisualElement s = new VisualElement();
				s.style.width = StyleLength.op_Implicit(28f);
				s.style.height = StyleLength.op_Implicit(28f);
				s.style.marginRight = StyleLength.op_Implicit(6f);
				s.style.marginTop = StyleLength.op_Implicit(4f);
				s.style.backgroundColor = StyleColor.op_Implicit(pc);
				UiKit.Radius(s, 4f);
				UiKit.Borders(s, 1f, UiKit.Border);
				((CallbackEventHandler)s).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					UiKit.Borders(s, 2f, UiKit.Gold);
				}, (TrickleDown)0);
				((CallbackEventHandler)s).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					UiKit.Borders(s, 1f, UiKit.Border);
				}, (TrickleDown)0);
				((CallbackEventHandler)s).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					c = pc;
					RebuildSliders();
					Apply(fromField: false);
				}, (TrickleDown)0);
				val2.Add(s);
			}
			field = TextField("#" + ColorUtility.ToHtmlStringRGB(c), 7, delegate(string v)
			{
				//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_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				Color val4 = default(Color);
				if (v.TrimStart(new char[1] { '#' }).Length == 6 && ColorUtility.TryParseHtmlString(v.StartsWith("#") ? v : ("#" + v), ref val4))
				{
					if (ColorUtility.ToHtmlStringRGB(val4) == ColorUtility.ToHtmlStringRGB(c))
					{
						UiLog.Verbose("Ui: colour hex " + v + " = current colour, sliders kept");
					}
					else
					{
						c = val4;
						RebuildSliders();
						Apply(fromField: true);
						UiLog.Verbose("Ui: colour typed " + v + ", sliders set");
					}
				}
			});
			((VisualElement)field).style.width = StyleLength.op_Implicit(130f);
			((VisualElement)field).style.flexGrow = StyleFloat.op_Implicit(0f);
			VisualElement val3 = Row("Hex", (VisualElement)(object)field);
			((VisualElement)field).style.flexGrow = StyleFloat.op_Implicit(0f);
			val.Add(val3);
			RebuildSliders();
			preview.style.backgroundColor = StyleColor.op_Implicit(c);
			set = delegate(string h)
			{
				//IL_000b: 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_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)
				Color val4 = default(Color);
				if (ColorUtility.TryParseHtmlString(h, ref val4))
				{
					c = val4;
					RebuildSliders();
					((BaseField<string>)(object)field).SetValueWithoutNotify(h);
					preview.style.backgroundColor = StyleColor.op_Implicit(c);
				}
			};
			return val;
			void Apply(bool fromField)
			{
				//IL_0006: 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_0027: Unknown result type (might be due to invalid IL or missing references)
				string text = "#" + ColorUtility.ToHtmlStringRGB(c);
				preview.style.backgroundColor = StyleColor.op_Implicit(c);
				if (!fromField && field != null)
				{
					((BaseField<string>)(object)field).SetValueWithoutNotify(text);
				}
				changed?.Invoke(text);
			}
			void RebuildSliders()
			{
				sliders.Clear();
				sliders.Add(Row("Red", Slider(0f, 255f, c.r * 255f, "0", delegate(float v)
				{
					c.r = v / 255f;
					Apply(fromField: false);
				})));
				sliders.Add(Row("Green", Slider(0f, 255f, c.g * 255f, "0", delegate(float v)
				{
					c.g = v / 255f;
					Apply(fromField: false);
				})));
				sliders.Add(Row("Blue", Slider(0f, 255f, c.b * 255f, "0", delegate(float v)
				{
					c.b = v / 255f;
					Apply(fromField: false);
				})));
			}
		}
	}
	internal static class UiKit
	{
		internal static readonly Color Panel = new Color(0.075f, 0.058f, 0.043f, 0.96f);

		internal static readonly Color PanelLight = new Color(0.125f, 0.098f, 0.072f, 0.96f);

		internal static readonly Color PanelHover = new Color(0.19f, 0.145f, 0.098f, 0.96f);

		internal static readonly Color Border = new Color(0.45f, 0.33f, 0.17f, 0.95f);

		internal static readonly Color Gold = new Color(1f, 0.72f, 0.36f, 1f);

		internal static readonly Color GoldDim = new Color(0.72f, 0.52f, 0.26f, 1f);

		internal static readonly Color Text = new Color(0.92f, 0.87f, 0.77f, 1f);

		internal static readonly Color TextDim = new Color(0.7f, 0.64f, 0.55f, 1f);

		internal static readonly Color Track = new Color(0.03f, 0.025f, 0.02f, 1f);

		internal static readonly Color OnDark = new Color(0.1f, 0.07f, 0.03f, 1f);

		internal const int TitleSize = 34;

		internal const int SectionSize = 24;

		internal const int FontSize = 22;

		internal const int ButtonSize = 21;

		internal const int SmallSize = 18;

		internal static string Owner = typeof(UiKit).Assembly.GetName().Name;

		private static UIDocument _doc;

		private static Font _bodyFont;

		private static Font _titleFont;

		private static FontAsset _bodyAsset;

		private static FontAsset _titleAsset;

		internal static PanelSettings Settings { get; private set; }

		internal static VisualElement Root
		{
			get
			{
				if ((Object)(object)_doc == (Object)null)
				{
					Create();
				}
				if (!((Object)(object)_doc != (Object)null))
				{
					return null;
				}
				return _doc.rootVisualElement;
			}
		}

		internal static void Reset()
		{
			if ((Object)(object)_doc != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)_doc).gameObject);
			}
			_doc = null;
		}

		private static void Create()
		{
			//IL_0023: 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_0065: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PanelSettings val = ScriptableObject.CreateInstance<PanelSettings>();
				((Object)val).name = "Kydl_PanelSettings";
				val.scaleMode = (PanelScaleMode)2;
				val.referenceResolution = new Vector2Int(1920, 1080);
				val.screenMatchMode = (PanelScreenMatchMode)0;
				val.match = 1f;
				val.sortingOrder = 500f;
				Settings = val;
				GameObject val2 = new GameObject("Kydl_UI_" + Owner);
				if (Application.isPlaying)
				{
					Object.DontDestroyOnLoad((Object)(object)val2);
				}
				_doc = val2.AddComponent<UIDocument>();
				_doc.panelSettings = val;
				VisualElement rootVisualElement = _doc.rootVisualElement;
				rootVisualElement.style.position = StyleEnum<Position>.op_Implicit((Position)1);
				rootVisualElement.style.left = StyleLength.op_Implicit(0f);
				rootVisualElement.style.top = StyleLength.op_Implicit(0f);
				rootVisualElement.style.right = StyleLength.op_Implicit(0f);
				rootVisualElement.style.bottom = StyleLength.op_Implicit(0f);
				rootVisualElement.pickingMode = (PickingMode)1;
				string text = LoadFonts();
				Font(rootVisualElement, title: false);
				rootVisualElement.style.color = StyleColor.op_Implicit(Text);
				rootVisualElement.style.fontSize = StyleLength.op_Implicit(22f);
				UiLog.Verbose("UiKit: UI Toolkit panel made (scale with screen " + Screen.width + "x" + Screen.height + " from 1920x1080, " + text + ")");
			}
			catch (Exception ex)
			{
				UiLog.Error("UiKit: UI Toolkit could not be started - the menus of this mod are not available: " + ex);
				_doc = null;
			}
		}

		private static string LoadFonts()
		{
			Font val = null;
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			foreach (Font val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					switch (((Object)val2).name)
					{
					case "Norse":
						_bodyFont = val2;
						break;
					case "Norsebold":
						_titleFont = val2;
						break;
					case "NotoEmoji-Regular":
						val = val2;
						break;
					}
				}
			}
			if ((Object)(object)_titleFont == (Object)null)
			{
				_titleFont = _bodyFont;
			}
			if ((Object)(object)_bodyFont == (Object)null)
			{
				_bodyFont = _titleFont;
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Font.CreateDynamicFontFromOSFont(new string[3] { "Segoe UI Emoji", "Segoe UI Symbol", "Noto Emoji" }, 32);
			}
			FontAsset val3 = MakeAsset(val, null);
			_bodyAsset = MakeAsset(_bodyFont, val3);
			_titleAsset = (((Object)(object)_titleFont == (Object)(object)_bodyFont) ? _bodyAsset : MakeAsset(_titleFont, val3));
			return "text font " + Describe(_bodyFont, _bodyAsset) + ", title font " + Describe(_titleFont, _titleAsset) + ", emoji font " + Describe(val, val3);
		}

		private static string Describe(Font f, FontAsset a)
		{
			if (!((Object)(object)f == (Object)null))
			{
				return "'" + ((Object)f).name + "'" + (((Object)(object)a != (Object)null) ? " (font asset made)" : " (legacy font, no emoji fallback)");
			}
			return "MISSING";
		}

		private static FontAsset MakeAsset(Font f, FontAsset fallback)
		{
			if ((Object)(object)f == (Object)null)
			{
				return null;
			}
			try
			{
				FontAsset val = FontAsset.CreateFontAsset(f);
				if ((Object)(object)val == (Object)null)
				{
					UiLog.Warn("UiKit: font asset from '" + ((Object)f).name + "' could not be made");
					return null;
				}
				((Object)val).name = "Kydl_" + ((Object)f).name;
				if ((Object)(object)fallback != (Object)null)
				{
					if (val.fallbackFontAssetTable == null)
					{
						val.fallbackFontAssetTable = new List<FontAsset>();
					}
					val.fallbackFontAssetTable.Add(fallback);
				}
				return val;
			}
			catch (Exception ex)
			{
				UiLog.Warn("UiKit: font asset from '" + ((Object)f).name + "' failed: " + ex.Message);
				return null;
			}
		}

		internal static void Font(VisualElement e, bool title)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			FontAsset val = (title ? _titleAsset : _bodyAsset);
			Font val2 = (title ? _titleFont : _bodyFont);
			if ((Object)(object)val != (Object)null)
			{
				e.style.unityFontDefinition = StyleFontDefinition.op_Implicit(FontDefinition.FromSDFFont(val));
			}
			else if ((Object)(object)val2 != (Object)null)
			{
				e.style.unityFont = StyleFont.op_Implicit(val2);
			}
		}

		internal static void Radius(VisualElement e, float r)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			e.style.borderTopLeftRadius = StyleLength.op_Implicit(r);
			e.style.borderTopRightRadius = StyleLength.op_Implicit(r);
			e.style.borderBottomLeftRadius = StyleLength.op_Implicit(r);
			e.style.borderBottomRightRadius = StyleLength.op_Implicit(r);
		}

		internal static void Borders(VisualElement e, float w, Color c)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_004a: 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_005b: 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_006c: 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_007d: 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)
			e.style.borderTopWidth = StyleFloat.op_Implicit(w);
			e.style.borderRightWidth = StyleFloat.op_Implicit(w);
			e.style.borderBottomWidth = StyleFloat.op_Implicit(w);
			e.style.borderLeftWidth = StyleFloat.op_Implicit(w);
			e.style.borderTopColor = StyleColor.op_Implicit(c);
			e.style.borderRightColor = StyleColor.op_Implicit(c);
			e.style.borderBottomColor = StyleColor.op_Implicit(c);
			e.style.borderLeftColor = StyleColor.op_Implicit(c);
		}

		internal static void Pad(VisualElement e, float v, float h)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			e.style.paddingTop = StyleLength.op_Implicit(v);
			e.style.paddingBottom = StyleLength.op_Implicit(v);
			e.style.paddingLeft = StyleLength.op_Implicit(h);
			e.style.paddingRight = StyleLength.op_Implicit(h);
		}

		internal static void Fade(VisualElement e, params string[] props)
		{
			//IL_0012: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			List<StylePropertyName> list = new List<StylePropertyName>();
			foreach (string text in props)
			{
				list.Add(new StylePropertyName(text));
			}
			e.style.transitionProperty = StyleList<StylePropertyName>.op_Implicit(list);
			e.style.transitionDuration = StyleList<TimeValue>.op_Implicit(new List<TimeValue>
			{
				new TimeValue(0.12f, (TimeUnit)0)
			});
		}

		internal static Label Label(string text, float size, Color color, bool title = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Label val = new Label(text);
			((VisualElement)val).pickingMode = (PickingMode)1;
			((VisualElement)val).style.fontSize = StyleLength.op_Implicit(size);
			((VisualElement)val).style.color = StyleColor.op_Implicit(color);
			if (title)
			{
				Font((VisualElement)(object)val, title: true);
			}
			return val;
		}

		internal static VisualElement Window(string title, string footer, Action onClose, out UiScroll body)
		{
			//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_0011: Expected O, but got Unknown
			//IL_0018: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_014e: Expected O, but got Unknown
			//IL_0155: 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)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: 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_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement
			{
				name = "kydl-window"
			};
			val.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			val.style.width = StyleLength.op_Implicit(760f);
			val.style.maxWidth = StyleLength.op_Implicit(Length.Percent(60f));
			val.style.height = StyleLength.op_Implicit(Length.Percent(70f));
			val.style.right = StyleLength.op_Implicit(Length.Percent(5f));
			val.style.left = StyleLength.op_Implicit((StyleKeyword)2);
			val.style.top = StyleLength.op_Implicit(Length.Percent(15f));
			UiLog.Verbose("UiKit: window '" + title + "' opened 5% from the right edge, 15% from the top");
			val.style.backgroundColor = StyleColor.op_Implicit(Panel);
			Radius(val, 8f);
			Borders(val, 2f, Border);
			val.style.borderTopColor = StyleColor.op_Implicit(Gold);
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0);
			val.pickingMode = (PickingMode)0;
			((CallbackEventHandler)val).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				((EventBase)e).StopPropagation();
			}, (TrickleDown)0);
			VisualElement val2 = new VisualElement();
			val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val2.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)3);
			val2.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val2.style.flexShrink = StyleFloat.op_Implicit(0f);
			Pad(val2, 12f, 18f);
			val2.style.borderBottomWidth = StyleFloat.op_Implicit(1f);
			val2.style.borderBottomColor = StyleColor.op_Implicit(Border);
			Label val3 = Label(title.ToUpperInvariant(), 34f, Gold, title: true);
			((VisualElement)val3).style.letterSpacing = StyleLength.op_Implicit(2f);
			val2.Add((VisualElement)(object)val3);
			val2.Add((VisualElement)(object)UiControls.Button("X", onClose));
			val.Add(val2);
			Drag(val2, val);
			body = new UiScroll(title);
			Pad(body.Content, 14f, 18f);
			val.Add(body.Root);
			Label val4 = Label(footer ?? "", 18f, TextDim);
			((VisualElement)val4).style.alignSelf = StyleEnum<Align>.op_Implicit((Align)2);
			((VisualElement)val4).style.marginTop = StyleLength.op_Implicit(4f);
			((VisualElement)val4).style.marginBottom = StyleLength.op_Implicit(8f);
			((VisualElement)val4).style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add((VisualElement)(object)val4);
			return val;
		}

		private static void Drag(VisualElement handle, VisualElement target)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			bool dragging = false;
			Vector2 start = Vector2.zero;
			Vector2 origin = Vector2.zero;
			((CallbackEventHandler)handle).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_006b: Unknown result type (might be due to invalid IL or missing references)
				if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0 && !(((EventBase)e).target is Button))
				{
					dragging = true;
					start = Vector2.op_Implicit(((PointerEventBase<PointerDownEvent>)(object)e).position);
					Rect layout = target.layout;
					float x = ((Rect)(ref layout)).x;
					layout = target.layout;
					origin = new Vector2(x, ((Rect)(ref layout)).y);
					target.style.right = StyleLength.op_Implicit((StyleKeyword)2);
					PointerCaptureHelper.CapturePointer((IEventHandler)(object)handle, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId);
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)handle).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent e)
			{
				//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_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
				if (dragging)
				{
					Vector2 val = origin + Vector2.op_Implicit(((PointerEventBase<PointerMoveEvent>)(object)e).position) - start;
					VisualElement parent = target.parent;
					float num = ((parent != null) ? (parent.resolvedStyle.width - 80f) : 2000f);
					float num2 = ((parent != null) ? (parent.resolvedStyle.height - 40f) : 2000f);
					target.style.left = StyleLength.op_Implicit(Mathf.Clamp(val.x, 0f - target.resolvedStyle.width + 80f, num));
					target.style.top = StyleLength.op_Implicit(Mathf.Clamp(val.y, 0f, num2));
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)handle).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate(PointerUpEvent e)
			{
				if (dragging)
				{
					dragging = false;
					PointerCaptureHelper.ReleasePointer((IEventHandler)(object)handle, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId);
					UiLog.Verbose("UiKit: window moved to " + target.resolvedStyle.left.ToString("0") + ", " + target.resolvedStyle.top.ToString("0"));
				}
			}, (TrickleDown)0);
		}
	}
	internal static class UiLog
	{
		public static Action<string> VerboseSink = delegate(string s)
		{
			Debug.Log((object)("[Kydl UI] " + s));
		};

		public static Action<string> WarnSink = delegate(string s)
		{
			Debug.LogWarning((object)("[Kydl UI] " + s));
		};

		public static Action<string> ErrorSink = delegate(string s)
		{
			Debug.LogError((object)("[Kydl UI] " + s));
		};

		public static void Verbose(string s)
		{
			VerboseSink?.Invoke(s);
		}

		public static void Warn(string s)
		{
			WarnSink?.Invoke(s);
		}

		public static void Error(string s)
		{
			ErrorSink?.Invoke(s);
		}
	}
	internal sealed class UiScroll
	{
		private const float BarWidth = 8f;

		private const float WheelStep = 60f;

		private const float MinThumb = 28f;

		internal readonly VisualElement Root;

		internal readonly VisualElement Content;

		private readonly VisualElement _viewport;

		private readonly VisualElement _bar;

		private readonly VisualElement _thumb;

		private readonly string _name;

		private float _offset;

		private float ContentH
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Rect layout = Content.layout;
				return ((Rect)(ref layout)).height;
			}
		}

		private float ViewH
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Rect layout = _viewport.layout;
				return ((Rect)(ref layout)).height;
			}
		}

		private float Max
		{
			get
			{
				float num = ContentH - ViewH;
				if (!(num > 0f) || float.IsNaN(num))
				{
					return 0f;
				}
				return num;
			}
		}

		internal UiScroll(string name)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0036: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0195: Expected O, but got Unknown
			//IL_01a5: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			_name = name;
			Root = new VisualElement
			{
				name = "kydl-scroll",
				userData = this
			};
			Root.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			Root.style.flexGrow = StyleFloat.op_Implicit(1f);
			Root.style.flexShrink = StyleFloat.op_Implicit(1f);
			Root.style.minHeight = StyleLength.op_Implicit(40f);
			_viewport = new VisualElement();
			_viewport.style.flexGrow = StyleFloat.op_Implicit(1f);
			_viewport.style.flexShrink = StyleFloat.op_Implicit(1f);
			_viewport.style.overflow = StyleEnum<Overflow>.op_Implicit((Overflow)1);
			Root.Add(_viewport);
			Content = new VisualElement();
			Content.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			Content.style.left = StyleLength.op_Implicit(0f);
			Content.style.right = StyleLength.op_Implicit(0f);
			Content.style.top = StyleLength.op_Implicit(0f);
			Content.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0);
			_viewport.Add(Content);
			_bar = new VisualElement();
			_bar.style.width = StyleLength.op_Implicit(8f);
			_bar.style.flexShrink = StyleFloat.op_Implicit(0f);
			_bar.style.marginLeft = StyleLength.op_Implicit(4f);
			_bar.style.marginRight = StyleLength.op_Implicit(4f);
			_bar.style.marginTop = StyleLength.op_Implicit(6f);
			_bar.style.marginBottom = StyleLength.op_Implicit(6f);
			_bar.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			UiKit.Radius(_bar, 4f);
			_thumb = new VisualElement();
			_thumb.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			_thumb.style.left = StyleLength.op_Implicit(0f);
			_thumb.style.right = StyleLength.op_Implicit(0f);
			_thumb.style.top = StyleLength.op_Implicit(0f);
			_thumb.style.height = StyleLength.op_Implicit(28f);
			_thumb.style.backgroundColor = StyleColor.op_Implicit(UiKit.GoldDim);
			UiKit.Radius(_thumb, 4f);
			((CallbackEventHandler)_thumb).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				_thumb.style.backgroundColor = StyleColor.op_Implicit(UiKit.Gold);
			}, (TrickleDown)0);
			((CallbackEventHandler)_thumb).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				_thumb.style.backgroundColor = StyleColor.op_Implicit(UiKit.GoldDim);
			}, (TrickleDown)0);
			_bar.Add(_thumb);
			Root.Add(_bar);
			((CallbackEventHandler)_viewport).RegisterCallback<GeometryChangedEvent>((EventCallback<GeometryChangedEvent>)delegate
			{
				Clamp();
			}, (TrickleDown)0);
			((CallbackEventHandler)Content).RegisterCallback<GeometryChangedEvent>((EventCallback<GeometryChangedEvent>)delegate
			{
				Clamp();
			}, (TrickleDown)0);
			((CallbackEventHandler)Root).RegisterCallback<WheelEvent>((EventCallback<WheelEvent>)delegate(WheelEvent e)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				ScrollBy(e.delta.y * 60f / 3f);
				((EventBase)e).StopPropagation();
			}, (TrickleDown)0);
			Drag();
		}

		internal void ScrollBy(float d)
		{
			_offset += d;
			Clamp();
		}

		internal void ScrollTo(float y)
		{
			_offset = y;
			Clamp();
		}

		private void Clamp()
		{
			//IL_0030: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			float max = Max;
			_offset = Mathf.Clamp(_offset, 0f, max);
			Content.style.top = StyleLength.op_Implicit(0f - _offset);
			bool flag = max > 0.5f;
			_bar.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!flag));
			if (flag)
			{
				Rect layout = _bar.layout;
				float height = ((Rect)(ref layout)).height;
				if (!float.IsNaN(height) && !(height <= 0f))
				{
					float num = Mathf.Max(28f, height * ViewH / Mathf.Max(1f, ContentH));
					_thumb.style.height = StyleLength.op_Implicit(num);
					_thumb.style.top = StyleLength.op_Implicit((height - num) * (_offset / max));
				}
			}
		}

		private void Drag()
		{
			bool dragging = false;
			float startY = 0f;
			float startOffset = 0f;
			((CallbackEventHandler)_thumb).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0)
				{
					dragging = true;
					startY = ((PointerEventBase<PointerDownEvent>)(object)e).position.y;
					startOffset = _offset;
					PointerCaptureHelper.CapturePointer((IEventHandler)(object)_thumb, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId);
					((EventBase)e).StopPropagation();
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)_thumb).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent e)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				if (dragging)
				{
					Rect layout = _bar.layout;
					float height = ((Rect)(ref layout)).height;
					layout = _thumb.layout;
					float num = height - ((Rect)(ref layout)).height;
					if (num > 1f)
					{
						ScrollTo(startOffset + (((PointerEventBase<PointerMoveEvent>)(object)e).position.y - startY) / num * Max);
					}
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)_thumb).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate(PointerUpEvent e)
			{
				if (dragging)
				{
					dragging = false;
					PointerCaptureHelper.ReleasePointer((IEventHandler)(object)_thumb, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId);
					UiLog.Verbose("UiScroll '" + _name + "': dragged to " + _offset.ToString("0") + " of " + Max.ToString("0"));
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)_bar).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				if ((object)((EventBase)e).target == _bar)
				{
					UiScroll uiScroll = this;
					float y = ((PointerEventBase<PointerDownEvent>)(object)e).localPosition.y;
					Rect layout = _thumb.layout;
					uiScroll.ScrollBy((y < ((Rect)(ref layout)).y) ? ((0f - ViewH) * 0.9f) : (ViewH * 0.9f));
				}
			}, (TrickleDown)0);
		}
	}
}
namespace Kydl.Common
{
	internal static class ConfigTools
	{
		private static readonly Regex Section = new Regex("^\\s*\\[(?<s>[^\\]]+)\\]\\s*$");

		private static readonly Regex CommaNumber = new Regex("^\\s*(?<k>[^=#]+?)\\s*=\\s*(?<v>-?\\d+,\\d+)\\s*$");

		internal static string[] Capture(ConfigFile c)
		{
			try
			{
				return (c != null && !string.IsNullOrEmpty(c.ConfigFilePath) && File.Exists(c.ConfigFilePath)) ? File.ReadAllLines(c.ConfigFilePath) : null;
			}
			catch (IOException ex)
			{
				ModLog.Warn("Config comma check skipped (file not readable): " + ex.Message);
				return null;
			}
			catch (UnauthorizedAccessException ex2)
			{
				ModLog.Warn("Config comma check skipped (no access): " + ex2.Message);
				return null;
			}
		}

		internal static int ApplyCommaFix(ConfigFile c, string[] lines)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			int num = 0;
			if (c == null || lines == null)
			{
				ModLog.Verbose("ConfigTools: no saved config lines, comma check not needed");
				return num;
			}
			string text = "";
			foreach (string input in lines)
			{
				Match match = Section.Match(input);
				if (match.Success)
				{
					text = match.Groups["s"].Value.Trim();
					continue;
				}
				Match match2 = CommaNumber.Match(input);
				if (!match2.Success)
				{
					continue;
				}
				ConfigDefinition val = new ConfigDefinition(text, match2.Groups["k"].Value);
				if (c.ContainsKey(val))
				{
					ConfigEntryBase val2 = c[val];
					if ((!(val2.SettingType != typeof(float)) || !(val2.SettingType != typeof(double))) && double.TryParse(match2.Groups["v"].Value.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
					{
						object boxedValue = val2.BoxedValue;
						val2.BoxedValue = ((val2.SettingType == typeof(float)) ? ((object)(float)result) : ((object)result));
						num++;
						ModLog.Warn("Config [" + text + "] " + val.Key + " = " + match2.Groups["v"].Value + ": a comma is read as the decimal point -> " + Convert.ToString(val2.BoxedValue, CultureInfo.InvariantCulture) + " (BepInEx had read " + Convert.ToString(boxedValue, CultureInfo.InvariantCulture) + "). Please use a dot in the config file.");
					}
				}
			}
			ModLog.Verbose("ConfigTools: comma check done, " + num + " value(s) corrected");
			return num;
		}

		internal static int DropRemoved(ConfigFile c)
		{
			int num = 0;
			try
			{
				PropertyInfo property = typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				IDictionary dictionary = ((property != null) ? (property.GetValue(c, null) as IDictionary) : null);
				if (dictionary != null)
				{
					num = dictionary.Count;
					dictionary.Clear();
				}
				else
				{
					ModLog.Verbose("ConfigTools: OrphanedEntries not found in this BepInEx, old entries stay in the file");
				}
				c.Save();
				if (num > 0)
				{
					ModLog.Info("Config: " + num + " entry(ies) that are no longer settings were removed from the file");
				}
			}
			catch (TargetInvocationException ex)
			{
				ModLog.Warn("Config: old entries could not be removed: " + ex.InnerException?.Message);
			}
			catch (IOException ex2)
			{
				ModLog.Warn("Config: the file could not be saved after removing old entries: " + ex2.Message);
			}
			return num;
		}
	}
	internal sealed class ConfigReloader : IDisposable
	{
		private readonly ConfigFile _config;

		private FileSystemWatcher _watcher;

		private volatile bool _changed;

		private float _reloadAt;

		private int _retries;

		internal bool Watching
		{
			get
			{
				if (_watcher != null)
				{
					return _watcher.EnableRaisingEvents;
				}
				return false;
			}
		}

		internal ConfigReloader(ConfigFile config)
		{
			_config = config;
			try
			{
				string configFilePath = config.ConfigFilePath;
				_watcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath))
				{
					NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite)
				};
				_watcher.Changed += delegate
				{
					_changed = true;
				};
				_watcher.Created += delegate
				{
					_changed = true;
				};
				_watcher.Renamed += delegate
				{
					_changed = true;
				};
				_watcher.EnableRaisingEvents = true;
				ModLog.Verbose("ConfigReloader: watching " + configFilePath);
			}
			catch (ArgumentException ex)
			{
				ModLog.Warn("Config file watcher not started (bad path; edits to the .cfg need a restart): " + ex.Message);
			}
			catch (IOException ex2)
			{
				ModLog.Warn("Config file watcher not started (edits to the .cfg need a restart): " + ex2.Message);
			}
		}

		internal bool Tick()
		{
			if (_changed)
			{
				_changed = false;
				_reloadAt = Time.realtimeSinceStartup + 0.5f;
				_retries = 0;
			}
			if (_reloadAt <= 0f || Time.realtimeSinceStartup < _reloadAt)
			{
				return false;
			}
			_reloadAt = 0f;
			try
			{
				if (!File.Exists(_config.ConfigFilePath))
				{
					ModLog.Verbose("ConfigReloader: the file is gone, nothing reloaded");
					return false;
				}
				_config.Reload();
				ModLog.Info("Config file changed on disk - reloaded.");
				return true;
			}
			catch (IOException ex)
			{
				if (++_retries <= 3)
				{
					_reloadAt = Time.realtimeSinceStartup + 1f;
					ModLog.Verbose("ConfigReloader: file locked, retry " + _retries + ": " + ex.Message);
				}
				else
				{
					ModLog.Warn("Config reload failed: " + ex.Message);
				}
				return false;
			}
		}

		public void Dispose()
		{
			if (_watcher != null)
			{
				_watcher.EnableRaisingEvents = false;
				_watcher.Dispose();
				_watcher = null;
				ModLog.Verbose("ConfigReloader: stopped");
			}
		}
	}
	internal static class KyCategory
	{
		internal const string Name = "KY-Items";

		internal static string For(string piece)
		{
			ModLog.Verbose("KyCategory: piece '" + piece + "' goes into the build menu category 'KY-Items'");
			return "KY-Items";
		}
	}
	internal static class Loc
	{
		private static Dictionary<string, string> _en = new Dictionary<string, string>();

		internal static bool Register(Dictionary<string, string> en)
		{
			_en = en ?? new Dictionary<string, string>();
			LocalizationManager.Instance.GetLocalization().AddJsonFile("English", ToJson(_en));
			ModLog.Verbose("Loc: " + _en.Count + " English text(s) registered");
			return _en.Count == (en?.Count ?? 0);
		}

		internal static bool Register(Dictionary<string, string> en, Dictionary<string, string> de)
		{
			if (de != null)
			{
				ModLog.Verbose("Loc: a German table (" + de.Count + " text(s)) was passed and is ignored - English only");
			}
			return Register(en);
		}

		private static string ToJson(Dictionary<string, string> d)
		{
			StringBuilder stringBuilder = new StringBuilder("{");
			bool flag = true;
			foreach (KeyValuePair<string, string> item in d)
			{
				if (!flag)
				{
					stringBuilder.Append(',');
				}
				flag = false;
				stringBuilder.Append('"').Append(Esc(item.Key)).Append("\":\"")
					.Append(Esc(item.Value))
					.Append('"');
			}
			return stringBuilder.Append('}').ToString();
		}

		private static string Esc(string s)
		{
			return (s ?? "").Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\n", "\\n");
		}

		internal static string Token(string key)
		{
			return "$" + key;
		}

		internal static string T(string key, params string[] args)
		{
			Localization instance = Localization.instance;
			string value;
			if (instance != null)
			{
				value = instance.Localize("$" + key);
			}
			else if (!_en.TryGetValue(key, out value))
			{
				value = key;
			}
			if (args != null)
			{
				for (int i = 0; i < args.Length; i++)
				{
					value = value.Replace("{" + i + "}", args[i]);
				}
			}
			return value;
		}
	}
	internal static class ModLog
	{
		private const string TimeFormat = "yyyy-MM-dd HH:mm:ss.fff";

		private const string LineFormat = "{0} - {1}";

		private const string SessionText = "NEW LOG SESSION STARTS HERE";

		private static ManualLogSource _source;

		private static bool _sessionStarted;

		private static string _modName = typeof(ModLog).Assembly.GetName().Name;

		private static Func<bool> _debugOn;

		private const double RepeatWindowSeconds = 2.5;

		private const int MaxRemembered = 4000;

		private static readonly Dictionary<string, double> LastWritten = new Dictionary<string, double>();

		private static readonly Stopwatch Clock = Stopwatch.StartNew();

		private static readonly object RepeatLock = new object();

		private static ManualLogSource Source
		{
			get
			{
				if (_source == null)
				{
					_source = Logger.CreateLogSource(_modName);
				}
				return _source;
			}
		}

		public static bool DebugOn
		{
			get
			{
				try
				{
					return _debugOn != null && _debugOn();
				}
				catch (NullReferenceException)
				{
					return false;
				}
			}
		}

		public static bool Init(ManualLogSource source, string modName, Func<bool> debugOn)
		{
			_source = source;
			if (!string.IsNullOrEmpty(modName))
			{
				_modName = modName;
			}
			_debugOn = debugOn;
			StartSession();
			return _source == source;
		}

		private static void StartSession()
		{
			if (!_sessionStarted)
			{
				_sessionStarted = true;
				Info("NEW LOG SESSION STARTS HERE");
			}
		}

		private static string Line(string message)
		{
			return string.Format(CultureInfo.InvariantCulture, "{0} - {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), message ?? "(null)");
		}

		public static void Info(string message)
		{
			Write((LogLevel)16, message);
		}

		public static void Warn(string message)
		{
			Write((LogLevel)4, message);
		}

		public static void Error(string message)
		{
			Write((LogLevel)2, message);
		}

		public static void Verbose(string message)
		{
			if (DebugOn)
			{
				Info(message);
			}
		}

		public static void VerboseWarn(string message)
		{
			if (DebugOn)
			{
				Warn(message);
			}
		}

		public static bool Check(string what, double actual, double expected, double tolerance, string unit)
		{
			double num = actual - expected;
			bool flag = !double.IsNaN(actual) && Math.Abs(num) <= Math.Abs(tolerance);
			string text = what + " = " + Num(actual) + Unit(unit) + " (expected " + Num(expected) + " +- " + Num(Math.Abs(tolerance)) + Unit(unit) + ")";
			if (flag)
			{
				Verbose("CHECK ok: " + text);
			}
			else
			{
				Warn("CHECK OFF: " + text + ", off by " + Num(num) + Unit(unit));
			}
			return flag;
		}

		public static bool CheckRange(string what, double actual, double min, double max, string unit)
		{
			bool flag = !double.IsNaN(actual) && actual >= min && actual <= max;
			string text = what + " = " + Num(actual) + Unit(unit) + " (expected " + Num(min) + " .. " + Num(max) + Unit(unit) + ")";
			if (flag)
			{
				Verbose("CHECK ok: " + text);
			}
			else
			{
				Warn("CHECK OFF: " + text);
			}
			return flag;
		}

		private static string Num(double v)
		{
			return v.ToString("0.###", CultureInfo.InvariantCulture);
		}

		private static string Unit(string unit)
		{
			if (!string.IsNullOrEmpty(unit))
			{
				return " " + unit;
			}
			return "";
		}

		internal static bool ResetRepeats()
		{
			lock (RepeatLock)
			{
				LastWritten.Clear();
				return LastWritten.Count == 0;
			}
		}

		internal static bool IsRepeat(LogLevel level, string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected I4, but got Unknown
			if ((int)level == 2)
			{
				return false;
			}
			string key = (int)level + "|" + message;
			double totalSeconds = Clock.Elapsed.TotalSeconds;
			lock (RepeatLock)
			{
				int num;
				if (LastWritten.TryGetValue(key, out var value))
				{
					num = ((totalSeconds - value < 2.5) ? 1 : 0);
					if (num != 0)
					{
						goto IL_0071;
					}
				}
				else
				{
					num = 0;
				}
				LastWritten[key] = totalSeconds;
				goto IL_0071;
				IL_0071:
				if (LastWritten.Count > 4000)
				{
					DropOld(totalSeconds);
				}
				return (byte)num != 0;
			}
		}

		private static void DropOld(double now)
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, double> item in LastWritten)
			{
				if (now - item.Value >= 2.5)
				{
					list.Add(item.Key);
				}
			}
			foreach (string item2 in list)
			{
				LastWritten.Remove(item2);
			}
		}

		private static void Write(LogLevel level, string message)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!IsRepeat(level, message))
				{
					Source.Log(level, (object)Line(message));
				}
			}
			catch (ObjectDisposedException)
			{
			}
			catch (Exception)
			{
			}
		}
	}
	internal sealed class Tunable<T>
	{
		private readonly T _fixed;

		private T _value;

		public string Name { get; }

		public string Section { get; }

		public string Description { get; }

		public T Default => _fixed;

		public bool External { get; private set; }

		public object Min { get; }

		public object Max { get; }

		public T Value
		{
			get
			{
				return _value;
			}
			set
			{
				T val = Clamp(value);
				if (!object.Equals(val, value))
				{
					string[] obj = new string[12]
					{
						"Tunable: ", Section, ".", Name, " = ", null, null, null, null, null,
						null, null
					};
					T val2 = value;
					obj[5] = val2?.ToString();
					obj[6] = " is outside ";
					obj[7] = Min?.ToString();
					obj[8] = "..";
					obj[9] = Max?.ToString();
					obj[10] = ", using ";
					val2 = val;
					obj[11] = val2?.ToString();
					ModLog.Verbose(string.Concat(obj));
				}
				value = val;
				if (!object.Equals(_value, value))
				{
					T value2 = _value;
					_value = value;
					string[] obj2 = new string[11]
					{
						"Tunable: ", Section, ".", Name, " = ", null, null, null, null, null,
						null
					};
					T val2 = value;
					obj2[5] = val2?.ToString();
					obj2[6] = " (was ";
					val2 = value2;
					obj2[7] = val2?.ToString();
					obj2[8] = ", fixed value ";
					obj2[9] = _fixed?.ToString();
					obj2[10] = ")";
					ModLog.Verbose(string.Concat(obj2));
					this.SettingChanged?.Invoke(this, EventArgs.Empty);
				}
			}
		}

		public event EventHandler SettingChanged;

		public Tunable(string section, string name, T value, string description = "")
		{
			Section = section;
			Name = name;
			Description = description ?? "";
			_fixed = value;
			_value = value;
		}

		public Tunable(string section, string name, T value, T min, T max, string description = "")
			: this(section, name, value, description)
		{
			if (Comparer<T>.Default.Compare(min, max) > 0)
			{
				T val = min;
				min = max;
				max = val;
			}
			Min = min;
			Max = max;
			_fixed = Clamp(value);
			_value = _fixed;
		}

		private T Clamp(T v)
		{
			if (Min == null || Max == null)
			{
				return v;
			}
			Comparer<T> comparer = Comparer<T>.Default;
			if (comparer.Compare(v, (T)Min) < 0)
			{
				return (T)Min;
			}
			if (comparer.Compare(v, (T)Max) > 0)
			{
				return (T)Max;
			}
			return v;
		}

		public Tunable<T> SetFromConfigOf(string mod)
		{
			External = true;
			ModLog.Verbose("Tunable: " + Section + "." + Name + " is set from the config of " + mod);
			return this;
		}

		public bool Reset()
		{
			Value = _fixed;
			return object.Equals(_value, _fixed);
		}

		public override string ToString()
		{
			string[] obj = new string[5] { Section, ".", Name, " = ", null };
			T value = _value;
			obj[4] = value?.ToString();
			return string.Concat(obj);
		}
	}
	internal static class UiInputLock
	{
		private static readonly HashSet<string> Holders = new HashSet<string>();

		private static Harmony _harmony;

		private static int _patched;

		internal static int Count => Holders.Count;

		internal static bool Install(string modGuid)
		{
			//IL_013e: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			if (_harmony != null)
			{
				return _patched > 0;
			}
			try
			{
				_harmony = new Harmony(modGuid + ".uilock");
				MethodInfo methodInfo = AccessTools.Method(typeof(TextInput), "IsVisible", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(UiInputLock), "VisiblePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					_patched++;
				}
				else
				{
					UiLog.Warn("UiInputLock: TextInput.IsVisible not found - the player can still move while a menu is open");
				}
				foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(ZInput)))
				{
					if (!(declaredMethod.Name != "GetMouseScrollWheel") && !(declaredMethod.ReturnType != typeof(float)) && !declaredMethod.IsGenericMethod)
					{
						_harmony.Patch((MethodBase)declaredMethod, (HarmonyMethod)null, new HarmonyMethod(typeof(UiInputLock), "ScrollPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						_patched++;
					}
				}
				UiLog.Verbose("UiInputLock: " + _patched + " game method(s) patched (TextInput.IsVisible + ZInput.GetMouseScrollWheel)");
			}
			catch (HarmonyException ex)
			{
				HarmonyException ex2 = ex;
				UiLog.Warn("UiInputLock: patching failed: " + ((Exception)(object)ex2).Message);
			}
			catch (Exception ex3)
			{
				UiLog.Warn("UiInputLock: install failed: " + ex3.Message);
			}
			return _patched > 0;
		}

		internal static bool Hold(string who)
		{
			Holders.Add(who);
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			UiLog.Verbose("UiInputLock: held by '" + who + "' (" + Holders.Count + " holder(s))");
			return Holders.Contains(who);
		}

		internal static bool Release(string who)
		{
			int count = Holders.Count;
			Holders.Remove(who);
			if (count != Holders.Count)
			{
				UiLog.Verbose("UiInputLock: released by '" + who + "' (" + Holders.Count + " holder(s) left)");
			}
			return !Holders.Contains(who);
		}

		private static void VisiblePostfix(ref bool __result)
		{
			if (Holders.Count > 0)
			{
				__result = true;
			}
		}

		private static void ScrollPostfix(re