Decompiled source of SearsCatalog v1.4.0

SearsCatalog.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ComfyLib;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
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.4.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
namespace SearsCatalog
{
	[HarmonyPatch(typeof(Hud))]
	internal static class HudPatch
	{
		private static readonly WaitForSeconds _waitOneSecond = new WaitForSeconds(1f);

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ref Hud __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SetupPieceSelectionWindow(__instance);
				((MonoBehaviour)__instance).StartCoroutine(SetupBuildHudPanelDelayed());
			}
		}

		private static IEnumerator SetupBuildHudPanelDelayed()
		{
			yield return _waitOneSecond;
			SearsCatalog.SetupBuildHudPanel();
		}

		private static void SetupPieceSelectionWindow(Hud hud)
		{
			//IL_000e: 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_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)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00cc: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)hud.m_pieceListRoot).parent;
			Resources val = default(Resources);
			val.standard = UIResources.GetSprite("UISprite");
			Scrollbar component = DefaultControls.CreateScrollbar(val).GetComponent<Scrollbar>();
			((Component)component).transform.SetParent(parent, false);
			((Component)component).GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.one)
				.SetPivot(Vector2.one)
				.SetPosition(Vector2.zero)
				.SetSizeDelta(new Vector2(10f, 0f));
			component.direction = (Direction)2;
			((Component)component).GetComponent<Image>().SetColor(new Color(0f, 0f, 0f, 0.6f));
			((Component)component.handleRect).GetComponent<Image>().SetColor(new Color(1f, 1f, 1f, 0.9f));
			((Component)parent).GetComponent<RectTransform>().OffsetSizeDelta(new Vector2(10f, 0f));
			ScrollRect obj = ((Component)parent).gameObject.AddComponent<ScrollRect>();
			obj.content = hud.m_pieceListRoot;
			obj.viewport = ((Component)parent).GetComponent<RectTransform>();
			obj.verticalScrollbar = component;
			obj.movementType = (MovementType)2;
			obj.inertia = false;
			obj.scrollSensitivity = hud.m_pieceIconSpacing;
			obj.verticalScrollbarVisibility = (ScrollbarVisibility)0;
			GameObject gameObject = ((Component)hud.m_pieceSelectionWindow.transform.parent).gameObject;
			RectTransform val2 = gameObject.RectTransform();
			val2.SetPosition(PluginConfig.BuildHudPanelPosition.Value);
			PanelDragger panelDragger = gameObject.AddComponent<PanelDragger>();
			panelDragger.TargetRectTransform = val2;
			panelDragger.OnPanelEndDrag += delegate(object _, Vector3 position)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				PluginConfig.BuildHudPanelPosition.Value = Vector2.op_Implicit(position);
			};
			PanelResizer panelResizer = UIBuilder.CreateResizer((Transform)(object)val2).AddComponent<PanelResizer>();
			panelResizer.TargetRectTransform = val2;
			panelResizer.OnPanelEndResize += delegate(object _, Vector2 sizeDelta)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				SearsCatalog.ResizeBuildHudPanel(sizeDelta);
			};
			SearsCatalog.BuildHudPanelTransform = val2;
			SearsCatalog.BuildHudScrollbar = component;
			SearsCatalog.BuildHudScrollRect = obj;
			SearsCatalog.BuildHudNeedRefresh = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("TogglePieceSelection")]
		private static void TogglePieceSelectionPostfix(ref Hud __instance)
		{
			if (PluginConfig.IsModEnabled.Value && __instance.m_pieceSelectionWindow.activeSelf)
			{
				SearsCatalog.CenterOnSelectedIndex();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("UpdatePieceList")]
		private static void UpdatePieceListPrefix(ref Hud __instance, ref PieceCategory category, ref bool __state)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			if (PluginConfig.IsModEnabled.Value)
			{
				__state = (int)__instance.m_lastPieceCategory == (int)category;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdatePieceList")]
		private static void UpdatePieceListPostfix(ref Hud __instance, ref bool __state)
		{
			//IL_0039: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.IsModEnabled.Value && SearsCatalog.BuildHudNeedIconLayoutRefresh)
			{
				SearsCatalog.BuildHudNeedIconLayoutRefresh = false;
				foreach (PieceIconData pieceIcon in __instance.m_pieceIcons)
				{
					pieceIcon.m_go.RectTransform().SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.up)
						.SetPivot(Vector2.up);
				}
			}
			if (PluginConfig.IsModEnabled.Value && (!__state || SearsCatalog.BuildHudNeedIconRecenter))
			{
				SearsCatalog.BuildHudNeedIconRecenter = false;
				SearsCatalog.CenterOnSelectedIndex();
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("UpdatePieceList")]
		private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Player), "GetBuildPieces", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null)
			}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<List<Piece>, List<Piece>>>((Func<List<Piece>, List<Piece>>)GetBuildPiecesDelegate) })
				.Advance(2)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GridColumnsDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null)
				})
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GridRowsDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null)
				})
				.Advance(3)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)PieceIconsCountMultiplyDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Hud), "m_pieceIcons"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(List<PieceIconData>), "Clear", (Type[])null, (Type[])null), (string)null)
				})
				.Advance(2)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					Transpilers.EmitDelegate<Action<Hud>>((Action<Hud>)PieceIconsClearPostDelegate)
				})
				.InstructionEnumeration();
		}

		private static List<Piece> GetBuildPiecesDelegate(List<Piece> buildPieces)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SearsCatalog.BuildHudRows = buildPieces.Count / SearsCatalog.BuildHudColumns + ((buildPieces.Count % SearsCatalog.BuildHudColumns != 0) ? 1 : 0);
			}
			return buildPieces;
		}

		private static int PieceIconsCountMultiplyDelegate(int value)
		{
			if (PluginConfig.IsModEnabled.Value && SearsCatalog.BuildHudNeedRefresh)
			{
				return -1;
			}
			return value;
		}

		private static void PieceIconsClearPostDelegate(Hud hud)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.IsModEnabled.Value)
			{
				hud.m_pieceListRoot.sizeDelta = new Vector2(hud.m_pieceIconSpacing * (float)SearsCatalog.BuildHudColumns, hud.m_pieceIconSpacing * (float)SearsCatalog.BuildHudRows);
				SearsCatalog.BuildHudNeedRefresh = false;
				SearsCatalog.BuildHudNeedIconLayoutRefresh = true;
				SearsCatalog.BuildHudNeedIconRecenter = true;
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("GetSelectedGrid")]
		private static IEnumerable<CodeInstruction> GetSelectedGridTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_002d: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
			}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GridColumnsDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null)
				})
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GridRowsDelegate) })
				.InstructionEnumeration();
		}

		private static int GridColumnsDelegate(int columns)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return columns;
			}
			return SearsCatalog.BuildHudColumns;
		}

		private static int GridRowsDelegate(int rows)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return rows;
			}
			return SearsCatalog.BuildHudRows;
		}
	}
	[HarmonyPatch(typeof(PieceTable))]
	internal static class PieceTablePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetCategory")]
		private static void SetCategoryPostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SearsCatalog.BuildHudNeedRefresh = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("PrevCategory")]
		private static void PrevCategoryPostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SearsCatalog.BuildHudNeedRefresh = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("NextCategory")]
		private static void NextCategoryPostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SearsCatalog.BuildHudNeedRefresh = true;
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("GetPiece", new Type[]
		{
			typeof(int),
			typeof(Vector2Int)
		})]
		private static IEnumerable<CodeInstruction> GetPieceTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarga_S, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Vector2Int), "get_y", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)null, (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.GetPiece()!").Advance(3)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceGetYPostDelegate) })
				.InstructionEnumeration();
		}

		private static int GetPieceGetYPostDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return SearsCatalog.BuildHudColumns;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("GetPieceIndex")]
		private static IEnumerable<CodeInstruction> GetPieceIndexTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_002d: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (Column A)").Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceIndexColumnPostDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
				})
				.ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (Column B)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceIndexColumnPostDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
				})
				.ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (Column C)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceIndexColumnPostDelegate) })
				.InstructionEnumeration();
		}

		private static int GetPieceIndexColumnPostDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return SearsCatalog.BuildHudColumns;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("LeftPiece")]
		private static IEnumerable<CodeInstruction> LeftPieceTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_002d: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(14), (string)null)
			}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)LeftPieceDelegate) })
				.InstructionEnumeration();
		}

		private static int LeftPieceDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return SearsCatalog.BuildHudColumns - 1;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("RightPiece")]
		private static IEnumerable<CodeInstruction> RightPieceTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_002d: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
			}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)RightPieceDelegate) })
				.InstructionEnumeration();
		}

		private static int RightPieceDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return SearsCatalog.BuildHudColumns;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("UpPiece")]
		private static IEnumerable<CodeInstruction> UpPieceTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_5, (object)null, (string)null)
			}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)UpPieceDelegate) })
				.InstructionEnumeration();
		}

		private static int UpPieceDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return SearsCatalog.BuildHudRows - 1;
		}

		[HarmonyTranspiler]
		[HarmonyPatch("DownPiece")]
		private static IEnumerable<CodeInstruction> DownPieceTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null)
			}).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)DownPieceDelegate) })
				.InstructionEnumeration();
		}

		private static int DownPieceDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return SearsCatalog.BuildHudRows;
		}

		[HarmonyPostfix]
		[HarmonyPatch("LeftPiece")]
		[HarmonyPatch("RightPiece")]
		[HarmonyPatch("UpPiece")]
		[HarmonyPatch("DownPiece")]
		private static void ControllerPiecePostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				SearsCatalog.CenterOnSelectedIndex();
			}
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal static class PlayerPatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch("UpdateBuildGuiInput")]
		private static IEnumerable<CodeInstruction> UpdateBuildGuiInputTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null)
			}).ThrowIfInvalid("Could not patch Player.UpdateBuildGuiInput()! (PrevCategory)").Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<float, float>>((Func<float, float>)GetAxisDelegate) })
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null)
				})
				.ThrowIfInvalid("Could not patch Player.UpdateBuildGuiInput()! (NextCategory)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<float, float>>((Func<float, float>)GetAxisDelegate) })
				.InstructionEnumeration();
		}

		private static float GetAxisDelegate(float result)
		{
			if (result != 0f && PluginConfig.IsModEnabled.Value)
			{
				return 0f;
			}
			return result;
		}
	}
	public static class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static ConfigEntry<int> BuildHudPanelRows { get; private set; }

		public static ConfigEntry<int> BuildHudPanelColumns { get; private set; }

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

		public static ConfigEntry<float> CategoryRootSizeWidthOffset { get; private set; }

		public static ConfigEntry<float> TabBorderSizeWidthOffset { get; private set; }

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

		public static void BindConfig(ConfigFile config)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod.");
			BuildHudPanelRows = config.BindInOrder("BuildHud.Panel", "buildHudPanelRows", 6, "BuildHud.Panel visible rows (vanilla: 6).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 14));
			BuildHudPanelRows.OnSettingChanged<int>(SearsCatalog.SetupBuildHudPanel);
			BuildHudPanelColumns = config.BindInOrder("BuildHud.Panel", "buildHudPanelColumns", 15, "BuildHud.Panel visible columns (vanilla: 15).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 26));
			BuildHudPanelColumns.OnSettingChanged<int>(SearsCatalog.SetupBuildHudPanel);
			BuildHudPanelPosition = config.BindInOrder<Vector2>("BuildHud.Panel", "buildHudPanelPosition", Vector2.zero, "BuildHud.Panel position relative to center of the screen.");
			CategoryRootSizeWidthOffset = config.BindInOrder("BuildHud.Panel.PieceSelection", "categoryRootSizeWidthOffset", -155f, "BuildHud.Panel.CategoryRoot.sizeDelta width offset relative to panel width.");
			CategoryRootSizeWidthOffset.OnSettingChanged<float>(SearsCatalog.SetupPieceSelectionWindow);
			TabBorderSizeWidthOffset = config.BindInOrder("BuildHud.Panel.PieceSelection", "tabBorderSizeWidthOffset", -45f, "BuildHud.Panel.PieceSelection.TabBorder.sizeDelta width offset relative to panel width.");
			TabBorderSizeWidthOffset.OnSettingChanged<float>(SearsCatalog.SetupPieceSelectionWindow);
			InputHelpSizeDeltaOffset = config.BindInOrder<Vector2>("BuildHud.Panel.PieceSelection", "inputHelpSizeDeltaOffset", new Vector2(-85f, 0f), "BuildHud.Panel.PieceSelection.InputHelp.sizeDelta offset relative to panel size.");
			InputHelpSizeDeltaOffset.OnSettingChanged<Vector2>(SearsCatalog.SetupPieceSelectionWindow);
		}
	}
	public static class ObjectExtensions
	{
		public static T Ref<T>(this T o) where T : Object
		{
			if (!Object.op_Implicit((Object)(object)o))
			{
				return default(T);
			}
			return o;
		}
	}
	public static class ScrollRectExtensions
	{
		public static void EnsureVisibility(this 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_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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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;
			float y = child.anchoredPosition.y;
			rect = child.rect;
			float num = y - ((Rect)(ref rect)).height;
			float num2 = 0f - anchoredPosition.y - padding;
			float num3 = 0f - anchoredPosition.y - height + padding;
			float num4 = ((y > num2) ? (num2 - y) : ((num < num3) ? (num3 - num) : 0f));
			anchoredPosition.y += num4;
			scrollRect.content.anchoredPosition = anchoredPosition;
		}
	}
	[BepInPlugin("redseiko.valheim.searscatalog", "SearsCatalog", "1.4.0")]
	public sealed class SearsCatalog : BaseUnityPlugin
	{
		public const string PluginGuid = "redseiko.valheim.searscatalog";

		public const string PluginName = "SearsCatalog";

		public const string PluginVersion = "1.4.0";

		private static RectTransform _tabBorderRectTransform;

		private static RectTransform _inputHelpLeftRectTransform;

		private static RectTransform _inputHelpRightRectTransform;

		public static Harmony HarmonyInstance { get; private set; }

		public static int BuildHudColumns { get; set; } = 15;


		public static int BuildHudRows { get; set; } = 0;


		public static bool BuildHudNeedRefresh { get; set; } = false;


		public static bool BuildHudNeedIconLayoutRefresh { get; set; } = false;


		public static bool BuildHudNeedIconRecenter { get; set; } = false;


		public static RectTransform BuildHudPanelTransform { get; set; }

		public static Scrollbar BuildHudScrollbar { get; set; }

		public static ScrollRect BuildHudScrollRect { get; set; }

		public static GameObject BuildHudPanelResizer { get; set; }

		private void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.searscatalog");
		}

		private void OnDestroy()
		{
			Harmony harmonyInstance = HarmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
		}

		public static void SetupBuildHudPanel()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Hud.m_instance) && Object.op_Implicit((Object)(object)BuildHudPanelTransform))
			{
				BuildHudColumns = PluginConfig.BuildHudPanelColumns.Value;
				BuildHudRows = 0;
				float pieceIconSpacing = Hud.m_instance.m_pieceIconSpacing;
				BuildHudPanelTransform.SetSizeDelta(new Vector2((float)BuildHudColumns * pieceIconSpacing + 35f, (float)PluginConfig.BuildHudPanelRows.Value * pieceIconSpacing + 70f));
				BuildHudNeedRefresh = true;
				SetupPieceSelectionWindow();
			}
		}

		public static void SetupPieceSelectionWindow()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Hud.m_instance) && Object.op_Implicit((Object)(object)BuildHudPanelTransform))
			{
				float x = BuildHudPanelTransform.sizeDelta.x;
				float y = BuildHudPanelTransform.sizeDelta.y;
				Hud.m_instance.m_pieceCategoryRoot.RectTransform().SetSizeWithCurrentAnchors((Axis)0, x + PluginConfig.CategoryRootSizeWidthOffset.Value);
				SetupTabBorder(Hud.m_instance, x);
				float num = x + PluginConfig.InputHelpSizeDeltaOffset.Value.x;
				float num2 = y / 2f + PluginConfig.InputHelpSizeDeltaOffset.Value.y;
				if (!Object.op_Implicit((Object)(object)_inputHelpLeftRectTransform))
				{
					Transform obj = Hud.m_instance.m_pieceSelectionWindow.transform.Find("InputHelp/MK hints/Left").Ref<Transform>();
					_inputHelpLeftRectTransform = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
				}
				_inputHelpLeftRectTransform.Ref<RectTransform>()?.SetPosition(new Vector2(num / -2f, num2));
				if (!Object.op_Implicit((Object)(object)_inputHelpRightRectTransform))
				{
					Transform obj2 = Hud.m_instance.m_pieceSelectionWindow.transform.Find("InputHelp/MK hints/Right").Ref<Transform>();
					_inputHelpRightRectTransform = ((obj2 != null) ? ((Component)obj2).GetComponent<RectTransform>() : null);
				}
				_inputHelpRightRectTransform.Ref<RectTransform>()?.SetPosition(new Vector2(num / 2f, num2));
			}
		}

		private static void SetupTabBorder(Hud hud, float width)
		{
			if (!Object.op_Implicit((Object)(object)_tabBorderRectTransform))
			{
				_tabBorderRectTransform = hud.m_pieceSelectionWindow.transform.Find("TabBorder").RectTransform<Transform>();
			}
			if (!Object.op_Implicit((Object)(object)_tabBorderRectTransform))
			{
				_tabBorderRectTransform = hud.m_pieceCategoryRoot.transform.Find("TabBorder").RectTransform<Transform>();
			}
			RectTransform obj = _tabBorderRectTransform.Ref<RectTransform>();
			if (obj != null)
			{
				obj.SetSizeWithCurrentAnchors((Axis)0, width + PluginConfig.TabBorderSizeWidthOffset.Value);
			}
		}

		public static void ResizeBuildHudPanel(Vector2 sizeDelta)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			float pieceIconSpacing = Hud.m_instance.m_pieceIconSpacing;
			PluginConfig.BuildHudPanelColumns.Value = Mathf.Max(Mathf.FloorToInt((sizeDelta.x - 35f) / pieceIconSpacing), 1);
			PluginConfig.BuildHudPanelRows.Value = Mathf.Max(Mathf.FloorToInt((sizeDelta.y - 70f) / pieceIconSpacing), 1);
		}

		public static void CenterOnSelectedIndex()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer.Ref<Player>()?.m_buildPieces) || !Object.op_Implicit((Object)(object)Hud.m_instance))
			{
				return;
			}
			Vector2Int selectedIndex = Player.m_localPlayer.m_buildPieces.GetSelectedIndex();
			int num = BuildHudColumns * ((Vector2Int)(ref selectedIndex)).y + ((Vector2Int)(ref selectedIndex)).x;
			if (num < Hud.m_instance.m_pieceIcons.Count)
			{
				PieceIconData val = Hud.m_instance.m_pieceIcons[num];
				if (Object.op_Implicit((Object)(object)val.m_go))
				{
					BuildHudScrollRect.EnsureVisibility(val.m_go.GetComponent<RectTransform>());
				}
			}
		}
	}
	public class PieceListPanel
	{
		public GameObject Panel { get; private set; }

		public GameObject Viewport { get; private set; }

		public GameObject Content { get; private set; }

		public ScrollRect ScrollRect { get; private set; }

		public PanelDragger PanelDragger { get; private set; }

		public ValueCell PieceNameFilter { get; private set; }

		public PieceListPanel(Transform parentTransform)
		{
			Panel = CreateChildPanel(parentTransform);
			PanelDragger = CreateChildPanelDragger(Panel.transform).AddComponent<PanelDragger>();
			PanelDragger.TargetRectTransform = Panel.RectTransform();
			PieceNameFilter = new ValueCell(Panel.transform);
			PieceNameFilter.Cell.LayoutElement().SetFlexible(1f);
			Viewport = CreateChildViewport(Panel.transform);
			Content = CreateChildContent(Viewport.transform);
			ScrollRect = CreateChildScrollRect(Panel, Viewport, Content);
		}

		private GameObject CreateChildPanel(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_0025: Expected O, but got Unknown
			//IL_0026: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			GameObject val = new GameObject("PieceListPanel", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetPadding(5, 5, 10, 5)
				.SetSpacing(5f);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(256, 256, 12, (FilterMode)1))
				.SetColor(new Color(0f, 0f, 0f, 0.9f));
			return val;
		}

		private GameObject CreateChildViewport(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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			GameObject val = new GameObject("Viewport", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<RectMask2D>().SetSoftness(Vector2Int.zero);
			val.AddComponent<LayoutElement>().SetFlexible(1f, 1f);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(128, 128, 8, (FilterMode)1))
				.SetColor(new Color(0.5f, 0.5f, 0.5f, 0.1f));
			val.AddComponent<Outline>().SetEffectDistance(new Vector2(2f, -2f));
			return val;
		}

		private GameObject CreateChildContent(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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_002c: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			GameObject val = new GameObject("Content", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			GameObjectExtensions.RectTransform(val).SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.up)
				.SetPivot(Vector2.up);
			val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetSpacing(0f);
			val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)2).SetVerticalFit((FitMode)2);
			val.AddComponent<Image>().SetColor(Color.clear).SetRaycastTarget(raycastTarget: true);
			return val;
		}

		private ScrollRect CreateChildScrollRect(GameObject panel, GameObject viewport, GameObject content)
		{
			return panel.AddComponent<ScrollRect>().SetViewport(viewport.RectTransform()).SetContent(content.RectTransform())
				.SetHorizontal(horizontal: false)
				.SetVertical(vertical: true)
				.SetScrollSensitivity(30f);
		}

		private GameObject CreateChildPanelDragger(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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0039: 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)
			//IL_0057: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			GameObject val = new GameObject("PanelDragger", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true);
			GameObjectExtensions.RectTransform(val).SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one)
				.SetPivot(new Vector2(0.5f, 0.5f))
				.SetSizeDelta(Vector2.zero);
			val.AddComponent<Image>().SetColor(Color.clear);
			return val;
		}
	}
	public class PieceListRow
	{
		private static readonly Lazy<ColorBlock> ButtonColorBlock = new Lazy<ColorBlock>((Func<ColorBlock>)delegate
		{
			//IL_0002: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock result = default(ColorBlock);
			((ColorBlock)(ref result)).normalColor = new Color(0f, 0f, 0f, 0.01f);
			((ColorBlock)(ref result)).highlightedColor = Color32.op_Implicit(new Color32((byte)50, (byte)161, (byte)217, (byte)128));
			((ColorBlock)(ref result)).disabledColor = new Color(0f, 0f, 0f, 0.1f);
			((ColorBlock)(ref result)).pressedColor = Color32.op_Implicit(new Color32((byte)50, (byte)161, (byte)217, (byte)192));
			((ColorBlock)(ref result)).selectedColor = Color32.op_Implicit(new Color32((byte)50, (byte)161, (byte)217, (byte)248));
			((ColorBlock)(ref result)).colorMultiplier = 1f;
			((ColorBlock)(ref result)).fadeDuration = 0f;
			return result;
		});

		public GameObject Row { get; private set; }

		public Image PieceIcon { get; private set; }

		public Text PieceName { get; private set; }

		public PieceListRow(Transform parentTransform)
		{
			Row = CreateChildRow(parentTransform);
			PieceIcon = CreateChildPieceIcon(Row.transform).Image();
			PieceName = CreateChildPieceName(Row.transform).Text();
			CreateChildRowSpacer(Row.transform);
		}

		public void SetContent(Piece piece)
		{
			PieceIcon.SetSprite(piece.m_icon);
			PieceName.SetText(Localization.m_instance.Localize(piece.m_name));
		}

		private GameObject CreateChildRow(Transform parentTransform)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PieceListRow", new Type[1] { typeof(RectTransform) });
			val.SetParent(parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetChildAlignment((TextAnchor)4)
				.SetPadding(5, 5, 5, 5)
				.SetSpacing(5f);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(400, 400, 5, (FilterMode)1));
			((Selectable)(object)val.AddComponent<Button>()).SetNavigationMode((Mode)0).SetTargetGraphic((Graphic)(object)val.Image()).SetColors(ButtonColorBlock.Value);
			val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2);
			val.AddComponent<ParentSizeFitter>();
			return val;
		}

		private GameObject CreateChildPieceIcon(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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			GameObject val = new GameObject("Piece.Icon", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<LayoutElement>().SetPreferred(20f, 20f);
			val.AddComponent<Image>().SetType((Type)0);
			return val;
		}

		private GameObject CreateChildPieceName(Transform parentTransform)
		{
			GameObject obj = UIBuilder.CreateLabel(parentTransform);
			obj.SetName("Piece.Name");
			return obj;
		}

		private GameObject CreateChildRowSpacer(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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			GameObject val = new GameObject("Spacer", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<LayoutElement>().SetFlexible(1f);
			return val;
		}
	}
}
namespace ComfyLib
{
	public static class ConfigFileExtensions
	{
		internal sealed class ConfigurationManagerAttributes
		{
			public Action<ConfigEntryBase> CustomDrawer;

