Decompiled source of ClientUI v0.3.9

XPRising.ClientUI.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using Bloodstone.Hooks;
using ClientUI.Hooks;
using ClientUI.UI;
using ClientUI.UI.Panel;
using ClientUI.UI.Util;
using ClientUI.UniverseLib.UI;
using ClientUI.UniverseLib.UI.Models;
using ClientUI.UniverseLib.UI.ObjectPool;
using ClientUI.UniverseLib.UI.Panels;
using ClientUI.UniverseLib.UI.Widgets;
using ClientUI.UniverseLib.UI.Widgets.ScrollView;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using TMPro;
using Unity.Entities;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using XPShared;
using XPShared.BloodstoneExtensions;
using XPShared.Transport;
using XPShared.Transport.Messages;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("XPRising.ClientUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.9.0")]
[assembly: AssemblyInformationalVersion("0.3.9+1.Branch.main.Sha.0b23557f1154d098dffabfc4cf7d77266c87cc7a.0b23557f1154d098dffabfc4cf7d77266c87cc7a")]
[assembly: AssemblyProduct("XPRising.ClientUI")]
[assembly: AssemblyTitle("XPRising.ClientUI")]
[assembly: AssemblyVersion("0.3.9.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ClientUI
{
	[BepInPlugin("XPRising.ClientUI", "XPRising.ClientUI", "0.3.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private static ManualLogSource _logger;

		internal static bool LoadUI;

		private static FrameTimer _uiInitialisedTimer;

		private static FrameTimer _connectUiTimer;

		private static Harmony _harmonyBootPatch;

		private static Harmony _harmonyCanvasPatch;

		private static Harmony _harmonyMenuPatch;

		internal static Harmony _harmonyVersionStringPatch;

		private const string TurboColourMap = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402";

		private float _testValue;

		private FrameTimer _testTimer1;

		private FrameTimer _testTimer2;

		private bool _buttonEnabled;

		internal static Plugin Instance { get; private set; }

		public override void Load()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			Instance = this;
			_logger = ((BasePlugin)this).Log;
			if (VWorld.IsServer)
			{
				Log((LogLevel)4, "Plugin XPRising.ClientUI is a client plugin only. Not continuing to load on server.");
				return;
			}
			UIManager.Initialize();
			_harmonyBootPatch = Harmony.CreateAndPatchAll(typeof(GameManangerPatch), (string)null);
			_harmonyMenuPatch = Harmony.CreateAndPatchAll(typeof(EscapeMenuPatch), (string)null);
			_harmonyCanvasPatch = Harmony.CreateAndPatchAll(typeof(UICanvasSystemPatch), (string)null);
			_harmonyVersionStringPatch = Harmony.CreateAndPatchAll(typeof(VersionStringPatch), (string)null);
			_connectUiTimer = new FrameTimer();
			_connectUiTimer.Initialise((Action)delegate
			{
				Utils.SendClientInitialisation();
				Log((LogLevel)16, "Sending client initialisation...");
			}, TimeSpan.FromSeconds(1.0), false);
			MessageUtils.RegisterType<ProgressSerialisedMessage>((Action<ProgressSerialisedMessage>)delegate(ProgressSerialisedMessage message)
			{
				if (UIManager.ContentPanel != null)
				{
					UIManager.ContentPanel.ChangeProgress(message);
				}
				if (LoadUI && UIManager.ContentPanel != null)
				{
					UIManager.SetActive(active: true);
					LoadUI = false;
				}
			});
			MessageUtils.RegisterType<ActionSerialisedMessage>((Action<ActionSerialisedMessage>)delegate(ActionSerialisedMessage message)
			{
				if (UIManager.ContentPanel != null)
				{
					UIManager.ContentPanel.SetButton(message);
				}
				if (LoadUI && UIManager.ContentPanel != null)
				{
					UIManager.SetActive(active: true);
					LoadUI = false;
				}
			});
			MessageUtils.RegisterType<NotificationMessage>((Action<NotificationMessage>)delegate(NotificationMessage message)
			{
				if (UIManager.ContentPanel != null)
				{
					UIManager.ContentPanel.AddMessage(message);
				}
				if (LoadUI && UIManager.ContentPanel != null)
				{
					UIManager.SetActive(active: true);
					LoadUI = false;
				}
			});
			MessageUtils.RegisterType<ConnectedMessage>((Action<ConnectedMessage>)delegate
			{
				_connectUiTimer.Stop();
				Log((LogLevel)16, "Client initialisation successful");
			});
			Log((LogLevel)16, "Plugin XPRising.ClientUI is loaded!");
		}

		public override bool Unload()
		{
			_harmonyBootPatch.UnpatchSelf();
			_harmonyCanvasPatch.UnpatchSelf();
			_harmonyMenuPatch.UnpatchSelf();
			_harmonyVersionStringPatch.UnpatchSelf();
			return true;
		}

		public static void GameDataOnInitialize(World world)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (VWorld.IsClient)
			{
				_harmonyBootPatch.UnpatchSelf();
				_uiInitialisedTimer = new FrameTimer();
				_uiInitialisedTimer.Initialise((Action)delegate
				{
					UIManager.OnInitialized();
					_uiInitialisedTimer.Stop();
					Log((LogLevel)32, "UI Manager initialised");
					_connectUiTimer.Start();
				}, TimeSpan.FromSeconds(5.0), true).Start();
			}
		}

		private static void GameDataOnDestroy()
		{
		}

		public static void Log(LogLevel level, string message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource logger = _logger;
			bool flag = default(bool);
			BepInExLogInterpolatedStringHandler val = new BepInExLogInterpolatedStringHandler(2, 2, level, ref flag);
			if (flag)
			{
				val.AppendFormatted<DateTime>(DateTime.Now, "u");
				val.AppendLiteral(": ");
				val.AppendFormatted<string>(message);
			}
			logger.Log(level, val);
		}

		private void AddTestUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//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_0030: 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_0046: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0083: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Expected O, but got Unknown
			UIManager.OnInitialized();
			_testTimer1 = new FrameTimer();
			_testTimer2 = new FrameTimer();
			UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage
			{
				Group = "Test1",
				Label = "TEST BAR",
				Colour = "red",
				Active = (ActiveState)2,
				Change = "",
				Header = "1X",
				ProgressPercentage = 0.45f,
				Tooltip = "Test Progress"
			});
			UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage
			{
				Group = "Test",
				Label = "TEST BAR 2",
				Colour = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402",
				Active = (ActiveState)2,
				Change = "",
				Header = "00",
				ProgressPercentage = 0f,
				Tooltip = "Test Progress 2",
				Flash = false
			});
			UIManager.ContentPanel.SetButton(new ActionSerialisedMessage
			{
				Group = "Test",
				ID = "TestButton2",
				Label = "Test disabled",
				Enabled = _buttonEnabled
			}, delegate
			{
			});
			UIManager.ContentPanel.SetButton(new ActionSerialisedMessage
			{
				Group = "Test",
				ID = "TestButton",
				Label = "Test colour and enable",
				Colour = "blue",
				Enabled = true
			}, delegate
			{
				//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_0024: 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_004c: Expected O, but got Unknown
				_buttonEnabled = !_buttonEnabled;
				UIManager.ContentPanel.SetButton(new ActionSerialisedMessage
				{
					Group = "Test",
					ID = "TestButton2",
					Label = "Test disabled",
					Enabled = _buttonEnabled
				});
			});
			_testTimer1.Initialise((Action)delegate
			{
				//IL_0052: 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_0062: 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_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Expected O, but got Unknown
				float num = 0.0125f;
				bool flash = _testValue % 1f > (_testValue + num) % 1f && _testValue % 2f < 1f;
				_testValue = (_testValue + num) % 100f;
				UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage
				{
					Group = "Test",
					Label = "TEST BAR 2",
					Colour = "@#30123B@#445ACD@#3E9BFE@#18D6CB@#46F783@#A2FC3C@#E1DC37@#FDA531@#EF5A11@#C42502@#7A0402",
					Active = (ActiveState)2,
					Change = "whoop",
					Header = $"{(int)_testValue:D2}",
					ProgressPercentage = _testValue % 1f,
					Tooltip = "Test Progress 2",
					Flash = flash
				});
			}, TimeSpan.FromMilliseconds(50.0), false).Start();
			_testTimer2.Initialise((Action)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: 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_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				UIManager.ContentPanel.AddMessage(new NotificationMessage
				{
					ID = "testMessage",
					Message = $"{DateTime.Now:u}: This is a test message",
					Severity = (LogLevel)4
				});
			}, TimeSpan.FromSeconds(3.0), false).Start();
			UIManager.ContentPanel.ChangeProgress(new ProgressSerialisedMessage
			{
				Group = "Test",
				Label = "TEST BAR 3",
				Colour = "white",
				Active = (ActiveState)2,
				Change = "",
				Header = "Xx",
				ProgressPercentage = 0.65f,
				Tooltip = "Test text colour"
			});
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "XPRising.ClientUI";

		public const string PLUGIN_NAME = "XPRising.ClientUI";

		public const string PLUGIN_VERSION = "0.3.9";
	}
}
namespace ClientUI.UniverseLib.UI
{
	public static class CoroutineUtility
	{
		private static ConcurrentBag<IEnumerator> _nextFrameRoutines = new ConcurrentBag<IEnumerator>();

