Decompiled source of UIBuddy v0.4.0

BepInEx\plugins\panthernet.UIBuddy.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Timers;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.UI;
using StunShared.UI;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using UIBuddy.Behaviors;
using UIBuddy.Classes;
using UIBuddy.KeyBinds;
using UIBuddy.Managers;
using UIBuddy.UI;
using UIBuddy.UI.Classes;
using UIBuddy.UI.Panel;
using UIBuddy.UI.Refs;
using UIBuddy.UI.ScrollView;
using UIBuddy.UI.ScrollView.Cells;
using UIBuddy.UI.ScrollView.Cells.Handlers;
using UIBuddy.UI.ScrollView.ObjectPool;
using UIBuddy.Utils;
using Unity.Entities;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("panthernet.UIBuddy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0+d9c9ace463288254a839755171fc2e3eb0a51a7c")]
[assembly: AssemblyProduct("UIBuddy")]
[assembly: AssemblyTitle("panthernet.UIBuddy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.0.0")]
[module: UnverifiableCode]
[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 UIBuddy
{
	[BepInProcess("VRising.exe")]
	[BepInPlugin("panthernet.UIBuddy", "UIBuddy", "0.4.0")]
	public class Plugin : BasePlugin
	{
		private static PanelManager _pm;

		internal static ManualLogSource Log;

		private static Harmony _harmony;

		private static CoreUpdateBehavior _updateBehavior;

		public static bool IsInitialized { get; set; }

		public static Plugin Instance { get; private set; }

		public static World VWorld { get; private set; }

		public static bool IsClient { get; private set; }

		public override void Load()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			IsClient = Application.productName != "VRisingServer";
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (!IsClient)
			{
				ManualLogSource log = Log;
				val = new BepInExInfoLogInterpolatedStringHandler(22, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("UIBuddy");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.4.0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] is a client mod! (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Application.productName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				log.LogInfo(val);
				return;
			}
			Log = ((BasePlugin)this).Log;
			ManualLogSource log2 = Log;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("panthernet.UIBuddy");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log2.LogInfo(val);
			Instance = this;
			LocalizationManager.Initialize();
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			KeybindingManager.LoadBindings();
			_updateBehavior = new CoreUpdateBehavior();
			_updateBehavior.Setup();
			ClassInjector.RegisterTypeInIl2Cpp<RectOutline>();
		}

		public static void UIOnInitialize(ScreenType type)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			try
			{
				PanelManager.CurrentScreenType = type;
				if (IsInitialized)
				{
					PanelManager.ReloadElements();
					return;
				}
				IsInitialized = true;
				Log.LogInfo((object)"Initializing UIBuddy...");
				EnsureThemeInitialized();
				ConfigManager.Initialize();
				_pm = new PanelManager();
				PanelManager.ReloadElements();
				Log.LogInfo((object)"UIBuddy initialized successfully");
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error initializing UIBuddy: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogError(val);
				Log.LogError((object)ex.StackTrace);
			}
		}

		private static void EnsureThemeInitialized()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			float opacity = Theme.Opacity;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Theme initialized with opacity: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(opacity);
			}
			log.LogInfo(val);
		}

		public static void Reset()
		{
			_pm?.Dispose();
		}

		public override bool Unload()
		{
			_updateBehavior?.Dispose();
			_harmony.UnpatchSelf();
			KeybindingManager.UnloadBindings();
			return ((BasePlugin)this).Unload();
		}

		public static void GameDataOnInitialize(World world)
		{
			VWorld = world;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "panthernet.UIBuddy";

		public const string PLUGIN_NAME = "UIBuddy";

		public const string PLUGIN_VERSION = "0.4.0";
	}
}
namespace UIBuddy.Utils
{
	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 Start(this IEnumerator routine)
		{
			StartCoroutine(routine);
		}

		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);
				}
			}
		}
	}
	internal static class Extensions
	{
		public static Color GetWithOpacity(this Color color, float opacity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Color(color.r, color.g, color.b, opacity);
		}
	}
	public static class HashUtils
	{
		private const uint FNVOffset32 = 2166136261u;

		private const uint FNVPrime32 = 16777619u;

		private static ulong FNVPrime64 = 1099511628211uL;

		private static ulong FNVOffset64 = 14695981039346656037uL;

		public static uint Hash32(string value)
		{
			uint num = 2166136261u;
			foreach (char c in value)
			{
				num = 16777619 * (num ^ c);
			}
			return num;
		}

		public static ulong Hash64(string value)
		{
			ulong num = FNVOffset64;
			foreach (char c in value)
			{
				num = FNVPrime64 * (num ^ c);
			}
			return num;
		}
	}
	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;
		}
	}
}
namespace UIBuddy.UI
{
	internal static class Theme
	{
		private static float _opacity;

		public static Color PanelBackground { get; private set; }

		public static Color SliderFill { get; private set; }