			public bool? Browsable;

			public bool? HideDefaultButton;

			public int? Order;
		}

		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)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = GetSettingOrder(section)
				}
			}));
		}

		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)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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,
					Order = GetSettingOrder(section)
				}
			}));
		}

		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>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}
	}
	public class DisableHighlightOnSelect : MonoBehaviour, ISelectHandler, IEventSystemHandler
	{
		private InputField _inputField;

		private void Start()
		{
			_inputField = ((Component)this).GetComponent<InputField>();
		}

		public void OnSelect(BaseEventData eventData)
		{
			((MonoBehaviour)this).StartCoroutine(DisableHighlight());
		}

		private IEnumerator DisableHighlight()
		{
			Color original = _inputField.selectionColor;
			_inputField.selectionColor = Color.clear;
			yield return null;
			_inputField.MoveTextEnd(false);
			_inputField.selectionColor = original;
		}
	}
	public class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		private Vector2 _lastMousePosition;

		public RectTransform TargetRectTransform;

		public event EventHandler<Vector3> OnPanelEndDrag;

		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_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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = eventData.position - _lastMousePosition;
			if (Object.op_Implicit((Object)(object)TargetRectTransform))
			{
				RectTransform targetRectTransform = TargetRectTransform;
				((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, ((Transform)TargetRectTransform).position.z);
			}
			_lastMousePosition = eventData.position;
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//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)
			if (Object.op_Implicit((Object)(object)TargetRectTransform))
			{
				this.OnPanelEndDrag?.Invoke(this, Vector2.op_Implicit(TargetRectTransform.anchoredPosition));
			}
		}
	}
	public class PanelResizer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
	{
		private CanvasGroup _canvasGroup;

		private float _targetAlpha;

		private Vector2 _lastMousePosition;

		private Coroutine _lerpAlphaCoroutine;

		public RectTransform TargetRectTransform;

		private Vector2 _originalPivot;

		public event EventHandler<Vector2> OnPanelEndResize;

		private void Awake()
		{
			_canvasGroup = ((Component)this).GetComponent<CanvasGroup>();
		}

		private void SetCanvasGroupAlpha(float alpha)
		{
			if (_lerpAlphaCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_lerpAlphaCoroutine);
				_lerpAlphaCoroutine = null;
			}
			if (_canvasGroup.alpha != alpha)
			{
				_lerpAlphaCoroutine = ((MonoBehaviour)this).StartCoroutine(LerpCanvasGroupAlpha(alpha, 0.25f));
			}
		}

		private IEnumerator LerpCanvasGroupAlpha(float targetAlpha, float lerpDuration)
		{
			float timeElapsed = 0f;
			float sourceAlpha = _canvasGroup.alpha;
			while (timeElapsed < lerpDuration)
			{
				float num = timeElapsed / lerpDuration;
				num = num * num * (3f - 2f * num);
				_canvasGroup.SetAlpha(Mathf.Lerp(sourceAlpha, targetAlpha, num));
				timeElapsed += Time.deltaTime;
				yield return null;
			}
			_canvasGroup.SetAlpha(targetAlpha);
		}

		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)
			//IL_001e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			SetCanvasGroupAlpha(1f);
			_lastMousePosition = eventData.position;
			_originalPivot = TargetRectTransform.pivot;
			SetPivot(TargetRectTransform, new Vector2(0f, 1f));
		}

		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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_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_0042: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = _lastMousePosition - eventData.position;
			if (Object.op_Implicit((Object)(object)TargetRectTransform))
			{
				RectTransform targetRectTransform = TargetRectTransform;
				targetRectTransform.sizeDelta += new Vector2(-1f * val.x, val.y);
			}
			SetCanvasGroupAlpha(1f);
			_lastMousePosition = eventData.position;
		}

		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			SetCanvasGroupAlpha(_targetAlpha);
			this.OnPanelEndResize?.Invoke(this, TargetRectTransform.sizeDelta);
			SetPivot(TargetRectTransform, _originalPivot);
		}

		private void SetPivot(RectTransform rectTransform, Vector2 pivot)
		{
			//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_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_0015: 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)
			//IL_001d: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector2.op_Implicit(rectTransform.pivot - pivot);
			Rect rect = rectTransform.rect;
			((Vector3)(ref val)).Scale(Vector2.op_Implicit(((Rect)(ref rect)).size));
			((Vector3)(ref val)).Scale(((Transform)rectTransform).localScale);
			val = ((Transform)rectTransform).rotation * val;
			rectTransform.pivot = pivot;
			((Transform)rectTransform).localPosition = ((Transform)rectTransform).localPosition - val;
		}
	}
	public class ParentSizeFitter : MonoBehaviour
	{
		private RectTransform _parentRectTransform;

		private RectTransform _rectTransform;

		private void Awake()
		{
			_parentRectTransform = ((Component)((Component)this).transform.parent).GetComponent<RectTransform>();
			_rectTransform = ((Component)this).GetComponent<RectTransform>();
		}

		private void OnRectTransformDimensionsChange()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_parentRectTransform))
			{
				_parentRectTransform = ((Component)((Component)this).transform.parent).GetComponent<RectTransform>();
			}
			if (!Object.op_Implicit((Object)(object)_rectTransform))
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			if (Object.op_Implicit((Object)(object)_rectTransform) && Object.op_Implicit((Object)(object)_parentRectTransform))
			{
				_rectTransform.SetSizeWithCurrentAnchors((Axis)0, _parentRectTransform.sizeDelta.x);
			}
		}
	}
	public class ValueCell
	{
		private static readonly Lazy<ColorBlock> InputFieldColorBlock = new Lazy<ColorBlock>((Func<ColorBlock>)delegate
		{
			//IL_0002: 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_0039: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			ColorBlock result = default(ColorBlock);
			((ColorBlock)(ref result)).normalColor = new Color(1f, 1f, 1f, 0.9f);
			((ColorBlock)(ref result)).highlightedColor = new Color(0.565f, 0.792f, 0.976f);
			((ColorBlock)(ref result)).disabledColor = new Color(0.2f, 0.2f, 0.2f, 0.8f);
			((ColorBlock)(ref result)).pressedColor = new Color(0.647f, 0.839f, 0.655f);
			((ColorBlock)(ref result)).selectedColor = new Color(1f, 0.878f, 0.51f);
			((ColorBlock)(ref result)).colorMultiplier = 1f;
			((ColorBlock)(ref result)).fadeDuration = 0.25f;
			return result;
		});

		public GameObject Cell { get; private set; }

		public Image Background { get; private set; }

		public InputField InputField { get; private set; }

		public ValueCell(Transform parentTransform)
		{
			Cell = CreateChildCell(parentTransform);
			Background = Cell.Image();
			InputField = CreateChildInputField(Cell.transform).GetComponent<InputField>();
			((Selectable)(object)InputField).SetTargetGraphic((Graphic)(object)Background);
		}

		private GameObject CreateChildCell(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_0025: Expected O, but got Unknown
			//IL_0026: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetPadding(6, 6, 4, 4)
				.SetSpacing(8f)
				.SetChildAlignment((TextAnchor)4);
			val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(64, 64, 8, (FilterMode)1))
				.SetColor(new Color(0.5f, 0.5f, 0.5f, 0.5f));
			val.AddComponent<Shadow>().SetEffectDistance(new Vector2(2f, -2f));
			val.AddComponent<LayoutElement>();
			return val;
		}

		private GameObject CreateChildInputField(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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			GameObject val = new GameObject("InputField", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false)
				.SetChildAlignment((TextAnchor)3)
				.SetSpacing(8f);
			val.AddComponent<LayoutElement>();
			GameObject val2 = UIBuilder.CreateLabel(val.transform);
			val2.SetName("InputField.Text");
			val2.Text().SetSupportRichText(supportRichText: false).SetText("InputField.Text");
			val2.AddComponent<LayoutElement>().SetFlexible(1f);
			((Selectable)(object)val.AddComponent<InputField>().SetTextComponent(val2.Text())).SetTransition((Transition)1).SetNavigationMode((Mode)0).SetColors(InputFieldColorBlock.Value);
			val.AddComponent<DisableHighlightOnSelect>();
			return val;
		}
	}
	public static class UIBuilder
	{
		private static readonly Dictionary<string, Sprite> RoundedCornerSpriteCache = new Dictionary<string, Sprite>();

		private static readonly Color32 ColorWhite = Color32.op_Implicit(Color.white);

		private static readonly Color32 ColorClear = Color32.op_Implicit(Color.clear);

		public static Sprite CreateRoundedCornerSprite(int width, int height, int radius, FilterMode filterMode = 1)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0041: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			string text = $"RoundedCorner-{width}w-{height}h-{radius}r";
			if (RoundedCornerSpriteCache.TryGetValue(text, out var value))
			{
				return value;
			}
			Texture2D val = Texture2DExtensions.SetName(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode(filterMode);
			Color32[] array = (Color32[])(object)new Color32[width * height];
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					array[i * width + j] = (IsCornerPixel(j, i, width, height, radius) ? ColorClear : ColorWhite);
				}
			}
			val.SetPixels32(array);
			val.Apply();
			int k;
			for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++)
			{
			}
			int l;
			for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++)
			{
			}
			value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName(text);
			RoundedCornerSpriteCache[text] = value;
			return value;
		}

		private static bool IsCornerPixel(int x, int y, int w, int h, int rad)
		{
			if (rad == 0)
			{
				return false;
			}
			int num = Math.Min(x, w - x);
			int num2 = Math.Min(y, h - y);
			if (num == 0 && num2 == 0)
			{
				return true;
			}
			if (num > rad || num2 > rad)
			{
				return false;
			}
			num = rad - num;
			num2 = rad - num2;
			return Math.Round(Math.Sqrt(num * num + num2 * num2)) > (double)rad;
		}

		public static GameObject CreateLabel(Transform parentTransform)
		{
			//IL_0023: 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)
			//IL_0030: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			GameObject val = new GameObject(((Object)parentTransform).name + ".Label", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<Text>().SetSupportRichText(supportRichText: true).SetFont(UIResources.AveriaSerifLibre)
				.SetFontSize(16)
				.SetAlignment((TextAnchor)3)
				.SetColor(Color.white)
				.SetResizeTextForBestFit(resizeTextForBestFit: false);
			val.AddComponent<Outline>().SetEffectColor(Color.black);
			return val;
		}

		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_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0039: 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)
			//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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			GameObject val = new GameObject("Resizer", new Type[1] { typeof(RectTransform) });
			GameObjectExtensions.SetParent(val, parentTransform);
			val.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true);
			GameObjectExtensions.RectTransform(val).SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right)
				.SetPivot(Vector2.right)
				.SetSizeDelta(new Vector2(40f, 40f))
				.SetPosition(new Vector2(10f, -10f));
			val.AddComponent<Image>().SetType((Type)1).SetSprite(CreateRoundedCornerSprite(128, 128, 12, (FilterMode)1))
				.SetColor(new Color(0.565f, 0.792f, 0.976f, 0.849f));
			val.AddComponent<Shadow>().SetEffectDistance(new Vector2(2f, -2f));
			val.AddComponent<CanvasGroup>().SetAlpha(0f);
			GameObject obj = CreateLabel(val.transform);
			obj.SetName("Resizer.Icon");
			obj.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true);
			obj.RectTransform().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one)
				.SetPivot(new Vector2(0.5f, 0.5f))
				.SetSizeDelta(Vector2.zero);
			obj.Text().SetAlignment((TextAnchor)4).SetFontSize(28)
				.SetHorizontalOverflow((HorizontalWrapMode)1)
				.SetVerticalOverflow((VerticalWrapMode)1)
				.SetText("⇖⇘");
			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 ComponentExtensions
	{
		public static RectTransform RectTransform<T>(this T component) where T : Component
		{
			if (!Object.op_Implicit((Object)(object)component))
			{
				return null;
			}
			return ((Component)component).GetComponent<RectTransform>();
		}

		public static T SetName<T>(this T component, string name) where T : Component
		{
			((Object)((Component)component).gameObject).name = name;
			return component;
		}
	}
	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 GameObjectExtensions
	{
		public static GameObject SetName(this GameObject gameObject, string name)
		{
			((Object)gameObject).name = name;
			return gameObject;
		}

		public static GameObject SetParent(this GameObject gameObject, Transform transform, bool worldPositionStays = false)
		{
			gameObject.transform.SetParent(transform, worldPositionStays);
			return gameObject;
		}

		public static IEnumerable<GameObject> Children(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return Enumerable.Empty<GameObject>();
			}
			return from Transform t in (IEnumerable)gameObject.transform
				select ((Component)t).gameObject;
		}

		public static Button Button(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return null;
			}
			return gameObject.GetComponent<Button>();
		}

		public static Image Image(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return null;
			}
			return gameObject.GetComponent<Image>();
		}

		public static LayoutElement LayoutElement(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return null;
			}
			return gameObject.GetComponent<LayoutElement>();
		}

		public static RectTransform RectTransform(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return null;
			}
			return gameObject.GetComponent<RectTransform>();
		}

		public static Text Text(this GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return null;
			}
			return gameObject.GetComponent<Text>();
		}
	}
	public static class GridLayoutGroupExtensions
	{
		public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			layoutGroup.cellSize = cellSize;
			return layoutGroup;
		}

		public static GridLayoutGroup SetConstraint(this GridLayoutGroup layoutGroup, Constraint constraint)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			layoutGroup.constraint = constraint;
			return layoutGroup;
		}

		public static GridLayoutGroup SetConstraintCount(this GridLayoutGroup layoutGroup, int constraintCount)
		{
			layoutGroup.constraintCount = constraintCount;
			return layoutGroup;
		}

		public static GridLayoutGroup SetStartAxis(this GridLayoutGroup layoutGroup, Axis startAxis)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			layoutGroup.startAxis = startAxis;
			return layoutGroup;
		}

		public static GridLayoutGroup SetStartCorner(this GridLayoutGroup layoutGroup, Corner startCorner)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			layoutGroup.startCorner = startCorner;
			return layoutGroup;
		}

		public static GridLayoutGroup SetPadding(this GridLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
		{
			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)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static GridLayoutGroup SetSpacing(this GridLayoutGroup layoutGroup, Vector2 spacing)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			layoutGroup.spacing = spacing;
			return layoutGroup;
		}
	}
	public static class HorizontalLayoutGroupExtensions
	{
		public static HorizontalLayoutGroup SetChildControl(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 HorizontalLayoutGroup SetChildForceExpand(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 HorizontalLayoutGroup SetChildAlignment(this HorizontalLayoutGroup layoutGroup, TextAnchor alignment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static HorizontalLayoutGroup SetPadding(this HorizontalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
		{
			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)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static HorizontalLayoutGroup SetSpacing(this HorizontalLayoutGroup layoutGroup, float spacing)
		{
			((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 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 InputFieldExtensions
	{
		public static InputField SetTextComponent(this InputField inputField, Text textComponent)
		{
			inputField.textComponent = textComponent;
			return inputField;
		}
	}
	public static class LayoutElementExtensions
	{
		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 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 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 SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout)
		{
			layoutElement.ignoreLayout = ignoreLayout;
			return layoutElement;
		}
	}
	public static class MaskExtensions
	{
		public static Mask SetShowMaskGraphic(this Mask mask, bool showMaskGraphic)
		{
			mask.showMaskGraphic = showMaskGraphic;
			return mask;
		}
	}
	public static class OutlineExtensions
	{
		public static Outline SetEffectColor(this Outline outline, Color effectColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Shadow)outline).effectColor = effectColor;
			return outline;
		}

		public static Outline SetEffectDistance(this Outline outline, Vector2 effectDistance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Shadow)outline).effectDistance = effectDistance;
			return outline;
		}

		public static Outline SetUseGraphicAlpha(this Outline outline, bool useGraphicAlpha)
		{
			((Shadow)outline).useGraphicAlpha = useGraphicAlpha;
			return outline;
		}
	}
	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 SetPositionX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(x, rectTransform.anchoredPosition.y);
			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 Selectable SetColors(this Selectable selectable, ColorBlock colors)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			selectable.colors = colors;
			return selectable;
		}

		public static Selectable SetImage(this Selectable selectable, Image image)
		{
			selectable.image = image;
			return selectable;
		}

		public static Selectable SetInteractable(this Selectable selectable, bool interactable)
		{
			selectable.interactable = interactable;
			return selectable;
		}

		public static Selectable SetTargetGraphic(this Selectable selectable, Graphic graphic)
		{
			selectable.targetGraphic = graphic;
			return selectable;
		}

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

		public static Selectable SetNavigationMode(this Selectable selectable, Mode mode)
		{
			//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_0009: 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)
			Navigation navigation = selectable.navigation;
			((Navigation)(ref navigation)).mode = mode;
			selectable.navigation = navigation;
			return selectable;
		}
	}
	public static class ShadowExtensions
	{
		public static Shadow SetEffectColor(this Shadow shadow, Color effectColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			shadow.effectColor = effectColor;
			return shadow;
		}

		public static Shadow SetEffectDistance(this Shadow shadow, Vector2 effectDistance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			shadow.effectDistance = effectDistance;
			return shadow;
		}
	}
	public static class ScrollRectExtensions
	{
		public static ScrollRect SetScrollSensitivity(this ScrollRect scrollRect, float sensitivity)
		{
			scrollRect.scrollSensitivity = sensitivity;
			return scrollRect;
		}

		public static ScrollRect SetVerticalScrollPosition(this ScrollRect scrollRect, float position)
		{
			scrollRect.verticalNormalizedPosition = position;
			return scrollRect;
		}

		public static ScrollRect SetViewport(this ScrollRect scrollRect, RectTransform viewport)
		{
			scrollRect.viewport = viewport;
			return scrollRect;
		}

		public static ScrollRect SetContent(this ScrollRect scrollRect, RectTransform content)
		{
			scrollRect.content = content;
			return scrollRect;
		}

		public static ScrollRect SetHorizontal(this ScrollRect scrollRect, bool horizontal)
		{
			scrollRect.horizontal = horizontal;
			return scrollRect;
		}

		public static ScrollRect SetVertical(this ScrollRect scrollRect, bool vertical)
		{
			scrollRect.vertical = vertical;
			return scrollRect;
		}
	}
	public static class SpriteExtensions
	{
		public static Sprite SetName(this Sprite sprite, string name)
		{
			((Object)sprite).name = name;
			return sprite;
		}
	}
	public static class TextExtensions
	{
		public static Text SetAlignment(this Text text, TextAnchor alignment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			text.alignment = alignment;
			return text;
		}

		public static Text SetColor(this Text text, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)text).color = color;
			return text;
		}

		public static Text SetFont(this Text text, Font font)
		{
			text.font = font;
			return text;
		}

		public static Text SetFontStyle(this Text text, FontStyle fontStyle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			text.fontStyle = fontStyle;
			return text;
		}

		public static Text SetFontSize(this Text text, int fontSize)
		{
			text.fontSize = fontSize;
			return text;
		}

		public static Text SetHorizontalOverflow(this Text text, HorizontalWrapMode wrapMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			text.horizontalOverflow = wrapMode;
			return text;
		}

		public static Text SetResizeTextForBestFit(this Text text, bool resizeTextForBestFit)
		{
			text.resizeTextForBestFit = resizeTextForBestFit;
			return text;
		}

		public static Text SetSupportRichText(this Text text, bool supportRichText)
		{
			text.supportRichText = supportRichText;
			return text;
		}

		public static Text SetText(this Text text, string value)
		{
			text.text = value;
			return text;
		}

		public static Text SetVerticalOverflow(this Text text, VerticalWrapMode wrapMode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			text.verticalOverflow = wrapMode;
			return text;
		}
	}
	public static class Texture2DExtensions
	{
		public static Texture2D SetName(this Texture2D texture, string name)
		{
			((Object)texture).name = name;
			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 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 class VerticalLayoutGroupExtensions
	{
		public static VerticalLayoutGroup SetChildControl(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 VerticalLayoutGroup SetChildForceExpand(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null)
		{
			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 VerticalLayoutGroup SetChildAlignment(this VerticalLayoutGroup layoutGroup, TextAnchor alignment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((LayoutGroup)layoutGroup).childAlignment = alignment;
			return layoutGroup;
		}

		public static VerticalLayoutGroup SetPadding(this VerticalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null)
		{
			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)layoutGroup).padding.left = left.Value;
			}
			if (right.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.right = right.Value;
			}
			if (top.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.top = top.Value;
			}
			if (bottom.HasValue)
			{
				((LayoutGroup)layoutGroup).padding.bottom = bottom.Value;
			}
			return layoutGroup;
		}

		public static VerticalLayoutGroup SetSpacing(this VerticalLayoutGroup layoutGroup, float spacing)
		{
			((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing;
			return layoutGroup;
		}
	}
	public class UIResources
	{
		private static readonly Dictionary<string, Font> FontCache = new Dictionary<string, Font>();

		private static readonly Dictionary<string, Sprite> SpriteCache = new Dictionary<string, Sprite>();

		public static Font AveriaSerifLibre => FindFont("AveriaSerifLibre-Regular");

		public static Font FindFont(string name)
		{
			if (!FontCache.TryGetValue(name, out var value))
			{
				value = Resources.FindObjectsOfTypeAll<Font>().First((Font f) => ((Object)f).name == name);
				FontCache[name] = value;
			}
			return value;
		}

		public static Sprite GetSprite(string spriteName)
		{
			if (!SpriteCache.TryGetValue(spriteName, out var value))
			{
				value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => ((Object)sprite).name == spriteName));
				SpriteCache[spriteName] = value;
			}
			return value;
		}
	}
}