		private static ConcurrentBag<IEnumerator> _thisFrameRoutines = new ConcurrentBag<IEnumerator>();

		public static void StartCoroutine(IEnumerator coroutine)
		{
			_nextFrameRoutines.Add(coroutine);
		}

		public static void TickRoutines()
		{
			ConcurrentBag<IEnumerator> nextFrameRoutines = _nextFrameRoutines;
			ConcurrentBag<IEnumerator> thisFrameRoutines = _thisFrameRoutines;
			_thisFrameRoutines = nextFrameRoutines;
			_nextFrameRoutines = thisFrameRoutines;
			while (!_thisFrameRoutines.IsEmpty)
			{
				if (_thisFrameRoutines.TryTake(out var result) && result.MoveNext())
				{
					_nextFrameRoutines.Add(result);
				}
			}
		}
	}
	public static class Il2CppExtensions
	{
		public static void AddListener(this UnityEvent action, Action listener)
		{
			action.AddListener(UnityAction.op_Implicit(listener));
		}

		public static void AddListener<T>(this UnityEvent<T> action, Action<T> listener)
		{
			action.AddListener(UnityAction<T>.op_Implicit(listener));
		}

		public static void RemoveListener(this UnityEvent action, Action listener)
		{
			action.RemoveListener(UnityAction.op_Implicit(listener));
		}

		public static void RemoveListener<T>(this UnityEvent<T> action, Action<T> listener)
		{
			action.RemoveListener(UnityAction<T>.op_Implicit(listener));
		}

		public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value)
		{
			group.childControlHeight = value;
		}