		public static Color SliderHandle { get; private set; }

		public static Color DarkBackground { get; private set; }

		public static Color SliderNormal { get; private set; }

		public static Color SliderHighlighted { get; private set; }

		public static Color SliderPressed { get; private set; }

		public static Color SelectableNormal { get; private set; }

		public static Color SelectableHighlighted { get; private set; }

		public static Color SelectablePressed { get; private set; }

		public static Color White { get; private set; }

		public static Color DefaultText { get; private set; }

		public static Color PlaceHolderText { get; private set; }

		public static Color InputFieldNormal { get; private set; }

		public static Color InputFieldHighlighted { get; private set; }

		public static Color InputFieldPressed { get; private set; }

		public static Color ElementOutlineColor { get; private set; }

		public static Color ToggleNormal { get; private set; }

		public static Color ToggleCheckMark { get; private set; }

		public static Color ViewportBackground { get; private set; }

		public static Color ScrollbarNormal { get; private set; }

		public static Color ScrollbarHighlighted { get; private set; }

		public static Color ScrollbarPressed { get; private set; }

		public static Color ScrollbarDisabled { get; private set; }

		public static float Opacity
		{
			get
			{
				return _opacity;
			}
			set
			{
				_opacity = value;
				UpdateColors();
			}
		}

		public static Color Level1 { get; set; }

		static Theme()
		{
			Opacity = 0.8f;
		}

		private static void UpdateColors()
		{
			//IL_0014: 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_0050: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_0104: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: 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_0230: 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_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			PanelBackground = new Color(0.07f, 0.07f, 0.07f, Opacity);
			DarkBackground = new Color(0.07f, 0.07f, 0.07f, Opacity);
			SliderFill = new Color(0.3f, 0.3f, 0.3f, Opacity);
			SliderHandle = new Color(0.5f, 0.5f, 0.5f, Opacity);
			SliderNormal = new Color(0.4f, 0.4f, 0.4f, Opacity);
			SliderHighlighted = new Color(0.55f, 0.55f, 0.55f, Opacity);
			SliderPressed = new Color(0.3f, 0.3f, 0.3f, Opacity);
			SelectableNormal = new Color(0.2f, 0.2f, 0.2f, Opacity);
			SelectableHighlighted = new Color(0.3f, 0.3f, 0.3f, Opacity);
			SelectablePressed = new Color(0.15f, 0.15f, 0.15f, Opacity);
			DefaultText = Color.white;
			White = Color.white;
			PlaceHolderText = SliderHandle;
			InputFieldNormal = new Color(1f, 1f, 1f, Opacity);
			InputFieldHighlighted = new Color(0.95f, 0.95f, 0.95f, Opacity);
			InputFieldPressed = new Color(0.78f, 0.78f, 0.78f, Opacity);
			ElementOutlineColor = new Color(1f, 1f, 0f, Opacity);
			ToggleNormal = new Color(0f, 0f, 0f, Opacity);
			ToggleCheckMark = new Color(0.6f, 0.7f, 0.6f, Opacity);
			ViewportBackground = new Color(0.07f, 0.07f, 0.07f, Opacity);
			ScrollbarNormal = new Color(0.4f, 0.4f, 0.4f, Opacity);
			ScrollbarHighlighted = new Color(0.5f, 0.5f, 0.5f, Opacity);
			ScrollbarPressed = new Color(0.3f, 0.3f, 0.3f, Opacity);
			ScrollbarDisabled = new Color(0.5f, 0.5f, 0.5f, Opacity);
		}
	}
	internal static class UIFactory
	{
		private static readonly Vector2 SmallElementSize = new Vector2(25f, 25f);

		private static readonly Vector2 OutlineDistance = new Vector2(2f, 2f);

		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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("UIBuddy_" + name)
			{
				layer = 5,
				hideFlags = (HideFlags)61
			};
			if (Object.op_Implicit((Object)(object)parent))
			{
				val.transform.SetParent(parent.transform, false);
				val.transform.SetAsLastSibling();
			}
			val.AddComponent<RectTransform>().sizeDelta = sizeDelta;
			return val;
		}

