Decompiled source of ScrollableLobbyUI v1.10.0

plugins/ScrollableLobbyUI/ScrollableLobbyUI.dll

Decompiled 2 weeks 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;
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.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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 iconSize = 70;

		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 => 74 * 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 val3 = (val.survivorDef = list[i]);
				if ((Object)(object)pickedSurvivor == (Object)(object)val3)
				{
					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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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(70f, 70f);
			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 mpEventSystemLocator2 = ((Component)this).GetComponent<MPEventSystemLocator>();
			GameObject survivorChoiceGrid2 = ((Component)((Component)this).transform.parent).gameObject;
			UILayerKey uiLayerKey2 = survivorChoiceGrid2.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, mpEventSystemLocator2, survivorChoiceGrid2, uiLayerKey2);
			inlineNextButtonComponent = SetupPagingButtonCharacterSlot("Next", SelectNextPage, "UITabRight", 10, 6, mpEventSystemLocator2, survivorChoiceGrid2, uiLayerKey2);
			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_0072: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Expected O, but got Unknown
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Expected O, but got Unknown
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Expected O, but got Unknown
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: Invalid comparison between Unknown and I4
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Expected O, but got Unknown
				//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_020f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: 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_0257: Unknown result type (might be due to invalid IL or missing references)
				//IL_027a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0288: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				//IL_036d: Unknown result type (might be due to invalid IL or missing references)
				//IL_037f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0386: Unknown result type (might be due to invalid IL or missing references)
				//IL_039c: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03de: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ee: Expected O, but got Unknown
				//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0403: Unknown result type (might be due to invalid IL or missing references)
				//IL_0425: Unknown result type (might be due to invalid IL or missing references)
				//IL_042a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0477: Unknown result type (might be due to invalid IL or missing references)
				//IL_0481: Expected O, but got Unknown
				//IL_048f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0499: Expected O, but got Unknown
				GameObject val17 = new GameObject(prefix + "ButtonContainer");
				val17.transform.SetParent(((Component)this).transform.parent, false);
				val17.transform.SetSiblingIndex(siblingIndex);
				val17.layer = 5;
				VerticalLayoutGroup obj10 = val17.AddComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj10).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)obj10).childControlWidth = true;
				LayoutElement item = val17.AddComponent<LayoutElement>();
				trackingHeightElements.Add(item);
				GameObject obj11 = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)("RoR2/Base/UI/" + buttonPrefix + "Button.prefab")).WaitForCompletion(), val17.transform, false);
				((Object)obj11).name = prefix + "Page";
				obj11.layer = 5;
				HGButton component = obj11.GetComponent<HGButton>();
				((Button)component).onClick = new ButtonClickedEvent();
				((UnityEvent)((Button)component).onClick).AddListener(new UnityAction(action.Invoke));
				LayoutElement component2 = obj11.GetComponent<LayoutElement>();
				component2.preferredWidth = 37f;
				component2.minWidth = 37f;
				GameObject val18 = new GameObject(prefix + "Glyph");
				val18.transform.SetParent(val17.transform, false);
				val18.layer = 5;
				val18.transform.SetSiblingIndex(0);
				val18.SetActive(Object.op_Implicit((Object)(object)mpEventSystemLocator2.eventSystem) && (int)mpEventSystemLocator2.eventSystem.currentInputSource == 1);
				RectTransform obj12 = val18.AddComponent<RectTransform>();
				obj12.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj12).localScale = new Vector3(1f, 1f, 1f);
				obj12.sizeDelta = new Vector2(0f, 0f);
				Image obj13 = val18.AddComponent<Image>();
				((Graphic)obj13).color = Color.white;
				((Behaviour)obj13).enabled = false;
				val18.AddComponent<LayoutElement>().minWidth = 37f;
				GameObject val19 = new GameObject("Text");
				val19.transform.SetParent(val18.transform);
				val19.layer = 5;
				RectTransform obj14 = val19.AddComponent<RectTransform>();
				obj14.anchorMin = new Vector2(0f, 0f);
				obj14.anchorMax = new Vector2(1f, 1f);
				obj14.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj14).localScale = new Vector3(1f, 1f, 1f);
				obj14.sizeDelta = new Vector2(48f, 48f);
				val19.AddComponent<MPEventSystemLocator>();
				InputBindingDisplayController obj15 = val19.AddComponent<InputBindingDisplayController>();
				obj15.actionName = actionName;
				obj15.axisRange = (AxisRange)0;
				obj15.useExplicitInputSource = true;
				obj15.explicitInputSource = (InputSource)1;
				obj15.Awake();
				LayoutElement obj16 = val19.AddComponent<LayoutElement>();
				obj16.preferredHeight = 37f;
				obj16.preferredWidth = 37f;
				TMP_FontAsset fontAsset2 = Addressables.LoadAssetAsync<TMP_FontAsset>((object)"RoR2/Base/Common/Fonts/Bombardier/tmpbombdropshadow.asset").WaitForCompletion();
				HGTextMeshProUGUI val20 = val19.AddComponent<HGTextMeshProUGUI>();
				((Graphic)val20).raycastTarget = false;
				((TMP_Text)val20).text = $"<sprite=\"tmpsprXboxOneGlyphs\" name=\"texXBoxOneGlyphs_{glyphIndex}\">";
				((TextMeshProUGUI)val20).UpdateFontAsset();
				((TMP_Text)val20).fontSize = 24f;
				((TMP_Text)val20).fontSizeMin = 18f;
				((TMP_Text)val20).fontSizeMax = 72f;
				((TMP_Text)val20).fontWeight = (FontWeight)400;
				((TMP_Text)val20).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val20).wordWrappingRatios = 0.4f;
				((TMP_Text)val20).overflowMode = (TextOverflowModes)0;
				((TMP_Text)val20).enableKerning = true;
				((TMP_Text)val20).richText = true;
				((TMP_Text)val20).parseCtrlCharacters = true;
				((TMP_Text)val20).isOrthographic = true;
				GameObject val21 = new GameObject("TMP SubMeshUI");
				val21.transform.SetParent(val19.transform);
				val21.layer = 5;
				RectTransform obj17 = val21.AddComponent<RectTransform>();
				obj17.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj17).localScale = new Vector3(1f, 1f, 1f);
				obj17.sizeDelta = new Vector2(0f, 0f);
				Material val22 = new Material(Addressables.LoadAssetAsync<Shader>((object)"TextMesh Pro/FormerResources/Shaders/TMP_Sprite.shader").WaitForCompletion());
				Texture val23 = Addressables.LoadAssetAsync<Texture>((object)"TextMesh Pro/FormerResources/Sprite Assets/texXBoxOneGlyphs.png").WaitForCompletion();
				val21.AddComponent<CanvasRenderer>().SetMaterial(val22, val23);
				TMP_SubMeshUI obj18 = val21.AddComponent<TMP_SubMeshUI>();
				obj18.fontAsset = fontAsset2;
				obj18.spriteAsset = Addressables.LoadAssetAsync<TMP_SpriteAsset>((object)"TextMesh Pro/FormerResources/Sprite Assets/tmpsprXboxOneGlyphs.asset").WaitForCompletion();
				obj18.m_TextComponent = (TextMeshProUGUI)(object)val20;
				HGGamepadInputEvent val24 = survivorChoiceGrid2.AddComponent<HGGamepadInputEvent>();
				val24.requiredTopLayer = uiLayerKey2;
				val24.actionName = actionName;
				val24.enabledObjectsIfActive = (GameObject[])(object)new GameObject[1] { val18 };
				val24.actionEvent = new UnityEvent();
				val24.actionEvent.AddListener(new UnityAction(action.Invoke));
				return component;
			}
			HGButton SetupPagingButtonCharacterSlot(string prefix, Action action, string actionName, int siblingIndex, int glyphIndex, MPEventSystemLocator mpEventSystemLocator, GameObject survivorChoiceGrid, UILayerKey uiLayerKey)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Expected O, but got Unknown
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Expected O, but got Unknown
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: 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_020d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0227: Unknown result type (might be due to invalid IL or missing references)
				//IL_023c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0247: Unknown result type (might be due to invalid IL or missing references)
				//IL_0252: Unknown result type (might be due to invalid IL or missing references)
				//IL_0267: Unknown result type (might be due to invalid IL or missing references)
				//IL_027b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0285: Unknown result type (might be due to invalid IL or missing references)
				//IL_028c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0298: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ea: Expected O, but got Unknown
				//IL_0316: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_040d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0412: Unknown result type (might be due to invalid IL or missing references)
				//IL_0432: Unknown result type (might be due to invalid IL or missing references)
				//IL_0437: Unknown result type (might be due to invalid IL or missing references)
				//IL_044e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0453: Unknown result type (might be due to invalid IL or missing references)
				//IL_0476: Unknown result type (might be due to invalid IL or missing references)
				//IL_048f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0496: Expected O, but got Unknown
				//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_04db: Invalid comparison between Unknown and I4
				//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0516: Unknown result type (might be due to invalid IL or missing references)
				//IL_052a: Unknown result type (might be due to invalid IL or missing references)
				//IL_053c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0562: Unknown result type (might be due to invalid IL or missing references)
				//IL_0569: Expected O, but got Unknown
				//IL_0596: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_05df: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0615: Unknown result type (might be due to invalid IL or missing references)
				//IL_0623: Unknown result type (might be due to invalid IL or missing references)
				//IL_064e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0653: Unknown result type (might be due to invalid IL or missing references)
				//IL_0703: Unknown result type (might be due to invalid IL or missing references)
				//IL_0708: Unknown result type (might be due to invalid IL or missing references)
				//IL_071a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0721: Unknown result type (might be due to invalid IL or missing references)
				//IL_0737: Unknown result type (might be due to invalid IL or missing references)
				//IL_0751: Unknown result type (might be due to invalid IL or missing references)
				//IL_0765: Unknown result type (might be due to invalid IL or missing references)
				//IL_0774: Unknown result type (might be due to invalid IL or missing references)
				//IL_0779: Unknown result type (might be due to invalid IL or missing references)
				//IL_0782: Unknown result type (might be due to invalid IL or missing references)
				//IL_0789: Expected O, but got Unknown
				//IL_078e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0793: Unknown result type (might be due to invalid IL or missing references)
				//IL_079e: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0808: Unknown result type (might be due to invalid IL or missing references)
				//IL_0812: Expected O, but got Unknown
				GameObject val = new GameObject(prefix + "ButtonContainer");
				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 = uiLayerKey;
				((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)mpEventSystemLocator.eventSystem) && (int)mpEventSystemLocator.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 val11 = new GameObject("Text");
				val11.transform.SetParent(val10.transform);
				val11.layer = 5;
				RectTransform obj5 = val11.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);
				val11.AddComponent<MPEventSystemLocator>();
				InputBindingDisplayController obj6 = val11.AddComponent<InputBindingDisplayController>();
				obj6.actionName = actionName;
				obj6.axisRange = (AxisRange)0;
				obj6.useExplicitInputSource = true;
				obj6.explicitInputSource = (InputSource)1;
				obj6.Awake();
				LayoutElement obj7 = val11.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 val12 = val11.AddComponent<HGTextMeshProUGUI>();
				((Graphic)val12).raycastTarget = false;
				((TMP_Text)val12).text = $"<sprite=\"tmpsprXboxOneGlyphs\" name=\"texXBoxOneGlyphs_{glyphIndex}\">";
				((TextMeshProUGUI)val12).UpdateFontAsset();
				((TMP_Text)val12).fontSize = 24f;
				((TMP_Text)val12).fontSizeMin = 18f;
				((TMP_Text)val12).fontSizeMax = 72f;
				((TMP_Text)val12).fontWeight = (FontWeight)400;
				((TMP_Text)val12).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val12).wordWrappingRatios = 0.4f;
				((TMP_Text)val12).overflowMode = (TextOverflowModes)0;
				((TMP_Text)val12).enableKerning = true;
				((TMP_Text)val12).richText = true;
				((TMP_Text)val12).parseCtrlCharacters = true;
				((TMP_Text)val12).isOrthographic = true;
				GameObject val13 = new GameObject("TMP SubMeshUI");
				val13.transform.SetParent(val11.transform);
				val13.layer = 5;
				RectTransform obj8 = val13.AddComponent<RectTransform>();
				obj8.anchoredPosition3D = new Vector3(0f, 0f, 0f);
				((Transform)obj8).localScale = new Vector3(1f, 1f, 1f);
				obj8.sizeDelta = new Vector2(0f, 0f);
				Material val14 = new Material(Addressables.LoadAssetAsync<Shader>((object)"TextMesh Pro/FormerResources/Shaders/TMP_Sprite.shader").WaitForCompletion());
				Texture val15 = Addressables.LoadAssetAsync<Texture>((object)"TextMesh Pro/FormerResources/Sprite Assets/texXBoxOneGlyphs.png").WaitForCompletion();
				val13.AddComponent<CanvasRenderer>().SetMaterial(val14, val15);
				TMP_SubMeshUI obj9 = val13.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)val12;
				HGGamepadInputEvent val16 = survivorChoiceGrid.AddComponent<HGGamepadInputEvent>();
				val16.requiredTopLayer = uiLayerKey;
				val16.actionName = actionName;
				val16.enabledObjectsIfActive = (GameObject[])(object)new GameObject[1] { val10 };
				val16.actionEvent = new UnityEvent();
				val10.AddComponent<VariantArrowToggler>().arrow = val8;
				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.InlinePageArrows.SettingChanged += OnInlinePageArrowsSettingsChanged;
		}

		private void OnDisable()
		{
			ScrollableLobbyUIPlugin.CharacterSelectRows.SettingChanged -= OnCharacterSelectRowsSettingsChanged;
			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 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 = Math.Max(1, (int)(width + 4f - (float)num) / 74);
			if (!ScrollableLobbyUIPlugin.InlinePageArrows.Value)
			{
				if (num2 * SurvivorRows < survivorDefList.Count)
				{
					((Component)((Component)arrowPreviousButtonComponent).transform.parent).gameObject.SetActive(true);
					((Component)((Component)arrowNextButtonComponent).transform.parent).gameObject.SetActive(true);
					num2 = Math.Max(1, num2 - 1);
				}
				else
				{
					((Component)((Component)arrowPreviousButtonComponent).transform.parent).gameObject.SetActive(false);
					((Component)((Component)arrowNextButtonComponent).transform.parent).gameObject.SetActive(false);
				}
			}
			else if (num2 * SurvivorRows < survivorDefList.Count)
			{
				num2 = Math.Max(SurvivorRows switch
				{
					1 => 3, 
					2 => 2, 
					_ => 1, 
				}, num2);
			}
			return num2;
		}

		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;
		}
	}
	[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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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
			ModConfigEntry val = new ModConfigEntry();
			val.DisplayName = "Scrollable lobby UI";
			string section = ((ConfigEntryBase)ScrollableLobbyUIPlugin.CharacterSelectRows).Definition.Section;
			val.SectionFields[section] = (IEnumerable<IConfigField>)(object)new IConfigField[5]
			{
				(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 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Expected O, but got Unknown
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Expected O, but got Unknown
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: 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_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_063e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Expected O, but got Unknown
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: 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);
			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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			scrollPanel.SetActive(false);
			if (Object.op_Implicit((Object)(object)locator.eventSystem) && (int)locator.eventSystem.currentInputSource == 1)
			{
				if (Object.op_Implicit((Object)(object)currentButton))
				{
					((EventSystem)locator.eventSystem).SetSelectedGameObject(((Component)currentButton).gameObject);
					((Selectable)((Component)currentButton).GetComponent<HGButton>()).OnSelect((BaseEventData)null);
				}
				else
				{
					MPButton button = currentRow.rowData[0].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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Expected O, but got Unknown
			//IL_03b0: 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_041e: 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++)
			{
				HGButton button = buttons.elements[i].button;
				ref HGButton reference = ref sourceButton;
				MPButton button2 = self.rowData[i].button;
				reference = (HGButton)(object)((button2 is HGButton) ? button2 : null);
				((MPButton)button).requiredTopLayer = component;
				Graphic targetGraphic = ((Selectable)button).targetGraphic;
				? val = ((targetGraphic is Image) ? targetGraphic : null);
				Graphic targetGraphic2 = ((Selectable)sourceButton).targetGraphic;
				((Image)val).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 val3 = 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 (val3.y - num < 0f)
						{
							content.anchoredPosition = new Vector2(content.anchoredPosition.x, 0f - component6.anchoredPosition.y - height + num);
						}
						else if (val3.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 val2 = (RectTransform)((Transform)self.rowPanelTransform).Find("LabelContainer/SlotLabel");
			headerLanguageController.token = ((Component)val2).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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			foreach (SkillGridButton element in buttons.elements)
			{
				ColorBlock colors = ((Selectable)element.button).colors;
				((ColorBlock)(ref colors)).colorMultiplier = 0.5f;
				((Selectable)element.button).colors = colors;
			}
			int num = currentRow.findCurrentChoice(currentRow.userProfile.loadout);
			if (num != -1)
			{
				SkillGridButton skillGridButton = buttons.elements[num];
				ColorBlock colors2 = ((Selectable)skillGridButton.button).colors;
				((ColorBlock)(ref colors2)).colorMultiplier = 1f;
				((Selectable)skillGridButton.button).colors = colors2;
				((MPButton)skillGridButton.button).onSelect.Invoke();
				choiceHighlightRect.SetParent(((Component)skillGridButton).transform, false);
			}
		}

		private void OnDestroy()
		{
			Instance = null;
		}
	}
	[BepInPlugin("com.KingEnderBrine.ScrollableLobbyUI", "Scrollable lobby UI", "1.10.0")]
	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 static hook_Awake <6>__CharacterSelectBarControllerAwake;

			public static hook_Build <7>__CharacterSelectBarControllerBuild;

			public static hook_EnforceValidChoice <8>__CharacterSelectBarControllerEnforceValidChoice;

			public static hook_PickIconBySurvivorDef <9>__CharacterSelectBarControllerPickIconBySurvivorDef;

			public static hook_Awake <10>__RuleBookViewerAwake;

			public static hook_SetData <11>__RuleCategoryControllerSetData;

			public static hook_Update <12>__RuleBookViewerStripUpdate;

			public static hook_SetData <13>__RuleBookViewerStripSetData;
		}

		public const string GUID = "com.KingEnderBrine.ScrollableLobbyUI";

		public const string Name = "Scrollable lobby UI";

		public const string Version = "1.10.0";

		internal static ConfigEntry<int> CharacterSelectRows { get; private set; }

		internal static ConfigEntry<bool> InlinePageArrows { get; private set; }

		internal static ConfigEntry<bool> ScrollRowsWithMouseWheel { get; private set; }

		internal static ConfigEntry<int> SkillRowHeight { get; private set; }

		internal static ConfigEntry<int> SkillCountForGridButton { get; private set; }

		private void Awake()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00e5: Unknown result type