		public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value)
		{
			group.childControlWidth = value;
		}
	}
	public class UIBase
	{
		internal static readonly int TOP_SORTORDER = 30000;

		public string ID { get; }

		public GameObject RootObject { get; }

		public RectTransform RootRect { get; }

		public Canvas Canvas { get; }

		public CanvasScaler Scaler { get; }

		public Action UpdateMethod { get; }

		public PanelManager Panels { get; }

		public bool Enabled
		{
			get
			{
				if (Object.op_Implicit((Object)(object)RootObject))
				{
					return RootObject.activeSelf;
				}
				return false;
			}
			set
			{
				UniversalUI.SetUIActive(ID, value);
			}
		}

		public UIBase(string id, Action updateMethod)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(id))
			{
				throw new ArgumentException("Cannot register a UI with a null or empty id!");
			}
			if (UniversalUI.registeredUIs.ContainsKey(id))
			{
				throw new ArgumentException("A UI with the id '" + id + "' is already registered!");
			}
			ID = id;
			UpdateMethod = updateMethod;
			RootObject = UIFactory.CreateUIObject(id + "_Root", UniversalUI.CanvasRoot);
			RootObject.SetActive(false);
			RootRect = RootObject.GetComponent<RectTransform>();
			Canvas = RootObject.AddComponent<Canvas>();
			Canvas.renderMode = (RenderMode)0;
			Canvas.referencePixelsPerUnit = 100f;
			Canvas.sortingOrder = TOP_SORTORDER;
			Canvas.overrideSorting = true;
			Scaler = RootObject.AddComponent<CanvasScaler>();
			Scaler.referenceResolution = UniversalUI.CanvasDimensions;
			Scaler.uiScaleMode = (ScaleMode)1;
			Scaler.screenMatchMode = (ScreenMatchMode)0;
			RootObject.AddComponent<GraphicRaycaster>();
			RectTransform component = RootObject.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.pivot = new Vector2(0.5f, 0.5f);
			Panels = CreatePanelManager();
			RootObject.SetActive(true);
			UniversalUI.registeredUIs.Add(id, this);
			UniversalUI.uiBases.Add(this);
		}

		protected virtual PanelManager CreatePanelManager()
		{
			return new PanelManager(this);
		}

		public void SetOnTop()
		{
			RootObject.transform.SetAsLastSibling();
			foreach (UIBase uiBasis in UniversalUI.uiBases)
			{
				int num = UniversalUI.CanvasRoot.transform.childCount - ((Transform)uiBasis.RootRect).GetSiblingIndex();
				uiBasis.Canvas.sortingOrder = TOP_SORTORDER - num;
			}
			UniversalUI.uiBases.Sort((UIBase a, UIBase b) => b.RootObject.transform.GetSiblingIndex().CompareTo(a.RootObject.transform.GetSiblingIndex()));
		}

		internal void Update()
		{
			try
			{
				Panels.Update();
				UpdateMethod?.Invoke();
			}
			catch (Exception value)
			{
				Plugin.Log((LogLevel)4, $"Exception invoking update method for {ID}: {value}");
			}
		}
	}
	public static class UIFactory
	{
		internal static Vector2 largeElementSize = new Vector2(100f, 30f);

		internal static Vector2 smallElementSize = new Vector2(25f, 25f);

		internal static Vector2 outlineDistance = new Vector2(2f, 2f);

		public static GameObject PlayerHUDCanvas { get; set; }

		public static TMP_FontAsset Font { get; set; }

		public static Material FontMaterial { get; set; }

		public static GameObject CreateUIObject(string name, GameObject parent, Vector2 sizeDelta = default(Vector2))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = 5,
				hideFlags = (HideFlags)61
			};
			if (Object.op_Implicit((Object)(object)parent))
			{
				val.transform.SetParent(parent.transform, false);
			}
			val.AddComponent<RectTransform>().sizeDelta = sizeDelta;
			return val;
		}

		internal static void SetDefaultTextValues(TextMeshProUGUI text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)text).color = Colour.DefaultText;
			((TMP_Text)text).font = Font;
			((TMP_Text)text).fontSize = 14f;
		}

		internal static void SetDefaultSelectableValues(Selectable selectable)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			Navigation navigation = selectable.navigation;
			navigation.mode = (Mode)4;
			selectable.navigation = navigation;
			ColorBlock val = default(ColorBlock);
			((ColorBlock)(ref val)).normalColor = new Color(0.2f, 0.2f, 0.2f);
			((ColorBlock)(ref val)).highlightedColor = new Color(0.3f, 0.3f, 0.3f);
			((ColorBlock)(ref val)).pressedColor = new Color(0.15f, 0.15f, 0.15f);
			((ColorBlock)(ref val)).colorMultiplier = 1f;
			ColorBlock colors = val;
			selectable.colors = colors;
		}

		public static LayoutElement SetLayoutElement(GameObject gameObject, int? minWidth = null, int? minHeight = null, int? flexibleWidth = null, int? flexibleHeight = null, int? preferredWidth = null, int? preferredHeight = null, bool? ignoreLayout = null)
		{
			LayoutElement val = gameObject.GetComponent<LayoutElement>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = gameObject.AddComponent<LayoutElement>();
			}
			if (minWidth.HasValue)
			{
				val.minWidth = minWidth.Value;
			}
			if (minHeight.HasValue)
			{
				val.minHeight = minHeight.Value;
			}
			if (flexibleWidth.HasValue)
			{
				val.flexibleWidth = flexibleWidth.Value;
			}
			if (flexibleHeight.HasValue)
			{
				val.flexibleHeight = flexibleHeight.Value;
			}
			if (preferredWidth.HasValue)
			{
				val.preferredWidth = preferredWidth.Value;
			}
			if (preferredHeight.HasValue)
			{
				val.preferredHeight = preferredHeight.Value;
			}
			if (ignoreLayout.HasValue)
			{
				val.ignoreLayout = ignoreLayout.Value;
			}
			return val;
		}

		public static T SetLayoutGroup<T>(GameObject gameObject, bool? forceWidth = null, bool? forceHeight = null, bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null, int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup
		{
			T val = gameObject.GetComponent<T>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = gameObject.AddComponent<T>();
			}
			return SetLayoutGroup(val, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop, padBottom, padLeft, padRight, childAlignment);
		}

		public static T SetLayoutGroup<T>(T group, bool? forceWidth = null, bool? forceHeight = null, bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null, int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (forceWidth.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).childForceExpandWidth = forceWidth.Value;
			}
			if (forceHeight.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).childForceExpandHeight = forceHeight.Value;
			}
			if (childControlWidth.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).childControlWidth = childControlWidth.Value;
			}
			if (childControlHeight.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).childControlHeight = childControlHeight.Value;
			}
			if (spacing.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).spacing = spacing.Value;
			}
			if (padTop.HasValue)
			{
				((LayoutGroup)(object)group).padding.top = padTop.Value;
			}
			if (padBottom.HasValue)
			{
				((LayoutGroup)(object)group).padding.bottom = padBottom.Value;
			}
			if (padLeft.HasValue)
			{
				((LayoutGroup)(object)group).padding.left = padLeft.Value;
			}
			if (padRight.HasValue)
			{
				((LayoutGroup)(object)group).padding.right = padRight.Value;
			}
			if (childAlignment.HasValue)
			{
				((LayoutGroup)(object)group).childAlignment = childAlignment.Value;
			}
			return group;
		}

		public static GameObject CreatePanel(string name, GameObject parent, out GameObject contentHolder, Color? bgColor = null)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(val, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = Vector2.zero;
			contentHolder = CreateUIObject("Content", val);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(contentHolder, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			Image obj = contentHolder.AddComponent<Image>();
			obj.type = (Type)3;
			((Graphic)obj).color = (Color)(((??)bgColor) ?? Colour.DarkBackground);
			Outline obj2 = contentHolder.AddComponent<Outline>();
			((Shadow)obj2).effectColor = Colour.DarkBackground;
			((Shadow)obj2).effectDistance = outlineDistance;
			return val;
		}

		public static GameObject CreateVerticalGroup(GameObject parent, string name, bool forceWidth, bool forceHeight, bool childControlWidth, bool childControlHeight, int spacing = 0, Vector4 padding = default(Vector4), Color? bgColor = null, TextAnchor? childAlignment = null)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(obj, (bool?)forceWidth, (bool?)forceHeight, (bool?)childControlWidth, (bool?)childControlHeight, (int?)spacing, (int?)(int)padding.x, (int?)(int)padding.y, (int?)(int)padding.z, (int?)(int)padding.w, childAlignment);
			((Graphic)obj.AddComponent<Image>()).color = (Color)(((??)bgColor) ?? Colour.PanelBackground);
			return obj;
		}

		public static GameObject CreateHorizontalGroup(GameObject parent, string name, bool forceExpandWidth, bool forceExpandHeight, bool childControlWidth, bool childControlHeight, int spacing = 0, Vector4 padding = default(Vector4), Color? bgColor = null, TextAnchor? childAlignment = null)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(obj, (bool?)forceExpandWidth, (bool?)forceExpandHeight, (bool?)childControlWidth, (bool?)childControlHeight, (int?)spacing, (int?)(int)padding.x, (int?)(int)padding.y, (int?)(int)padding.z, (int?)(int)padding.w, childAlignment);
			((Graphic)obj.AddComponent<Image>()).color = (Color)(((??)bgColor) ?? Colour.PanelBackground);
			return obj;
		}

		public static GameObject CreateGridGroup(GameObject parent, string name, Vector2 cellSize, Vector2 spacing, Color? bgColor = null)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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)
			GameObject obj = CreateUIObject(name, parent);
			GridLayoutGroup obj2 = obj.AddComponent<GridLayoutGroup>();
			((LayoutGroup)obj2).childAlignment = (TextAnchor)0;
			obj2.cellSize = cellSize;
			obj2.spacing = spacing;
			((Graphic)obj.AddComponent<Image>()).color = (Color)(((??)bgColor) ?? Colour.PanelBackground);
			return obj;
		}

		public static TextMeshProUGUI CreateLabel(GameObject parent, string name, string defaultText, TextAlignmentOptions alignment = 514, Color? color = null, int fontSize = 14)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = CreateUIObject(name, parent).AddComponent<TextMeshProUGUI>();
			((Graphic)val).color = (Color)(((??)color) ?? Colour.DefaultText);
			((TMP_Text)val).font = Font;
			((TMP_Text)val).text = defaultText;
			((TMP_Text)val).alignment = alignment;
			((TMP_Text)val).fontSize = fontSize;
			try
			{
				((TMP_Text)val).outlineWidth = 0.15f;
				((TMP_Text)val).outlineColor = Color32.op_Implicit(Color.black);
			}
			catch (Exception)
			{
			}
			return val;
		}

		public static ButtonRef CreateButton(GameObject parent, string name, string text, Color? normalColor = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Color val = (Color)(((??)normalColor) ?? Colour.SliderFill);
			ColorBlock val2 = default(ColorBlock);
			((ColorBlock)(ref val2)).normalColor = val;
			((ColorBlock)(ref val2)).highlightedColor = val * 1.2f;
			((ColorBlock)(ref val2)).selectedColor = val * 1.1f;
			((ColorBlock)(ref val2)).pressedColor = val * 0.7f;
			((ColorBlock)(ref val2)).disabledColor = val * 0.4f;
			((ColorBlock)(ref val2)).colorMultiplier = 1f;
			ColorBlock colors = val2;
			val2 = default(ColorBlock);
			ButtonRef buttonRef = CreateButton(parent, name, text, val2);
			((Selectable)buttonRef.Component).colors = colors;
			return buttonRef;
		}

		public static ButtonRef CreateButton(GameObject parent, string name, string text, ColorBlock colors)
		{
			//IL_0002: 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_001b: 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_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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			GameObject val2 = CreateUIObject("Text", val);
			Image obj = val.AddComponent<Image>();
			obj.type = (Type)1;
			((Graphic)obj).color = Color.white;
			Outline obj2 = val.AddComponent<Outline>();
			((Shadow)obj2).effectColor = Colour.DarkBackground;
			((Shadow)obj2).effectDistance = outlineDistance;
			Button obj3 = val.AddComponent<Button>();
			SetDefaultSelectableValues((Selectable)(object)obj3);
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((Selectable)obj3).colors = colors;
			TextMeshProUGUI obj4 = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj4).text = text;
			SetDefaultTextValues(obj4);
			((TMP_Text)obj4).alignment = (TextAlignmentOptions)514;
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			SetButtonDeselectListener(obj3);
			return new ButtonRef(obj3);
		}

		internal static void SetButtonDeselectListener(Button button)
		{
			((UnityEvent)(object)button.onClick).AddListener(delegate
			{
				((Selectable)button).OnDeselect((BaseEventData)null);
			});
		}

		public static GameObject CreateSlider(GameObject parent, string name, out Slider slider)
		{
			//IL_0002: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0072: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			GameObject obj = CreateUIObject("Background", val);
			GameObject val2 = CreateUIObject("Fill Area", val);
			GameObject val3 = CreateUIObject("Fill", val2);
			GameObject val4 = CreateUIObject("Handle Slide Area", val);
			GameObject val5 = CreateUIObject("Handle", val4);
			Image obj2 = obj.AddComponent<Image>();
			obj2.type = (Type)1;
			((Graphic)obj2).color = Colour.PanelBackground;
			RectTransform component = obj.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.25f);
			component.anchorMax = new Vector2(1f, 0.75f);
			component.sizeDelta = new Vector2(0f, 0f);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0.25f);
			component2.anchorMax = new Vector2(1f, 0.75f);
			component2.anchoredPosition = new Vector2(-5f, 0f);
			component2.sizeDelta = new Vector2(-20f, 0f);
			Image obj3 = val3.AddComponent<Image>();
			obj3.type = (Type)1;
			((Graphic)obj3).color = Colour.SliderFill;
			val3.GetComponent<RectTransform>().sizeDelta = new Vector2(10f, 0f);
			RectTransform component3 = val4.GetComponent<RectTransform>();
			component3.sizeDelta = new Vector2(-20f, 0f);
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = Colour.SliderHandle;
			val5.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 0f);
			slider = val.AddComponent<Slider>();
			slider.fillRect = val3.GetComponent<RectTransform>();
			slider.handleRect = val5.GetComponent<RectTransform>();
			((Selectable)slider).targetGraphic = (Graphic)(object)val6;
			slider.direction = (Direction)0;
			ColorBlock val7 = default(ColorBlock);
			((ColorBlock)(ref val7)).normalColor = new Color(0.4f, 0.4f, 0.4f);
			((ColorBlock)(ref val7)).highlightedColor = new Color(0.55f, 0.55f, 0.55f);
			((ColorBlock)(ref val7)).pressedColor = new Color(0.3f, 0.3f, 0.3f);
			((ColorBlock)(ref val7)).colorMultiplier = 1f;
			ColorBlock colors = val7;
			((Selectable)slider).colors = colors;
			return val;
		}

		public static GameObject CreateScrollbar(GameObject parent, string name, out Scrollbar scrollbar)
		{
			//IL_0002: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			GameObject val2 = CreateUIObject("Sliding Area", val);
			GameObject obj = CreateUIObject("Handle", val2);
			Image obj2 = val.AddComponent<Image>();
			obj2.type = (Type)1;
			((Graphic)obj2).color = Colour.DarkBackground;
			Image val3 = obj.AddComponent<Image>();
			val3.type = (Type)1;
			((Graphic)val3).color = Colour.SliderHandle;
			RectTransform component = val2.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(-20f, -20f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			RectTransform component2 = obj.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(20f, 20f);
			scrollbar = val.AddComponent<Scrollbar>();
			scrollbar.handleRect = component2;
			((Selectable)scrollbar).targetGraphic = (Graphic)(object)val3;
			SetDefaultSelectableValues((Selectable)(object)scrollbar);
			return val;
		}

		public static GameObject CreateToggle(GameObject parent, string name, out Toggle toggle, out TextMeshProUGUI text, Color bgColor = default(Color), int checkWidth = 20, int checkHeight = 20)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)(TextAnchor)3);
			toggle = val.AddComponent<Toggle>();
			toggle.isOn = true;
			SetDefaultSelectableValues((Selectable)(object)toggle);
			Toggle t2 = toggle;
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener<bool>(delegate
			{
				((Selectable)t2).OnDeselect((BaseEventData)null);
			});
			GameObject val2 = CreateUIObject("Background", val);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = ((bgColor == default(Color)) ? Colour.DarkBackground : bgColor);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val2, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)0, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null);
			SetLayoutElement(val2, checkWidth, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
			Image val4 = CreateUIObject("Checkmark", val2).AddComponent<Image>();
			((Graphic)val4).color = Colour.CheckMark;
			GameObject val5 = CreateUIObject("Label", val);
			text = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)text).text = "";
			((TMP_Text)text).alignment = (TextAlignmentOptions)4097;
			SetDefaultTextValues(text);
			SetLayoutElement(val5, 0, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
			toggle.graphic = (Graphic)(object)val4;
			((Selectable)toggle).targetGraphic = (Graphic)(object)val3;
			return val;
		}

		public static InputFieldRef CreateInputField(GameObject parent, string name, string placeHolderText)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			Image val2 = val.AddComponent<Image>();
			val2.type = (Type)1;
			((Graphic)val2).color = Colour.DarkBackground;
			TMP_InputField obj = val.AddComponent<TMP_InputField>();
			Navigation navigation = ((Selectable)obj).navigation;
			navigation.mode = (Mode)0;
			((Selectable)obj).navigation = navigation;
			obj.lineType = (LineType)0;
			((Selectable)obj).interactable = true;
			((Selectable)obj).transition = (Transition)1;
			((Selectable)obj).targetGraphic = (Graphic)(object)val2;
			ColorBlock val3 = default(ColorBlock);
			((ColorBlock)(ref val3)).normalColor = new Color(1f, 1f, 1f, 1f);
			((ColorBlock)(ref val3)).highlightedColor = new Color(0.95f, 0.95f, 0.95f, 1f);
			((ColorBlock)(ref val3)).pressedColor = new Color(0.78f, 0.78f, 0.78f, 1f);
			((ColorBlock)(ref val3)).colorMultiplier = 1f;
			ColorBlock colors = val3;
			((Selectable)obj).colors = colors;
			GameObject val4 = CreateUIObject("TextArea", val);
			val4.AddComponent<RectMask2D>();
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			GameObject obj2 = CreateUIObject("Placeholder", val4);
			TextMeshProUGUI val5 = obj2.AddComponent<TextMeshProUGUI>();
			SetDefaultTextValues(val5);
			((TMP_Text)val5).text = placeHolderText ?? "...";
			((Graphic)val5).color = Colour.PlaceHolderText;
			((TMP_Text)val5).enableWordWrapping = true;
			((TMP_Text)val5).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val5).fontSize = 14f;
			RectTransform component2 = obj2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			obj.placeholder = (Graphic)(object)val5;
			GameObject obj3 = CreateUIObject("Text", val4);
			TextMeshProUGUI val6 = obj3.AddComponent<TextMeshProUGUI>();
			SetDefaultTextValues(val6);
			((TMP_Text)val6).text = "";
			((Graphic)val6).color = Colour.DefaultText;
			((TMP_Text)val6).enableWordWrapping = true;
			((TMP_Text)val6).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val6).fontSize = 14f;
			RectTransform component3 = obj3.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			obj.textComponent = (TMP_Text)(object)val6;
			obj.characterLimit = 16000;
			return new InputFieldRef(obj);
		}

		public static GameObject CreateDropdown(GameObject parent, string name, out TMP_Dropdown dropdown, string defaultItemText, int itemFontSize, Action<int> onValueChanged, string[] defaultOptions = null)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0654: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Expected O, but got Unknown
			GameObject val = CreateUIObject(name, parent, largeElementSize);
			GameObject obj = CreateUIObject("Label", val);
			GameObject obj2 = CreateUIObject("Arrow", val);
			GameObject val2 = CreateUIObject("Template", val);
			GameObject val3 = CreateUIObject("Viewport", val2);
			GameObject val4 = CreateUIObject("Content", val3);
			GameObject val5 = CreateUIObject("Item", val4);
			GameObject val6 = CreateUIObject("Item Background", val5);
			CreateUIObject("Item Checkmark", val5);
			GameObject val7 = CreateUIObject("Item Label", val5);
			Scrollbar scrollbar;
			GameObject obj3 = CreateScrollbar(val2, "DropdownScroll", out scrollbar);
			scrollbar.SetDirection((Direction)2, true);
			ColorBlock val8 = default(ColorBlock);
			((ColorBlock)(ref val8)).normalColor = new Color(0.45f, 0.45f, 0.45f);
			((ColorBlock)(ref val8)).highlightedColor = new Color(0.6f, 0.6f, 0.6f);
			((ColorBlock)(ref val8)).pressedColor = new Color(0.4f, 0.4f, 0.4f);
			((ColorBlock)(ref val8)).colorMultiplier = 1f;
			ColorBlock colors = val8;
			((Selectable)scrollbar).colors = colors;
			RectTransform component = obj3.GetComponent<RectTransform>();
			component.anchorMin = Vector2.right;
			component.anchorMax = Vector2.one;
			component.pivot = Vector2.one;
			component.sizeDelta = new Vector2(component.sizeDelta.x, 0f);
			TextMeshProUGUI val9 = val7.AddComponent<TextMeshProUGUI>();
			SetDefaultTextValues(val9);
			((TMP_Text)val9).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val9).text = defaultItemText;
			((TMP_Text)val9).fontSize = itemFontSize;
			TextMeshProUGUI obj4 = obj2.AddComponent<TextMeshProUGUI>();
			SetDefaultTextValues(obj4);
			((TMP_Text)obj4).text = "▼";
			RectTransform component2 = obj2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(1f, 0.5f);
			component2.anchorMax = new Vector2(1f, 0.5f);
			component2.sizeDelta = new Vector2(20f, 20f);
			component2.anchoredPosition = new Vector2(-15f, 0f);
			Image val10 = val6.AddComponent<Image>();
			((Graphic)val10).color = Colour.SliderFill;
			Toggle itemToggle = val5.AddComponent<Toggle>();
			((Selectable)itemToggle).targetGraphic = (Graphic)(object)val10;
			itemToggle.isOn = true;
			val8 = default(ColorBlock);
			((ColorBlock)(ref val8)).normalColor = new Color(0.35f, 0.35f, 0.35f, 1f);
			((ColorBlock)(ref val8)).highlightedColor = new Color(0.25f, 0.55f, 0.25f, 1f);
			((ColorBlock)(ref val8)).colorMultiplier = 1f;
			ColorBlock colors2 = val8;
			((Selectable)itemToggle).colors = colors2;
			((UnityEvent<bool>)(object)itemToggle.onValueChanged).AddListener<bool>(delegate
			{
				((Selectable)itemToggle).OnDeselect((BaseEventData)null);
			});
			Image obj5 = val2.AddComponent<Image>();
			obj5.type = (Type)1;
			((Graphic)obj5).color = Color.black;
			ScrollRect obj6 = val2.AddComponent<ScrollRect>();
			obj6.scrollSensitivity = 35f;
			obj6.content = val4.GetComponent<RectTransform>();
			obj6.viewport = val3.GetComponent<RectTransform>();
			obj6.horizontal = false;
			obj6.movementType = (MovementType)2;
			obj6.verticalScrollbar = scrollbar;
			obj6.verticalScrollbarVisibility = (ScrollbarVisibility)2;
			obj6.verticalScrollbarSpacing = -3f;
			val3.AddComponent<Mask>().showMaskGraphic = false;
			val3.AddComponent<Image>().type = (Type)1;
			TextMeshProUGUI val11 = obj.AddComponent<TextMeshProUGUI>();
			SetDefaultTextValues(val11);
			((TMP_Text)val11).alignment = (TextAlignmentOptions)4097;
			Image val12 = val.AddComponent<Image>();
			((Graphic)val12).color = Colour.DarkBackground;
			val12.type = (Type)1;
			dropdown = val.AddComponent<TMP_Dropdown>();
			((Selectable)dropdown).targetGraphic = (Graphic)(object)val12;
			dropdown.template = val2.GetComponent<RectTransform>();
			dropdown.captionText = (TMP_Text)(object)val11;
			dropdown.itemText = (TMP_Text)(object)val9;
			dropdown.RefreshShownValue();
			RectTransform component3 = obj.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = new Vector2(10f, 2f);
			component3.offsetMax = new Vector2(-28f, -2f);
			RectTransform component4 = val2.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = new Vector2(1f, 0f);
			component4.pivot = new Vector2(0.5f, 1f);
			component4.anchoredPosition = new Vector2(0f, 2f);
			component4.sizeDelta = new Vector2(0f, 150f);
			RectTransform component5 = val3.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0f, 0f);
			component5.anchorMax = new Vector2(1f, 1f);
			component5.sizeDelta = new Vector2(-18f, 0f);
			component5.pivot = new Vector2(0f, 1f);
			RectTransform component6 = val4.GetComponent<RectTransform>();
			component6.anchorMin = new Vector2(0f, 1f);
			component6.anchorMax = new Vector2(1f, 1f);
			component6.pivot = new Vector2(0.5f, 1f);
			component6.anchoredPosition = new Vector2(0f, 0f);
			component6.sizeDelta = new Vector2(0f, 28f);
			RectTransform component7 = val5.GetComponent<RectTransform>();
			component7.anchorMin = new Vector2(0f, 0.5f);
			component7.anchorMax = new Vector2(1f, 0.5f);
			component7.sizeDelta = new Vector2(0f, 25f);
			RectTransform component8 = val6.GetComponent<RectTransform>();
			component8.anchorMin = Vector2.zero;
			component8.anchorMax = Vector2.one;
			component8.sizeDelta = Vector2.zero;
			RectTransform component9 = val7.GetComponent<RectTransform>();
			component9.anchorMin = Vector2.zero;
			component9.anchorMax = Vector2.one;
			component9.offsetMin = new Vector2(20f, 1f);
			component9.offsetMax = new Vector2(-10f, -2f);
			val2.SetActive(false);
			if (onValueChanged != null)
			{
				((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener(UnityAction<int>.op_Implicit(onValueChanged));
			}
			if (defaultOptions != null)
			{
				foreach (string text in defaultOptions)
				{
					dropdown.options.Add(new OptionData(text));
				}
			}
			return val;
		}

		public static ScrollPool<T> CreateScrollPool<T>(GameObject parent, string name, out GameObject uiRoot, out GameObject content, Color? bgColor = null) where T : ICell
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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_01e1: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: 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_03a2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent, new Vector2(1f, 1f));
			((Graphic)val.AddComponent<Image>()).color = (Color)(((??)bgColor) ?? Colour.DarkBackground);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			int? flexibleHeight = 9999;
			int? flexibleWidth = 9999;
			SetLayoutElement(val, null, null, flexibleWidth, flexibleHeight);
			GameObject val2 = CreateUIObject("Viewport", val);
			flexibleWidth = 9999;
			flexibleHeight = 9999;
			SetLayoutElement(val2, null, null, flexibleWidth, flexibleHeight);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.pivot = new Vector2(0f, 1f);
			component.sizeDelta = new Vector2(0f, 0f);
			component.offsetMax = new Vector2(-10f, 0f);
			val2.AddComponent<RectMask2D>();
			((Graphic)val2.AddComponent<Image>()).color = Colour.ViewportBackground;
			val2.AddComponent<Mask>();
			content = CreateUIObject("Content", val2);
			RectTransform component2 = content.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.pivot = new Vector2(0.5f, 1f);
			component2.sizeDelta = new Vector2(0f, 0f);
			component2.offsetMax = new Vector2(0f, 0f);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(content, (bool?)true, (bool?)false, (bool?)true, (bool?)true, (int?)0, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)(TextAnchor)1);
			content.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			ScrollRect obj = val.AddComponent<ScrollRect>();
			obj.movementType = (MovementType)2;
			obj.inertia = true;
			obj.elasticity = 0.125f;
			obj.scrollSensitivity = 25f;
			obj.horizontal = false;
			obj.vertical = true;
			obj.viewport = component;
			obj.content = component2;
			GameObject obj2 = CreateVerticalGroup(val, "SliderContainer", forceWidth: false, forceHeight: false, childControlWidth: true, childControlHeight: true);
			int? minWidth = 25;
			flexibleHeight = 0;
			flexibleWidth = 9999;
			SetLayoutElement(obj2, minWidth, null, flexibleHeight, flexibleWidth);
			obj2.AddComponent<Mask>().showMaskGraphic = false;
			CreateSliderScrollbar(obj2, out var slider);
			ColorBlock val3 = default(ColorBlock);
			((ColorBlock)(ref val3)).disabledColor = new Color(0.1f, 0.1f, 0.1f);
			((ColorBlock)(ref val3)).colorMultiplier = 1f;
			ColorBlock colors = val3;
			((Selectable)slider).colors = colors;
			uiRoot = val;
			return new ScrollPool<T>(obj);
		}

		public static GameObject CreateSliderScrollbar(GameObject parent, out Slider slider)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_004a: 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_0060: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("SliderScrollbar", parent, smallElementSize);
			val.AddComponent<Mask>().showMaskGraphic = false;
			((Graphic)val.AddComponent<Image>()).color = Colour.DarkBackground;
			GameObject obj = CreateUIObject("Background", val);
			GameObject val2 = CreateUIObject("Handle Slide Area", val);
			GameObject val3 = CreateUIObject("Handle", val2);
			Image obj2 = obj.AddComponent<Image>();
			obj2.type = (Type)1;
			((Graphic)obj2).color = Colour.DarkBackground;
			obj.AddComponent<Mask>();
			RectTransform component = obj.GetComponent<RectTransform>();
			component.pivot = new Vector2(0f, 1f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			component.offsetMax = new Vector2(0f, 0f);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.op_Implicit(Vector3.zero);
			component2.anchorMax = Vector2.op_Implicit(Vector3.one);
			component2.pivot = Vector2.op_Implicit(new Vector3(0.5f, 0.5f));
			Image val4 = val3.AddComponent<Image>();
			((Graphic)val4).color = Colour.SliderHandle;
			val3.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
			int? minWidth = 21;
			int? flexibleWidth = 0;
			SetLayoutElement(val3, minWidth, null, flexibleWidth);
			LayoutElement obj3 = val.AddComponent<LayoutElement>();
			obj3.minWidth = 25f;
			obj3.flexibleWidth = 0f;
			obj3.minHeight = 30f;
			obj3.flexibleHeight = 9999f;
			slider = val.AddComponent<Slider>();
			slider.handleRect = val3.GetComponent<RectTransform>();
			((Selectable)slider).targetGraphic = (Graphic)(object)val4;
			slider.direction = (Direction)3;
			int? minWidth2 = 25;
			flexibleWidth = 0;
			int? flexibleHeight = 9999;
			SetLayoutElement(val, minWidth2, null, flexibleWidth, flexibleHeight);
			Slider obj4 = slider;
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = new Color(0.4f, 0.4f, 0.4f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.5f, 0.5f, 0.5f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.3f, 0.3f, 0.3f);
			((ColorBlock)(ref colors)).disabledColor = new Color(0.5f, 0.5f, 0.5f);
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((Selectable)obj4).colors = colors;
			return val;
		}

		public static GameObject CreateScrollView(GameObject parent, string name, out GameObject content, out AutoSliderScrollbar autoScrollbar, Color color = default(Color))
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_00b8: 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_00ce: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			Image obj = val.AddComponent<Image>();
			obj.type = (Type)3;
			((Graphic)obj).color = ((color == default(Color)) ? Colour.DarkBackground : color);
			int? flexibleHeight = 9999;
			int? flexibleWidth = 9999;
			SetLayoutElement(val, null, null, flexibleWidth, flexibleHeight);
			GameObject val2 = CreateUIObject("Viewport", val);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.pivot = new Vector2(0f, 1f);
			component2.offsetMax = new Vector2(-28f, 0f);
			((Graphic)val2.AddComponent<Image>()).color = Colour.ViewportBackground;
			val2.AddComponent<Mask>().showMaskGraphic = false;
			content = CreateUIObject("Content", val2);
			GameObject gameObject = content;
			bool? forceWidth = true;
			bool? forceHeight = false;
			bool? childControlWidth = true;
			bool? childControlHeight = true;
			TextAnchor? childAlignment = (TextAnchor)0;
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(gameObject, forceWidth, forceHeight, childControlWidth, childControlHeight, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, childAlignment);
			GameObject gameObject2 = content;
			flexibleWidth = 9999;
			SetLayoutElement(gameObject2, null, null, null, flexibleWidth);
			RectTransform component3 = content.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.pivot = new Vector2(0f, 1f);
			content.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			GameObject val3 = CreateUIObject("AutoSliderScrollbar", val);
			RectTransform component4 = val3.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(1f, 0f);
			component4.anchorMax = Vector2.one;
			component4.offsetMin = new Vector2(-25f, 0f);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(val3, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			((Graphic)val3.AddComponent<Image>()).color = Colour.PanelBackground;
			val3.AddComponent<Mask>().showMaskGraphic = false;
			Scrollbar scrollbar;
			GameObject val4 = CreateScrollbar(val3, "HiddenScrollviewScroller", out scrollbar);
			scrollbar.SetDirection((Direction)2, true);
			for (int i = 0; i < val4.transform.childCount; i++)
			{
				((Component)val4.transform.GetChild(i)).gameObject.SetActive(false);
			}
			CreateSliderScrollbar(val3, out var slider);
			autoScrollbar = new AutoSliderScrollbar(scrollbar, slider, component3, component2);
			ScrollRect obj2 = val.AddComponent<ScrollRect>();
			obj2.horizontal = false;
			obj2.vertical = true;
			obj2.verticalScrollbar = scrollbar;
			obj2.movementType = (MovementType)2;
			obj2.scrollSensitivity = 35f;
			obj2.horizontalScrollbarVisibility = (ScrollbarVisibility)2;
			obj2.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			obj2.viewport = component2;
			obj2.content = component3;
			return val;
		}
	}
	public static class UniversalUI
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static GameFrameUpdateEventHandler <0>__Update;
		}

		internal static readonly Dictionary<string, UIBase> registeredUIs = new Dictionary<string, UIBase>();

		internal static readonly List<UIBase> uiBases = new List<UIBase>();

		public const int MAX_INPUTFIELD_CHARS = 16000;

		public static Vector2 CanvasDimensions = new Vector2(1920f, 1080f);

		public static bool Initializing { get; internal set; } = true;


		public static bool AnyUIShowing => registeredUIs.Any((KeyValuePair<string, UIBase> it) => it.Value.Enabled);

		public static GameObject CanvasRoot { get; private set; }

		public static GameObject PoolHolder { get; private set; }

		public static Font DefaultFont { get; private set; }

		public static UIBase RegisterUI(string id, Action updateMethod)
		{
			return new UIBase(id, updateMethod);
		}

		public static T RegisterUI<T>(string id, Action updateMethod) where T : UIBase
		{
			return (T)Activator.CreateInstance(typeof(T), id, updateMethod);
		}

		public static void SetUIActive(string id, bool active)
		{
			if (registeredUIs.TryGetValue(id, out var value))
			{
				value.RootObject.SetActive(active);
				if (active)
				{
					value.SetOnTop();
				}
				else if (value != PanelManager.resizeCursorUIBase)
				{
					PanelManager.ForceEndResize();
				}
				return;
			}
			throw new ArgumentException("There is no UI registered with the id '" + id + "'");
		}

		internal static void Init()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//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_0053: Expected O, but got Unknown
			CreateRootCanvas();
			PoolHolder = new GameObject("PoolHolder");
			PoolHolder.transform.parent = CanvasRoot.transform;
			PoolHolder.SetActive(false);
			object obj = <>O.<0>__Update;
			if (obj == null)
			{
				GameFrameUpdateEventHandler val = Update;
				<>O.<0>__Update = val;
				obj = (object)val;
			}
			GameFrame.OnUpdate += (GameFrameUpdateEventHandler)obj;
			Initializing = false;
		}

		internal static void Update()
		{
			if (Initializing)
			{
				return;
			}
			CoroutineUtility.TickRoutines();
			if (!AnyUIShowing || !Object.op_Implicit((Object)(object)CanvasRoot))
			{
				return;
			}
			InputManager.Update();
			InputFieldRef.UpdateInstances();
			UIBehaviourModel.UpdateInstances();
			PanelManager.focusHandledThisFrame = false;
			PanelManager.draggerHandledThisFrame = false;
			for (int i = 0; i < uiBases.Count; i++)
			{
				UIBase uIBase = uiBases[i];
				if (uIBase.Enabled)
				{
					uIBase.Update();
				}
			}
		}

		private static void CreateRootCanvas()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			CanvasRoot = new GameObject("UniverseLibCanvas");
			Object.DontDestroyOnLoad((Object)(object)CanvasRoot);
			GameObject canvasRoot = CanvasRoot;
			((Object)canvasRoot).hideFlags = (HideFlags)(((Object)canvasRoot).hideFlags | 0x3D);
			CanvasRoot.layer = 5;
			CanvasRoot.transform.position = new Vector3(0f, 0f, 1f);
			CanvasRoot.SetActive(false);
			CanvasRoot.SetActive(true);
		}
	}
}
namespace ClientUI.UniverseLib.UI.Widgets
{
	public class AutoSliderScrollbar : UIBehaviourModel
	{
		private float lastAnchorPosition;

