Decompiled source of ScrollableLobbyUI v1.10.7

plugins/ScrollableLobbyUI/ScrollableLobbyUI.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using IL.RoR2.UI;
using InLobbyConfig;
using InLobbyConfig.Fields;
using LeTai.Asset.TranslucentImage;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using On.RoR2.UI;
using Rewired;
using RoR2;
using RoR2.UI;
using RoR2.UI.SkinControllers;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.10.7.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ScrollableLobbyUI
{
	public class ButtonsNavigationController : MonoBehaviour
	{
		private bool buttonsWereActive;

		private MPEventSystemLocator eventSystemLocator;

		public UILayerKey requiredTopLayer;

		public LoadoutPanelController loadoutPanel;

		protected MPEventSystem eventSystem
		{
			get
			{
				MPEventSystemLocator obj = eventSystemLocator;
				if (obj == null)
				{
					return null;
				}
				return obj.eventSystem;
			}
		}

		public void Awake()
		{
			eventSystemLocator = ((Component)this).GetComponent<MPEventSystemLocator>();
			buttonsWereActive = true;
		}

		public void Update()
		{
			//IL_0048: 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_0035: 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)
			bool flag = ButtonsShouldBeActive();
			if (buttonsWereActive != flag && Object.op_Implicit((Object)(object)loadoutPanel))
			{
				HGButton[] componentsInChildren = ((Component)loadoutPanel).GetComponentsInChildren<HGButton>();
				foreach (HGButton obj in componentsInChildren)
				{
					Navigation val;
					Navigation navigation;
					if (!flag)
					{
						val = default(Navigation);
						((Navigation)(ref val)).mode = (Mode)0;
						navigation = val;
					}
					else
					{
						val = default(Navigation);
						((Navigation)(ref val)).mode = (Mode)3;
						navigation = val;
					}
					((Selectable)obj).navigation = navigation;
				}
			}
			buttonsWereActive = flag;
		}

		protected bool ButtonsShouldBeActive()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			if (((Component)this).gameObject.activeInHierarchy && Object.op_Implicit((Object)(object)eventSystem))
			{
				if ((int)eventSystem.currentInputSource != 0)
				{
					if (!Object.op_Implicit((Object)(object)requiredTopLayer) || requiredTopLayer.representsTopLayer)
					{
						return (int)eventSystem.currentInputSource == 1;
					}
					return false;
				}
				return true;
			}
			return false;
		}
	}
	[RequireComponent(typeof(CharacterSelectBarController))]
	public class CharacterSelectBarControllerExtra : MonoBehaviour
	{
		public class VariantArrowToggler : MonoBehaviour
		{
			public GameObject arrow;

			private void Start()
			{
				if (Object.op_Implicit((Object)(object)arrow))
				{
					arrow.SetActive(false);
				}
			}

			private void OnEnable()
			{
				if (Object.op_Implicit((Object)(object)arrow))
				{
					arrow.SetActive(false);
				}
			}

			private void OnDisable()
			{
				if (Object.op_Implicit((Object)(object)arrow))
				{
					arrow.SetActive(true);
				}
			}
		}

		private const int iconSpacing = 4;

		private const int iconPadding = 6;

		private const int buttonSide = 37;

		private CharacterSelectBarController characterSelectBar;

		private HGButtonHistory buttonHistory;

		private int fillerCount;

		private SurvivorDef pickedSurvivor;

		private readonly List<LayoutElement> trackingHeightElements;

		private readonly List<SurvivorDef> survivorDefList;

		private HGButton arrowPreviousButtonComponent;

		private HGButton arrowNextButtonComponent;

		private HGButton inlinePreviousButtonComponent;

		private HGButton inlineNextButtonComponent;

		private int SurvivorRows => ScrollableLobbyUIPlugin.CharacterSelectRows.Value;

		private int SurvivorsPerRow { get; set; }

		private int SurvivorsPerPage => SurvivorsPerRow * SurvivorRows;

		private int ContainerHeight => (ScrollableLobbyUIPlugin.CharacterIconSize.Value + 4) * SurvivorRows - 4 + 12;

		private GridLayoutGroup IconContainerGrid => characterSelectBar.iconContainerGrid;

		private UIElementAllocator<SurvivorIconController> SurvivorIconControllers => characterSelectBar.survivorIconControllers;

		private UIElementAllocator<RectTransform> FillerIconControllers => characterSelectBar.fillerIcons;

		private MPEventSystemLocator EventSystemLocator => characterSelectBar.eventSystemLocator;

		private LocalUser LocalUser
		{
			get
			{
				EventSystem current = EventSystem.current;
				return ((MPEventSystem)(((current is MPEventSystem) ? current : null)?)).localUser;
			}
		}

		public int PageCount { get; private set; }

		public int CurrentPageIndex { get; private set; }

		public bool IsOnFirstPage => CurrentPageIndex == 0;

		public bool IsOnLastPage => PageCount == CurrentPageIndex + 1;

		private void RebuildPage()
		{
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Expected O, but got Unknown
			characterSelectBar.pickedIcon = null;
			IList<SurvivorDef> list;
			if (ScrollableLobbyUIPlugin.InlinePageArrows.Value)
			{
				if (PageCount == 1)
				{
					list = survivorDefList;
					((Component)inlinePreviousButtonComponent).gameObject.SetActive(false);
					((Component)inlineNextButtonComponent).gameObject.SetActive(false);
				}
				else if (IsOnFirstPage)
				{
					list = survivorDefList.Take(SurvivorsPerPage - 1).ToArray();
					((Component)inlinePreviousButtonComponent).gameObject.SetActive(false);
					((Component)inlineNextButtonComponent).gameObject.SetActive(true);
				}
				else
				{
					((Component)inlinePreviousButtonComponent).gameObject.SetActive(true);
					((Component)inlineNextButtonComponent).gameObject.SetActive(!IsOnLastPage);
					int num = SurvivorsPerPage - 2;
					list = survivorDefList.Skip(SurvivorsPerPage - 1 + num * (CurrentPageIndex - 1)).Take(IsOnLastPage ? (num + 1) : num).ToArray();
				}
				((Component)inlinePreviousButtonComponent).transform.SetSiblingIndex(0);
				RectTransform? obj = FillerIconControllers.elements.FirstOrDefault();
				int siblingIndex = ((obj != null) ? ((Transform)obj).GetSiblingIndex() : ((Component)inlineNextButtonComponent).transform.parent.childCount);
				((Component)inlineNextButtonComponent).transform.SetSiblingIndex(siblingIndex);
			}
			else
			{
				list = survivorDefList.Skip(CurrentPageIndex * SurvivorsPerPage).Take(SurvivorsPerPage).ToArray();
				if (Object.op_Implicit((Object)(object)arrowPreviousButtonComponent) && Object.op_Implicit((Object)(object)arrowNextButtonComponent))
				{
					((Selectable)arrowPreviousButtonComponent).interactable = !IsOnFirstPage;
					((Selectable)arrowNextButtonComponent).interactable = !IsOnLastPage;
				}
			}
			ReadOnlyCollection<SurvivorIconController> elements = SurvivorIconControllers.elements;
			for (int i = 0; i < elements.Count; i++)
			{
				SurvivorIconController val = elements[i];
				if (i >= list.Count)
				{
					((Component)val).gameObject.SetActive(false);
					continue;
				}
				((Component)val).gameObject.SetActive(true);
				SurvivorDef val2 = (val.survivorDef = list[i]);
				if ((Object)(object)pickedSurvivor == (Object)(object)val2)
				{
					characterSelectBar.pickedIcon = val;
				}
			}
			foreach (RectTransform element in FillerIconControllers.elements)
			{
				((Component)element).gameObject.SetActive(IsOnLastPage);
			}
			if (!Object.op_Implicit((Object)(object)buttonHistory) || !Object.op_Implicit((Object)(object)buttonHistory.lastRememberedGameObject) || !Object.op_Implicit((Object)(object)EventSystemLocator) || !Object.op_Implicit((Object)(object)EventSystemLocator.eventSystem))
			{
				return;
			}
			if (buttonHistory.lastRememberedGameObject.activeInHierarchy)
			{
				((Selectable)buttonHistory.lastRememberedGameObject.GetComponent<HGButton>()).OnSelect(new BaseEventData(EventSystem.current));
				return;
			}
			SurvivorIconController? obj2 = ((IEnumerable<SurvivorIconController>)elements).LastOrDefault((Func<SurvivorIconController, bool>)((SurvivorIconController el) => ((Component)el).gameObject.activeInHierarchy));
			if (obj2 != null)
			{
				((Selectable)((Component)obj2).GetComponent<HGButton>()).Select();
			}
		}

		private void GatherSurvivorsInfo()
		{
			if (survivorDefList.Count > 0)
			{
				return;
			}
			foreach (SurvivorDef orderedSurvivorDef in SurvivorCatalog.orderedSurvivorDefs)
			{
				if (characterSelectBar.ShouldDisplaySurvivor(orderedSurvivorDef))
				{
					survivorDefList.Add(orderedSurvivorDef);
				}
			}
		}

		private void PrepareContainer()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			Object.DestroyImmediate((Object)(object)((Component)this).GetComponent<AdjustGridLayoutCellSize>());
			LayoutElement component = ((Component)this).GetComponent<LayoutElement>();
			trackingHeightElements.Add(component);
			component.preferredWidth = float.MaxValue;
			LayoutElement item = ((Component)((Component)this).transform.parent).GetComponent<LayoutElement>() ?? ((Component)((Component)this).transform.parent).gameObject.AddComponent<LayoutElement>();
			trackingHeightElements.Add(item);
			ContentSizeFitter obj = ((Component)((Component)this).transform.parent).gameObject.AddComponent<ContentSizeFitter>();
			obj.verticalFit = (FitMode)2;
			obj.horizontalFit = (FitMode)0;
			GameObject val = new GameObject("SurvivorChoiceGridContainer");
			val.transform.SetParent(((Component)this).transform.parent, false);
			val.transform.SetSiblingIndex(2);
			((Component)this).transform.SetParent(val.transform, false);
			val.AddComponent<HorizontalLayoutGroup>();
			LayoutElement item2 = val.AddComponent<LayoutElement>();
			trackingHeightElements.Add(item2);
			IconContainerGrid.cellSize = new Vector2((float)ScrollableLobbyUIPlugin.CharacterIconSize.Value, (float)ScrollableLobbyUIPlugin.CharacterIconSize.Value);
			IconContainerGrid.constraint = (Constraint)1;
			((LayoutGroup)IconContainerGrid).childAlignment = (TextAnchor)4;
			Transform parent = ((Component)this).transform.parent;
			object obj2;
			if (parent == null)
			{
				obj2 = null;
			}
			else
			{
				Transform parent2 = parent.parent;
				obj2 = ((parent2 != null) ? parent2.parent : null);
			}
			VerticalLayoutGroup component2 = ((Component)obj2).GetComponent<VerticalLayoutGroup>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				RectOffset padding = ((LayoutGroup)component2).padding;
				((LayoutGroup)component2).padding = new RectOffset(padding.left, padding.right, 0, padding.bottom);
			}
		}

		private void AllocateCells()
		{
			SurvivorIconControllers.AllocateElements(Mathf.Min(SurvivorsPerPage, survivorDefList.Count));
			SurvivorIconController val = SurvivorIconControllers.elements.FirstOrDefault();
			if (Object.op_Implicit((Object)(object)val))
			{
				((Component)val).GetComponent<MPButton>().defaultFallbackButton = true;
			}
			FillerIconControllers.AllocateElements(fillerCount);
			FillerIconControllers.MoveElementsToContainerEnd();
		}

		private void SetupPagingStuff()
		{
			MPEventSystemLocator mpEventSystemLocator = ((Component)this).GetComponent<MPEventSystemLocator>();
			GameObject survivorChoiceGrid = ((Component)((Component)this).transform.parent).gameObject;
			UILayerKey uiLayerKey = survivorChoiceGrid.GetComponentInParent<UILayerKey>();
			arrowPreviousButtonComponent = SetupPagingButton("Previous", "Left", SelectPreviousPage, "UITabLeft", 0, 2);
			arrowNextButtonComponent = SetupPagingButton("Next", "Right", SelectNextPage, "UITabRight", 10, 6);
			inlinePreviousButtonComponent = SetupPagingButtonCharacterSlot("Previous", SelectPreviousPage, "UITabLeft", 0, 2, mpEventSystemLocator, survivorChoiceGrid, uiLayerKey);
			inlineNextButtonComponent = SetupPagingButtonCharacterSlot("Next", SelectNextPage, "UITabRight", 10, 6, mpEventSystemLocator, survivorChoiceGrid, uiLayerKey);
			HGButton SetupPagingButton(string prefix, string buttonPrefix, Action action, string actionName, int siblingIndex, int glyphIndex)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				//IL_0079: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Expected O, but got Unknown
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Expected O, but got Unknown
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Invalid comparison between Unknown and I4
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Expected O, but got Unknown
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0221: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: 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_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_028c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0299: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0374: Unknown result type (might be due to invalid IL or missing references)
				//IL_0379: Unknown result type (might be due to invalid IL or missing references)
				//IL_038b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0392: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03fa: Expected O, but got Unknown
				//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0404: Unknown result type (might be due to invalid IL or missing references)
				//IL_040f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0431: Unknown result type (might be due to invalid IL or missing references)
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_0484: Unknown result type (might be due to invalid IL or missing references)
				//IL_048e: Expected O, but got Unknown
				//IL_049c: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a6: Expected O, but got Unknown
				GameObject val = new GameObject(prefix + "ButtonContainer");
				val.SetActive(false);
				val.transform.SetParent(((Component)this).transform.parent, false);
				val.transform.SetSiblingIndex(siblingIndex);
				val.layer = 5;
				VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
				LayoutElement item = val.AddComponent<LayoutElement>();
				trackingHeightElements.Add(item);
				GameObject val2 = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)("RoR2/Base/UI/" + buttonPrefix + "Button.prefab")).WaitForCompletion(), val.transform, false);
				((Object)val2).name = prefix + "Page";
				val2.layer = 5;
				HGButton component = val2.GetComponent<HGButton>();
				((Button)component).onClick = new ButtonClickedEvent();
				((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(action.Invoke));
				LayoutElement component2 = val2.GetComponent<LayoutElement>();
				component2.preferredWidth = 37f;
				component2.minWidth = 37f;
				GameObject val3 = new GameObject(prefix + "Glyph");
				val3.transform.SetParent(val.transform, false);
				val3.layer = 5;
				val3.transform.SetSiblingIndex(0);
				val3.SetActive(Object.op_Implicit((Object)(object)mpEventSystemLocator.eventSystem) && (int)mpEventSystemLocator.eventSystem.currentInputSource == 1);
				RectTransform obj2 = val3.AddComponent<RectTransform>();
				obj2.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj2).localScale = new Vector3(1f, 1f, 1f);
				obj2.sizeDelta = new Vector2(0f, 0f);
				Image obj3 = val3.AddComponent<Image>();
				((Graphic)obj3).color = Color.white;
				((Behaviour)obj3).enabled = false;
				val3.AddComponent<LayoutElement>().minWidth = 37f;
				GameObject val4 = new GameObject("Text");
				val4.transform.SetParent(val3.transform);
				val4.layer = 5;
				RectTransform obj4 = val4.AddComponent<RectTransform>();
				obj4.anchorMin = new Vector2(0f, 0f);
				obj4.anchorMax = new Vector2(1f, 1f);
				obj4.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj4).localScale = new Vector3(1f, 1f, 1f);
				obj4.sizeDelta = new Vector2(48f, 48f);
				val4.AddComponent<MPEventSystemLocator>();
				InputBindingDisplayController obj5 = val4.AddComponent<InputBindingDisplayController>();
				obj5.actionName = actionName;
				obj5.axisRange = (AxisRange)0;
				obj5.useExplicitInputSource = true;
				obj5.explicitInputSource = (InputSource)1;
				LayoutElement obj6 = val4.AddComponent<LayoutElement>();
				obj6.preferredHeight = 37f;
				obj6.preferredWidth = 37f;
				TMP_FontAsset fontAsset = Addressables.LoadAssetAsync<TMP_FontAsset>((object)"RoR2/Base/Common/Fonts/Bombardier/tmpbombdropshadow.asset").WaitForCompletion();
				HGTextMeshProUGUI val5 = val4.AddComponent<HGTextMeshProUGUI>();
				((Graphic)val5).raycastTarget = false;
				((TMP_Text)val5).text = $"<sprite=\"tmpsprXboxOneGlyphs\" name=\"texXBoxOneGlyphs_{glyphIndex}\">";
				((TextMeshProUGUI)val5).UpdateFontAsset();
				((TMP_Text)val5).fontSize = 24f;
				((TMP_Text)val5).fontSizeMin = 18f;
				((TMP_Text)val5).fontSizeMax = 72f;
				((TMP_Text)val5).fontWeight = (FontWeight)400;
				((TMP_Text)val5).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val5).wordWrappingRatios = 0.4f;
				((TMP_Text)val5).overflowMode = (TextOverflowModes)0;
				((TMP_Text)val5).enableKerning = true;
				((TMP_Text)val5).richText = true;
				((TMP_Text)val5).parseCtrlCharacters = true;
				((TMP_Text)val5).isOrthographic = true;
				GameObject val6 = new GameObject("TMP SubMeshUI");
				val6.transform.SetParent(val4.transform);
				val6.layer = 5;
				RectTransform obj7 = val6.AddComponent<RectTransform>();
				obj7.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj7).localScale = new Vector3(1f, 1f, 1f);
				obj7.sizeDelta = new Vector2(0f, 0f);
				Material val7 = new Material(Addressables.LoadAssetAsync<Shader>((object)"TextMesh Pro/FormerResources/Shaders/TMP_Sprite.shader").WaitForCompletion());
				Texture val8 = Addressables.LoadAssetAsync<Texture>((object)"TextMesh Pro/FormerResources/Sprite Assets/texXBoxOneGlyphs.png").WaitForCompletion();
				val6.AddComponent<CanvasRenderer>().SetMaterial(val7, val8);
				TMP_SubMeshUI obj8 = val6.AddComponent<TMP_SubMeshUI>();
				obj8.fontAsset = fontAsset;
				obj8.spriteAsset = Addressables.LoadAssetAsync<TMP_SpriteAsset>((object)"TextMesh Pro/FormerResources/Sprite Assets/tmpsprXboxOneGlyphs.asset").WaitForCompletion();
				obj8.m_TextComponent = (TextMeshProUGUI)(object)val5;
				HGGamepadInputEvent val9 = survivorChoiceGrid.AddComponent<HGGamepadInputEvent>();
				val9.requiredTopLayer = uiLayerKey;
				val9.actionName = actionName;
				val9.enabledObjectsIfActive = (GameObject[])(object)new GameObject[1] { val3 };
				val9.actionEvent = new UnityEvent();
				val9.actionEvent.AddListener(new UnityAction(action.Invoke));
				val2.SetActive(true);
				return component;
			}
			HGButton SetupPagingButtonCharacterSlot(string prefix, Action action, string actionName, int siblingIndex, int glyphIndex, MPEventSystemLocator val11, GameObject val18, UILayerKey requiredTopLayer)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				//IL_004e: 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_0071: 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_00c1: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Expected O, but got Unknown
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0203: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0243: 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_0259: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_028c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0293: 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_02b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f1: Expected O, but got Unknown
				//IL_031d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03be: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0414: Unknown result type (might be due to invalid IL or missing references)
				//IL_0419: Unknown result type (might be due to invalid IL or missing references)
				//IL_0439: Unknown result type (might be due to invalid IL or missing references)
				//IL_043e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0455: Unknown result type (might be due to invalid IL or missing references)
				//IL_045a: Unknown result type (might be due to invalid IL or missing references)
				//IL_047d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0496: Unknown result type (might be due to invalid IL or missing references)
				//IL_049d: Expected O, but got Unknown
				//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e2: Invalid comparison between Unknown and I4
				//IL_0503: Unknown result type (might be due to invalid IL or missing references)
				//IL_051d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0531: Unknown result type (might be due to invalid IL or missing references)
				//IL_0543: Unknown result type (might be due to invalid IL or missing references)
				//IL_0569: Unknown result type (might be due to invalid IL or missing references)
				//IL_0570: Expected O, but got Unknown
				//IL_059d: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_061c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0629: Unknown result type (might be due to invalid IL or missing references)
				//IL_064f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0654: Unknown result type (might be due to invalid IL or missing references)
				//IL_0704: Unknown result type (might be due to invalid IL or missing references)
				//IL_0709: Unknown result type (might be due to invalid IL or missing references)
				//IL_071b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0722: Unknown result type (might be due to invalid IL or missing references)
				//IL_0738: Unknown result type (might be due to invalid IL or missing references)
				//IL_0752: Unknown result type (might be due to invalid IL or missing references)
				//IL_0766: Unknown result type (might be due to invalid IL or missing references)
				//IL_0775: Unknown result type (might be due to invalid IL or missing references)
				//IL_077a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0783: Unknown result type (might be due to invalid IL or missing references)
				//IL_078a: Expected O, but got Unknown
				//IL_078f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0794: Unknown result type (might be due to invalid IL or missing references)
				//IL_079f: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0809: Unknown result type (might be due to invalid IL or missing references)
				//IL_0813: Expected O, but got Unknown
				GameObject val = new GameObject(prefix + "ButtonContainer");
				val.SetActive(false);
				val.transform.SetParent(((Component)this).transform, false);
				val.transform.SetSiblingIndex(siblingIndex);
				val.layer = 5;
				val.AddComponent<RectTransform>().sizeDelta = new Vector2(48f, 48f);
				val.AddComponent<CanvasRenderer>();
				Image val2 = val.AddComponent<Image>();
				val2.sprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texUICleanButton.png").WaitForCompletion();
				val2.overrideSprite = val2.sprite;
				val2.type = (Type)1;
				val2.fillMethod = (FillMethod)4;
				HGButton val3 = val.AddComponent<HGButton>();
				((Selectable)val3).image = val2;
				((Selectable)val3).targetGraphic = (Graphic)(object)val2;
				((MPButton)val3).requiredTopLayer = requiredTopLayer;
				((Button)val3).onClick = new ButtonClickedEvent();
				((UnityEvent)((Button)val3).onClick).AddListener(new UnityAction(action.Invoke));
				((Selectable)val3).interactable = true;
				AnimationTriggers animationTriggers = ((Selectable)val3).animationTriggers;
				animationTriggers.normalTrigger = "Normal";
				animationTriggers.highlightedTrigger = "Highlighted";
				animationTriggers.pressedTrigger = "Pressed";
				animationTriggers.selectedTrigger = "Highlighted";
				animationTriggers.disabledTrigger = "Disabled";
				ButtonSkinController obj = val.AddComponent<ButtonSkinController>();
				obj.useRecommendedImage = true;
				obj.useRecommendedMaterial = true;
				obj.useRecommendedAlignment = true;
				obj.useRecommendedLabel = true;
				obj.useRecommendedButtonHeight = false;
				obj.useRecommendedButtonWidth = false;
				((BaseSkinController)obj).skinData = Addressables.LoadAssetAsync<UISkinData>((object)"RoR2/Base/UI/skinCleanButton.asset").WaitForCompletion();
				GameObject val4 = new GameObject("InteractableHighlight");
				val4.transform.SetParent(val.transform, false);
				val4.layer = 5;
				val4.AddComponent<RectTransform>().sizeDelta = new Vector2(72f, 72f);
				val4.AddComponent<CanvasRenderer>();
				Image val5 = val4.AddComponent<Image>();
				val5.sprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texUIOutlineOnly.png").WaitForCompletion();
				val5.overrideSprite = val5.sprite;
				val5.type = (Type)1;
				val5.fillMethod = (FillMethod)4;
				GameObject val6 = new GameObject("HoverHighlight");
				val6.transform.SetParent(val.transform, false);
				val6.layer = 5;
				RectTransform obj2 = val6.AddComponent<RectTransform>();
				obj2.sizeDelta = new Vector2(8f, 8f);
				((Transform)obj2).localScale = new Vector3(1.1f, 1.1f, 1.1f);
				obj2.anchoredPosition = new Vector2(4f, -4f);
				obj2.anchorMin = Vector2.zeroVector;
				obj2.anchorMax = Vector2.oneVector;
				obj2.offsetMin = new Vector2(0f, -8f);
				obj2.offsetMax = new Vector2(8f, 0f);
				val6.AddComponent<Canvas>();
				val6.AddComponent<RefreshCanvasDrawOrder>().canvasSortingOrderDelta = 1;
				val6.AddComponent<CanvasRenderer>();
				Image val7 = val6.AddComponent<Image>();
				val7.sprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texUIHighlightBoxOutlineThick.png").WaitForCompletion();
				val7.overrideSprite = val7.sprite;
				val7.type = (Type)1;
				val7.fillMethod = (FillMethod)4;
				GameObject val8 = new GameObject("ArrowText");
				val8.transform.SetParent(val.transform, false);
				val8.layer = 5;
				val8.AddComponent<RectTransform>().anchoredPosition = new Vector2(0f, 2f);
				val8.AddComponent<CanvasRenderer>();
				HGTextMeshProUGUI val9 = val8.AddComponent<HGTextMeshProUGUI>();
				if (prefix == "Next")
				{
					((TMP_Text)val9).text = ">";
				}
				else
				{
					((TMP_Text)val9).text = "<";
				}
				((TMP_Text)val9).fontSize = 56f;
				((TMP_Text)val9).fontSizeMin = 55f;
				((TMP_Text)val9).fontSizeMax = 57f;
				((TMP_Text)val9).enableKerning = true;
				((TMP_Text)val9).enableAutoSizing = true;
				((Graphic)val9).raycastTarget = false;
				val3.imageOnHover = val7;
				val3.imageOnInteractable = val5;
				((MPButton)val3).allowAllEventSystems = true;
				((MPButton)val3).submitOnPointerUp = true;
				ColorBlock colors = ((Selectable)val3).colors;
				((ColorBlock)(ref colors)).normalColor = Color32.op_Implicit(new Color32((byte)83, (byte)103, (byte)120, byte.MaxValue));
				((ColorBlock)(ref colors)).highlightedColor = Color32.op_Implicit(new Color32((byte)252, byte.MaxValue, (byte)177, (byte)187));
				((ColorBlock)(ref colors)).pressedColor = Color32.op_Implicit(new Color32((byte)189, (byte)192, (byte)113, (byte)251));
				((ColorBlock)(ref colors)).selectedColor = Color32.op_Implicit(new Color32((byte)252, byte.MaxValue, (byte)177, (byte)187));
				((ColorBlock)(ref colors)).disabledColor = Color32.op_Implicit(new Color32((byte)65, (byte)51, (byte)51, (byte)182));
				((ColorBlock)(ref colors)).colorMultiplier = 1f;
				((ColorBlock)(ref colors)).fadeDuration = 0f;
				((Selectable)val3).colors = colors;
				val3.showImageOnHover = true;
				GameObject val10 = new GameObject(prefix + "Glyph");
				val10.transform.SetParent(val.transform, false);
				val10.layer = 5;
				val10.transform.SetSiblingIndex(0);
				val10.SetActive(Object.op_Implicit((Object)(object)val11.eventSystem) && (int)val11.eventSystem.currentInputSource == 1);
				RectTransform obj3 = val10.AddComponent<RectTransform>();
				obj3.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj3).localScale = new Vector3(1f, 1f, 1f);
				obj3.sizeDelta = new Vector2(0f, 0f);
				Image obj4 = val10.AddComponent<Image>();
				((Graphic)obj4).color = Color.white;
				((Behaviour)obj4).enabled = false;
				val10.AddComponent<LayoutElement>().minWidth = 37f;
				GameObject val12 = new GameObject("Text");
				val12.transform.SetParent(val10.transform);
				val12.layer = 5;
				RectTransform obj5 = val12.AddComponent<RectTransform>();
				obj5.anchorMin = new Vector2(0f, 0f);
				obj5.anchorMax = new Vector2(1f, 1f);
				obj5.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj5).localScale = new Vector3(1f, 1f, 1f);
				obj5.sizeDelta = new Vector2(48f, 48f);
				val12.AddComponent<MPEventSystemLocator>();
				InputBindingDisplayController obj6 = val12.AddComponent<InputBindingDisplayController>();
				obj6.actionName = actionName;
				obj6.axisRange = (AxisRange)0;
				obj6.useExplicitInputSource = true;
				obj6.explicitInputSource = (InputSource)1;
				LayoutElement obj7 = val12.AddComponent<LayoutElement>();
				obj7.preferredHeight = 37f;
				obj7.preferredWidth = 37f;
				TMP_FontAsset fontAsset = Addressables.LoadAssetAsync<TMP_FontAsset>((object)"RoR2/Base/Common/Fonts/Bombardier/tmpbombdropshadow.asset").WaitForCompletion();
				HGTextMeshProUGUI val13 = val12.AddComponent<HGTextMeshProUGUI>();
				((Graphic)val13).raycastTarget = false;
				((TMP_Text)val13).text = $"<sprite=\"tmpsprXboxOneGlyphs\" name=\"texXBoxOneGlyphs_{glyphIndex}\">";
				((TextMeshProUGUI)val13).UpdateFontAsset();
				((TMP_Text)val13).fontSize = 24f;
				((TMP_Text)val13).fontSizeMin = 18f;
				((TMP_Text)val13).fontSizeMax = 72f;
				((TMP_Text)val13).fontWeight = (FontWeight)400;
				((TMP_Text)val13).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val13).wordWrappingRatios = 0.4f;
				((TMP_Text)val13).overflowMode = (TextOverflowModes)0;
				((TMP_Text)val13).enableKerning = true;
				((TMP_Text)val13).richText = true;
				((TMP_Text)val13).parseCtrlCharacters = true;
				((TMP_Text)val13).isOrthographic = true;
				GameObject val14 = new GameObject("TMP SubMeshUI");
				val14.transform.SetParent(val12.transform);
				val14.layer = 5;
				RectTransform obj8 = val14.AddComponent<RectTransform>();
				obj8.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj8).localScale = new Vector3(1f, 1f, 1f);
				obj8.sizeDelta = new Vector2(0f, 0f);
				Material val15 = new Material(Addressables.LoadAssetAsync<Shader>((object)"TextMesh Pro/FormerResources/Shaders/TMP_Sprite.shader").WaitForCompletion());
				Texture val16 = Addressables.LoadAssetAsync<Texture>((object)"TextMesh Pro/FormerResources/Sprite Assets/texXBoxOneGlyphs.png").WaitForCompletion();
				val14.AddComponent<CanvasRenderer>().SetMaterial(val15, val16);
				TMP_SubMeshUI obj9 = val14.AddComponent<TMP_SubMeshUI>();
				obj9.fontAsset = fontAsset;
				obj9.spriteAsset = Addressables.LoadAssetAsync<TMP_SpriteAsset>((object)"TextMesh Pro/FormerResources/Sprite Assets/tmpsprXboxOneGlyphs.asset").WaitForCompletion();
				obj9.m_TextComponent = (TextMeshProUGUI)(object)val13;
				HGGamepadInputEvent val17 = val18.AddComponent<HGGamepadInputEvent>();
				val17.requiredTopLayer = requiredTopLayer;
				val17.actionName = actionName;
				val17.enabledObjectsIfActive = (GameObject[])(object)new GameObject[1] { val10 };
				val17.actionEvent = new UnityEvent();
				val10.AddComponent<VariantArrowToggler>().arrow = val8;
				val.SetActive(true);
				return val3;
			}
		}

		private void Awake()
		{
			buttonHistory = ((Component)this).GetComponent<HGButtonHistory>();
			characterSelectBar = ((Component)this).GetComponent<CharacterSelectBarController>();
			((UnityEvent<SurvivorPickInfo>)(object)characterSelectBar.onSurvivorPicked).AddListener((UnityAction<SurvivorPickInfo>)delegate(SurvivorPickInfo survivorInfo)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				pickedSurvivor = survivorInfo.pickedSurvivor;
			});
			PrepareContainer();
			SetupPagingStuff();
			UpdateHeights();
			SurvivorsPerRow = CalculateSurvivorsPerRow();
		}

		private void OnEnable()
		{
			ScrollableLobbyUIPlugin.CharacterSelectRows.SettingChanged += OnCharacterSelectRowsSettingsChanged;
			ScrollableLobbyUIPlugin.CharacterIconSize.SettingChanged += CharacterIconSizeSettingChanged;
			ScrollableLobbyUIPlugin.InlinePageArrows.SettingChanged += OnInlinePageArrowsSettingsChanged;
		}

		private void OnDisable()
		{
			ScrollableLobbyUIPlugin.CharacterSelectRows.SettingChanged -= OnCharacterSelectRowsSettingsChanged;
			ScrollableLobbyUIPlugin.CharacterIconSize.SettingChanged -= CharacterIconSizeSettingChanged;
			ScrollableLobbyUIPlugin.InlinePageArrows.SettingChanged -= OnInlinePageArrowsSettingsChanged;
		}

		private void OnCharacterSelectRowsSettingsChanged(object sender, EventArgs e)
		{
			SurvivorIconController? obj = SurvivorIconControllers.elements.FirstOrDefault();
			SurvivorDef item = ((obj != null) ? obj.survivorDef : null);
			int num = survivorDefList.IndexOf(item);
			if (num == -1)
			{
				CurrentPageIndex = 0;
			}
			else
			{
				int num2 = RecalculateSurvivorIndexWithInlineButtons(num);
				CurrentPageIndex = num2 / SurvivorsPerPage;
			}
			Build();
		}

		private void CharacterIconSizeSettingChanged(object sender, EventArgs e)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			IconContainerGrid.cellSize = new Vector2((float)ScrollableLobbyUIPlugin.CharacterIconSize.Value, (float)ScrollableLobbyUIPlugin.CharacterIconSize.Value);
			UpdateHeights();
		}

		private void OnInlinePageArrowsSettingsChanged(object sender, EventArgs e)
		{
			int survivorsPerRow = CalculateSurvivorsPerRow();
			int num = CurrentPageIndex * SurvivorsPerPage;
			SurvivorsPerRow = survivorsPerRow;
			CurrentPageIndex = num / SurvivorsPerPage;
			Build();
		}

		private void Update()
		{
			int num = CalculateSurvivorsPerRow();
			if (num != SurvivorsPerRow)
			{
				int num2 = CurrentPageIndex * SurvivorsPerPage;
				SurvivorsPerRow = num;
				CurrentPageIndex = num2 / SurvivorsPerPage;
				Build();
			}
		}

		private int CalculateSurvivorsPerRow()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)IconContainerGrid).transform.parent.parent.parent;
			Rect rect = ((RectTransform)((parent is RectTransform) ? parent : null)).rect;
			float width = ((Rect)(ref rect)).width;
			int num = ((!ScrollableLobbyUIPlugin.InlinePageArrows.Value) ? 12 : 0);
			int num2 = (int)(width + 4f - (float)num);
			int num3 = ScrollableLobbyUIPlugin.CharacterIconSize.Value + 4;
			int num4 = num2 % num3;
			int num5 = Math.Max(1, num2 / num3);
			if (!ScrollableLobbyUIPlugin.InlinePageArrows.Value)
			{
				if (num5 * SurvivorRows < survivorDefList.Count)
				{
					((Component)((Component)arrowPreviousButtonComponent).transform.parent).gameObject.SetActive(true);
					((Component)((Component)arrowNextButtonComponent).transform.parent).gameObject.SetActive(true);
					num5 = Math.Max(1, num5 - Mathf.CeilToInt((74f - (float)num4) / (float)(ScrollableLobbyUIPlugin.CharacterIconSize.Value + 4)));
				}
				else
				{
					((Component)((Component)arrowPreviousButtonComponent).transform.parent).gameObject.SetActive(false);
					((Component)((Component)arrowNextButtonComponent).transform.parent).gameObject.SetActive(false);
				}
			}
			else if (num5 * SurvivorRows < survivorDefList.Count)
			{
				num5 = Math.Max(SurvivorRows switch
				{
					1 => 3, 
					2 => 2, 
					_ => 1, 
				}, num5);
			}
			return num5;
		}

		private void UpdateHeights()
		{
			foreach (LayoutElement trackingHeightElement in trackingHeightElements)
			{
				trackingHeightElement.minHeight = ContainerHeight;
				trackingHeightElement.preferredHeight = ContainerHeight;
			}
		}

		internal void Build()
		{
			((Component)inlinePreviousButtonComponent).gameObject.SetActive(ScrollableLobbyUIPlugin.InlinePageArrows.Value);
			((Component)inlineNextButtonComponent).gameObject.SetActive(ScrollableLobbyUIPlugin.InlinePageArrows.Value);
			((Component)((Component)arrowPreviousButtonComponent).transform.parent).gameObject.SetActive(!ScrollableLobbyUIPlugin.InlinePageArrows.Value);
			((Component)((Component)arrowNextButtonComponent).transform.parent).gameObject.SetActive(!ScrollableLobbyUIPlugin.InlinePageArrows.Value);
			GatherSurvivorsInfo();
			if (ScrollableLobbyUIPlugin.InlinePageArrows.Value)
			{
				int count = survivorDefList.Count;
				int num = survivorDefList.Count - (SurvivorsPerPage - 1) * 2;
				_ = survivorDefList.Count;
				int num2 = ((survivorDefList.Count > SurvivorsPerPage) ? (2 + (num / (SurvivorsPerPage - 2) + ((num % (SurvivorsPerPage - 2) > 0) ? 1 : 0)) * 2) : 0);
				int num3 = num2;
				count += num3;
				PageCount = count / SurvivorsPerPage + ((count % SurvivorsPerPage > 0) ? 1 : 0);
				fillerCount = PageCount * SurvivorsPerPage - count;
			}
			else
			{
				int count2 = survivorDefList.Count;
				PageCount = count2 / SurvivorsPerPage + ((count2 % SurvivorsPerPage > 0) ? 1 : 0);
				fillerCount = PageCount * SurvivorsPerPage - count2;
			}
			CurrentPageIndex = Mathf.Clamp(CurrentPageIndex, 0, PageCount - 1);
			IconContainerGrid.constraintCount = SurvivorsPerRow;
			UpdateHeights();
			AllocateCells();
			RebuildPage();
		}

		internal void EnforceValidChoice()
		{
			if ((Object.op_Implicit((Object)(object)characterSelectBar.pickedIcon) && characterSelectBar.pickedIcon.survivorIsAvailable) || SurvivorIsAvailable(pickedSurvivor))
			{
				return;
			}
			int num = survivorDefList.IndexOf(pickedSurvivor);
			for (int num2 = -1; num2 < survivorDefList.Count; num2 *= -1)
			{
				int num3 = num + num2;
				if (0 <= num3 && num3 < survivorDefList.Count)
				{
					SurvivorDef val = survivorDefList[num3];
					if (SurvivorIsAvailable(val))
					{
						characterSelectBar.PickIconBySurvivorDef(val);
						break;
					}
				}
				if (num2 >= 0)
				{
					num2++;
				}
			}
		}

		private bool SurvivorIsAvailable(SurvivorDef survivorDef)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)survivorDef) && SurvivorCatalog.SurvivorIsUnlockedOnThisClient(survivorDef.survivorIndex) && survivorDef.CheckRequiredExpansionEnabled((NetworkUser)null))
			{
				return survivorDef.CheckUserHasRequiredEntitlement(LocalUser);
			}
			return false;
		}

		public void SelectNextPage()
		{
			if (!IsOnLastPage)
			{
				CurrentPageIndex++;
				RebuildPage();
			}
		}

		public void SelectPreviousPage()
		{
			if (!IsOnFirstPage)
			{
				CurrentPageIndex--;
				RebuildPage();
			}
		}

		public void OpenPageWithCharacter(SurvivorIndex survivorIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OpenPageWithCharacter(SurvivorCatalog.GetSurvivorDef(survivorIndex));
		}

		public void OpenPageWithCharacter(SurvivorDef survivorDef)
		{
			int num = survivorDefList.FindIndex((SurvivorDef el) => (Object)(object)el == (Object)(object)survivorDef);
			if (num != -1)
			{
				CurrentPageIndex = RecalculateSurvivorIndexWithInlineButtons(num) / SurvivorsPerPage;
				RebuildPage();
			}
		}

		private int RecalculateSurvivorIndexWithInlineButtons(int index)
		{
			if (!ScrollableLobbyUIPlugin.InlinePageArrows.Value)
			{
				return index;
			}
			if (PageCount == 1)
			{
				return index;
			}
			if (index == survivorDefList.Count)
			{
				return index + 2 + (PageCount - 2) * 2;
			}
			if (index < SurvivorsPerPage - 1)
			{
				return index;
			}
			int num = SurvivorsPerPage - 2;
			index -= SurvivorsPerPage - 1;
			while (index > 0)
			{
				num += 2;
				index -= SurvivorsPerPage - 2;
				num = ((index <= 0) ? (num + (SurvivorsPerPage - 2 + index)) : (num + (SurvivorsPerPage - 2)));
			}
			return num;
		}

		public CharacterSelectBarControllerExtra()
		{
			int num = ((!ScrollableLobbyUIPlugin.InlinePageArrows.Value) ? 1 : (ScrollableLobbyUIPlugin.CharacterSelectRows.Value switch
			{
				1 => 3, 
				2 => 2, 
				_ => 1, 
			}));
			SurvivorsPerRow = num;
			trackingHeightElements = new List<LayoutElement>();
			survivorDefList = new List<SurvivorDef>();
			PageCount = 1;
			((MonoBehaviour)this)..ctor();
		}
	}
	public class ClearTextOnDisable : MonoBehaviour
	{
		public List<LanguageTextMeshController> textObjects;

		private void OnDisable()
		{
			if (textObjects == null)
			{
				return;
			}
			foreach (LanguageTextMeshController textObject in textObjects)
			{
				if (Object.op_Implicit((Object)(object)textObject))
				{
					textObject.token = string.Empty;
				}
			}
		}
	}
	public class ConstrainedScrollRect : ScrollRect
	{
		public enum Constraint
		{
			None,
			OnlyDrag,
			OnlyScroll
		}

		public Constraint scrollConstraint;

		public ScrollRect redirectConstrained;

		private void RedirectEvent<T>(Action<T> action) where T : IEventSystemHandler
		{
			if (Object.op_Implicit((Object)(object)redirectConstrained))
			{
				T[] components = ((Component)redirectConstrained).GetComponents<T>();
				foreach (T obj in components)
				{
					action(obj);
				}
			}
		}

		public override void OnInitializePotentialDrag(PointerEventData eventData)
		{
			RedirectEvent<IInitializePotentialDragHandler>((Action<IInitializePotentialDragHandler>)delegate(IInitializePotentialDragHandler redirectObject)
			{
				redirectObject.OnInitializePotentialDrag(eventData);
			});
			((ScrollRect)this).OnInitializePotentialDrag(eventData);
		}

		public override void OnDrag(PointerEventData eventData)
		{
			if (scrollConstraint == Constraint.OnlyScroll)
			{
				RedirectEvent<IDragHandler>((Action<IDragHandler>)delegate(IDragHandler redirectObject)
				{
					redirectObject.OnDrag(eventData);
				});
			}
			else
			{
				((ScrollRect)this).OnDrag(eventData);
			}
		}

		public override void OnBeginDrag(PointerEventData eventData)
		{
			if (scrollConstraint == Constraint.OnlyScroll)
			{
				RedirectEvent<IBeginDragHandler>((Action<IBeginDragHandler>)delegate(IBeginDragHandler redirectObject)
				{
					redirectObject.OnBeginDrag(eventData);
				});
			}
			else
			{
				((ScrollRect)this).OnBeginDrag(eventData);
			}
		}

		public override void OnEndDrag(PointerEventData eventData)
		{
			if (scrollConstraint == Constraint.OnlyScroll)
			{
				RedirectEvent<IEndDragHandler>((Action<IEndDragHandler>)delegate(IEndDragHandler redirectObject)
				{
					redirectObject.OnEndDrag(eventData);
				});
			}
			else
			{
				((ScrollRect)this).OnEndDrag(eventData);
			}
		}

		public override void OnScroll(PointerEventData eventData)
		{
			if (scrollConstraint == Constraint.OnlyDrag)
			{
				RedirectEvent<IScrollHandler>((Action<IScrollHandler>)delegate(IScrollHandler redirectObject)
				{
					redirectObject.OnScroll(eventData);
				});
			}
			else
			{
				((ScrollRect)this).OnScroll(eventData);
			}
		}
	}
	public class ContinuousScrollOnPress : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler
	{
		public float sensitivity = 150f;

		public MoveDirection moveDirection = (MoveDirection)4;

		public ScrollRect scrollRect;

		private bool mouseDown;

		private HGButton button;

		private void Awake()
		{
			button = ((Component)this).GetComponent<HGButton>();
		}

		private void OnEnable()
		{
			mouseDown = false;
		}

		private void Update()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected I4, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00c2: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (mouseDown && ((Selectable)button).interactable)
			{
				float num = sensitivity * Time.deltaTime;
				MoveDirection val = moveDirection;
				switch ((int)val)
				{
				case 0:
				{
					RectTransform content4 = scrollRect.content;
					((Transform)content4).localPosition = ((Transform)content4).localPosition - new Vector3(num, 0f);
					break;
				}
				case 1:
				{
					RectTransform content3 = scrollRect.content;
					((Transform)content3).localPosition = ((Transform)content3).localPosition + new Vector3(0f, num);
					break;
				}
				case 2:
				{
					RectTransform content2 = scrollRect.content;
					((Transform)content2).localPosition = ((Transform)content2).localPosition + new Vector3(num, 0f);
					break;
				}
				case 3:
				{
					RectTransform content = scrollRect.content;
					((Transform)content).localPosition = ((Transform)content).localPosition - new Vector3(0f, num);
					break;
				}
				}
			}
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			mouseDown = true;
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			mouseDown = false;
		}
	}
	public class CoroutineOnStart : MonoBehaviour
	{
		public IEnumerator coroutine;

		public void Start()
		{
			if (coroutine != null)
			{
				((MonoBehaviour)this).StartCoroutine(coroutine);
				coroutine = null;
			}
		}
	}
	[RequireComponent(typeof(LayoutElement))]
	public class DynamicContentSizeFitter : MonoBehaviour
	{
		private LayoutElement layoutElement;

		public RectTransform watchTransform;

		public float maxWidth = -1f;

		public float maxHeight = -1f;

		public bool useMaxHeight;

		public bool useMaxWidth;

		public float MaxHeight
		{
			get
			{
				if (!(maxHeight < 0f))
				{
					return maxHeight;
				}
				return float.MaxValue;
			}
		}

		public float MaxWidth
		{
			get
			{
				if (!(maxWidth < 0f))
				{
					return maxWidth;
				}
				return float.MaxValue;
			}
		}

		private void Start()
		{
			layoutElement = ((Component)this).GetComponent<LayoutElement>();
		}

		private void OnGUI()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)watchTransform))
			{
				Rect rect = watchTransform.rect;
				if (useMaxWidth)
				{
					layoutElement.preferredWidth = Mathf.Min(((Rect)(ref rect)).width, MaxWidth);
				}
				if (useMaxHeight)
				{
					layoutElement.preferredHeight = Mathf.Min(((Rect)(ref rect)).height, MaxHeight);
				}
			}
		}
	}
	internal class GamepadScrollRectHelper : MonoBehaviour
	{
		public UILayerKey requiredTopLayer;

		public float stickScale = 3000f;

		private ScrollRect scrollRect;

		private MPEventSystemLocator eventSystemLocator;

		private void Start()
		{
			scrollRect = ((Component)this).GetComponent<ScrollRect>();
			eventSystemLocator = ((Component)this).GetComponent<MPEventSystemLocator>();
		}

		private bool GamepadIsCurrentInputSource()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)eventSystemLocator) && Object.op_Implicit((Object)(object)eventSystemLocator.eventSystem))
			{
				return (int)eventSystemLocator.eventSystem.currentInputSource == 1;
			}
			return false;
		}

		private bool CanAcceptInput()
		{
			if (Object.op_Implicit((Object)(object)requiredTopLayer))
			{
				return requiredTopLayer.representsTopLayer;
			}
			return true;
		}

		private void Update()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (GamepadIsCurrentInputSource() && CanAcceptInput())
			{
				Rect rect = scrollRect.content.rect;
				float height = ((Rect)(ref rect)).height;
				float axis = eventSystemLocator.eventSystem.player.GetAxis(13);
				scrollRect.verticalNormalizedPosition = Mathf.Clamp01(scrollRect.verticalNormalizedPosition + axis * stickScale * Time.unscaledDeltaTime / height);
			}
		}
	}
	public static class InLobbyConfigIntegration
	{
		public const string GUID = "com.KingEnderBrine.InLobbyConfig";

		private static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig");

		private static object ModConfig { get; set; }

		public static void OnStart()
		{
			if (Enabled)
			{
				OnStartInternal();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void OnStartInternal()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Expected O, but got Unknown
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			ModConfigEntry val = new ModConfigEntry();
			val.DisplayName = "Scrollable lobby UI";
			string section = ((ConfigEntryBase)ScrollableLobbyUIPlugin.CharacterSelectRows).Definition.Section;
			val.SectionFields[section] = (IEnumerable<IConfigField>)(object)new IConfigField[6]
			{
				(IConfigField)new IntConfigField(((ConfigEntryBase)ScrollableLobbyUIPlugin.CharacterSelectRows).Definition.Key, ((ConfigEntryBase)ScrollableLobbyUIPlugin.CharacterSelectRows).Description.Description, (Func<int>)(() => ScrollableLobbyUIPlugin.CharacterSelectRows.Value), (Action<int>)null, (Action<int>)delegate(int newValue)
				{
					ScrollableLobbyUIPlugin.CharacterSelectRows.Value = newValue;
				}, (int?)1, (int?)50),
				(IConfigField)new IntConfigField(((ConfigEntryBase)ScrollableLobbyUIPlugin.CharacterIconSize).Definition.Key, ((ConfigEntryBase)ScrollableLobbyUIPlugin.CharacterIconSize).Description.Description, (Func<int>)(() => ScrollableLobbyUIPlugin.CharacterIconSize.Value), (Action<int>)null, (Action<int>)delegate(int newValue)
				{
					ScrollableLobbyUIPlugin.CharacterIconSize.Value = newValue;
				}, (int?)1, (int?)500),
				(IConfigField)new BooleanConfigField(((ConfigEntryBase)ScrollableLobbyUIPlugin.InlinePageArrows).Definition.Key, ((ConfigEntryBase)ScrollableLobbyUIPlugin.InlinePageArrows).Description.Description, (Func<bool>)(() => ScrollableLobbyUIPlugin.InlinePageArrows.Value), (Action<bool>)delegate(bool newValue)
				{
					ScrollableLobbyUIPlugin.InlinePageArrows.Value = newValue;
				}),
				(IConfigField)new BooleanConfigField(((ConfigEntryBase)ScrollableLobbyUIPlugin.ScrollRowsWithMouseWheel).Definition.Key, ((ConfigEntryBase)ScrollableLobbyUIPlugin.ScrollRowsWithMouseWheel).Description.Description, (Func<bool>)(() => ScrollableLobbyUIPlugin.ScrollRowsWithMouseWheel.Value), (Action<bool>)delegate(bool newValue)
				{
					ScrollableLobbyUIPlugin.ScrollRowsWithMouseWheel.Value = newValue;
				}),
				(IConfigField)new IntConfigField(((ConfigEntryBase)ScrollableLobbyUIPlugin.SkillRowHeight).Definition.Key, ((ConfigEntryBase)ScrollableLobbyUIPlugin.SkillRowHeight).Description.Description, (Func<int>)(() => ScrollableLobbyUIPlugin.SkillRowHeight.Value), (Action<int>)null, (Action<int>)delegate(int newValue)
				{
					ScrollableLobbyUIPlugin.SkillRowHeight.Value = newValue;
				}, (int?)1, (int?)320),
				(IConfigField)new IntConfigField(((ConfigEntryBase)ScrollableLobbyUIPlugin.SkillCountForGridButton).Definition.Key, ((ConfigEntryBase)ScrollableLobbyUIPlugin.SkillCountForGridButton).Description.Description, (Func<int>)(() => ScrollableLobbyUIPlugin.SkillCountForGridButton.Value), (Action<int>)null, (Action<int>)delegate(int newValue)
				{
					ScrollableLobbyUIPlugin.SkillCountForGridButton.Value = newValue;
				}, (int?)1, (int?)int.MaxValue)
			};
			ModConfigCatalog.Add(val);
			ModConfig = val;
		}
	}
	public class LoadoutButtonInfo : MonoBehaviour
	{
		public LoadoutRowInfo row;

		private void Start()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((MPButton)((Component)this).GetComponent<HGButton>()).onSelect.AddListener((UnityAction)delegate
			{
				LoadoutSkillGridController.Instance.selectedButton = this;
				LoadoutRowInfo.selectedRow = row;
			});
		}
	}
	public class LoadoutRowInfo : MonoBehaviour
	{
		public Row row;

		private GameObject skillGrid;

		private bool couldAcceptInput;

		private bool wasSelected;

		private MPEventSystemLocator locator;

		private GameObject glyph;

		private UILayerKey requiredTopLayer;

		public static LoadoutRowInfo selectedRow;

		private void Start()
		{
			MakeButton();
			SkillCountForGridButton_SettingChanged(null, null);
			ScrollableLobbyUIPlugin.SkillCountForGridButton.SettingChanged += SkillCountForGridButton_SettingChanged;
		}

		private void MakeButton()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0090: 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_00c0: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00f4: 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: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: 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_024d: 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_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0682: Expected O, but got Unknown
			//IL_0687: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			skillGrid = new GameObject("SkillGridButton");
			skillGrid.transform.SetParent(((Component)this).transform, false);
			RectTransform obj = skillGrid.AddComponent<RectTransform>();
			obj.anchoredPosition = new Vector2(0f, 0f);
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 0.5f);
			obj.sizeDelta = new Vector2(20f, 0f);
			skillGrid.AddComponent<RectMask2D>();
			VerticalLayoutGroup obj2 = skillGrid.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(4, 0, 8, 8);
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f;
			GameObject val = new GameObject("Button");
			val.transform.SetParent(skillGrid.transform, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = Color.clear;
			LayoutElement obj3 = val.AddComponent<LayoutElement>();
			obj3.minWidth = 24f;
			obj3.flexibleHeight = 10000f;
			HGButton obj4 = val.AddComponent<HGButton>();
			((UnityEvent)((Button)obj4).onClick).AddListener((UnityAction)delegate
			{
				LoadoutSkillGridController.Instance?.Show(row);
			});
			((Selectable)obj4).targetGraphic = (Graphic)(object)val2;
			GameObject val3 = new GameObject("Text");
			val3.transform.SetParent(val.transform, false);
			RectTransform obj5 = val3.AddComponent<RectTransform>();
			obj5.anchorMin = new Vector2(0f, 0f);
			obj5.anchorMax = new Vector2(1f, 1f);
			obj5.offsetMin = new Vector2(0f, 0f);
			obj5.offsetMax = new Vector2(0f, 0f);
			obj5.pivot = new Vector2(0.5f, 0.5f);
			((Transform)obj5).Rotate(Vector3.forward, 270f);
			HGTextMeshProUGUI obj6 = val3.AddComponent<HGTextMeshProUGUI>();
			((TMP_Text)obj6).text = "···";
			((TMP_Text)obj6).alignment = (TextAlignmentOptions)514;
			((TMP_Text)obj6).enableAutoSizing = true;
			((TMP_Text)obj6).fontSizeMin = 3f;
			((TMP_Text)obj6).fontSizeMax = 72f;
			((TMP_Text)obj6).fontWeight = (FontWeight)700;
			((TMP_Text)obj6).fontStyle = (FontStyles)1;
			GameObject val4 = new GameObject("BaseOutline");
			val4.transform.SetParent(val.transform, false);
			RectTransform obj7 = val4.AddComponent<RectTransform>();
			obj7.anchorMin = new Vector2(0f, 0f);
			obj7.anchorMax = new Vector2(1f, 1f);
			obj7.offsetMin = new Vector2(0f, 0f);
			obj7.offsetMax = new Vector2(0f, 0f);
			obj7.pivot = new Vector2(0.5f, 0.5f);
			Image obj8 = val4.AddComponent<Image>();
			obj8.sprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texUIOutlineOnly.png").WaitForCompletion();
			obj8.type = (Type)1;
			GameObject val5 = new GameObject("HoverOutline");
			val5.transform.SetParent(val.transform, false);
			RectTransform obj9 = val5.AddComponent<RectTransform>();
			obj9.anchorMin = new Vector2(0f, 0f);
			obj9.anchorMax = new Vector2(1f, 1f);
			obj9.offsetMin = new Vector2(0f, -8f);
			obj9.offsetMax = new Vector2(8f, 0f);
			obj9.pivot = new Vector2(0.5f, 0.5f);
			Image val6 = val5.AddComponent<Image>();
			val6.sprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/texUIHighlightBoxOutlineThick.png").WaitForCompletion();
			val6.type = (Type)1;
			obj4.imageOnHover = val6;
			obj4.showImageOnHover = true;
			glyph = new GameObject("Glyph");
			glyph.transform.SetParent(skillGrid.transform, false);
			glyph.layer = 5;
			glyph.transform.SetSiblingIndex(0);
			glyph.SetActive(false);
			RectTransform obj10 = glyph.AddComponent<RectTransform>();
			obj10.anchoredPosition3D = new Vector3(0f, 0f, 0f);
			((Transform)obj10).localScale = new Vector3(1f, 1f, 1f);
			obj10.sizeDelta = new Vector2(0f, 0f);
			Image obj11 = glyph.AddComponent<Image>();
			((Graphic)obj11).color = Color.white;
			((Behaviour)obj11).enabled = false;
			LayoutElement obj12 = glyph.AddComponent<LayoutElement>();
			obj12.minWidth = 24f;
			obj12.minHeight = 24f;
			GameObject val7 = new GameObject("Text");
			val7.transform.SetParent(glyph.transform);
			val7.layer = 5;
			RectTransform obj13 = val7.AddComponent<RectTransform>();
			obj13.anchorMin = new Vector2(0f, 0f);
			obj13.anchorMax = new Vector2(1f, 1f);
			obj13.anchoredPosition3D = new Vector3(0f, 0f, 0f);
			((Transform)obj13).localScale = new Vector3(1f, 1f, 1f);
			obj13.sizeDelta = new Vector2(24f, 24f);
			val7.AddComponent<MPEventSystemLocator>();
			InputBindingDisplayController obj14 = val7.AddComponent<InputBindingDisplayController>();
			obj14.actionName = "Sprint";
			obj14.axisRange = (AxisRange)0;
			obj14.useExplicitInputSource = true;
			obj14.explicitInputSource = (InputSource)1;
			obj14.Awake();
			LayoutElement obj15 = val7.AddComponent<LayoutElement>();
			obj15.preferredHeight = 24f;
			obj15.preferredWidth = 24f;
			TMP_FontAsset fontAsset = Addressables.LoadAssetAsync<TMP_FontAsset>((object)"RoR2/Base/Common/Fonts/Bombardier/tmpbombdropshadow.asset").WaitForCompletion();
			HGTextMeshProUGUI val8 = val7.AddComponent<HGTextMeshProUGUI>();
			((Graphic)val8).raycastTarget = false;
			((TextMeshProUGUI)val8).UpdateFontAsset();
			((TMP_Text)val8).fontSize = 24f;
			((TMP_Text)val8).fontSizeMin = 18f;
			((TMP_Text)val8).fontSizeMax = 72f;
			((TMP_Text)val8).fontWeight = (FontWeight)400;
			((TMP_Text)val8).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val8).wordWrappingRatios = 0.4f;
			((TMP_Text)val8).overflowMode = (TextOverflowModes)0;
			((TMP_Text)val8).enableKerning = true;
			((TMP_Text)val8).richText = true;
			((TMP_Text)val8).parseCtrlCharacters = true;
			((TMP_Text)val8).isOrthographic = true;
			GameObject val9 = new GameObject("TMP SubMeshUI");
			val9.transform.SetParent(val7.transform);
			val9.layer = 5;
			RectTransform obj16 = val9.AddComponent<RectTransform>();
			obj16.anchoredPosition3D = new Vector3(0f, 0f, 0f);
			((Transform)obj16).localScale = new Vector3(1f, 1f, 1f);
			obj16.sizeDelta = new Vector2(0f, 0f);
			Material val10 = new Material(Addressables.LoadAssetAsync<Shader>((object)"TextMesh Pro/FormerResources/Shaders/TMP_Sprite.shader").WaitForCompletion());
			Texture val11 = Addressables.LoadAssetAsync<Texture>((object)"TextMesh Pro/FormerResources/Sprite Assets/texXBoxOneGlyphs.png").WaitForCompletion();
			val9.AddComponent<CanvasRenderer>().SetMaterial(val10, val11);
			TMP_SubMeshUI obj17 = val9.AddComponent<TMP_SubMeshUI>();
			obj17.fontAsset = fontAsset;
			obj17.spriteAsset = Addressables.LoadAssetAsync<TMP_SpriteAsset>((object)"TextMesh Pro/FormerResources/Sprite Assets/tmpsprXboxOneGlyphs.asset").WaitForCompletion();
			obj17.m_TextComponent = (TextMeshProUGUI)(object)val8;
			requiredTopLayer = ((Component)this).GetComponentInParent<UILayerKey>();
			if (!((Component)this).TryGetComponent<MPEventSystemLocator>(ref locator))
			{
				locator = ((Component)this).gameObject.AddComponent<MPEventSystemLocator>();
			}
		}

		private void Update()
		{
			bool flag = CanAcceptInput();
			bool flag2 = (Object)(object)this == (Object)(object)selectedRow;
			if (couldAcceptInput != flag || flag2 != wasSelected)
			{
				glyph.SetActive(flag && flag2);
			}
			couldAcceptInput = flag;
			wasSelected = flag2;
		}

		public bool CanShowGrid()
		{
			return skillGrid.activeSelf;
		}

		protected bool CanAcceptInput()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			if (((Component)this).gameObject.activeInHierarchy && (!Object.op_Implicit((Object)(object)requiredTopLayer) || requiredTopLayer.representsTopLayer))
			{
				MPEventSystem eventSystem = locator.eventSystem;
				if (Object.op_Implicit((Object)(object)eventSystem))
				{
					return (int)eventSystem.currentInputSource == 1;
				}
				return false;
			}
			return false;
		}

		private void OnDestroy()
		{
			ScrollableLobbyUIPlugin.SkillCountForGridButton.SettingChanged -= SkillCountForGridButton_SettingChanged;
			if ((Object)(object)selectedRow == (Object)(object)this)
			{
				selectedRow = null;
			}
		}

		private void SkillCountForGridButton_SettingChanged(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)skillGrid))
			{
				skillGrid.SetActive(row.rowData.Count >= ScrollableLobbyUIPlugin.SkillCountForGridButton.Value);
			}
		}
	}
	public class LoadoutSkillGridController : MonoBehaviour
	{
		private GameObject scrollPanel;

		private GameObject panel;

		public GameObject infoPanel;

		private UIElementAllocator<SkillGridButton> buttons;

		private GameObject buttonPrefab;

		private Row currentRow;

		private LoadoutButtonInfo currentButton;

		private Transform choiceHighlightRect;

		private MPEventSystemLocator locator;

		private LanguageTextMeshController headerLanguageController;

		public LoadoutButtonInfo selectedButton;

		public static LoadoutSkillGridController Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			UserProfile.onLoadoutChangedGlobal += OnLoadoutChangedGlobal;
		}

		public void Start()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Expected O, but got Unknown
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Expected O, but got Unknown
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Expected O, but got Unknown
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Expected O, but got Unknown
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Expected O, but got Unknown
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Expected O, but got Unknown
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Expected O, but got Unknown
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_0583: Expected O, but got Unknown
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Expected O, but got Unknown
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Expected O, but got Unknown
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Expected O, but got Unknown
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Expected O, but got Unknown
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Expected O, but got Unknown
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Expected O, but got Unknown
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.SetAsLastSibling();
			locator = ((Component)this).gameObject.AddComponent<MPEventSystemLocator>();
			CharacterSelectController componentInParent = infoPanel.GetComponentInParent<CharacterSelectController>();
			Transform val = ((Component)componentInParent).transform.Find("SafeArea/RightHandPanel/PopoutPanelContainer/PopoutPanelPrefab");
			scrollPanel = new GameObject("ScrollPanel");
			scrollPanel.SetActive(false);
			scrollPanel.transform.SetParent(((Component)this).transform, false);
			RectTransform obj = scrollPanel.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.sizeDelta = new Vector2(0f, 0f);
			obj.pivot = new Vector2(0.5f, 0f);
			VerticalLayoutGroup obj2 = scrollPanel.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(12, 12, 4, 4);
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			GameObject val2 = new GameObject("Header");
			val2.transform.SetParent(scrollPanel.transform, false);
			RectTransform obj3 = val2.AddComponent<RectTransform>();
			obj3.anchorMin = new Vector2(0f, 0f);
			obj3.anchorMax = new Vector2(1f, 1f);
			obj3.sizeDelta = new Vector2(0f, 0f);
			obj3.pivot = new Vector2(0.5f, 0f);
			val2.AddComponent<LayoutElement>();
			((LayoutGroup)val2.AddComponent<HorizontalLayoutGroup>()).padding = new RectOffset(80, 80, 0, 0);
			GameObject val3 = new GameObject("Text");
			val3.transform.SetParent(val2.transform, false);
			HGTextMeshProUGUI val4 = val3.AddComponent<HGTextMeshProUGUI>();
			((TMP_Text)val4).fontSizeMin = 12f;
			((TMP_Text)val4).fontSizeMax = 24f;
			((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
			val3.SetActive(false);
			headerLanguageController = val3.AddComponent<LanguageTextMeshController>();
			headerLanguageController.token = "";
			headerLanguageController.textMeshPro = (TMP_Text)(object)val4;
			val3.SetActive(true);
			GameObject headerButtonObj = Object.Instantiate<GameObject>(((Component)val.Find("Canvas/Main/CancelButton")).gameObject, val2.transform, false);
			headerButtonObj.transform.SetParent(val2.transform, false);
			HGButton component = headerButtonObj.GetComponent<HGButton>();
			((Button)component).onClick = new ButtonClickedEvent();
			((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(Hide));
			GameObject val5 = new GameObject("ViewPort");
			val5.transform.SetParent(scrollPanel.transform, false);
			RectTransform val6 = val5.AddComponent<RectTransform>();
			val6.anchorMin = new Vector2(0f, 0f);
			val6.anchorMax = new Vector2(1f, 1f);
			val6.sizeDelta = new Vector2(0f, 0f);
			val6.pivot = new Vector2(0.5f, 0f);
			val6.offsetMin = new Vector2(12f, 12f);
			val6.offsetMax = new Vector2(-12f, -12f);
			val5.AddComponent<LayoutElement>().flexibleHeight = 10000f;
			panel = new GameObject("Panel");
			panel.transform.SetParent(val5.transform, false);
			RectTransform val7 = panel.AddComponent<RectTransform>();
			val7.anchorMin = new Vector2(0f, 0f);
			val7.anchorMax = new Vector2(1f, 1f);
			val7.sizeDelta = new Vector2(0f, 0f);
			val7.pivot = new Vector2(0.5f, 1f);
			TranslucentImage obj4 = scrollPanel.AddComponent<TranslucentImage>();
			((Graphic)obj4).color = Color.black;
			obj4.flatten = 0.2f;
			((Graphic)obj4).material = Addressables.LoadAssetAsync<Material>((object)"TranslucentImage/Default-Translucent.mat").WaitForCompletion();
			val5.AddComponent<RectMask2D>();
			ScrollRect obj5 = scrollPanel.AddComponent<ScrollRect>();
			obj5.horizontal = false;
			obj5.content = val7;
			obj5.viewport = val6;
			obj5.scrollSensitivity = 30f;
			obj5.movementType = (MovementType)2;
			UILayer val8 = ScriptableObject.CreateInstance<UILayer>();
			val8.priority = 20;
			LoadoutPanelController componentInChildren = infoPanel.GetComponentInChildren<LoadoutPanelController>();
			GameObject descriptionText = ((Component)((Component)componentInChildren.hoverTextDescription).transform.parent).gameObject;
			((UnityEvent<SurvivorPickInfo>)(object)componentInParent.characterSelectBarController.onSurvivorPicked).AddListener((UnityAction<SurvivorPickInfo>)delegate
			{
				Hide();
			});
			OnDisableEvent obj6 = ((Component)componentInChildren).gameObject.AddComponent<OnDisableEvent>();
			obj6.action = new UnityEvent();
			obj6.action.AddListener(new UnityAction(Hide));
			UILayerKey val9 = panel.AddComponent<UILayerKey>();
			val9.layer = val8;
			val9.onBeginRepresentTopLayer = new UnityEvent();
			val9.onBeginRepresentTopLayer.AddListener((UnityAction)delegate
			{
				descriptionText.SetActive(true);
			});
			val9.onEndRepresentTopLayer = new UnityEvent();
			val9.onEndRepresentTopLayer.AddListener((UnityAction)delegate
			{
				descriptionText.SetActive(false);
			});
			GameObject val10 = new GameObject();
			val10.SetActive(false);
			val10.transform.SetParent(scrollPanel.transform, false);
			OnDisableEvent obj7 = val10.AddComponent<OnDisableEvent>();
			obj7.action = new UnityEvent();
			obj7.action.AddListener((UnityAction)delegate
			{
				headerButtonObj.SetActive(true);
			});
			OnEnableEvent obj8 = val10.AddComponent<OnEnableEvent>();
			obj8.action = new UnityEvent();
			obj8.action.AddListener((UnityAction)delegate
			{
				headerButtonObj.SetActive(false);
			});
			GridLayoutGroup obj9 = panel.AddComponent<GridLayoutGroup>();
			obj9.constraint = (Constraint)1;
			obj9.constraintCount = 9;
			obj9.cellSize = new Vector2(70f, 70f);
			obj9.spacing = new Vector2(4f, 8f);
			((LayoutGroup)obj9).padding = new RectOffset(4, 4, 4, 4);
			((LayoutGroup)obj9).childAlignment = (TextAnchor)1;
			HGGamepadInputEvent obj10 = panel.AddComponent<HGGamepadInputEvent>();
			obj10.actionName = "UICancel";
			obj10.actionEvent = new UnityEvent();
			obj10.actionEvent.AddListener(new UnityAction(Hide));
			obj10.requiredTopLayer = val9;
			obj10.enabledObjectsIfActive = (GameObject[])(object)new GameObject[1] { val10 };
			HGGamepadInputEvent obj11 = ((Component)this).gameObject.AddComponent<HGGamepadInputEvent>();
			obj11.actionName = "Sprint";
			obj11.actionEvent = new UnityEvent();
			obj11.actionEvent.AddListener((UnityAction)delegate
			{
				if (Object.op_Implicit((Object)(object)selectedButton) && selectedButton.row.CanShowGrid())
				{
					currentButton = selectedButton;
					Show(selectedButton.row.row);
				}
			});
			obj11.requiredTopLayer = infoPanel.GetComponent<UILayerKey>();
			obj11.enabledObjectsIfActive = Array.Empty<GameObject>();
			ContentSizeFitter obj12 = panel.AddComponent<ContentSizeFitter>();
			obj12.horizontalFit = (FitMode)0;
			obj12.verticalFit = (FitMode)2;
			((Graphic)panel.AddComponent<Image>()).color = Color.clear;
			buttonPrefab = MakeButtonPrefab();
			buttons = new UIElementAllocator<SkillGridButton>(val7, buttonPrefab, true, false);
		}

		private GameObject MakeButtonPrefab()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("LoadoutButton");
			val.SetActive(false);
			val.transform.SetParent(((Component)this).transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.anchorMin = obj.pivot;
			obj.anchorMax = obj.pivot;
			obj.sizeDelta = new Vector2(64f, 64f);
			LayoutElement obj2 = val.AddComponent<LayoutElement>();
			obj2.preferredHeight = 70f;
			obj2.preferredWidth = 70f;
			GameObject val2 = Object.Instantiate<GameObject>(LoadoutPanelController.loadoutButtonPrefab, val.transform, false);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.pivot = new Vector2(0f, 0f);
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(4f, 4f);
			component.offsetMax = new Vector2(-4f, -4f);
			val.AddComponent<SkillGridButton>().button = val2.GetComponent<HGButton>();
			return val;
		}

		public void Hide()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!scrollPanel.activeSelf)
			{
				return;
			}
			scrollPanel.SetActive(false);
			if (Object.op_Implicit((Object)(object)locator.eventSystem) && (int)locator.eventSystem.currentInputSource == 1)
			{
				if (Object.op_Implicit((Object)(object)currentButton))
				{
					HGButton component = ((Component)currentButton).GetComponent<HGButton>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((EventSystem)locator.eventSystem).SetSelectedGameObject(((Component)currentButton).gameObject);
						((Selectable)component).OnSelect((BaseEventData)null);
					}
				}
				else
				{
					MPButton button = currentRow.rowData[0].button;
					if (Object.op_Implicit((Object)(object)button))
					{
						((EventSystem)locator.eventSystem).SetSelectedGameObject(((Component)button).gameObject);
						((Selectable)button).OnSelect((BaseEventData)null);
					}
				}
			}
			currentRow = null;
			currentButton = null;
			buttons.AllocateElements(0);
		}

		public void Show(Row self)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Expected O, but got Unknown
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			if (self == currentRow || scrollPanel.activeSelf)
			{
				return;
			}
			currentRow = self;
			UILayerKey component = panel.GetComponent<UILayerKey>();
			GridLayoutGroup gridLayout = panel.GetComponent<GridLayoutGroup>();
			GridLayoutGroup obj = gridLayout;
			Rect rect = ((Component)this).GetComponent<RectTransform>().rect;
			obj.constraintCount = (int)(((Rect)(ref rect)).width / (gridLayout.cellSize.x + gridLayout.spacing.x));
			buttons.AllocateElements(self.rowData.Count);
			scrollPanel.GetComponent<ScrollRect>().verticalNormalizedPosition = 1f;
			HGButton sourceButton = default(HGButton);
			for (int i = 0; i < buttons.elements.Count; i++)
			{
				RowData val = self.rowData[i];
				SkillGridButton skillGridButton = buttons.elements[i];
				skillGridButton.defIndex = val.defIndex;
				HGButton button = skillGridButton.button;
				ref HGButton reference = ref sourceButton;
				MPButton button2 = val.button;
				reference = (HGButton)(object)((button2 is HGButton) ? button2 : null);
				((MPButton)button).requiredTopLayer = component;
				Graphic targetGraphic = ((Selectable)button).targetGraphic;
				? val2 = ((targetGraphic is Image) ? targetGraphic : null);
				Graphic targetGraphic2 = ((Selectable)sourceButton).targetGraphic;
				((Image)val2).sprite = ((Image)((targetGraphic2 is Image) ? targetGraphic2 : null)).sprite;
				((Selectable)button).interactable = ((Selectable)sourceButton).interactable;
				((MPButton)button).disableGamepadClick = ((MPButton)sourceButton).disableGamepadClick;
				((MPButton)button).disablePointerClick = ((MPButton)sourceButton).disablePointerClick;
				button.hoverToken = sourceButton.hoverToken;
				button.updateTextOnHover = sourceButton.updateTextOnHover;
				button.hoverLanguageTextMeshController = sourceButton.hoverLanguageTextMeshController;
				((MPButton)button).onSelect.AddListener((UnityAction)delegate
				{
					//IL_006b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0071: Invalid comparison between Unknown and I4
					//IL_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references)
					//IL_009d: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a2: 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_00ca: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
					//IL_0112: Unknown result type (might be due to invalid IL or missing references)
					//IL_011d: Unknown result type (might be due to invalid IL or missing references)
					//IL_012b: Unknown result type (might be due to invalid IL or missing references)
					ScrollRect componentInParent = ((Component)button).GetComponentInParent<ScrollRect>(true);
					RectTransform component6 = ((Component)((Component)button).transform.parent).GetComponent<RectTransform>();
					if (Object.op_Implicit((Object)(object)locator) && Object.op_Implicit((Object)(object)locator.eventSystem) && (int)locator.eventSystem.currentInputSource == 1)
					{
						RectTransform content = componentInParent.content;
						Vector2 val4 = Vector2.op_Implicit(((Transform)componentInParent.viewport).InverseTransformPoint(((Transform)component6).position));
						Rect rect2 = ((Component)componentInParent.viewport).GetComponent<RectTransform>().rect;
						float height = ((Rect)(ref rect2)).height;
						float num = gridLayout.cellSize.y / 2f;
						if (val4.y - num < 0f)
						{
							content.anchoredPosition = new Vector2(content.anchoredPosition.x, 0f - component6.anchoredPosition.y - height + num);
						}
						else if (val4.y + num > height)
						{
							content.anchoredPosition = new Vector2(content.anchoredPosition.x, 0f - component6.anchoredPosition.y - num);
						}
					}
				});
				((UnityEvent)((Button)button).onClick).AddListener((UnityAction)delegate
				{
					if (Object.op_Implicit((Object)(object)sourceButton))
					{
						((MPButton)sourceButton).InvokeClick();
					}
				});
				Navigation navigation = ((Selectable)button).navigation;
				((Navigation)(ref navigation)).mode = (Mode)4;
				int index = (i + buttons.elements.Count - 1) % buttons.elements.Count;
				((Navigation)(ref navigation)).selectOnLeft = (Selectable)(object)buttons.elements[index].button;
				int index2 = (i + buttons.elements.Count + 1) % buttons.elements.Count;
				((Navigation)(ref navigation)).selectOnRight = (Selectable)(object)buttons.elements[index2].button;
				if (i - gridLayout.constraintCount >= 0)
				{
					((Navigation)(ref navigation)).selectOnUp = (Selectable)(object)buttons.elements[i - gridLayout.constraintCount].button;
				}
				if (i + gridLayout.constraintCount < buttons.elements.Count)
				{
					((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)buttons.elements[i + gridLayout.constraintCount].button;
				}
				else if (i / gridLayout.constraintCount < buttons.elements.Count / gridLayout.constraintCount)
				{
					ReadOnlyCollection<SkillGridButton> elements = buttons.elements;
					((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)elements[elements.Count - 1].button;
				}
				((Selectable)button).navigation = navigation;
				ViewableTag component2 = ((Component)button).GetComponent<ViewableTag>();
				ViewableTag component3 = ((Component)sourceButton).GetComponent<ViewableTag>();
				component2.viewableName = component3.viewableName;
				component2.Refresh();
				TooltipProvider component4 = ((Component)button).GetComponent<TooltipProvider>();
				TooltipProvider component5 = ((Component)sourceButton).GetComponent<TooltipProvider>();
				component4.overrideTitleText = component5.overrideTitleText;
				component4.overrideBodyText = component5.overrideBodyText;
				component4.titleColor = component5.titleColor;
			}
			if (Object.op_Implicit((Object)(object)choiceHighlightRect))
			{
				Object.Destroy((Object)(object)choiceHighlightRect);
			}
			choiceHighlightRect = Object.Instantiate<GameObject>(((Component)LoadoutPanelController.rowPrefab.transform.Find("ButtonSelectionHighlight, Checkbox")).gameObject, panel.transform).transform;
			Object.Destroy((Object)(object)((Component)choiceHighlightRect).GetComponent<RefreshCanvasDrawOrder>());
			UpdateHighlightedChoice();
			RectTransform val3 = (RectTransform)((Transform)self.rowPanelTransform).Find("LabelContainer/SlotLabel");
			headerLanguageController.token = ((Component)val3).GetComponent<LanguageTextMeshController>().token;
			scrollPanel.SetActive(true);
		}

		private void OnLoadoutChangedGlobal(UserProfile userProfile)
		{
			if (Object.op_Implicit((Object)(object)scrollPanel) && scrollPanel.activeInHierarchy && userProfile == currentRow?.userProfile)
			{
				UpdateHighlightedChoice();
			}
		}

		private void UpdateHighlightedChoice()
		{
			//IL_0041: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			int num = currentRow.findCurrentChoice(currentRow.userProfile.loadout);
			foreach (SkillGridButton element in buttons.elements)
			{
				ColorBlock colors = ((Selectable)element.button).colors;
				if (num == element.defIndex)
				{
					((ColorBlock)(ref colors)).colorMultiplier = 1f;
					((MPButton)element.button).onSelect.Invoke();
					choiceHighlightRect.SetParent(((Component)element).transform, false);
				}
				else
				{
					((ColorBlock)(ref colors)).colorMultiplier = 0.5f;
				}
				((Selectable)element.button).colors = colors;
			}
		}

		private void OnDestroy()
		{
			Instance = null;
		}
	}
	[BepInPlugin("com.KingEnderBrine.ScrollableLobbyUI", "Scrollable lobby UI", "1.10.7")]
	public class ScrollableLobbyUIPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__CharacterSelectControllerRebuildLocal;

			public static hook_Awake <1>__CharacterSelectControllerAwake;

			public static hook_Awake <2>__LoadoutPanelControllerAwake;

			public static hook_ctor <3>__LoadoutPanelControllerRowCtor;

			public static hook_FinishSetup <4>__LoadoutPanelControllerRowFinishSetup;

			public static hook_OnDestroy <5>__LoadoutPanelControllerOnDestroy;

			public sta