		public static LabelRef CreateLabel(GameObject parent, string name, string defaultText, TextAlignmentOptions alignment = 514, Color? color = null, int fontSize = 14, float outlineWidth = 0.15f, Color? outlineColor = 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_002e: 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_004b: 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_006f: 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)
			GameObject val = CreateUIObject(name, parent);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((Graphic)val2).color = (Color)(((??)color) ?? Theme.DefaultText);
			((TMP_Text)val2).font = Font;
			((TMP_Text)val2).text = defaultText;
			((TMP_Text)val2).alignment = alignment;
			((TMP_Text)val2).fontSize = fontSize;
			try
			{
				((TMP_Text)val2).outlineWidth = outlineWidth;
				((TMP_Text)val2).outlineColor = Color32.op_Implicit((Color)(((??)outlineColor) ?? Color.black));
			}
			catch (Exception)
			{
			}
			return new LabelRef
			{
				GameObject = val,
				TextMesh = val2
			};
		}

		public static ToggleRef CreateToggle(GameObject parent, string name, Color bgColor = default(Color), int checkWidth = 20, int checkHeight = 20)
		{
			//IL_0009: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			ToggleRef toggleRef = new ToggleRef();
			toggleRef.GameObject = CreateUIObject(name, parent, SmallElementSize);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(toggleRef.GameObject, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)(TextAnchor)3);
			toggleRef.Toggle = toggleRef.GameObject.AddComponent<Toggle>();
			toggleRef.Toggle.isOn = true;
			SetDefaultSelectableValues((Selectable)(object)toggleRef.Toggle);
			GameObject val = CreateUIObject("Background", toggleRef.GameObject);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = ((bgColor == default(Color)) ? Theme.ToggleNormal : bgColor);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)0, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null);
			SetLayoutElement(val, checkWidth, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
			Image val3 = CreateUIObject("Checkmark", val).AddComponent<Image>();
			((Graphic)val3).color = Theme.ToggleCheckMark;
			GameObject val4 = CreateUIObject("Label", toggleRef.GameObject);
			toggleRef.Text = val4.AddComponent<TextMeshProUGUI>();
			((TMP_Text)toggleRef.Text).text = "";
			((TMP_Text)toggleRef.Text).alignment = (TextAlignmentOptions)4097;
			SetDefaultTextValues(toggleRef.Text);
			SetLayoutElement(val4, 0, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
			toggleRef.Toggle.graphic = (Graphic)(object)val3;
			((Selectable)toggleRef.Toggle).targetGraphic = (Graphic)(object)val2;
			return toggleRef;
		}

		public static InputFieldRef CreateInputField(GameObject parent, string name, string placeHolderText, int charLimit = 255)
		{
			//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_006c: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00ac: 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_00cb: 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_00e1: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_0208: 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)
			GameObject val = CreateUIObject(name, parent);
			Image val2 = val.AddComponent<Image>();
			val2.type = (Type)1;
			((Graphic)val2).color = Theme.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 = Theme.InputFieldNormal;
			((ColorBlock)(ref val3)).highlightedColor = Theme.InputFieldHighlighted;
			((ColorBlock)(ref val3)).pressedColor = Theme.InputFieldPressed;
			((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 = Theme.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 = Theme.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 = charLimit;
			return new InputFieldRef(obj);
		}

		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 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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(val, (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);
			if (bgColor.HasValue)
			{
				((Graphic)val.AddComponent<Image>()).color = bgColor.Value;
			}
			return val;
		}

		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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (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);
			if (bgColor.HasValue)
			{
				((Graphic)val.AddComponent<Image>()).color = bgColor.Value;
			}
			return val;
		}

		public static SliderRef CreateSlider(GameObject parent, string name)
		{
			//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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: 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 = Theme.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 = Theme.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 = Theme.SliderHandle;
			Outline obj4 = val5.AddComponent<Outline>();
			((Shadow)obj4).effectColor = Theme.DarkBackground;
			((Shadow)obj4).effectDistance = OutlineDistance;
			val5.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 0f);
			Slider obj5 = val.AddComponent<Slider>();
			obj5.fillRect = val3.GetComponent<RectTransform>();
			obj5.handleRect = val5.GetComponent<RectTransform>();
			((Selectable)obj5).targetGraphic = (Graphic)(object)val6;
			obj5.direction = (Direction)0;
			ColorBlock val7 = default(ColorBlock);
			((ColorBlock)(ref val7)).normalColor = Theme.SliderNormal;
			((ColorBlock)(ref val7)).highlightedColor = Theme.SliderHighlighted;
			((ColorBlock)(ref val7)).pressedColor = Theme.SliderPressed;
			((ColorBlock)(ref val7)).colorMultiplier = 1f;
			ColorBlock colors = val7;
			((Selectable)obj5).colors = colors;
			return new SliderRef(obj5, 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) ?? Theme.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 = Theme.White;
			Outline obj2 = val.AddComponent<Outline>();
			((Shadow)obj2).effectColor = Theme.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);
		}

		private static void SetDefaultSelectableValues(Selectable selectable)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0050: 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 = Theme.SelectableNormal;
			((ColorBlock)(ref val)).highlightedColor = Theme.SelectableHighlighted;
			((ColorBlock)(ref val)).pressedColor = Theme.SelectablePressed;
			((ColorBlock)(ref val)).colorMultiplier = 1f;
			ColorBlock colors = val;
			selectable.colors = colors;
		}

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

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

		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_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: 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) ?? Theme.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 = Theme.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;
			GameObject val3 = CreateUIObject("AutoSliderScrollbar", val);
			RectTransform component3 = val3.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(1f, 0f);
			component3.anchorMax = Vector2.one;
			component3.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 = Theme.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);
			new AutoSliderScrollbar(scrollbar, slider, component2, component);
			ScrollRect obj = val.AddComponent<ScrollRect>();
			obj.horizontal = false;
			obj.vertical = true;
			obj.verticalScrollbar = scrollbar;
			obj.movementType = (MovementType)2;
			obj.scrollSensitivity = 35f;
			obj.horizontalScrollbarVisibility = (ScrollbarVisibility)2;
			obj.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			obj.viewport = component;
			obj.content = component2;
			uiRoot = val;
			return new ScrollPool<T>(obj);
		}

		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 = Theme.DarkBackground;
			Image val3 = obj.AddComponent<Image>();
			val3.type = (Type)1;
			((Graphic)val3).color = Theme.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 CreateSliderScrollbar(GameObject parent, out Slider slider)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("SliderScrollbar", parent, SmallElementSize);
			((Graphic)val.AddComponent<Image>()).color = Theme.DarkBackground;
			GameObject val2 = CreateUIObject("Handle Slide Area", val);
			GameObject obj = CreateUIObject("Handle", val2);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.op_Implicit(Vector3.zero);
			component.anchorMax = Vector2.op_Implicit(Vector3.one);
			component.pivot = Vector2.op_Implicit(new Vector3(0.5f, 0.5f));
			Image val3 = obj.AddComponent<Image>();
			((Graphic)val3).color = Theme.SliderHandle;
			RectTransform component2 = obj.GetComponent<RectTransform>();
			component2.pivot = new Vector2(0.5f, 0.5f);
			int? minWidth = 21;
			int? flexibleWidth = 0;
			SetLayoutElement(obj, minWidth, null, flexibleWidth);
			LayoutElement obj2 = val.AddComponent<LayoutElement>();
			obj2.minWidth = 25f;
			obj2.flexibleWidth = 0f;
			obj2.minHeight = 30f;
			obj2.flexibleHeight = 9999f;
			slider = val.AddComponent<Slider>();
			slider.handleRect = component2;
			slider.fillRect = component2;
			((Selectable)slider).targetGraphic = (Graphic)(object)val3;
			slider.direction = (Direction)3;
			int? minWidth2 = 25;
			flexibleWidth = 0;
			int? flexibleHeight = 9999;
			SetLayoutElement(val, minWidth2, null, flexibleWidth, flexibleHeight);
			Slider obj3 = slider;
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = Theme.ScrollbarNormal;
			((ColorBlock)(ref colors)).highlightedColor = Theme.ScrollbarHighlighted;
			((ColorBlock)(ref colors)).pressedColor = Theme.ScrollbarPressed;
			((ColorBlock)(ref colors)).disabledColor = Theme.ScrollbarDisabled;
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((Selectable)obj3).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)) ? Theme.Level1 : 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 = Theme.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 = Theme.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;
		}
	}
}
namespace UIBuddy.UI.ScrollView
{
	public class AutoSliderScrollbar : UIBehaviourModel
	{
		private float _lastAnchorPosition;