		private float lastContentHeight;

		private float lastViewportHeight;

		private bool _refreshWanted;

		public override GameObject UIRoot
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Slider))
				{
					return ((Component)Slider).gameObject;
				}
				return null;
			}
		}

		public Slider Slider { get; }

		public Scrollbar Scrollbar { get; }

		public RectTransform ContentRect { get; }

		public RectTransform ViewportRect { get; }

		public AutoSliderScrollbar(Scrollbar scrollbar, Slider slider, RectTransform contentRect, RectTransform viewportRect)
		{
			Scrollbar = scrollbar;
			Slider = slider;
			ContentRect = contentRect;
			ViewportRect = viewportRect;
			((UnityEvent<float>)(object)Scrollbar.onValueChanged).AddListener<float>(OnScrollbarValueChanged);
			((UnityEvent<float>)(object)Slider.onValueChanged).AddListener<float>(OnSliderValueChanged);
			Slider.Set(0f, false);
			UpdateSliderHandle();
		}

		public override void Update()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (base.Enabled)
			{
				_refreshWanted = false;
				if (((Transform)ContentRect).localPosition.y != lastAnchorPosition)
				{
					lastAnchorPosition = ((Transform)ContentRect).localPosition.y;
					_refreshWanted = true;
				}
				Rect rect = ContentRect.rect;
				if (((Rect)(ref rect)).height != lastContentHeight)
				{
					rect = ContentRect.rect;
					lastContentHeight = ((Rect)(ref rect)).height;
					_refreshWanted = true;
				}
				rect = ViewportRect.rect;
				if (((Rect)(ref rect)).height != lastViewportHeight)
				{
					rect = ViewportRect.rect;
					lastViewportHeight = ((Rect)(ref rect)).height;
					_refreshWanted = true;
				}
				if (_refreshWanted)
				{
					UpdateSliderHandle();
				}
			}
		}

		public void UpdateSliderHandle()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ContentRect.rect;
			float height = ((Rect)(ref rect)).height;
			rect = ViewportRect.rect;
			float height2 = ((Rect)(ref rect)).height;
			if (height <= height2)
			{
				Slider.handleRect.SetSizeWithCurrentAnchors((Axis)1, 0f);
				Slider.value = 0f;
				((Selectable)Slider).interactable = false;
				return;
			}
			float val = height2 * Math.Min(1f, height2 / height);
			val = Math.Max(15f, val);
			RectTransform handleContainerRect = Slider.m_HandleContainerRect;
			handleContainerRect.offsetMax = new Vector2(handleContainerRect.offsetMax.x, 0f - val * 0.5f);
			handleContainerRect.offsetMin = new Vector2(handleContainerRect.offsetMin.x, val * 0.5f);
			Slider.handleRect.SetSizeWithCurrentAnchors((Axis)1, val);
			((Selectable)Slider).interactable = !Mathf.Approximately(val, height2);
			float value = 0f;
			if (height > 0f)
			{
				decimal num = (decimal)((Transform)ContentRect).localPosition.y;
				rect = ViewportRect.rect;
				value = (float)(num / (decimal)(height - ((Rect)(ref rect)).height));
			}
			Slider.value = value;
		}

		public void OnScrollbarValueChanged(float value)
		{
			value = 1f - value;
			if (Slider.value != value)
			{
				Slider.Set(value, false);
			}
		}

		public void OnSliderValueChanged(float value)
		{
			value = 1f - value;
			Scrollbar.value = value;
		}
	}
}
namespace ClientUI.UniverseLib.UI.Widgets.ScrollView
{
	public class DataHeightCache<T> where T : ICell
	{
		private readonly List<DataViewInfo> heightCache = new List<DataViewInfo>();

