Decompiled source of SearsCatalog v1.10.0

SearsCatalog.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using ComfyLib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SearsCatalog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SearsCatalog")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cc8e41cd-c04e-45b6-b9e5-de60df83a8eb")]
[assembly: AssemblyFileVersion("1.10.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.10.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SearsCatalog
{
	public static class PluginConfig
	{
		public enum SearchFilterMode
		{
			Vanilla,
			Advanced
		}

		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<bool> BuildUiCanMovePanel { get; private set; }

		public static ConfigEntry<Vector2> BuildUiPanelPosition { get; private set; }

		public static ConfigEntry<bool> BuildUiCanResizePanel { get; private set; }

		public static ConfigEntry<Vector2> BuildUiPanelSizeDelta { get; private set; }

		public static ConfigEntry<SearchFilterMode> BuildUiSearchFilterMode { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod.");
			BuildUiCanMovePanel = config.BindInOrder("BuildUi.Panel", "canMovePanel", defaultValue: true, "Allow moving the BuildUi panel.");
			BuildUiPanelPosition = config.BindInOrder<Vector2>("BuildUi.Panel", "panelPosition", Vector2.zero, "BuildUi panel RectTransform.anchoredPosition value.");
			BuildUiCanResizePanel = config.BindInOrder("BuildUi.Panel", "canResizePanel", defaultValue: true, "Allow resizing the BuildUi panel.");
			BuildUiPanelSizeDelta = config.BindInOrder<Vector2>("BuildUi.Panel", "panelSizeDelta", Vector2.zero, "BuildUi panel RectTransform.sizeDelta value.");
			BuildUiSearchFilterMode = config.BindInOrder("BuildUi.SearchFilter", "searchFilterMode", SearchFilterMode.Advanced, "BuildUi search-filter mode. Advanced enables multi-word searching.");
			BuildUiSearchFilterMode.OnSettingChanged<SearchFilterMode>(PieceSearchFilter.ResetSearch);
		}
	}
	public static class BuildUiController
	{
		public static RectTransform SelectionWindow { get; private set; }

		public static PanelDragger WindowDragger { get; private set; }

		public static PanelResizer WindowResizer { get; private set; }

		public static PooledGridView PieceGridView { get; private set; }

		public static List<Piece> CurrentPieces => PieceSearchFilter.CurrentPieces;

		public static List<Piece> FilteredPieces => PieceSearchFilter.FilteredPieces;

		public static void SetupBuildUi(BuildUi buildUi)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0020: Expected O, but got Unknown
			RectTransform val = (RectTransform)((Component)buildUi).transform.Find("bar/SelectionWindow");
			SelectionWindow = val;
			SetupWindowInteractions(val);
			SetupTagListLayout(buildUi.m_tagListContainer);
			SetupPieceGridView(buildUi.m_pieceScrollRect);
			PieceSearchFilter.Initialize();
		}

		private static void SetupWindowInteractions(RectTransform selectionWindow)
		{
			PanelDragger panelDragger = default(PanelDragger);
			if (!((Component)selectionWindow).TryGetComponent<PanelDragger>(ref panelDragger))
			{
				panelDragger = ((Component)selectionWindow).gameObject.AddComponent<PanelDragger>();
				panelDragger.OnPanelDragEnd.AddListener((UnityAction<Vector2>)HandlePanelDragEnd);
				((Behaviour)panelDragger).enabled = false;
			}
			if (!((Component)(object)selectionWindow).TryGetComponentInChildren<PanelResizer>(out PanelResizer component))
			{
				component = UIBuilder.CreateResizer((Transform)(object)selectionWindow).AddComponent<PanelResizer>();
				component.SetTargetRectTransform(selectionWindow);
				component.OnPanelResizeEnd.AddListener((UnityAction<Vector2>)HandlePanelResizeEnd);
				((Behaviour)component).enabled = false;
			}
			WindowDragger = panelDragger;
			WindowResizer = component;
		}

		private static void SetupTagListLayout(RectTransform tagListContainer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			tagListContainer.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.up).SetPivot(Vector2.zero)
				.SetPosition(Vector2.zero);
			RectTransformExtensions.SetAnchorMin((RectTransform)((Transform)tagListContainer).Find("LayoutGroup"), Vector2.up).SetAnchorMax(Vector2.up).SetPivot(Vector2.up)
				.SetPosition(Vector2.zero);
		}

		private static void SetupPieceGridView(ScrollRect scrollRect)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			PieceGridView = new PooledGridView(scrollRect);
			PieceGridView.Setup(CreatePieceButton, RenderPieceButton);
			PieceGridView.ScrollPadding = PieceGridView.StepSize.y;
		}

		private static RectTransform CreatePieceButton(Transform parent)
		{
			return Object.Instantiate<GameObject>(Hud.m_instance.m_buildUi.m_pieceButtonPrefab, parent).GetComponent<RectTransform>();
		}

		private static void RenderPieceButton(int index, GameObject item)
		{
			if (index >= 0 && index < FilteredPieces.Count)
			{
				item.GetComponent<BuildUiPieceButton>().Setup(FilteredPieces[index], Hud.m_instance.m_buildUi);
			}
		}

		private static void HandlePanelDragEnd(Vector2 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			PluginConfig.BuildUiPanelPosition.Value = position;
		}

		private static void HandlePanelResizeEnd(Vector2 sizeDelta)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			PluginConfig.BuildUiPanelSizeDelta.Value = sizeDelta;
			Canvas.ForceUpdateCanvases();
			PieceGridView.UpdatePoolSize();
			Hud.m_instance.m_buildUi.ConfigureButtonNavigation();
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				Piece selectedPiece = default(Piece);
				Vector2Int val = default(Vector2Int);
				int num = default(int);
				PieceCategory val2 = default(PieceCategory);
				PieceTable val3 = default(PieceTable);
				Player.m_localPlayer.GetBuildSelection(ref selectedPiece, ref val, ref num, ref val2, ref val3);
				UpdatePieceSelection(Hud.m_instance.m_buildUi, selectedPiece);
			}
		}

		public static void DestroyBuildUi(BuildUi buildUi)
		{
			PieceSearchFilter.Destroy();
			SelectionWindow = null;
			WindowDragger = null;
			WindowResizer = null;
			PieceGridView = null;
		}

		public static void ShowBuildUi(BuildUi buildUi)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)SelectionWindow))
			{
				if (!PluginConfig.IsModEnabled.Value)
				{
					SelectionWindow.SetSizeDelta(Vector2.zero).SetPosition(Vector2.zero);
					((Behaviour)WindowDragger).enabled = false;
					((Behaviour)WindowResizer).enabled = false;
				}
				else
				{
					SelectionWindow.SetSizeDelta(PluginConfig.BuildUiPanelSizeDelta.Value).SetPosition(PluginConfig.BuildUiPanelPosition.Value);
					((Behaviour)WindowDragger).enabled = PluginConfig.BuildUiCanMovePanel.Value;
					((Behaviour)WindowResizer).enabled = PluginConfig.BuildUiCanResizePanel.Value;
					PieceGridView.UpdatePoolSize();
					PieceGridView.Refresh();
				}
			}
		}

		public static void UpdatePieceButtons(BuildUi buildUi)
		{
			buildUi.m_availablePieceCount = buildUi.m_currentBuildTool.m_availablePieces.Count;
			IPieceList pieceList = buildUi.m_pieceLists[buildUi.m_currentPieceList];
			bool active = LoadPieces(buildUi, pieceList);
			((Component)buildUi.m_specialButtonsContainer).gameObject.SetActive(active);
			PieceSearchFilter.ResetSearchTerm();
			ApplySearch(GetSearchTerm(buildUi));
			buildUi.ConfigureButtonNavigation();
		}

		private static bool LoadPieces(BuildUi buildUi, IPieceList pieceList)
		{
			buildUi.m_tempPieces.Clear();
			pieceList.GetAvailablePiecesWithTag(buildUi.m_currentTagId, buildUi.m_currentBuildTool, (IList<Piece>)buildUi.m_tempPieces);
			CurrentPieces.Clear();
			bool flag = false;
			int i = 0;
			for (int count = buildUi.m_tempPieces.Count; i < count; i++)
			{
				Piece val = buildUi.m_tempPieces[i];
				if (val.m_repairPiece || val.m_removePiece)
				{
					if (pieceList.ShowTags)
					{
						flag = true;
						SetupSpecialButton(buildUi, val);
					}
				}
				else
				{
					CurrentPieces.Add(val);
				}
			}
			buildUi.m_tempPieces.Clear();
			if (!flag && Object.op_Implicit((Object)(object)buildUi.m_specialPieceButton))
			{
				((Component)buildUi.m_specialPieceButton).gameObject.SetActive(false);
			}
			return flag;
		}

		private static void SetupSpecialButton(BuildUi buildUi, Piece piece)
		{
			BuildUiPieceButton val = buildUi.m_specialPieceButton;
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = Object.Instantiate<GameObject>(buildUi.m_pieceButtonPrefab, (Transform)(object)buildUi.m_specialButtonsContainer).GetComponent<BuildUiPieceButton>();
				((Component)val).transform.SetAsFirstSibling();
				buildUi.m_specialPieceButton = val;
			}
			((Component)val).gameObject.SetActive(true);
			val.Setup(piece, buildUi);
		}

		private static string GetSearchTerm(BuildUi buildUi)
		{
			if (!Object.op_Implicit((Object)(object)buildUi.m_searchField) || !((Behaviour)buildUi.m_searchField).isActiveAndEnabled)
			{
				return string.Empty;
			}
			return ((TMP_InputField)buildUi.m_searchField).text;
		}

		public static void UpdateSearch(BuildUi buildUi, string term)
		{
			if (!string.IsNullOrWhiteSpace(term) && buildUi.m_currentTagId != -1)
			{
				buildUi.SetCurrentTag(-1, false);
				buildUi.UpdatePieceButtons();
			}
			else
			{
				ApplySearch(term);
				buildUi.ConfigureButtonNavigation();
			}
		}

		private static void ApplySearch(string term)
		{
			PieceSearchFilter.ApplySearch(term);
			PieceGridView.SetTotalItems(FilteredPieces.Count);
		}

		public static void UpdatePieceSelection(BuildUi buildUi, Piece selectedPiece)
		{
			if (TryGetTargetSelection(buildUi, selectedPiece, out var target))
			{
				EventSystem.current.SetSelectedGameObject(target);
			}
		}

		private static bool TryGetTargetSelection(BuildUi buildUi, Piece selectedPiece, out GameObject target)
		{
			if (PieceSearchFilter.TryFindFilteredPieceIndex(selectedPiece, out var index))
			{
				PieceGridView.ScrollToItem(index);
				if (PieceGridView.TryGetGridItem(index, out target))
				{
					return true;
				}
			}
			if (FilteredPieces.Count > 0 && PieceGridView.TryGetFirstVisibleItem(out target))
			{
				return true;
			}
			if (((Component)buildUi.m_tagListContainer).gameObject.activeSelf)
			{
				target = ((Component)buildUi.m_showAllTagsButton).gameObject;
				return Object.op_Implicit((Object)(object)target);
			}
			target = null;
			return false;
		}

		public static void FocusPiece(Piece piece)
		{
			if (PieceSearchFilter.TryFindFilteredPieceIndex(piece, out var index))
			{
				PieceGridView.ScrollToItem(index);
			}
		}

		public static void ConfigureButtonNavigation(BuildUi buildUi)
		{
			//IL_000d: 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)
			ConfigureGridNavigation(buildUi);
			GridNavigationUtility.ConfigureExplicitNavigation(buildUi.m_tagListScrollContent, buildUi.GetTagListEdgeNavigation());
			Button val = default(Button);
			if (Object.op_Implicit((Object)(object)buildUi.m_specialPieceButton) && ((Component)buildUi.m_specialPieceButton).TryGetComponent<Button>(ref val))
			{
				((Selectable)val).navigation = buildUi.GetSpecialButtonNavigation();
			}
		}

		private static void ConfigureGridNavigation(BuildUi buildUi)
		{
			//IL_0066: 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)
			Selectable selectOnUp = (Selectable)((Object.op_Implicit((Object)(object)buildUi.m_specialPieceButton) && ((Component)buildUi.m_specialPieceButton).gameObject.activeInHierarchy) ? ((object)((Component)buildUi.m_specialPieceButton).GetComponent<Selectable>()) : ((object)buildUi.m_searchField));
			BuildUiTagButton val = default(BuildUiTagButton);
			Selectable selectOnLeft = ((buildUi.TryGetTagButtonById(buildUi.m_currentTagId, ref val) && Object.op_Implicit((Object)(object)val)) ? ((Component)val).GetComponent<Selectable>() : ((Component)buildUi.m_showAllTagsButton).GetComponent<Selectable>());
			PooledGridView pieceGridView = PieceGridView;
			Navigation edgeNavigation = default(Navigation);
			((Navigation)(ref edgeNavigation)).selectOnLeft = selectOnLeft;
			((Navigation)(ref edgeNavigation)).selectOnUp = selectOnUp;
			pieceGridView.EdgeNavigation = edgeNavigation;
			PieceGridView.UpdateNavigation();
		}

		public static GameObject GetFirstPieceButton()
		{
			if (PieceGridView.TryGetFirstVisibleItem(out var gameObject))
			{
				return gameObject;
			}
			return null;
		}

		public static void SelectFirstPiece()
		{
			if (PieceGridView.TryGetFirstVisibleItem(out var gameObject))
			{
				EventSystem.current.SetSelectedGameObject(gameObject);
			}
		}

		public static void SelectFirstAvailableButton(BuildUi buildUi)
		{
			GameObject gameObject;
			Selectable val2 = default(Selectable);
			if (((Component)buildUi.m_tagListContainer).gameObject.activeSelf)
			{
				Selectable val = default(Selectable);
				if (((Component)buildUi.m_showAllTagsButton).TryGetComponent<Selectable>(ref val))
				{
					val.Select();
				}
			}
			else if (PieceGridView.TryGetFirstVisibleItem(out gameObject) && gameObject.TryGetComponent<Selectable>(ref val2))
			{
				val2.Select();
			}
		}
	}
	public static class PieceSearchFilter
	{
		private static readonly Dictionary<string, string> _cachedSearchStrings = new Dictionary<string, string>();

		private static readonly List<Piece> _searchMatches = new List<Piece>();

		private static string _previousSearchTerm = string.Empty;

		public static List<Piece> CurrentPieces { get; } = new List<Piece>();

		public static List<Piece> FilteredPieces { get; } = new List<Piece>();

		public static void Initialize()
		{
			Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(ResetSearch));
			Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(ResetSearch));
		}

		public static void Destroy()
		{
			Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(ResetSearch));
			CurrentPieces.Clear();
			FilteredPieces.Clear();
			ResetSearch();
		}

		public static void ResetSearch()
		{
			_cachedSearchStrings.Clear();
			_previousSearchTerm = string.Empty;
		}

		public static void ResetSearchTerm()
		{
			_previousSearchTerm = string.Empty;
		}

		private static void ResetFilteredPieces()
		{
			if (FilteredPieces.Capacity < CurrentPieces.Count)
			{
				FilteredPieces.Capacity = CurrentPieces.Count;
			}
			FilteredPieces.Clear();
			FilteredPieces.AddRange(CurrentPieces);
			_previousSearchTerm = string.Empty;
		}

		public static bool TryFindFilteredPieceIndex(Piece piece, out int index)
		{
			if (!Object.op_Implicit((Object)(object)piece))
			{
				index = -1;
				return false;
			}
			string name = ((Object)((Component)piece).gameObject).name;
			int i = 0;
			for (int count = FilteredPieces.Count; i < count; i++)
			{
				Piece val = FilteredPieces[i];
				if ((Object)(object)val == (Object)(object)piece || ((Object)((Component)val).gameObject).name == name)
				{
					index = i;
					return true;
				}
			}
			index = -1;
			return false;
		}

		public static void ApplySearch(string term)
		{
			if (string.IsNullOrEmpty(term))
			{
				ResetFilteredPieces();
				return;
			}
			bool flag = PluginConfig.BuildUiSearchFilterMode.Value == PluginConfig.SearchFilterMode.Vanilla;
			Span<Range> destination = stackalloc Range[16];
			int num = 0;
			string text;
			if (flag)
			{
				text = term.Replace(" ", string.Empty).ToLowerInvariant();
			}
			else
			{
				text = term.Trim().ToLowerInvariant();
				num = ParseQueryTokens(text.AsSpan(), destination);
			}
			if (string.IsNullOrEmpty(text) || (!flag && num == 0))
			{
				ResetFilteredPieces();
			}
			else if (!(text == _previousSearchTerm))
			{
				if (FilteredPieces.Capacity < CurrentPieces.Count)
				{
					FilteredPieces.Capacity = CurrentPieces.Count;
				}
				FilterPieces((!string.IsNullOrEmpty(_previousSearchTerm) && text.StartsWith(_previousSearchTerm, StringComparison.Ordinal)) ? FilteredPieces : CurrentPieces, text.AsSpan(), destination.Slice(0, num), flag);
				_previousSearchTerm = text;
			}
		}

		private static void FilterPieces(List<Piece> sourcePieces, ReadOnlySpan<char> searchTerm, ReadOnlySpan<Range> tokens, bool isVanillaSearch)
		{
			_searchMatches.Clear();
			if (_searchMatches.Capacity < sourcePieces.Count)
			{
				_searchMatches.Capacity = sourcePieces.Count;
			}
			int i = 0;
			for (int count = sourcePieces.Count; i < count; i++)
			{
				Piece val = sourcePieces[i];
				if (MatchesSearch(val, searchTerm, tokens, isVanillaSearch))
				{
					_searchMatches.Add(val);
				}
			}
			FilteredPieces.Clear();
			FilteredPieces.AddRange(_searchMatches);
			_searchMatches.Clear();
		}

		private static int ParseQueryTokens(ReadOnlySpan<char> query, Span<Range> destination)
		{
			int num = 0;
			int length = destination.Length;
			int i = 0;
			int length2 = query.Length;
			while (i < length2 && num < length)
			{
				for (; i < length2 && char.IsWhiteSpace(query[i]); i++)
				{
				}
				if (i >= length2)
				{
					break;
				}
				int j;
				for (j = i; j < length2 && !char.IsWhiteSpace(query[j]); j++)
				{
				}
				destination[num++] = i..j;
				i = j;
			}
			return num;
		}

		private static bool MatchesSearch(Piece piece, ReadOnlySpan<char> searchTerm, ReadOnlySpan<Range> tokens, bool isVanillaSearch)
		{
			ReadOnlySpan<char> span = GetOrCreateSearchString(piece, isVanillaSearch).AsSpan();
			if (isVanillaSearch)
			{
				return span.Contains(searchTerm, StringComparison.Ordinal);
			}
			int i = 0;
			for (int length = tokens.Length; i < length; i++)
			{
				Range range = tokens[i];
				ReadOnlySpan<char> value = searchTerm[range.Start..range.End];
				if (!span.Contains(value, StringComparison.Ordinal))
				{
					return false;
				}
			}
			return true;
		}

		private static string GetOrCreateSearchString(Piece piece, bool isVanillaSearch)
		{
			if (!_cachedSearchStrings.TryGetValue(((Object)((Component)piece).gameObject).name, out var value))
			{
				value = CreateSearchString(piece, ItemData.m_stringBuilder, isVanillaSearch);
				_cachedSearchStrings[((Object)((Component)piece).gameObject).name] = value;
			}
			return value;
		}

		private static string CreateSearchString(Piece piece, StringBuilder searchStringBuilder, bool stripSpaces)
		{
			searchStringBuilder.Clear().AppendLocalized(piece.m_name, stripSpaces);
			if (piece.m_resources == null)
			{
				return searchStringBuilder.ToString();
			}
			int i = 0;
			for (int num = piece.m_resources.Length; i < num; i++)
			{
				Requirement val = piece.m_resources[i];
				if (val != null && Object.op_Implicit((Object)(object)val.m_resItem))
				{
					searchStringBuilder.Append('\0').AppendLocalized(val.m_resItem.m_itemData.m_shared.m_name, stripSpaces);
				}
			}
			return searchStringBuilder.ToString();
		}

		private static void AppendLocalized(this StringBuilder builder, string text, bool stripSpaces)
		{
			string text2 = Localization.m_instance.Localize(text).ToLowerInvariant();
			if (!stripSpaces)
			{
				builder.Append(text2);
				return;
			}
			int i = 0;
			for (int length = text2.Length; i < length; i++)
			{
				char c = text2[i];
				if (c != ' ')
				{
					builder.Append(c);
				}
			}
		}
	}
	public static class ScrollRectUtils
	{
		public static void EnsureVisibility(ScrollRect scrollRect, RectTransform child, float padding = 0f)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = scrollRect.viewport.rect;
			float height = ((Rect)(ref rect)).height;
			Vector2 anchoredPosition = scrollRect.content.anchoredPosition;
			rect = child.rect;
			float height2 = ((Rect)(ref rect)).height;
			float num = child.anchoredPosition.y + (1f - child.pivot.y) * height2;
			float num2 = num - height2;
			float num3 = 0f - anchoredPosition.y - padding;
			float num4 = 0f - anchoredPosition.y - height + padding;
			float num5 = ((num > num3) ? (num3 - num) : ((num2 < num4) ? (num4 - num2) : 0f));
			anchoredPosition.y += num5;
			scrollRect.content.anchoredPosition = anchoredPosition;
		}
	}
	[HarmonyPatch(typeof(BuildUi))]
	internal static class BuildUiPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void StartPostfix(BuildUi __instance)
		{
			BuildUiController.SetupBuildUi(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnDestroy")]
		private static void OnDestroyPrefix(BuildUi __instance)
		{
			BuildUiController.DestroyBuildUi(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch("OpenBuildMenu")]
		private static void OpenBuildMenuPrefix(BuildUi __instance)
		{
			BuildUiController.ShowBuildUi(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdatePieceButtons")]
		private static bool UpdatePieceButtonsPrefix(BuildUi __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.UpdatePieceButtons(__instance);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdateSearch")]
		private static bool UpdateSearchPrefix(BuildUi __instance, string term)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.UpdateSearch(__instance, term);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdatePieceSelection")]
		private static bool UpdatePieceSelectionPrefix(BuildUi __instance, Piece selectedPiece)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.UpdatePieceSelection(__instance, selectedPiece);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("FocusPiece")]
		private static bool FocusPiecePrefix(BuildUiPieceButton button)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.FocusPiece(button.Piece);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("ConfigureButtonNavigation")]
		private static bool ConfigureButtonNavigationPrefix(BuildUi __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.ConfigureButtonNavigation(__instance);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetFirstPieceButton")]
		private static bool GetFirstPieceButtonPrefix(ref GameObject __result)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				__result = BuildUiController.GetFirstPieceButton();
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("SelectFirstPiece")]
		private static bool SelectFirstPiecePrefix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.SelectFirstPiece();
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("SelectFirstAvailableButton")]
		private static bool SelectFirstAvailableButtonPrefix(BuildUi __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildUiController.SelectFirstAvailableButton(__instance);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(BuildUiPieceButton))]
	internal static class BuildUiPieceButtonPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Setup")]
		private static void SetupPrefix(BuildUiPieceButton __instance)
		{
			Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(__instance.RefreshSearchTerm));
		}
	}
	[BepInPlugin("redseiko.valheim.searscatalog", "SearsCatalog", "1.10.0")]
	public sealed class SearsCatalog : BaseUnityPlugin
	{
		public const string PluginGuid = "redseiko.valheim.searscatalog";

		public const string PluginName = "SearsCatalog";

		public const string PluginVersion = "1.10.0";

		private void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.searscatalog");
		}
	}
}
namespace ComfyLib
{
	public static class ConfigFileExtensions
	{
		internal sealed class ConfigurationManagerAttributes
		{
			public Action<ConfigEntryBase> CustomDrawer;

