Decompiled source of SearsCatalog v1.6.0

SearsCatalog.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
using TMPro;
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.6.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SearsCatalog
{
	public static class BuildHudController
	{
		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; }

		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 >= 0 && num < Hud.m_instance.m_pieceIcons.Count)
			{
				PieceIconData val = Hud.m_instance.m_pieceIcons[num];
				if (Object.op_Implicit((Object)(object)val.m_go))
				{
					ScrollRectUtils.EnsureVisibility(BuildHudScrollRect, val.m_go.GetComponent<RectTransform>());
				}
			}
		}

		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 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;
			}
		}

		public 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 component2 = gameObject.GetComponent<RectTransform>();
			component2.SetPosition(PluginConfig.BuildHudPanelPosition.Value);
			PanelDragger panelDragger = gameObject.AddComponent<PanelDragger>();
			panelDragger.TargetRectTransform = component2;
			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)component2).AddComponent<PanelResizer>();
			panelResizer.TargetRectTransform = component2;
			panelResizer.OnPanelEndResize += delegate(object _, Vector2 sizeDelta)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				ResizeBuildHudPanel(sizeDelta);
			};
			BuildHudPanelTransform = component2;
			BuildHudScrollbar = component;
			BuildHudScrollRect = obj;
			BuildHudNeedRefresh = true;
		}

		public static void SetBuildPanelPosition(Vector2 position)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			BuildHudPanelTransform.Ref<RectTransform>()?.SetPosition(position);
		}
	}
	public static class ScrollRectUtils
	{
		public static void EnsureVisibility(ScrollRect scrollRect, RectTransform child, float padding = 0f)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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;
		}
	}
	[HarmonyPatch(typeof(Hud))]
	internal static class HudPatch
	{
		private static readonly WaitForSeconds _waitOneSecond = new WaitForSeconds(1f);

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

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

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

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

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

		[HarmonyTranspiler]
		[HarmonyPatch("UpdatePieceList")]
		private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler1(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2]
			{
				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)
			}).ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (GetBuildPieces)")
				.Advance(2)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					Transpilers.EmitDelegate<Action<List<Piece>>>((Action<List<Piece>>)GetBuildPiecesDelegate)
				})
				.InstructionEnumeration();
		}

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

		[HarmonyTranspiler]
		[HarmonyPatch("UpdatePieceList")]
		private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler2(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_1, (object)null, (string)null)
			}).ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (GridColumns)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GridColumnsDelegate) })
				.MatchStartForward((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)
				})
				.ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (GridRows)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GridRowsDelegate) })
				.InstructionEnumeration();
		}

		[HarmonyTranspiler]
		[HarmonyPatch("UpdatePieceList")]
		private static IEnumerable<CodeInstruction> UpdatePieceListTranspiler3(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_0026: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((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)
			}).ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (PieceIconsCount)")
				.Advance(3)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)PieceIconsCountMultiplyDelegate) })
				.MatchStartForward((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)
				})
				.ThrowIfInvalid("Could not patch Hud.UpdatePieceList()! (PieceIconsClear)")
				.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 int PieceIconsCountMultiplyDelegate(int value)
		{
			if (PluginConfig.IsModEnabled.Value && BuildHudController.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)BuildHudController.BuildHudColumns, hud.m_pieceIconSpacing * (float)BuildHudController.BuildHudRows);
				BuildHudController.BuildHudNeedRefresh = false;
				BuildHudController.BuildHudNeedIconLayoutRefresh = true;
				BuildHudController.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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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 BuildHudController.BuildHudColumns;
		}

		private static int GridRowsDelegate(int rows)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return rows;
			}
			return BuildHudController.BuildHudRows;
		}
	}
	[HarmonyPatch(typeof(PieceTable))]
	internal static class PieceTablePatch
	{
		[HarmonyPatch]
		private static class GetPiecePatch
		{
			[HarmonyTargetMethod]
			private static MethodBase CalculateMethod()
			{
				return ReflectionUtils.GetFirstMatchingMethod(typeof(PieceTable), "GetPiece", new Type[2]
				{
					typeof(int),
					typeof(Vector2Int)
				}, new Type[2]
				{
					typeof(PieceCategory),
					typeof(Vector2Int)
				});
			}

			[HarmonyTranspiler]
			private static IEnumerable<CodeInstruction> GetPieceTranspiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0002: 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_0026: Expected O, but got Unknown
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Expected O, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarga_S, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Vector2Int), "y"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)null, (string)null)
				}).ThrowIfInvalid("Could not patch PieceTable.GetPiece()! (GetY)")
					.Advance(3)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceGetYDelegate) })
					.InstructionEnumeration();
			}

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

		[HarmonyPostfix]
		[HarmonyPatch("SetCategory")]
		private static void SetCategoryPostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildHudController.BuildHudNeedRefresh = true;
			}
		}

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

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

		[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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (ColumnA)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceIndexColumnDelegate) })
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
				})
				.ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (ColumnB)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceIndexColumnDelegate) })
				.MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
				})
				.ThrowIfInvalid("Could not patch PieceTable.GetPieceIndex()! (ColumnC)")
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<int, int>>((Func<int, int>)GetPieceIndexColumnDelegate) })
				.InstructionEnumeration();
		}

		private static int GetPieceIndexColumnDelegate(int value)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return value;
			}
			return BuildHudController.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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(14), (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.LeftPiece()! (Column)")
				.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 BuildHudController.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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(15), (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.RightPiece()! (Column)")
				.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 BuildHudController.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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_5, (object)null, (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.UpPiece()! (Row)")
				.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 BuildHudController.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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_6, (object)null, (string)null)
			}).ThrowIfInvalid("Could not patch PieceTable.DownPiece()! (Row)")
				.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 BuildHudController.BuildHudRows;
		}

		[HarmonyPostfix]
		[HarmonyPatch("LeftPiece")]
		[HarmonyPatch("RightPiece")]
		[HarmonyPatch("UpPiece")]
		[HarmonyPatch("DownPiece")]
		private static void ControllerPiecePostfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				BuildHudController.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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null), (string)null)
			}).ThrowIfInvalid("Could not patch Player.UpdateBuildGuiInput()! (GetMouseScrollWheel)")
				.Repeat((Action<CodeMatcher>)InsertGetMouseScrollWheelDelegate, (Action<string>)null)
				.InstructionEnumeration();
		}

		private static void InsertGetMouseScrollWheelDelegate(CodeMatcher matcher)
		{
			matcher.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<float, float>>((Func<float, float>)GetAxisDelegate) });
		}

		private static float GetAxisDelegate(float result)
		{
			if (!PluginConfig.IsModEnabled.Value)
			{
				return result;
			}
			return 0f;
		}
	}
	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 void BindConfig(ConfigFile config)
		{
			//IL_00c7: 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>(BuildHudController.SetupBuildHudPanel);
			BuildHudPanelColumns = config.BindInOrder("BuildHud.Panel", "buildHudPanelColumns", 15, "BuildHud.Panel visible columns (vanilla: 15).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 26));
			BuildHudPanelColumns.OnSettingChanged<int>(BuildHudController.SetupBuildHudPanel);
			BuildHudPanelPosition = config.BindInOrder<Vector2>("BuildHud.Panel", "buildHudPanelPosition", Vector2.zero, "BuildHud.Panel position relative to center of the screen.");
			BuildHudPanelPosition.OnSettingChanged((Action<Vector2>)BuildHudController.SetBuildPanelPosition);
		}
	}
	[BepInPlugin("redseiko.valheim.searscatalog", "SearsCatalog", "1.6.0")]
	public sealed class SearsCatalog : BaseUnityPlugin
	{
		public const string PluginGuid = "redseiko.valheim.searscatalog";

		public const string PluginName = "SearsCatalog";

		public const string PluginVersion = "1.6.0";

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

			public bool? Browsable;

			public bool? HideDefaultButton;

			public bool? HideSettingName;

			public bool? IsAdvanced;

			public int? Order;

			public bool? ReadOnly;
		}

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

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

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

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

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

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

		public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
		{
			configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
			};
		}
	}
	public static class ObjectExtensions
	{
		public static T FirstByNameOrThrow<T>(this T[] unityObjects, string name) where T : Object
		{
			foreach (T val in unityObjects)
			{
				if (((Object)val).name == name)
				{
					return val;
				}
			}
			throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}");
		}

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

		public static T SetName<T>(this T unityObject, string name) where T : Object
		{
			((Object)unityObject).name = name;
			return unityObject;
		}
	}
	public static class ReflectionUtils
	{
		public static MethodInfo GetFirstMatchingMethod(Type type, string methodName, params Type[][] parameterTypesList)
		{
			foreach (Type[] types in parameterTypesList)
			{
				MethodInfo method = type.GetMethod(methodName, AccessTools.allDeclared, null, types, null);
				if (method != null)
				{
					return method;
				}
			}
			return null;
		}
	}
	public sealed 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			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, 0f);
			}
			_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 sealed 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 static class UIBuilder
	{
		public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false);
			((Object)obj).name = "Label";
			((TMP_Text)obj).fontSize = 16f;
			((TMP_Text)obj).richText = true;
			((Graphic)obj).color = Color.white;
			((TMP_Text)obj).enableAutoSizing = false;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((TMP_Text)obj).text = string.Empty;
			return obj;
		}

		public static TextMeshProUGUI CreateTMPHeaderLabel(Transform parentTransform)
		{
			TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.headerText, parentTransform, false);
			((Object)obj).name = "Label";
			((TMP_Text)obj).fontSize = 32f;
			((TMP_Text)obj).richText = true;
			((TMP_Text)obj).enableAutoSizing = false;
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((TMP_Text)obj).text = string.Empty;
			return obj;
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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