		private float _lastContentHeight;

		private float _lastViewportHeight;

		private bool _refreshWanted;

		protected 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_005b: 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_003f: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (base.Enabled)
			{
				_refreshWanted = false;
				if ((double)Math.Abs(((Transform)ContentRect).localPosition.y - _lastAnchorPosition) > 0.0001)
				{
					_lastAnchorPosition = ((Transform)ContentRect).localPosition.y;
					_refreshWanted = true;
				}
				Rect rect = ContentRect.rect;
				if ((double)Math.Abs(((Rect)(ref rect)).height - _lastContentHeight) > 0.0001)
				{
					rect = ContentRect.rect;
					_lastContentHeight = ((Rect)(ref rect)).height;
					_refreshWanted = true;
				}
				rect = ViewportRect.rect;
				if ((double)Math.Abs(((Rect)(ref rect)).height - _lastViewportHeight) > 0.0001)
				{
					rect = ViewportRect.rect;
					_lastViewportHeight = ((Rect)(ref rect)).height;
					_refreshWanted = true;
				}
				if (_refreshWanted)
				{
					UpdateSliderHandle();
				}
			}
		}

		private 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 num = 0f;
			if (height > 0f)
			{
				decimal num2 = (decimal)((Transform)ContentRect).localPosition.y;
				rect = ViewportRect.rect;
				num = (float)(num2 / (decimal)(height - ((Rect)(ref rect)).height));
			}
			Slider.Set(num, true);
		}

		private void OnScrollbarValueChanged(float value)
		{
			value = 1f - value;
			if ((double)Math.Abs(Slider.value - value) > 0.0001)
			{
				Slider.Set(value, true);
			}
		}

		private void OnSliderValueChanged(float value)
		{
			value = 1f - value;
			if ((double)Math.Abs(Scrollbar.value - value) > 0.0001)
			{
				Scrollbar.Set(value, true);
			}
		}
	}
	public class DataHeightCache<T> where T : ICell
	{
		private readonly List<DataViewInfo> _heightCache = new List<DataViewInfo>();

		private float _totalHeight;

		private float? _mDefaultHeight;

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

		private ScrollPool<T> ScrollPool { get; }

		public DataViewInfo this[int index]
		{
			get
			{
				if (_heightCache.Count != 0)
				{
					return _heightCache[index];
				}
				return DataViewInfo.None;
			}
			set
			{
				SetIndex(index, value);
			}
		}

		public int Count => _heightCache.Count;

		public float TotalHeight => _totalHeight;

		private float DefaultHeight
		{
			get
			{
				float? mDefaultHeight = _mDefaultHeight;
				if (!mDefaultHeight.HasValue)
				{
					float? num = (_mDefaultHeight = ScrollPool.PrototypeHeight);
					return num.Value;
				}
				return mDefaultHeight.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
	{
		[CompilerGenerated]
		private sealed class <EnumerateCellPool>d__60 : IEnumerator<CellInfo>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CellInfo <>2__current;

			public ScrollPool<T> <>4__this;

			private int <cellIdx>5__2;

			private int <dataIndex>5__3;

			private int <iterated>5__4;

			CellInfo IEnumerator<CellInfo>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EnumerateCellPool>d__60(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				ScrollPool<T> scrollPool = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<cellIdx>5__2 = scrollPool.topPoolIndex;
					<dataIndex>5__3 = scrollPool.TopDataIndex;
					<iterated>5__4 = 0;
					break;
				case 1:
					<>1__state = -1;
					<cellIdx>5__2++;
					if (<cellIdx>5__2 >= scrollPool.CellPool.Count)
					{
						<cellIdx>5__2 = 0;
					}
					<dataIndex>5__3++;
					<iterated>5__4++;
					break;
				}
				if (<iterated>5__4 < scrollPool.CellPool.Count)
				{
					scrollPool._current.cellIndex = <cellIdx>5__2;
					scrollPool._current.dataIndex = <dataIndex>5__3;
					<>2__current = scrollPool._current;
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ForceDelayedJump>d__52 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ScrollPool<T> <>4__this;

			public float normalizedPos;

			public int dataIndex;

			public Action<T> onJumped;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ForceDelayedJump>d__52(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				ScrollPool<T> scrollPool = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					scrollPool.slider.value = normalizedPos;
					<>2__current = null;
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					scrollPool.RefreshCells(andReloadFromDataSource: true, setSlider: false);
					foreach (CellInfo item in scrollPool)
					{
						if (item.dataIndex == dataIndex)
						{
							onJumped?.Invoke(scrollPool.CellPool[item.cellIndex]);
							break;
						}
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <InitCoroutine>d__56 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ScrollPool<T> <>4__this;

			public Action onHeightChangedListener;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitCoroutine>d__56(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0034: 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_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				ScrollPool<T> scrollPool = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					scrollPool.ScrollRect.content.anchoredPosition = Vector2.zero;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					LayoutRebuilder.ForceRebuildLayoutImmediate(scrollPool.Content);
					scrollPool.prevAnchoredPos = scrollPool.Content.anchoredPosition;
					scrollPool.CheckRecycleViewBounds(extendPoolIfGrown: false);
					scrollPool.CreateCellPool();
					foreach (CellInfo item in scrollPool)
					{
						scrollPool.SetCell(scrollPool.CellPool[item.cellIndex], item.dataIndex);
					}
					LayoutRebuilder.ForceRebuildLayoutImmediate(scrollPool.Content);
					Rect rect = scrollPool.Content.rect;
					scrollPool.prevContentHeight = ((Rect)(ref rect)).height;
					scrollPool.SetScrollBounds();
					scrollPool.UpdateSliderHandle();
					((UnityEvent<Vector2>)(object)scrollPool.ScrollRect.onValueChanged).AddListener<Vector2>(scrollPool.OnValueChangedListener);
					scrollPool.OnHeightChanged += onHeightChangedListener;
					onHeightChangedListener?.Invoke();
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

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


		protected 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
			{
				return writingLocked;
			}
			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 == null || writingLocked)
			{
				return;
			}
			Rect rect;
			if (!CheckRecycleViewBounds(extendPoolIfGrown: true))
			{
				rect = Content.rect;
				if (((Rect)(ref rect)).height == prevContentHeight)
				{
					return;
				}
			}
			rect = Content.rect;
			prevContentHeight = ((Rect)(ref rect)).height;
			OnValueChangedListener(Vector2.zero);
			this.OnHeightChanged?.Invoke();
		}

		public void Refresh(bool setCellData, bool jumpToTop = false)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (jumpToTop)
			{
				bottomDataIndex = CellPool.Count - 1;
				Content.anchoredPosition = Vector2.zero;
			}
			RefreshCells(setCellData, setSlider: true);
		}

		public void JumpToIndex(int index, Action<T> onJumped)
		{
			CheckDataSourceCountChange();
			if (HeightCache.Count <= index)
			{
				throw new IndexOutOfRangeException($"Requested jump index {index} is out of bounds. Data count: {HeightCache.Count}");
			}
			DataViewInfo dataViewInfo = HeightCache[index];
			float num = dataViewInfo.height * (float)((decimal)dataViewInfo.dataIndex / (decimal)HeightCache.Count);
			float normalizedPos = (dataViewInfo.startPosition + num) / HeightCache.TotalHeight;
			CoroutineUtility.StartCoroutine(ForceDelayedJump(index, normalizedPos, onJumped));
		}

		[IteratorStateMachine(typeof(ScrollPool<>.<ForceDelayedJump>d__52))]
		private IEnumerator ForceDelayedJump(int dataIndex, float normalizedPos, Action<T> onJumped)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ForceDelayedJump>d__52(0)
			{
				<>4__this = this,
				dataIndex = dataIndex,
				normalizedPos = normalizedPos,
				onJumped = onJumped
			};
		}

		public IEnumerator<CellInfo> GetEnumerator()
		{
			return EnumerateCellPool();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return EnumerateCellPool();
		}

		public void Initialize(ICellPoolDataSource<T> dataSource, Action onHeightChangedListener = null)
		{
			DataSource = dataSource;
			HeightCache = new DataHeightCache<T>(this);
			Pool<T>.GetPool();
			contentLayout = ((Component)ScrollRect.content).GetComponent<VerticalLayoutGroup>();
			slider = ((Component)ScrollRect).GetComponentInChildren<Slider>();
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener<float>(OnSliderValueChanged);
			ScrollRect.vertical = true;
			ScrollRect.horizontal = false;
			CoroutineUtility.StartCoroutine(InitCoroutine(onHeightChangedListener));
		}

		[IteratorStateMachine(typeof(ScrollPool<>.<InitCoroutine>d__56))]
		private IEnumerator InitCoroutine(Action onHeightChangedListener)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitCoroutine>d__56(0)
			{
				<>4__this = this,
				onHeightChangedListener = onHeightChangedListener
			};
		}

		private void SetScrollBounds()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = Viewport.rect;
			float num = ((Rect)(ref rect)).height * 0.5f;
			float totalDataHeight = TotalDataHeight;
			rect = Viewport.rect;
			NormalizedScrollBounds = new Vector2(num, totalDataHeight - ((Rect)(ref rect)).height * 0.5f);
		}

		private bool CheckRecycleViewBounds(bool extendPoolIfGrown)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			RecycleViewBounds = new Vector2(Viewport.MinY() + HalfThreshold, Viewport.MaxY() - HalfThreshold);
			Rect rect;
			if (extendPoolIfGrown)
			{
				float num = prevViewportHeight;
				rect = Viewport.rect;
				if (num < ((Rect)(ref rect)).height && prevViewportHeight != 0f)
				{
					CheckExtendCellPool();
				}
			}
			float num2 = prevViewportHeight;
			rect = Viewport.rect;
			bool result = num2 == ((Rect)(ref rect)).height;
			rect = Viewport.rect;
			prevViewportHeight = ((Rect)(ref rect)).height;
			return result;
		}

		[IteratorStateMachine(typeof(ScrollPool<>.<EnumerateCellPool>d__60))]
		private IEnumerator<CellInfo> EnumerateCellPool()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EnumerateCellPool>d__60(0)
			{
				<>4__this = this
			};
		}

		private void CreateCellPool()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			CheckDataSourceCountChange(out var _);
			float num = 0f;
			Rect rect = ScrollRect.viewport.rect;
			float num2 = ((Rect)(ref rect)).height + RecycleThreshold;
			topPoolIndex = 0;
			bottomPoolIndex = -1;
			for (WritingLocked = true; num <= num2; num += PrototypeHeight)
			{
				bottomPoolIndex++;
				T val = Pool<T>.Borrow();
				CellPool.Add(val);
				DataSource.OnCellBorrowed(val);
				((Transform)val.Rect).SetParent((Transform)(object)ScrollRect.content, false);
			}
			bottomDataIndex = CellPool.Count - 1;
			LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
		}

		private bool CheckExtendCellPool()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			CheckDataSourceCountChange();
			float num = Math.Abs(RecycleViewBounds.y - RecycleViewBounds.x);
			float num2 = (float)CellPool.Count * PrototypeHeight;
			int num3 = (int)Math.Floor((decimal)(num - num2) / (decimal)PrototypeHeight);
			if (num3 > 0)
			{
				WritingLocked = true;
				bottomDataIndex += num3;
				float y = ((Transform)Content).localPosition.y;
				Rect rect = Content.rect;
				_ = ((Rect)(ref rect)).height;
				for (int i = 0; i < num3; i++)
				{
					T val = Pool<T>.Borrow();
					DataSource.OnCellBorrowed(val);
					((Transform)val.Rect).SetParent((Transform)(object)ScrollRect.content, false);
					CellPool.Add(val);
					if (CellPool.Count > 1)
					{
						int num4 = CellPool.Count - 1 - topPoolIndex % (CellPool.Count - 1);
						((Transform)val.Rect).SetSiblingIndex(num4 + 1);
						if (bottomPoolIndex == num4 - 1)
						{
							bottomPoolIndex++;
						}
					}
				}
				RefreshCells(andReloadFromDataSource: false, setSlider: true);
				if (Math.Abs(((Transform)Content).localPosition.y - y) > 0.0001f)
				{
					float num5 = ((Transform)Content).localPosition.y - y;
					((Transform)Content).localPosition = new Vector3(((Transform)Content).localPosition.x, ((Transform)Content).localPosition.y - num5);
				}
				return true;
			}
			return false;
		}

		private bool CheckDataSourceCountChange()
		{
			bool shouldJumpToBottom;
			return CheckDataSourceCountChange(out shouldJumpToBottom);
		}

		private bool CheckDataSourceCountChange(out bool shouldJumpToBottom)
		{
			shouldJumpToBottom = false;
			int itemCount = DataSource.ItemCount;
			if (bottomDataIndex > itemCount && bottomDataIndex >= CellPool.Count)
			{
				bottomDataIndex = Math.Max(itemCount - 1, CellPool.Count - 1);
				shouldJumpToBottom = true;
			}
			if (HeightCache.Count < itemCount)
			{
				HeightCache.SetIndex(itemCount - 1, PrototypeHeight);
				return true;
			}
			if (HeightCache.Count > itemCount)
			{
				while (HeightCache.Count > itemCount)
				{
					HeightCache.RemoveLast();
				}
				return false;
			}
			return false;
		}

		private void RefreshCells(bool andReloadFromDataSource, bool setSlider)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (!CellPool.Any())
			{
				return;
			}
			CheckRecycleViewBounds(extendPoolIfGrown: true);
			CheckDataSourceCountChange(out var shouldJumpToBottom);
			using (IEnumerator<CellInfo> enumerator = GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					CellInfo current = enumerator.Current;
					T cachedCell = CellPool[current.cellIndex];
					if (andReloadFromDataSource)
					{
						SetCell(cachedCell, current.dataIndex);
						continue;
					}
					DataHeightCache<T> heightCache = HeightCache;
					int dataIndex = current.dataIndex;
					Rect rect = cachedCell.Rect.rect;
					heightCache.SetIndex(dataIndex, ((Rect)(ref rect)).height);
				}
			}
			if (andReloadFromDataSource)
			{
				RecycleBottomToTop();
				RecycleTopToBottom();
			}
			if (setSlider)
			{
				UpdateSliderHandle();
			}
			if (shouldJumpToBottom)
			{
				float num = Viewport.MaxY() - CellPool[bottomPoolIndex].Rect.MaxY();
				RectTransform content = Content;
				content.anchoredPosition += Vector2.up * num;
			}
			if (andReloadFromDataSource)
			{
				LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
			}
			SetScrollBounds();
			ScrollRect.UpdatePrevData();
		}

		private void RefreshCellHeightsFast()
		{
			//IL_003b: 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)
			using IEnumerator<CellInfo> enumerator = GetEnumerator();
			while (enumerator.MoveNext())
			{
				CellInfo current = enumerator.Current;
				DataHeightCache<T> heightCache = HeightCache;
				int dataIndex = current.dataIndex;
				Rect rect = CellPool[current.cellIndex].Rect.rect;
				heightCache.SetIndex(dataIndex, ((Rect)(ref rect)).height);
			}
		}

		private void SetCell(T cachedCell, int dataIndex)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			cachedCell.Enable();
			DataSource.SetCell(cachedCell, dataIndex);
			LayoutRebuilder.ForceRebuildLayoutImmediate(cachedCell.Rect);
			DataHeightCache<T> heightCache = HeightCache;
			Rect rect = cachedCell.Rect.rect;
			heightCache.SetIndex(dataIndex, ((Rect)(ref rect)).height);
		}

		private void OnValueChangedListener(Vector2 val)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0056: 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_00b0: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (WritingLocked || DataSource == null)
			{
				return;
			}
			if (InputManager.Mouse.ScrollDelta != Vector2.zero)
			{
				ScrollRect.StopMovement();
			}
			RefreshCellHeightsFast();
			CheckRecycleViewBounds(extendPoolIfGrown: true);
			float y = (Vector2.op_Implicit(((Transform)ScrollRect.content).localPosition) - prevAnchoredPos).y;
			float num = 0f;
			if (y > 0f)
			{
				if (ShouldRecycleTop)
				{
					num = RecycleTopToBottom();
				}
			}
			else if (y < 0f && ShouldRecycleBottom)
			{
				num = RecycleBottomToTop();
			}
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, num);
			ScrollRect scrollRect = ScrollRect;
			scrollRect.m_ContentStartPosition += val2;
			ScrollRect scrollRect2 = ScrollRect;
			scrollRect2.m_PrevPosition += val2;
			prevAnchoredPos = ScrollRect.content.anchoredPosition;
			SetScrollBounds();
			UpdateSliderHandle();
		}

		private float GetCellExtent(RectTransform cell)
		{
			return cell.MaxY() - ((HorizontalOrVerticalLayoutGroup)contentLayout).spacing;
		}

		private float RecycleTopToBottom()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			while (ShouldRecycleTop && CurrentDataCount < DataSource.ItemCount)
			{
				WritingLocked = true;
				T cachedCell = CellPool[topPoolIndex];
				((Transform)cachedCell.Rect).SetAsLastSibling();
				Rect rect = cachedCell.Rect.rect;
				float height = ((Rect)(ref rect)).height;
				RectTransform content = Content;
				content.anchoredPosition -= Vector2.up * height;
				num += height + ((HorizontalOrVerticalLayoutGroup)contentLayout).spacing;
				SetCell(cachedCell, CurrentDataCount);
				bottomDataIndex++;
				bottomPoolIndex = topPoolIndex;
				topPoolIndex = (topPoolIndex + 1) % CellPool.Count;
			}
			return 0f - num;
		}

		private float RecycleBottomToTop()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			while (ShouldRecycleBottom && CurrentDataCount > CellPool.Count)
			{
				WritingLocked = true;
				T cachedCell = CellPool[bottomPoolIndex];
				((Transform)cachedCell.Rect).SetAsFirstSibling();
				Rect rect = cachedCell.Rect.rect;
				float height = ((Rect)(ref rect)).height;
				RectTransform content = Content;
				content.anchoredPosition += Vector2.up * height;
				num += height + ((HorizontalOrVerticalLayoutGroup)contentLayout).spacing;
				bottomDataIndex--;
				SetCell(cachedCell, TopDataIndex);
				rect = cachedCell.Rect.rect;
				float num2 = ((Rect)(ref rect)).height - height;
				if (num2 != 0f)
				{
					RectTransform content2 = Content;
					content2.anchoredPosition += Vector2.up * num2;
					num += num2;
				}
				topPoolIndex = bottomPoolIndex;
				bottomPoolIndex = (bottomPoolIndex - 1 + CellPool.Count) % CellPool.Count;
			}
			return num;
		}

		private void OnSliderValueChanged(float val)
		{
			//IL_005d: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			if (DataSource == null || (WritingLocked && val != 0f && val != 1f))
			{
				return;
			}
			ScrollRect.StopMovement();
			RefreshCellHeightsFast();
			float num = val * (NormalizedScrollBounds.y - NormalizedScrollBounds.x) + NormalizedScrollBounds.x;
			Rect rect = Viewport.rect;
			float num2 = ((Rect)(ref rect)).height * 0.5f;
			float num3 = num - num2;
			int firstDataIndexAtPosition = HeightCache.GetFirstDataIndexAtPosition(num3);
			firstDataIndexAtPosition = Math.Max(0, firstDataIndexAtPosition);
			firstDataIndexAtPosition = Math.Min(DataSource.ItemCount - 1, firstDataIndexAtPosition);
			int val2 = Math.Max(0, firstDataIndexAtPosition - (int)((float)ExtraPoolCells * 0.5f));
			val2 = Math.Min(Math.Max(0, DataSource.ItemCount - CellPool.Count), val2);
			DataViewInfo dataViewInfo = HeightCache[val2];
			if ((float)dataViewInfo == (float)DataViewInfo.None)
			{
				return;
			}
			float startPosition = dataViewInfo.startPosition;
			float num4 = ((!(num3 < HalfThreshold)) ? (num3 - startPosition) : num3);
			Content.anchoredPosition = new Vector2(0f, num4);
			int num5 = val2 + CellPool.Count - 1;
			if (bottomDataIndex != num5)
			{
				if (TopDataIndex > val2 && TopDataIndex < num5)
				{
					int num6 = TopDataIndex - val2;
					for (int i = 0; i < num6; i++)
					{
						((Transform)CellPool[bottomPoolIndex].Rect).SetAsFirstSibling();
						topPoolIndex = bottomPoolIndex;
						bottomPoolIndex = (bottomPoolIndex - 1 + CellPool.Count) % CellPool.Count;
						bottomDataIndex--;
						SetCell(CellPool[topPoolIndex], TopDataIndex);
					}
				}
				else if (bottomDataIndex > val2 && bottomDataIndex < num5)
				{
					int num7 = num5 - bottomDataIndex;
					for (int j = 0; j < num7; j++)
					{
						((Transform)CellPool[topPoo