			public bool? Browsable;

			public bool? HideDefaultButton;

			public bool? HideSettingName;

			public bool? IsAdvanced;

			public int? Order;

			public bool? ReadOnly;
		}

		private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();

		private static int GetSettingOrder(string section)
		{
			if (!_sectionToSettingOrder.TryGetValue(section, out var value))
			{
				value = 0;
			}
			_sectionToSettingOrder[section] = value - 1;
			return value;
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = null,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = browsable,
					CustomDrawer = customDrawer,
					HideDefaultButton = hideDefaultButton,
					HideSettingName = hideSettingName,
					IsAdvanced = isAdvanced,
					Order = GetSettingOrder(section),
					ReadOnly = readOnly
				}
			}));
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
		{
			configEntry.SettingChanged += delegate
			{
				settingChangedHandler();
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((ConfigEntry<T>)(object)((SettingChangedEventArgs)eventArgs).ChangedSetting);
			};
		}
	}
	public static class ComponentExtensions
	{
		public static bool TryGetComponentInChildren<T>(this Component parentComponent, out T component) where T : Component
		{
			component = parentComponent.GetComponentInChildren<T>();
			return Object.op_Implicit((Object)(object)component);
		}

		public static bool TryGetComponentInChildren<T>(this GameObject gameObject, out T component) where T : Component
		{
			component = gameObject.GetComponentInChildren<T>();
			return Object.op_Implicit((Object)(object)component);
		}

		public static bool TryGetComponentInParent<T>(this Component childComponent, out T component) where T : Component
		{
			component = childComponent.GetComponentInParent<T>();
			return Object.op_Implicit((Object)(object)component);
		}

		public static bool TryGetComponentInParent<T>(this GameObject gameObject, out T component) where T : Component
		{
			component = gameObject.GetComponentInParent<T>();
			return Object.op_Implicit((Object)(object)component);
		}
	}
	public static class ObjectExtensions
	{
		public static T FirstByNameOrThrow<T>(this T[] unityObjects, string name) where T : Object
		{
			foreach (T val in unityObjects)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}");
		}

		public static T Ref<T>(this T unityObject) where T : Object
		{
			if (!Object.op_Implicit((Object)(object)unityObject))
			{
				return default(T);
			}
			return unityObject;
		}

		public static T SetName<T>(this T unityObject, string name) where T : Object
		{
			((Object)unityObject).name = name;
			return unityObject;
		}
	}
	public sealed class ComfyTween<T>
	{
		private readonly MonoBehaviour _runner;

		private readonly float _duration;

		private readonly Func<T> _getCurrentValue;

		private readonly Action<T> _onUpdate;

		private readonly Func<T, T, float, T> _lerpFunc;

		private Coroutine _coroutine;

		public ComfyTween(MonoBehaviour runner, float duration, Func<T> getCurrentValue, Action<T> onUpdate, Func<T, T, float, T> lerpFunc)
		{
			_runner = runner;
			_duration = duration;
			_getCurrentValue = getCurrentValue;
			_onUpdate = onUpdate;
			_lerpFunc = lerpFunc;
		}

		public void To(T targetValue)
		{
			if (_coroutine != null)
			{
				_runner.StopCoroutine(_coroutine);
			}
			_coroutine = _runner.StartCoroutine(TweenCoroutine(_getCurrentValue(), targetValue));
		}

		private IEnumerator TweenCoroutine(T start, T target)
		{
			float timeElapsed = 0f;
			while (timeElapsed < _duration)
			{
				float num = timeElapsed / _duration;
				num = num * num * (3f - 2f * num);
				_onUpdate(_lerpFunc(start, target, num));
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			_onUpdate(target);
			_coroutine = null;
		}
	}
	public sealed class PooledGridView
	{
		private sealed class PooledItemState
		{
			public RectTransform RectTransform;

			public Selectable Selectable;

			public int Index = -1;

			public void SetActive(bool isActive)
			{
				if (((Component)RectTransform).gameObject.activeSelf != isActive)
				{
					((Component)RectTransform).gameObject.SetActive(isActive);
				}
			}
		}

		private int _columns = 1;

		private int _totalRows;

		private int _maxVisibleRows;

		private float _totalHeight;

		private Vector2 _stepSize;

		private Func<Transform, RectTransform> _itemFactory;

		private Action<int, GameObject> _onItemRender = OnItemRender;

		private int _totalItems;

		private PooledItemState[] _itemStates = Array.Empty<PooledItemState>();

		public GameObject Container { get; private set; }

		public RectTransform RectTransform { get; private set; }

		public GameObject Viewport { get; private set; }

		public RectTransform ViewportRectTransform { get; private set; }

		public GameObject Content { get; private set; }

		public RectTransform ContentRectTransform { get; private set; }

		public ScrollRect ScrollRect { get; private set; }

		public Vector2 ItemSize { get; private set; } = new Vector2(64f, 64f);

		public Vector2 ItemSpacing { get; private set; } = new Vector2(4f, 4f);

		public RectOffset Padding { get; private set; } = new RectOffset(4, 4, 4, 4);

		public int FirstVisibleIndex { get; private set; }

		public Navigation EdgeNavigation { get; set; }

		public float ScrollPadding { get; set; }

		public Vector2 StepSize => _stepSize;

		public PooledGridView(ScrollRect scrollRect)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			Container = ((Component)scrollRect).gameObject;
			RectTransform = Container.GetComponent<RectTransform>();
			Viewport = ((Component)scrollRect.viewport).gameObject;
			ViewportRectTransform = scrollRect.viewport;
			Content = ((Component)scrollRect.content).gameObject;
			ContentRectTransform = scrollRect.content;
			ScrollRect = scrollRect;
			GridLayoutGroup val = default(GridLayoutGroup);
			if (Content.TryGetComponent<GridLayoutGroup>(ref val))
			{
				ItemSize = val.cellSize;
				ItemSpacing = val.spacing;
				Padding = ((LayoutGroup)val).padding;
				((Behaviour)val).enabled = false;
			}
			ContentSizeFitter val2 = default(ContentSizeFitter);
			if (Content.TryGetComponent<ContentSizeFitter>(ref val2))
			{
				((Behaviour)val2).enabled = false;
			}
			ContentRectTransform.SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.one).SetPivot(Vector2.up);
			((UnityEvent<Vector2>)(object)ScrollRect.onValueChanged).AddListener((UnityAction<Vector2>)OnScroll);
		}

		private static void OnItemRender(int index, GameObject item)
		{
		}

		public PooledGridView SetItemSize(Vector2 size)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (ItemSize == size)
			{
				return this;
			}
			ItemSize = size;
			UpdatePoolSize();
			RefreshTotalHeight();
			return this;
		}

		public PooledGridView SetSpacing(Vector2 spacing)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (ItemSpacing == spacing)
			{
				return this;
			}
			ItemSpacing = spacing;
			UpdatePoolSize();
			RefreshTotalHeight();
			return this;
		}

		public PooledGridView SetPadding(RectOffset padding)
		{
			Padding = padding;
			UpdatePoolSize();
			RefreshTotalHeight();
			return this;
		}

		public void Setup(Func<Transform, RectTransform> itemFactory, Action<int, GameObject> onItemRender)
		{
			_itemFactory = itemFactory;
			_onItemRender = onItemRender;
			UpdatePoolSize();
		}

		public void UpdatePoolSize()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (_itemFactory != null)
			{
				_stepSize = ItemSize + ItemSpacing;
				_columns = Mathf.Max(1, Mathf.FloorToInt((GetAvailableWidth() + ItemSpacing.x) / _stepSize.x));
				_maxVisibleRows = Mathf.CeilToInt((GetViewportHeight() - (float)Padding.top - (float)Padding.bottom + _stepSize.y * 2f) / _stepSize.y);
				EnsurePoolCapacity((_maxVisibleRows + 2) * _columns);
				RefreshTotalHeight();
				Invalidate();
				Refresh();
			}
		}

		private float GetAvailableWidth()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ViewportRectTransform.rect;
			float width = ((Rect)(ref rect)).width;
			if (width <= 0f)
			{
				rect = RectTransform.rect;
				width = ((Rect)(ref rect)).width;
			}
			return width - (float)Padding.left - (float)Padding.right;
		}

		private float GetViewportHeight()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ViewportRectTransform.rect;
			float height = ((Rect)(ref rect)).height;
			if (height <= 0f)
			{
				rect = RectTransform.rect;
				height = ((Rect)(ref rect)).height;
			}
			return height;
		}

		private void EnsurePoolCapacity(int requiredPoolSize)
		{
			if (_itemStates.Length < requiredPoolSize)
			{
				int num = _itemStates.Length;
				Array.Resize(ref _itemStates, requiredPoolSize);
				for (int i = num; i < requiredPoolSize; i++)
				{
					_itemStates[i] = CreatePooledItem();
				}
			}
		}

		private PooledItemState CreatePooledItem()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			RectTransform val = _itemFactory(Content.transform);
			val.SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.up).SetPivot(new Vector2(0.5f, 0.5f))
				.SetSizeDelta(ItemSize);
			return new PooledItemState
			{
				RectTransform = val,
				Selectable = ((Component)val).GetComponent<Selectable>(),
				Index = -1
			};
		}

		private void RefreshTotalHeight()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			_totalRows = Mathf.CeilToInt((float)_totalItems / (float)_columns);
			_totalHeight = (float)(Padding.top + Padding.bottom) + (float)_totalRows * ItemSize.y + (float)Mathf.Max(0, _totalRows - 1) * ItemSpacing.y;
			ContentRectTransform.SetSizeWithCurrentAnchors((Axis)1, Mathf.Max(0f, _totalHeight));
			float num = Mathf.Max(0f, _totalHeight - GetViewportHeight());
			Vector2 anchoredPosition = ScrollRect.content.anchoredPosition;
			if (anchoredPosition.y > num)
			{
				anchoredPosition.y = num;
				ScrollRect.content.anchoredPosition = anchoredPosition;
			}
		}

		public void Invalidate()
		{
			for (int i = 0; i < _itemStates.Length; i++)
			{
				_itemStates[i].Index = -1;
			}
		}

		public void SetTotalItems(int count)
		{
			_totalItems = count;
			RefreshTotalHeight();
			Invalidate();
			Refresh();
		}

		public void Refresh()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		private Vector2 GetItemAnchoredPosition(int index)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			int num = index / _columns;
			int num2 = index % _columns;
			return new Vector2((float)Padding.left + (float)num2 * _stepSize.x + ItemSize.x / 2f, 0f - ((float)Padding.top + (float)num * _stepSize.y + ItemSize.y / 2f));
		}

		private void OnScroll(Vector2 sliderValue)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (_itemStates.Length == 0 || _stepSize.y <= 0f || _columns <= 0)
			{
				return;
			}
			CalculateVisibleItemRange(out var startIndex, out var endIndex);
			for (int i = startIndex; i < endIndex; i++)
			{
				PooledItemState pooledItemState = _itemStates[i % _itemStates.Length];
				if (pooledItemState.Index != i)
				{
					pooledItemState.Index = i;
					pooledItemState.RectTransform.anchoredPosition = GetItemAnchoredPosition(i);
					_onItemRender(i, ((Component)pooledItemState.RectTransform).gameObject);
				}
				pooledItemState.SetActive(isActive: true);
			}
			for (int j = 0; j < _itemStates.Length; j++)
			{
				PooledItemState pooledItemState2 = _itemStates[j];
				if (pooledItemState2.Index < startIndex || pooledItemState2.Index >= endIndex)
				{
					pooledItemState2.SetActive(isActive: false);
				}
			}
			UpdateItemNavigation(startIndex, endIndex);
		}

		private void CalculateVisibleItemRange(out int startIndex, out int endIndex)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			Vector2 anchoredPosition = ScrollRect.content.anchoredPosition;
			int num = Mathf.Max(0, Mathf.FloorToInt((anchoredPosition.y - (float)Padding.top) / _stepSize.y));
			FirstVisibleIndex = Mathf.Min(num * _columns, Mathf.Max(0, _totalItems - 1));
			int num2 = Mathf.Max(0, num - 1);
			int num3 = Mathf.Min(num2 + _maxVisibleRows + 2, _totalRows);
			startIndex = num2 * _columns;
			endIndex = Mathf.Min(num3 * _columns, _totalItems);
		}

		private Selectable GetItemSelectable(int index)
		{
			return _itemStates[index % _itemStates.Length].Selectable;
		}

		private void UpdateItemNavigation(int startIndex, int endIndex)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			if (_columns <= 0 || _totalItems <= 0)
			{
				return;
			}
			for (int i = startIndex; i < endIndex; i++)
			{
				Selectable selectable = _itemStates[i % _itemStates.Length].Selectable;
				if (!Object.op_Implicit((Object)(object)selectable))
				{
					continue;
				}
				Navigation navigation = selectable.navigation;
				((Navigation)(ref navigation)).mode = (Mode)4;
				int num = i % _columns;
				int num2 = i / _columns;
				Navigation edgeNavigation;
				Selectable selectOnLeft;
				if (num <= 0 || i - 1 < startIndex)
				{
					edgeNavigation = EdgeNavigation;
					selectOnLeft = ((Navigation)(ref edgeNavigation)).selectOnLeft;
				}
				else
				{
					selectOnLeft = GetItemSelectable(i - 1);
				}
				((Navigation)(ref navigation)).selectOnLeft = selectOnLeft;
				Selectable selectOnRight;
				if (num >= _columns - 1 || i + 1 >= endIndex)
				{
					edgeNavigation = EdgeNavigation;
					selectOnRight = ((Navigation)(ref edgeNavigation)).selectOnRight;
				}
				else
				{
					selectOnRight = GetItemSelectable(i + 1);
				}
				((Navigation)(ref navigation)).selectOnRight = selectOnRight;
				object selectOnUp;
				if (num2 <= 0 || i - _columns < startIndex)
				{
					if (num2 != 0)
					{
						selectOnUp = null;
					}
					else
					{
						edgeNavigation = EdgeNavigation;
						selectOnUp = ((Navigation)(ref edgeNavigation)).selectOnUp;
					}
				}
				else
				{
					selectOnUp = GetItemSelectable(i - _columns);
				}
				((Navigation)(ref navigation)).selectOnUp = (Selectable)selectOnUp;
				((Navigation)(ref navigation)).selectOnDown = ((i + _columns < endIndex) ? GetItemSelectable(i + _columns) : null);
				selectable.navigation = navigation;
			}
		}

		public void UpdateNavigation()
		{
			if (_itemStates.Length != 0 && !(_stepSize.y <= 0f) && _columns > 0)
			{
				CalculateVisibleItemRange(out var startIndex, out var endIndex);
				UpdateItemNavigation(startIndex, endIndex);
			}
		}

		public bool TryGetGridItem(int index, out GameObject gameObject)
		{
			if (index >= 0 && index < _totalItems && _itemStates.Length != 0)
			{
				PooledItemState pooledItemState = _itemStates[index % _itemStates.Length];
				if (pooledItemState.Index == index && ((Component)pooledItemState.RectTransform).gameObject.activeSelf)
				{
					gameObject = ((Component)pooledItemState.RectTransform).gameObject;
					return true;
				}
			}
			gameObject = null;
			return false;
		}

		public bool TryGetFirstVisibleItem(out GameObject gameObject)
		{
			if (!TryGetGridItem(FirstVisibleIndex, out gameObject))
			{
				return TryGetGridItem(0, out gameObject);
			}
			return true;
		}

		public void ScrollToItem(int index)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (_columns > 0 && index >= 0 && index < _totalItems)
			{
				int num = index / _columns;
				float num2 = (float)Padding.top + (float)num * _stepSize.y;
				float num3 = num2 + ItemSize.y;
				float viewportHeight = GetViewportHeight();
				float num4 = Mathf.Max(0f, (viewportHeight - ItemSize.y) / 2f);
				float num5 = Mathf.Clamp(ScrollPadding, 0f, num4);
				Vector2 anchoredPosition = ScrollRect.content.anchoredPosition;
				float y = anchoredPosition.y;
				float num6 = y + num5;
				float num7 = y + viewportHeight - num5;
				float num8 = y;
				if (num2 < num6)
				{
					num8 = (float)num * _stepSize.y - num5;
				}
				else if (num3 > num7)
				{
					num8 = num3 + num5 + (float)Padding.bottom - viewportHeight;
				}
				float num9 = Mathf.Max(0f, _totalHeight - viewportHeight);
				num8 = Mathf.Clamp(num8, 0f, num9);
				if (!Mathf.Approximately(num8, y))
				{
					anchoredPosition.y = num8;
					ScrollRect.content.anchoredPosition = anchoredPosition;
					Refresh();
				}
			}
		}
	}
	public sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		public readonly UnityEvent<Vector2> OnPanelDragEnd = new UnityEvent<Vector2>();

		private Vector2 _lastMousePosition;

		private RectTransform _targetRectTransform;

		public void SetTargetRectTransform(RectTransform targetRectTransform)
		{
			_targetRectTransform = targetRectTransform;
		}

		private void Start()
		{
			if (!Object.op_Implicit((Object)(object)_targetRectTransform))
			{
				_targetRectTransform = ((Component)this).GetComponent<RectTransform>();
			}
		}

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_lastMousePosition = eventData.position;
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = eventData.position - _lastMousePosition;
			RectTransform targetRectTransform = _targetRectTransform;
			((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, 0f);
			_lastMousePosition = eventData.position;
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			OnPanelDragEnd.Invoke(_targetRectTransform.anchoredPosition);
		}
	}
	public sealed class PanelResizer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
	{
		public UnityEvent<Vector2> OnPanelResizeEnd = new UnityEvent<Vector2>();

		private CanvasGroup _canvasGroup;

		private ComfyTween<float> _alphaTween;

		private float _targetAlpha;

		private Vector2 _lastMousePosition;

		private RectTransform _targetRectTransform;

		public void SetTargetRectTransform(RectTransform rectTransform)
		{
			_targetRectTransform = rectTransform;
		}

		private void Awake()
		{
			_canvasGroup = ((Component)this).GetComponent<CanvasGroup>();
			_alphaTween = new ComfyTween<float>((MonoBehaviour)(object)this, 0.25f, (Func<float>)(() => _canvasGroup.alpha), (Action<float>)delegate(float alpha)
			{
				_canvasGroup.SetAlpha(alpha);
			}, (Func<float, float, float, float>)Mathf.Lerp);
		}

		private void SetCanvasGroupAlpha(float alpha)
		{
			if (_canvasGroup.alpha != alpha)
			{
				_alphaTween.To(alpha);
			}
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			_targetAlpha = 1f;
			SetCanvasGroupAlpha(_targetAlpha);
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			_targetAlpha = 0f;
			if (!eventData.dragging)
			{
				SetCanvasGroupAlpha(_targetAlpha);
			}
		}

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			SetCanvasGroupAlpha(1f);
			_lastMousePosition = eventData.position;
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0046: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = _lastMousePosition - eventData.position;
			RectTransform targetRectTransform = _targetRectTransform;
			targetRectTransform.sizeDelta += new Vector2(-1f * val.x, val.y);
			_lastMousePosition = eventData.position;
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			SetCanvasGroupAlpha(_targetAlpha);
			OnPanelResizeEnd.Invoke(_targetRectTransform.sizeDelta);
		}
	}
	public static class UIBuilder
	{
		public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false);
			((TMP_Text)obj.SetName<TextMeshProUGUI>("Label").SetRichText<TextMeshProUGUI>(richText: true).SetEnableAutoSizing<TextMeshProUGUI>(enableAutoSizing: false)
				.SetTextWrappingMode<TextMeshProUGUI>((TextWrappingModes)0)
				.SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0)
				.SetColor<TextMeshProUGUI>(Color.white)
				.SetFontSize<TextMeshProUGUI>(16f)).SetText(string.Empty);
			return obj;
		}

		public static TextMeshProUGUI CreateTMPHeaderLabel(Transform parentTransform)
		{
			TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.headerText, parentTransform, false);
			((TMP_Text)obj.SetName<TextMeshProUGUI>("Label").SetRichText<TextMeshProUGUI>(richText: true).SetEnableAutoSizing<TextMeshProUGUI>(enableAutoSizing: false)
				.SetTextWrappingMode<TextMeshProUGUI>((TextWrappingModes)0)
				.SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0)
				.SetFontSize<TextMeshProUGUI>(32f)).SetText(string.Empty);
			return obj;
		}

		public static GameObject CreateResizer(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			GameObject val = new GameObject("Resizer", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parentTransform, false);
			val.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true);
			val.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right)
				.SetPivot(Vector2.right)
				.SetSizeDelta(new Vector2(42.5f, 42.5f))
				.SetPosition(new Vector2(10f, -10f));
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button"))
				.SetColor(new Color(1f, 1f, 1f, 0.95f));
			val.AddComponent<CanvasGroup>().SetAlpha(0f);
			TextMeshProUGUI obj = CreateTMPLabel(val.transform);
			obj.SetName<TextMeshProUGUI>("Icon");
			((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetPivot(new Vector2(0.5f, 0.5f))
				.SetSizeDelta(Vector2.zero);
			((TMP_Text)obj.SetAlignment<TextMeshProUGUI>((TextAlignmentOptions)514).SetFontSize<TextMeshProUGUI>(24f).SetOverflowMode<TextMeshProUGUI>((TextOverflowModes)0)).SetText("<rotate=-45>↔</rotate>");
			return val;
		}
	}
	public static class CanvasGroupExtensions
	{
		public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha)
		{
			canvasGroup.alpha = alpha;
			return canvasGroup;
		}

		public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts)
		{
			canvasGroup.blocksRaycasts = blocksRaycasts;
			return canvasGroup;
		}
	}
	public static class ColorExtensions
	{
		public static Color SetAlpha(this Color color, float alpha)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			color.a = alpha;
			return color;
		}
	}
	public static class ContentSizeFitterExtensions
	{
		public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			fitter.horizontalFit = fitMode;
			return fitter;
		}

		public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			fitter.verticalFit = fitMode;
			return fitter;
		}
	}
	public static class LayoutGroupExtensions
	{
		public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : HorizontalOrVerticalLayoutGroup
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)(object)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value;
			}
			if (height.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value;
			}
			return layoutGroup;
		}

		public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value;
			}
			if (height.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value;
			}
			return layoutGroup;
		}

		public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup
		{
			if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue)
			{
				throw new ArgumentException("Value for left, right, top or bottom must be provided.");
			}
			if (left.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup
		{
			((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
			return layoutGroup;
		}
	}
	public static class ImageExtensions
	{
		public static Image SetColor(this Image image, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).color = color;
			return image;
		}

		public static Image SetFillAmount(this Image image, float amount)
		{
			image.fillAmount = amount;
			return image;
		}

		public static Image SetFillCenter(this Image image, bool fillCenter)
		{
			image.fillCenter = fillCenter;
			return image;
		}

		public static Image SetFillMethod(this Image image, FillMethod fillMethod)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			image.fillMethod = fillMethod;
			return image;
		}

		public static Image SetFillOrigin(this Image image, OriginHorizontal origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			image.fillOrigin = (int)origin;
			return image;
		}

		public static Image SetFillOrigin(this Image image, OriginVertical origin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			image.fillOrigin = (int)origin;
			return image;
		}

		public static Image SetMaskable(this Image image, bool maskable)
		{
			((MaskableGraphic)image).maskable = maskable;
			return image;
		}

		public static Image SetMaterial(this Image image, Material material)
		{
			((Graphic)image).material = material;
			return image;
		}

		public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier)
		{
			image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier;
			return image;
		}

		public static Image SetPreserveAspect(this Image image, bool preserveAspect)
		{
			image.preserveAspect = preserveAspect;
			return image;
		}

		public static Image SetRaycastTarget(this Image image, bool raycastTarget)
		{
			((Graphic)image).raycastTarget = raycastTarget;
			return image;
		}

		public static Image SetSprite(this Image image, Sprite sprite)
		{
			image.sprite = sprite;
			return image;
		}

		public static Image SetType(this Image image, Type type)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			image.type = type;
			return image;
		}
	}
	public static class LayoutElementExtensions
	{
		public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.flexibleWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.flexibleHeight = height.Value;
			}
			return layoutElement;
		}

		public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout)
		{
			layoutElement.ignoreLayout = ignoreLayout;
			return layoutElement;
		}

		public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.minWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.minHeight = height.Value;
			}
			return layoutElement;
		}

		public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null)
		{
			if (!width.HasValue && !height.HasValue)
			{
				throw new ArgumentException("Value for width or height must be provided.");
			}
			if (width.HasValue)
			{
				layoutElement.preferredWidth = width.Value;
			}
			if (height.HasValue)
			{
				layoutElement.preferredHeight = height.Value;
			}
			return layoutElement;
		}
	}
	public static class RectMask2DExtensions
	{
		public static RectMask2D SetSoftness(this RectMask2D rectMask2d, Vector2Int softness)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectMask2d.softness = softness;
			return rectMask2d;
		}
	}
	public static class RectTransformExtensions
	{
		public static RectTransform OffsetPosition(this RectTransform rectTransform, Vector2 offset)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition += offset;
			return rectTransform;
		}

		public static RectTransform OffsetSizeDelta(this RectTransform rectTransform, Vector2 offset)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta += offset;
			return rectTransform;
		}

		public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = anchorMin;
			return rectTransform;
		}

		public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMax = anchorMax;
			return rectTransform;
		}

		public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.pivot = pivot;
			return rectTransform;
		}

		public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = position;
			return rectTransform;
		}

		public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta = sizeDelta;
			return rectTransform;
		}
	}
	public static class SelectableExtensions
	{
		public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).colors = colors;
			return selectable;
		}

		public static T SetImage<T>(this T selectable, Image image) where T : Selectable
		{
			((Selectable)selectable).image = image;
			return selectable;
		}

		public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable
		{
			((Selectable)selectable).interactable = interactable;
			return selectable;
		}

		public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).spriteState = spriteState;
			return selectable;
		}

		public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable
		{
			((Selectable)selectable).targetGraphic = graphic;
			return selectable;
		}

		public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)selectable).transition = transition;
			return selectable;
		}

		public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Navigation navigation = ((Selectable)selectable).navigation;
			((Navigation)(ref navigation)).mode = mode;
			((Selectable)selectable).navigation = navigation;
			return selectable;
		}
	}
	public static class ScrollRectExtensions
	{
		public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect
		{
			((ScrollRect)scrollRect).content = content;
			return scrollRect;
		}

		public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect
		{
			((ScrollRect)scrollRect).horizontal = horizontal;
			return scrollRect;
		}

		public static T SetInertia<T>(this T scrollRect, bool inertia) where T : ScrollRect
		{
			((ScrollRect)scrollRect).inertia = inertia;
			return scrollRect;
		}

		public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ScrollRect)scrollRect).movementType = movementType;
			return scrollRect;
		}

		public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect
		{
			((ScrollRect)scrollRect).scrollSensitivity = sensitivity;
			return scrollRect;
		}

		public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect
		{
			((ScrollRect)scrollRect).vertical = vertical;
			return scrollRect;
		}

		public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect
		{
			((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar;
			return scrollRect;
		}

		public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect
		{
			((ScrollRect)scrollRect).verticalNormalizedPosition = position;
			return scrollRect;
		}

		public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility;
			return scrollRect;
		}

		public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect
		{
			((ScrollRect)scrollRect).viewport = viewport;
			return scrollRect;
		}
	}
	public static class TextMeshProExtensions
	{
		public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).alignment = alignment;
			return tmpText;
		}

		public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)(object)tmpText).color = color;
			return tmpText;
		}

		public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text
		{
			((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing;
			return tmpText;
		}

		public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text
		{
			((TMP_Text)tmpText).font = font;
			return tmpText;
		}

		public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text
		{
			((TMP_Text)tmpText).fontSize = fontSize;
			return tmpText;
		}

		public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text
		{
			((TMP_Text)tmpText).fontMaterial = fontMaterial;
			return tmpText;
		}

		public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).margin = margin;
			return tmpText;
		}

		public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).overflowMode = overflowMode;
			return tmpText;
		}

		public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text
		{
			((TMP_Text)tmpText).richText = richText;
			return tmpText;
		}

		public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)tmpText).textWrappingMode = textWrappingMode;
			return tmpText;
		}
	}
	public static class Texture2DExtensions
	{
		public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Texture)texture).filterMode = filterMode;
			return texture;
		}

		public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Texture)texture).wrapMode = wrapMode;
			return texture;
		}
	}
	public static class UIResources
	{
		public static readonly ResourceCache<Sprite> SpriteCache = new ResourceCache<Sprite>();

		public static readonly ResourceCache<Material> MaterialCache = new ResourceCache<Material>();

		public static Sprite GetSprite(string spriteName)
		{
			return SpriteCache.GetResource(spriteName);
		}

		public static Material GetMaterial(string materialName)
		{
			return MaterialCache.GetResource(materialName);
		}
	}
	public sealed class ResourceCache<T> where T : Object
	{
		private readonly Dictionary<string, T> _cache = new Dictionary<string, T>();

		public T GetResource(string resourceName)
		{
			if (!_cache.TryGetValue(resourceName, out var value))
			{
				value = Resources.FindObjectsOfTypeAll<T>().FirstByNameOrThrow(resourceName);
				_cache[resourceName] = value;
			}
			return value;
		}
	}
}