		private float totalHeight;

		private float? m_defaultHeight;

		private readonly List<int> rangeCache = new List<int>();

		private ScrollPool<T> ScrollPool { get; }

		public DataViewInfo this[int index]
		{
			get
			{
				return heightCache[index];
			}
			set
			{
				SetIndex(index, value);
			}
		}

		public int Count => heightCache.Count;

		public float TotalHeight => totalHeight;

		public float DefaultHeight
		{
			get
			{
				float? defaultHeight = m_defaultHeight;
				if (!defaultHeight.HasValue)
				{
					float? num = (m_defaultHeight = ScrollPool.PrototypeHeight);
					return num.Value;
				}
				return defaultHeight.GetValueOrDefault();
			}
		}

		public DataHeightCache(ScrollPool<T> scrollPool)
		{
			ScrollPool = scrollPool;
		}

		private int GetRangeCeilingOfPosition(float position)
		{
			return (int)Math.Ceiling((decimal)position / (decimal)DefaultHeight);
		}

		private int GetRangeFloorOfPosition(float position)
		{
			return (int)Math.Floor((decimal)position / (decimal)DefaultHeight);
		}

		public int GetFirstDataIndexAtPosition(float desiredHeight)
		{
			if (!heightCache.Any())
			{
				return 0;
			}
			int rangeFloorOfPosition = GetRangeFloorOfPosition(desiredHeight);
			if (rangeFloorOfPosition < 0)
			{
				return 0;
			}
			if (rangeFloorOfPosition >= rangeCache.Count)
			{
				return ScrollPool.DataSource.ItemCount - 1;
			}
			int num = rangeCache[rangeFloorOfPosition];
			DataViewInfo dataViewInfo = heightCache[num];
			int rangeCeilingOfPosition = GetRangeCeilingOfPosition(dataViewInfo.startPosition);
			int num2 = rangeCeilingOfPosition + dataViewInfo.normalizedSpread - 1;
			if (rangeFloorOfPosition < rangeCeilingOfPosition || rangeFloorOfPosition > num2)
			{
				RecalculateStartPositions(ScrollPool.DataSource.ItemCount - 1);
				rangeFloorOfPosition = GetRangeFloorOfPosition(desiredHeight);
				num = rangeCache[rangeFloorOfPosition];
			}
			return num;
		}

