Decompiled source of Erenshor Compare Equipment v1.2.4

BepInEx\plugins\CompareEquipment\Erenshor-CompareEquipment.dll

Decompiled a day 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 BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Erenshor-CompareEquipment")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Erenshor-CompareEquipment")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("03679c8f-fee7-45fc-bfb1-1a12fd2df04b")]
[assembly: AssemblyFileVersion("1.2.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.2.4.0")]
namespace Erenshor_CompareEquipment;

public class CoroutineRunner : MonoBehaviour
{
	private static CoroutineRunner _instance;

	public static CoroutineRunner Instance
	{
		get
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("CoroutineRunner");
				Object.DontDestroyOnLoad((Object)val);
				_instance = val.AddComponent<CoroutineRunner>();
			}
			return _instance;
		}
	}

	public static void Run(IEnumerator coroutine)
	{
		((MonoBehaviour)Instance).StartCoroutine(coroutine);
	}
}
[BepInPlugin("Brad522.CompareEquipment", "Compare Equipment", "1.2.4")]
public class CompareEquipment : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ItemIcon))]
	[HarmonyPatch("OnPointerEnter")]
	private class PlayerItemOnPointerEnterPatch
	{
		private static bool Prefix(ItemIcon __instance)
		{
			//IL_0006: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.MyItem.RequiredSlot == 0)
			{
				return true;
			}
			GameData.HighlightedItem = __instance;
			((Component)__instance).transform.localScale = Vector3.one * 1.33f;
			if ((Object)(object)__instance.MyItem == (Object)(object)GameData.PlayerInv.Empty || __instance.dragging)
			{
				return false;
			}
			GameData.PlayerAud.PlayOneShot(GameData.Misc.Click, 0.05f * GameData.SFXVol);
			curItemLook = new ItemSlotData(__instance);
			float y = Input.mousePosition.y;
			int num = ((y > (float)(Screen.height / 2)) ? (-225) : 225);
			int num2 = -250 - 347;
			DisplayItemInfoWindow(new Vector2(-250f, (float)num), y);
			if (!GameData.InspectSim.InspectWindow.activeSelf)
			{
				DisplayCompareWindow(new Vector2((float)num2, (float)num), y);
			}
			else
			{
				DisplayCompareWindow(new Vector2((float)num2, (float)num), y, inspectSim: true);
			}
			HandleItemQuests();
			return false;
		}
	}

	[HarmonyPatch(typeof(ItemIcon))]
	[HarmonyPatch("OnPointerExit")]
	private class PlayerItemOnPointerExitPatch
	{
		private static bool Prefix(ItemIcon __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.MyItem.RequiredSlot == 0)
			{
				return true;
			}
			GameData.HighlightedItem = null;
			if (GameData.ItemInfoWindow.isWindowActive())
			{
				GameData.ItemInfoWindow.CloseItemWindow();
			}
			if (((ItemInfoWindow)ItemCompareWindow).isWindowActive())
			{
				((ItemInfoWindow)ItemCompareWindow).CloseItemWindow();
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(SimItemDisplay))]
	[HarmonyPatch("OnPointerEnter")]
	private class SimItemOnPointerEnterPatch
	{
		private static bool Prefix(SimItemDisplay __instance)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.MyItem == (Object)(object)GameData.PlayerInv.Empty)
			{
				return false;
			}
			GameData.PlayerAud.PlayOneShot(GameData.Misc.Click, 0.05f * GameData.SFXVol);
			float y = Input.mousePosition.y;
			int num = ((y > (float)(Screen.height / 2)) ? (-225) : 225);
			curItemLook = new ItemSlotData(__instance);
			DisplayItemInfoWindow(new Vector2(-250f, (float)num), y);
			return false;
		}
	}

	[HarmonyPatch(typeof(SimItemDisplay))]
	[HarmonyPatch("OnPointerExit")]
	private class SimItemOnPointerExitPatch
	{
		private static void Postfix(SimItemDisplay __instance)
		{
			if (GameData.ItemInfoWindow.isWindowActive())
			{
				GameData.ItemInfoWindow.CloseItemWindow();
			}
		}
	}

	[HarmonyPatch(typeof(ItemInfoWindow))]
	[HarmonyPatch("DisplayItem")]
	private class ItemInfoWindowDisplayItemPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldsfld && list[i].operand is FieldInfo fieldInfo && fieldInfo.Name == "ItemInfoWindow" && fieldInfo.DeclaringType == typeof(GameData))
				{
					list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null)
					{
						labels = list[i].labels
					};
				}
			}
			return list.AsEnumerable();
		}
	}

	[HarmonyPatch(typeof(ItemInfoWindow))]
	[HarmonyPatch("LoadSpellDetails")]
	private class ItemInfoWindowLoadSpellDetailsPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldsfld && list[i].operand is FieldInfo fieldInfo && fieldInfo.Name == "ItemInfoWindow" && fieldInfo.DeclaringType == typeof(GameData))
				{
					list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null)
					{
						labels = list[i].labels
					};
				}
			}
			return list.AsEnumerable();
		}
	}

	public class ItemSlotData
	{
		public object Source { get; }

		public Item MyItem { get; }

		public SlotType ThisSlotType { get; }

		public int Quant { get; }

		public Transform transform
		{
			get
			{
				object source = Source;
				object obj = ((source is ItemIcon) ? source : null);
				object obj2 = ((obj != null) ? ((Component)obj).transform : null);
				if (obj2 == null)
				{
					object source2 = Source;
					object obj3 = ((source2 is SimItemDisplay) ? source2 : null);
					if (obj3 == null)
					{
						return null;
					}
					obj2 = ((Component)obj3).transform;
				}
				return (Transform)obj2;
			}
		}

		public bool VendorSlot
		{
			get
			{
				object source = Source;
				return ((ItemIcon)(((source is ItemIcon) ? source : null)?)).VendorSlot ?? false;
			}
		}

		public bool LootSlot
		{
			get
			{
				object source = Source;
				return ((ItemIcon)(((source is ItemIcon) ? source : null)?)).LootSlot ?? false;
			}
		}

		public ItemSlotData(ItemIcon icon)
		{
			//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)
			Source = icon;
			MyItem = icon.MyItem;
			ThisSlotType = icon.ThisSlotType;
			Quant = icon.Quantity;
		}

		public ItemSlotData(SimInvSlot slot)
		{
			//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)
			Source = slot;
			MyItem = slot.MyItem;
			ThisSlotType = slot.ThisSlotType;
			Quant = slot.Quant;
		}

		public ItemSlotData(SimItemDisplay slot)
		{
			//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)
			Source = slot;
			MyItem = slot.MyItem;
			ThisSlotType = slot.Slot;
			Quant = slot.ItemLvl;
		}
	}

	[CompilerGenerated]
	private sealed class <WaitForCompareWindow>d__43 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Item item;

		public Vector3 position;

		public int quantity;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WaitForCompareWindow>d__43(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0049: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)ItemCompareWindow == (Object)null)
			{
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			((ItemInfoWindow)ItemCompareWindow).DisplayItem(item, Vector2.op_Implicit(position), quantity);
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	internal const string ModName = "CompareEquipment";

	internal const string ModVersion = "1.2.4";

	internal const string ModDescription = "Compare Equipment";

	internal const string Author = "Brad522";

	private const string ModGUID = "Brad522.CompareEquipment";

	private readonly Harmony harmony = new Harmony("Brad522.CompareEquipment");

	private GameObject gameUI;

	private GameObject playerInvUI;

	private GameObject inspectSimUI;

	private ItemIcon dragIcon;

	private static RectTransform canvasRect;

	private static RectTransform positionDummy;

	private bool uiInitialized;

	private static float halfScaledWindowWidth;

	private static float minValidX;

	private static Resolution curResolution;

	public static GameObject clonedItemInfo;

	public static ItemCompareWindow ItemCompareWindow;

	public static ItemSlotData curItemLook;

	public static ItemSlotData curItemEquip;

	public static List<ItemSlotData> equipSlots;

	public static Vector3 compareWindowPos;

	private ConfigEntry<KeyboardShortcut> switchKey;

	public void Awake()
	{
		//IL_004a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		harmony.PatchAll();
		uiInitialized = false;
		TryInitializeUIReferences();
		float num = (float)Screen.width / 1920f;
		float num2 = (float)Screen.height / 1080f;
		float num3 = Mathf.Min(num, num2);
		halfScaledWindowWidth = 350f * num3 / 2f;
		curResolution = Screen.currentResolution;
		minValidX = 5f;
		switchKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Hotkey", new KeyboardShortcut((KeyCode)102, Array.Empty<KeyCode>()), "Hotkey used to switch the slot you are comparing with.");
		((BaseUnityPlugin)this).Logger.LogMessage((object)"CompareEquipment loaded successfully!");
	}

	private void OnDestroy()
	{
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		harmony.UnpatchAll("Brad522.CompareEquipment");
		if ((Object)(object)clonedItemInfo != (Object)null)
		{
			Object.Destroy((Object)(object)clonedItemInfo);
		}
		if ((Object)(object)ItemCompareWindow != (Object)null)
		{
			Object.Destroy((Object)(object)ItemCompareWindow);
		}
		if ((Object)(object)positionDummy != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)positionDummy).gameObject);
		}
		if (equipSlots != null)
		{
			equipSlots.Clear();
		}
		gameUI = null;
		playerInvUI = null;
		inspectSimUI = null;
		dragIcon = null;
		canvasRect = null;
		positionDummy = null;
		clonedItemInfo = null;
		ItemCompareWindow = null;
		curItemLook = null;
		curItemEquip = null;
		equipSlots = null;
		switchKey = null;
		compareWindowPos = default(Vector3);
		uiInitialized = false;
		curResolution = default(Resolution);
		halfScaledWindowWidth = 0f;
		minValidX = 0f;
	}

	private void Update()
	{
		if (uiInitialized && !CheckUIElementsInit())
		{
			uiInitialized = false;
		}
		if (!uiInitialized)
		{
			TryInitializeUIReferences();
		}
		if (uiInitialized)
		{
			ClampWindows();
			HandleClosingWindows();
			HandleCompareWindowSwitch();
		}
	}

	private bool CheckUIElementsInit()
	{
		if ((Object)(object)gameUI != (Object)null && (Object)(object)clonedItemInfo != (Object)null && (Object)(object)ItemCompareWindow != (Object)null && (Object)(object)playerInvUI != (Object)null && (Object)(object)inspectSimUI != (Object)null && (Object)(object)dragIcon != (Object)null && (Object)(object)canvasRect != (Object)null)
		{
			return (Object)(object)positionDummy != (Object)null;
		}
		return false;
	}

	private void TryInitializeUIReferences()
	{
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Expected O, but got Unknown
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)gameUI == (Object)null)
		{
			gameUI = GameObject.Find("UI");
			if ((Object)(object)gameUI == (Object)null)
			{
				return;
			}
		}
		if ((Object)(object)clonedItemInfo == (Object)null)
		{
			GameObject val = FindChild(gameUI.transform, "ItemInfo");
			if ((Object)(object)val != (Object)null)
			{
				clonedItemInfo = Object.Instantiate<GameObject>(val, gameUI.transform);
			}
		}
		if ((Object)(object)ItemCompareWindow == (Object)null && (Object)(object)clonedItemInfo != (Object)null)
		{
			gameUI.AddComponent<ItemCompareWindow>();
		}
		if ((Object)(object)ItemCompareWindow != (Object)null)
		{
			InitItemCompareWindow();
		}
		if ((Object)(object)playerInvUI == (Object)null)
		{
			playerInvUI = FindChild(gameUI.transform, "UIElements/InvPar/PlayerInv");
		}
		if ((Object)(object)inspectSimUI == (Object)null)
		{
			inspectSimUI = FindChild(gameUI.transform, "UIElements/SimInspectPar/InspectSim");
		}
		if ((Object)(object)dragIcon == (Object)null && (Object)(object)playerInvUI != (Object)null)
		{
			dragIcon = FindAndGet<ItemIcon>(playerInvUI.transform, "Mouse Slot/ItemIcon (2)");
		}
		if ((Object)(object)canvasRect == (Object)null)
		{
			canvasRect = ((Component)gameUI.GetComponent<Canvas>()).GetComponent<RectTransform>();
		}
		if ((Object)(object)positionDummy == (Object)null)
		{
			GameObject val2 = new GameObject("PositionDummy");
			val2.transform.SetParent(gameUI.transform);
			RectTransform obj = val2.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0.5f, 0.5f);
			obj.anchorMax = new Vector2(0.5f, 0.5f);
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.sizeDelta = Vector2.zero;
			val2.SetActive(false);
			positionDummy = obj;
		}
		uiInitialized = CheckUIElementsInit();
	}

	private void ClampWindows()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0038: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: 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)
		if (!uiInitialized || !((ItemInfoWindow)ItemCompareWindow).isWindowActive())
		{
			return;
		}
		int width = ((Resolution)(ref curResolution)).width;
		Resolution currentResolution = Screen.currentResolution;
		if (width == ((Resolution)(ref currentResolution)).width)
		{
			int height = ((Resolution)(ref curResolution)).height;
			currentResolution = Screen.currentResolution;
			if (height == ((Resolution)(ref currentResolution)).height)
			{
				goto IL_0083;
			}
		}
		curResolution = Screen.currentResolution;
		float num = (float)Screen.width / 1920f;
		float num2 = (float)Screen.height / 1080f;
		float num3 = Mathf.Min(num, num2);
		halfScaledWindowWidth = 350f * num3 / 2f;
		goto IL_0083;
		IL_0083:
		if (CheckOutOfBounds())
		{
			Transform transform = ((ItemInfoWindow)ItemCompareWindow).ParentWindow.transform;
			Transform transform2 = GameData.ItemInfoWindow.ParentWindow.transform;
			Vector2 val = Vector2.op_Implicit(transform.position);
			Vector2 val2 = Vector2.op_Implicit(transform2.position);
			float num4 = val.x - halfScaledWindowWidth;
			float num5 = Mathf.Max(0f, minValidX - num4);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(num5, 0f);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(200f, 100f);
			transform2.position = Vector2.op_Implicit(val2 + val3);
			Vector2 val5 = val + val3;
			transform.position = Vector2.op_Implicit(val5);
			compareWindowPos = Vector2.op_Implicit(val5 + val4);
		}
	}

	private void HandleClosingWindows()
	{
		if (uiInitialized && (((ItemInfoWindow)ItemCompareWindow).isWindowActive() || GameData.ItemInfoWindow.isWindowActive()))
		{
			bool flag = (Object)(object)playerInvUI == (Object)null || !playerInvUI.activeSelf;
			bool num = (Object)(object)inspectSimUI == (Object)null || !inspectSimUI.activeSelf;
			bool flag2 = (Object)(object)dragIcon != (Object)null && dragIcon.dragging;
			bool flag3 = flag || flag2;
			bool num2 = num && flag3;
			if (flag3 && ((ItemInfoWindow)ItemCompareWindow).isWindowActive())
			{
				((ItemInfoWindow)ItemCompareWindow).CloseItemWindow();
			}
			if (num2 && GameData.ItemInfoWindow.isWindowActive())
			{
				GameData.ItemInfoWindow.CloseItemWindow();
			}
		}
	}

	private void HandleCompareWindowSwitch()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Invalid comparison between Unknown and I4
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Invalid comparison between Unknown and I4
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Invalid comparison between Unknown and I4
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Invalid comparison between Unknown and I4
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Invalid comparison between Unknown and I4
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Invalid comparison between Unknown and I4
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Invalid comparison between Unknown and I4
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Invalid comparison between Unknown and I4
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Invalid comparison between Unknown and I4
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		if (!uiInitialized || !((ItemInfoWindow)ItemCompareWindow).isWindowActive())
		{
			return;
		}
		KeyboardShortcut value = switchKey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown() && curItemLook != null && curItemEquip != null && !((Object)(object)curItemLook.MyItem == (Object)(object)GameData.PlayerInv.Empty) && ((int)curItemLook.MyItem.RequiredSlot == 15 || (int)curItemLook.MyItem.RequiredSlot == 7 || (int)curItemLook.MyItem.RequiredSlot == 6) && ((int)curItemEquip.ThisSlotType == 13 || (int)curItemEquip.ThisSlotType == 14 || (int)curItemEquip.ThisSlotType == 7 || (int)curItemEquip.ThisSlotType == 6))
		{
			if ((int)curItemEquip.ThisSlotType == 6 || (int)curItemEquip.ThisSlotType == 7)
			{
				curItemEquip = GetEquippedItem(curItemEquip.ThisSlotType, switchRingWrist: true);
			}
			else
			{
				curItemEquip = GetEquippedItem(GetAlternateSlotType(curItemEquip.ThisSlotType), switchRingWrist: false);
			}
			if (curItemEquip != null && !((Object)(object)curItemEquip.MyItem == (Object)(object)GameData.PlayerInv.Empty))
			{
				((ItemInfoWindow)ItemCompareWindow).CloseItemWindow();
				((ItemInfoWindow)ItemCompareWindow).DisplayItem(curItemEquip.MyItem, Vector2.op_Implicit(compareWindowPos), curItemEquip.Quant);
			}
		}
	}

	private static bool CheckOutOfBounds()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		return ((ItemInfoWindow)ItemCompareWindow).ParentWindow.transform.position.x - halfScaledWindowWidth < minValidX - 0.01f;
	}

	private void InitItemCompareWindow()
	{
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_040c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		clonedItemInfo.SetActive(false);
		Transform transform = clonedItemInfo.transform;
		((ItemInfoWindow)ItemCompareWindow).ParentWindow = clonedItemInfo;
		((ItemInfoWindow)ItemCompareWindow).OtherTextParent = FindChild(transform, "OtherText");
		((ItemInfoWindow)ItemCompareWindow).StatTextParent = FindChild(transform, "EquipmentInfo");
		((ItemInfoWindow)ItemCompareWindow).ItemEffect = FindChild(transform, "OnClick");
		((ItemInfoWindow)ItemCompareWindow).ReqLvl = FindChild(transform, "ReqLvl");
		((ItemInfoWindow)ItemCompareWindow).SpellDetailsWindow = FindChild(transform, "Spell Details");
		((ItemInfoWindow)ItemCompareWindow).Banner = FindAndGet<Image>(transform, "BG");
		((ItemInfoWindow)ItemCompareWindow).ItemIcon = FindAndGet<Image>(transform, "Icon");
		((ItemInfoWindow)ItemCompareWindow).ItemName = FindAndGet<TextMeshProUGUI>(transform, "Title");
		((ItemInfoWindow)ItemCompareWindow).Lore = FindAndGet<TextMeshProUGUI>(transform, "Lore");
		((ItemInfoWindow)ItemCompareWindow).Usable = FindAndGet<TextMeshProUGUI>(transform, "UsableBy");
		((ItemInfoWindow)ItemCompareWindow).itemPrice = FindAndGet<TextMeshProUGUI>(transform, "Text (TMP) (6)");
		Transform parent = ((ItemInfoWindow)ItemCompareWindow).ItemEffect.transform.Find("Image (1)");
		((ItemInfoWindow)ItemCompareWindow).ClickDesc = FindAndGet<TextMeshProUGUI>(parent, "SpellDesc");
		((ItemInfoWindow)ItemCompareWindow).ClickSpell = FindAndGet<TextMeshProUGUI>(parent, "SpellName");
		Transform transform2 = ((ItemInfoWindow)ItemCompareWindow).StatTextParent.transform;
		((ItemInfoWindow)ItemCompareWindow).AC = FindAndGet<TextMeshProUGUI>(transform2, "ArmorStat");
		((ItemInfoWindow)ItemCompareWindow).Agi = FindAndGet<TextMeshProUGUI>(transform2, "AgiStat");
		((ItemInfoWindow)ItemCompareWindow).Cha = FindAndGet<TextMeshProUGUI>(transform2, "ChaStat");
		((ItemInfoWindow)ItemCompareWindow).DelNum = FindAndGet<TextMeshProUGUI>(transform2, "DelStat");
		((ItemInfoWindow)ItemCompareWindow).DelTXT = FindAndGet<TextMeshProUGUI>(transform2, "Delay");
		((ItemInfoWindow)ItemCompareWindow).Dex = FindAndGet<TextMeshProUGUI>(transform2, "DexStat");
		((ItemInfoWindow)ItemCompareWindow).DMGNum = FindAndGet<TextMeshProUGUI>(transform2, "DmgStat");
		((ItemInfoWindow)ItemCompareWindow).DMGtxt = FindAndGet<TextMeshProUGUI>(transform2, "Damage");
		((ItemInfoWindow)ItemCompareWindow).End = FindAndGet<TextMeshProUGUI>(transform2, "EndStat");
		((ItemInfoWindow)ItemCompareWindow).ER = FindAndGet<TextMeshProUGUI>(transform2, "ERStat");
		((ItemInfoWindow)ItemCompareWindow).HP = FindAndGet<TextMeshProUGUI>(transform2, "HealthStat");
		((ItemInfoWindow)ItemCompareWindow).Int = FindAndGet<TextMeshProUGUI>(transform2, "IntStat");
		((ItemInfoWindow)ItemCompareWindow).Mana = FindAndGet<TextMeshProUGUI>(transform2, "ManaStat");
		((ItemInfoWindow)ItemCompareWindow).MR = FindAndGet<TextMeshProUGUI>(transform2, "MRStat");
		((ItemInfoWindow)ItemCompareWindow).PR = FindAndGet<TextMeshProUGUI>(transform2, "PRStat");
		((ItemInfoWindow)ItemCompareWindow).Res = FindAndGet<TextMeshProUGUI>(transform2, "ResStat");
		((ItemInfoWindow)ItemCompareWindow).Slot = FindAndGet<TextMeshProUGUI>(transform2, "SlotType");
		((ItemInfoWindow)ItemCompareWindow).Str = FindAndGet<TextMeshProUGUI>(transform2, "StrStat");
		((ItemInfoWindow)ItemCompareWindow).VR = FindAndGet<TextMeshProUGUI>(transform2, "VRStat");
		((ItemInfoWindow)ItemCompareWindow).Wis = FindAndGet<TextMeshProUGUI>(transform2, "WisStat");
		((ItemInfoWindow)ItemCompareWindow).RangeNum = FindAndGet<TextMeshProUGUI>(transform2, "RangeStat");
		((ItemInfoWindow)ItemCompareWindow).RangeText = FindAndGet<TextMeshProUGUI>(transform2, "Range");
		Transform parent2 = ((ItemInfoWindow)ItemCompareWindow).SpellDetailsWindow.transform.Find("Image (1)");
		((ItemInfoWindow)ItemCompareWindow).SpellDetailsDesc = FindAndGet<TextMeshProUGUI>(parent2, "SpellDesc");
		((ItemInfoWindow)ItemCompareWindow).SpellDetailsImage = FindAndGet<Image>(parent2, "Image");
		((ItemInfoWindow)ItemCompareWindow).SpellDetailsName = FindAndGet<TextMeshProUGUI>(parent2, "SpellName");
		((ItemInfoWindow)ItemCompareWindow).GodlyText = new Color(0.9894f, 0.533f, 1f, 1f);
		((ItemInfoWindow)ItemCompareWindow).Legendary = new Color(1f, 0f, 0.7107f, 1f);
		((ItemInfoWindow)ItemCompareWindow).Blessed = new Color(0f, 0.5583f, 1f, 1f);
		((ItemInfoWindow)ItemCompareWindow).BlessedText = new Color(0f, 0.9802f, 1f, 1f);
		((ItemInfoWindow)ItemCompareWindow).Normal = Color.white;
		((ItemInfoWindow)ItemCompareWindow).NormalText = Color.white;
	}

	private T FindAndGet<T>(Transform parent, string path) where T : Component
	{
		Transform val = parent.Find(path);
		if (!((Object)(object)val != (Object)null))
		{
			return default(T);
		}
		return ((Component)val).GetComponent<T>();
	}

	private GameObject FindChild(Transform parent, string path)
	{
		Transform obj = parent.Find(path);
		if (obj == null)
		{
			return null;
		}
		return ((Component)obj).gameObject;
	}

	public static ItemSlotData GetEquippedItem(SlotType slotNeeded, bool switchRingWrist)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Invalid comparison between Unknown and I4
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Invalid comparison between Unknown and I4
		foreach (ItemSlotData equipSlot in equipSlots)
		{
			SlotType thisSlotType = equipSlot.ThisSlotType;
			if (!switchRingWrist || equipSlot != curItemEquip)
			{
				if (thisSlotType == slotNeeded)
				{
					return equipSlot;
				}
				if ((int)slotNeeded == 15 && ((int)thisSlotType == 13 || (int)thisSlotType == 14) && (Object)(object)equipSlot.MyItem != (Object)(object)GameData.PlayerInv.Empty)
				{
					return equipSlot;
				}
			}
		}
		return null;
	}

	private SlotType GetAlternateSlotType(SlotType curSlotType)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		if ((int)curSlotType != 13)
		{
			if ((int)curSlotType == 14)
			{
				return (SlotType)13;
			}
			return curSlotType;
		}
		return (SlotType)14;
	}

	private static void DisplayItemInfoWindow(Vector2 offset, float mouseY)
	{
		//IL_000a: 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_0012: 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)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = CalculatePosition(curItemLook.transform, offset, mouseY);
		if (!(val == Vector2.zero))
		{
			GameData.ItemInfoWindow.DisplayItem(curItemLook.MyItem, val, curItemLook.Quant);
		}
	}

	private static void DisplayCompareWindow(Vector2 offset, float mouseY)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		DisplayCompareWindow(offset, mouseY, inspectSim: false);
	}

	private static void DisplayCompareWindow(Vector2 offset, float mouseY, bool inspectSim)
	{
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		if (!inspectSim)
		{
			equipSlots = GameData.PlayerInv.EquipmentSlots.Select((ItemIcon slot) => new ItemSlotData(slot)).ToList();
		}
		else
		{
			equipSlots = GameData.InspectSim.Who.MyEquipment.Select((SimInvSlot slot) => new ItemSlotData(slot)).ToList();
		}
		if (!inspectSim && equipSlots.Any((ItemSlotData slot) => slot.Source == curItemLook.Source))
		{
			return;
		}
		curItemEquip = GetEquippedItem(curItemLook.MyItem.RequiredSlot, switchRingWrist: false);
		if (curItemEquip == null || !((Object)(object)curItemEquip.MyItem != (Object)(object)GameData.PlayerInv.Empty))
		{
			return;
		}
		Vector2 val = CalculatePosition(curItemLook.transform, offset, mouseY);
		if (!(val == Vector2.zero))
		{
			compareWindowPos = Vector2.op_Implicit(val);
			if ((Object)(object)ItemCompareWindow != (Object)null)
			{
				((ItemInfoWindow)ItemCompareWindow).DisplayItem(curItemEquip.MyItem, Vector2.op_Implicit(compareWindowPos), curItemEquip.Quant);
			}
			else
			{
				CoroutineRunner.Run(WaitForCompareWindow(curItemEquip.MyItem, compareWindowPos, curItemEquip.Quant));
			}
		}
	}

	private static Vector2 CalculatePosition(Transform itemTransform, Vector2 offset, float mouseY)
	{
		//IL_0005: 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_0050: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: 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)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = (((int)curItemLook.ThisSlotType != 0 && !curItemLook.VendorSlot && !curItemLook.LootSlot) ? itemTransform.position : itemTransform.parent.position);
		if ((Object)(object)canvasRect == (Object)null)
		{
			return Vector2.zero;
		}
		Vector2 val2 = default(Vector2);
		RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, Vector2.op_Implicit(val), (Camera)null, ref val2);
		int num = ((!(mouseY > (float)Screen.height * 0.5f)) ? 1 : (-1));
		Vector2 val3 = default(Vector2);
		((Vector2)(ref val3))..ctor(-200f, 100f * (float)num);
		Vector2 val4 = default(Vector2);
		RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, Vector2.op_Implicit(val) + val3, (Camera)null, ref val4);
		Vector2 val5 = val4 - val2;
		positionDummy.anchoredPosition = val2 - val5 + offset;
		return Vector2.op_Implicit(((Component)positionDummy).transform.position);
	}

	private static void HandleItemQuests()
	{
		if ((Object)(object)curItemLook.MyItem.AssignQuestOnRead != (Object)null && (curItemLook.MyItem.AssignQuestOnRead.repeatable || !GameData.CompletedQuests.Contains(curItemLook.MyItem.AssignQuestOnRead.DBName)))
		{
			GameData.AssignQuest(curItemLook.MyItem.AssignQuestOnRead.DBName);
		}
		if ((Object)(object)curItemLook.MyItem.CompleteOnRead != (Object)null)
		{
			GameData.FinishQuest(curItemLook.MyItem.CompleteOnRead.DBName);
		}
	}

	[IteratorStateMachine(typeof(<WaitForCompareWindow>d__43))]
	private static IEnumerator WaitForCompareWindow(Item item, Vector3 position, int quantity)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitForCompareWindow>d__43(0)
		{
			item = item,
			position = position,
			quantity = quantity
		};
	}
}
public class ItemCompareWindow : ItemInfoWindow
{
	private void Start()
	{
		CompareEquipment.ItemCompareWindow = this;
	}
}