		private int GetRangeSpread(float startPosition, float height)
		{
			float num = startPosition % DefaultHeight;
			if (num != 0f)
			{
				height -= DefaultHeight - num;
			}
			return (int)Math.Ceiling((decimal)height / (decimal)DefaultHeight);
		}

		public void Add(float value)
		{
			value = Math.Max(DefaultHeight, value);
			int rangeSpread = GetRangeSpread(totalHeight, value);
			heightCache.Add(new DataViewInfo(heightCache.Count, value, totalHeight, rangeSpread));
			int item = heightCache.Count - 1;
			for (int i = 0; i < rangeSpread; i++)
			{
				rangeCache.Add(item);
			}
			totalHeight += value;
		}

		public void RemoveLast()
		{
			if (heightCache.Any())
			{
				totalHeight -= heightCache[heightCache.Count - 1];
				heightCache.RemoveAt(heightCache.Count - 1);
				int count = heightCache.Count;
				while (rangeCache.Count > 0 && rangeCache[rangeCache.Count - 1] == count)
				{
					rangeCache.RemoveAt(rangeCache.Count - 1);
				}
			}
		}

		public void SetIndex(int dataIndex, float height)
		{
			height = (float)Math.Floor(height);
			height = Math.Max(DefaultHeight, height);
			if (dataIndex >= ScrollPool.DataSource.ItemCount)
			{
				while (heightCache.Count > dataIndex)
				{
					RemoveLast();
				}
				return;
			}
			if (dataIndex >= heightCache.Count)
			{
				while (dataIndex > heightCache.Count)
				{
					Add(DefaultHeight);
				}
				Add(height);
				return;
			}
			DataViewInfo value = heightCache[dataIndex];
			if (value.height != height)
			{
				float num = height - value.height;
				totalHeight += num;
				value.height = height;
			}
			if (dataIndex > 0)
			{
				DataViewInfo dataViewInfo = heightCache[dataIndex - 1];
				value.startPosition = dataViewInfo.startPosition + dataViewInfo.height;
			}
			int rangeCeilingOfPosition = GetRangeCeilingOfPosition(value.startPosition);
			int rangeSpread = GetRangeSpread(value.startPosition, height);
			if (rangeCache[rangeCeilingOfPosition] != dataIndex)
			{
				RecalculateStartPositions(ScrollPool.DataSource.ItemCount - 1);
				rangeCeilingOfPosition = GetRangeCeilingOfPosition(value.startPosition);
				rangeSpread = GetRangeSpread(value.startPosition, height);
			}
			if (rangeCache[rangeCeilingOfPosition] != dataIndex)
			{
				throw new IndexOutOfRangeException($"Trying to set dataIndex {dataIndex} at rangeIndex {rangeCeilingOfPosition}, but cache is corrupt or invalid!");
			}
			if (rangeSpread != value.normalizedSpread)
			{
				int spreadDiff = rangeSpread - value.normalizedSpread;
				value.normalizedSpread = rangeSpread;
				UpdateSpread(dataIndex, rangeCeilingOfPosition, spreadDiff);
			}
			heightCache[dataIndex] = value;
		}

		private void UpdateSpread(int dataIndex, int rangeIndex, int spreadDiff)
		{
			if (spreadDiff > 0)
			{
				while (rangeCache[rangeIndex] == dataIndex && spreadDiff > 0)
				{
					rangeCache.Insert(rangeIndex, dataIndex);
					spreadDiff--;
				}
			}
			else
			{
				while (rangeCache[rangeIndex] == dataIndex && spreadDiff < 0)
				{
					rangeCache.RemoveAt(rangeIndex);
					spreadDiff++;
				}
			}
		}

		private void RecalculateStartPositions(int toIndex)
		{
			if (heightCache.Count <= 1)
			{
				return;
			}
			rangeCache.Clear();
			DataViewInfo dataViewInfo = DataViewInfo.None;
			for (int i = 0; i <= toIndex && i < heightCache.Count; i++)
			{
				DataViewInfo dataViewInfo2 = heightCache[i];
				if (!dataViewInfo.Equals(DataViewInfo.None))
				{
					dataViewInfo2.startPosition = dataViewInfo.startPosition + dataViewInfo.height;
				}
				else
				{
					dataViewInfo2.startPosition = 0f;
				}
				dataViewInfo2.normalizedSpread = GetRangeSpread(dataViewInfo2.startPosition, dataViewInfo2.height);
				for (int j = 0; j < dataViewInfo2.normalizedSpread; j++)
				{
					rangeCache.Add(dataViewInfo2.dataIndex);
				}
				heightCache[i] = dataViewInfo2;
				dataViewInfo = dataViewInfo2;
			}
		}
	}
	public struct DataViewInfo
	{
		private static DataViewInfo s_default;

		public int dataIndex;

		public int normalizedSpread;

		public float height;

		public float startPosition;

		public static DataViewInfo None => s_default;

		public static implicit operator float(DataViewInfo it)
		{
			return it.height;
		}

		public DataViewInfo(int index, float height, float startPos, int spread)
		{
			dataIndex = index;
			this.height = height;
			startPosition = startPos;
			normalizedSpread = spread;
		}

		public override bool Equals(object obj)
		{
			DataViewInfo dataViewInfo = (DataViewInfo)obj;
			if (dataIndex == dataViewInfo.dataIndex && height == dataViewInfo.height && startPosition == dataViewInfo.startPosition)
			{
				return normalizedSpread == dataViewInfo.normalizedSpread;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
	}
	public interface ICell : IPooledObject
	{
		bool Enabled { get; }

		RectTransform Rect { get; set; }

		void Enable();

		void Disable();
	}
	public interface ICellPoolDataSource<T> where T : ICell
	{
		int ItemCount { get; }

		void OnCellBorrowed(T cell);

		void SetCell(T cell, int index);
	}
	public struct CellInfo
	{
		public int cellIndex;

		public int dataIndex;
	}
	public class ScrollPool<T> : UIBehaviourModel, IEnumerable<CellInfo>, IEnumerable where T : ICell
	{
		internal DataHeightCache<T> HeightCache;

		internal Slider slider;

		internal ScrollRect ScrollRect;

		internal VerticalLayoutGroup contentLayout;

		internal float? _protoHeight;

		private Vector2 RecycleViewBounds;

		private Vector2 NormalizedScrollBounds;

		private int bottomDataIndex;

		private int topPoolIndex;

		private int bottomPoolIndex;

		private Vector2 prevAnchoredPos;

		private float prevViewportHeight;

		private float prevContentHeight = 1f;

		private bool writingLocked;

		private float timeofLastWriteLock;

		private CellInfo _current;

		public ICellPoolDataSource<T> DataSource { get; set; }

		public List<T> CellPool { get; } = new List<T>();


		public override GameObject UIRoot
		{
			get
			{
				if ((Object)(object)ScrollRect != (Object)null)
				{
					return ((Component)ScrollRect).gameObject;
				}
				return null;
			}
		}

		public RectTransform Viewport => ScrollRect.viewport;

		public RectTransform Content => ScrollRect.content;

		internal float PrototypeHeight
		{
			get
			{
				float? protoHeight = _protoHeight;
				if (!protoHeight.HasValue)
				{
					float? num = (_protoHeight = Pool<T>.Instance.DefaultHeight);
					return num.Value;
				}
				return protoHeight.GetValueOrDefault();
			}
		}

		internal int ExtraPoolCells => 10;

		internal float RecycleThreshold => PrototypeHeight * (float)ExtraPoolCells;

		internal float HalfThreshold => RecycleThreshold * 0.5f;

		private int TopDataIndex => Math.Max(0, bottomDataIndex - CellPool.Count + 1);

		private int CurrentDataCount => bottomDataIndex + 1;

		private float TotalDataHeight => HeightCache.TotalHeight + (float)((LayoutGroup)contentLayout).padding.top + (float)((LayoutGroup)contentLayout).padding.bottom;

		public bool WritingLocked
		{
			get
			{
				if (!writingLocked)
				{
					return PanelManager.Resizing;
				}
				return true;
			}
			internal set
			{
				if (writingLocked != value)
				{
					timeofLastWriteLock = Time.realtimeSinceStartup;
					writingLocked = value;
				}
			}
		}

		private bool ShouldRecycleTop
		{
			get
			{
				if (GetCellExtent(CellPool[topPoolIndex].Rect) > RecycleViewBounds.x)
				{
					return GetCellExtent(CellPool[bottomPoolIndex].Rect) > RecycleViewBounds.y;
				}
				return false;
			}
		}

		private bool ShouldRecycleBottom
		{
			get
			{
				//IL_001f: 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)
				if (((Transform)CellPool[bottomPoolIndex].Rect).position.y < RecycleViewBounds.y)
				{
					return ((Transform)CellPool[topPoolIndex].Rect).position.y < RecycleViewBounds.x;
				}
				return false;
			}
		}

		private event Action OnHeightChanged;

		public ScrollPool(ScrollRect scrollRect)
		{
			ScrollRect = scrollRect;
		}

		public override void Update()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ScrollRect) || DataSource == nu