Decompiled source of HoverCompare v0.5.1

plugins/HoverCompare.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HoverCompare.Ui;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HoverCompare")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.1.0")]
[assembly: AssemblyInformationalVersion("0.5.1+a99958903dbf0adcd3c6756a01a81dbc8e385771")]
[assembly: AssemblyProduct("HoverCompare")]
[assembly: AssemblyTitle("HoverCompare")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HoverCompare
{
	[BepInPlugin("dev.biozip.hovercompare", "HoverCompare", "0.5.1")]
	[BepInProcess("valheim.exe")]
	public class HoverComparePlugin : BaseUnityPlugin
	{
		public enum ShowMode
		{
			Always,
			Hold,
			Toggle
		}

		public enum ViewMode
		{
			Compact,
			Full
		}

		public enum Language
		{
			Auto,
			English,
			Russian
		}

		public const string Guid = "dev.biozip.hovercompare";

		public const string Version = "0.5.1";

		internal static ManualLogSource Log;

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<ShowMode> _mode;

		private ConfigEntry<KeyboardShortcut> _key;

		private ConfigEntry<ViewMode> _view;

		private ConfigEntry<int> _cards;

		private ConfigEntry<bool> _hideTip;

		private ConfigEntry<float> _scale;

		private ConfigEntry<KeyboardShortcut> _widen;

		private ConfigEntry<KeyCode> _details;

		private ConfigEntry<Language> _lang;

		private readonly ComparePanel _panel = new ComparePanel();

		private Harmony _harmony;

		private bool _toggled = true;

		private void Awake()
		{
			//IL_0065: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show the comparison panel next to item tooltips.");
			_mode = ((BaseUnityPlugin)this).Config.Bind<ShowMode>("General", "Mode", ShowMode.Always, "Always: whenever a tooltip is shown. Hold: only while the key is held. Toggle: the key switches it on and off.");
			_key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Key", new KeyboardShortcut((KeyCode)96, Array.Empty<KeyCode>()), "Key for the Hold and Toggle modes.");
			_view = ((BaseUnityPlugin)this).Config.Bind<ViewMode>("Panel", "View", ViewMode.Full, "Full: every stat, equal ones marked with =. Compact: only the stats that differ, with a count of the rest.");
			_cards = ((BaseUnityPlugin)this).Config.Bind<int>("Panel", "MaxCompared", 3, "How many items of the same kind to compare against at once. The equipped one always comes first.");
			_hideTip = ((BaseUnityPlugin)this).Config.Bind<bool>("Panel", "ReplaceGameTooltip", true, "Show the comparison in place of the game's tooltip for items you can wear. Off keeps the game's tooltip and puts the panel beside it, which keeps text added by other mods such as EpicLoot.");
			_widen = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "WidenKey", new KeyboardShortcut((KeyCode)306, Array.Empty<KeyCode>()), "Hold to compare a weapon with every weapon you carry, not only with the same kind.");
			_details = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DetailsKey", (KeyCode)308, "Hold to read the full text of set bonuses and item effects. With LeftAlt the right Alt works too. None turns it off.");
			_scale = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "TextScale", 1.2f, "Text size relative to the game's recipe description.");
			_lang = ((BaseUnityPlugin)this).Config.Bind<Language>("Panel", "Language", Language.Auto, "Panel labels. Auto follows the game language: Russian if the game is in Russian, English otherwise. Item names always follow the game.");
			_harmony = new Harmony("dev.biozip.hovercompare");
			Hovered.Refresh = delegate
			{
				Tick(keys: false);
			};
			Hovered.Patch(_harmony);
			foreach (string item in Hovered.Hooked)
			{
				Log.LogInfo((object)("подключено: " + item));
			}
			foreach (string item2 in Hovered.Failed)
			{
				Log.LogWarning((object)("НЕ подключено: " + item2));
			}
			Log.LogInfo((object)"HoverCompare 0.5.1 загружен");
		}

		private void OnDestroy()
		{
			_panel.Drop();
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
		}

		private void LateUpdate()
		{
			Tick(keys: true);
		}

		private void Tick(bool keys)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Invalid comparison between Unknown and I4
			if (!_enabled.Value || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				_panel.Hide();
				return;
			}
			KeyboardShortcut value;
			if (keys && _mode.Value == ShowMode.Toggle)
			{
				value = _key.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					_toggled = !_toggled;
				}
			}
			if (_mode.Value != ShowMode.Always)
			{
				if (_mode.Value == ShowMode.Hold)
				{
					value = _key.Value;
					if (((KeyboardShortcut)(ref value)).IsPressed())
					{
						goto IL_00b3;
					}
				}
				if (_mode.Value != ShowMode.Toggle || !_toggled)
				{
					_panel.Hide();
					return;
				}
			}
			goto IL_00b3;
			IL_00b3:
			L.Ru = Russian();
			ComparePanel.Compact = _view.Value == ViewMode.Compact;
			ComparePanel.MaxCards = Mathf.Clamp(_cards.Value, 1, 6);
			ComparePanel.HideGameTooltip = _hideTip.Value;
			ComparePanel.TextScale = Mathf.Clamp(_scale.Value, 0.75f, 3f);
			value = _widen.Value;
			ComparePanel.Widen = ((KeyboardShortcut)(ref value)).IsPressed();
			value = _widen.Value;
			ComparePanel.WidenKey = KeyName(((KeyboardShortcut)(ref value)).MainKey);
			KeyCode value2 = _details.Value;
			ComparePanel.DetailsKey = (((int)value2 == 0) ? "" : KeyName(value2));
			ComparePanel.DetailsHeld = (int)value2 != 0 && (Input.GetKey(value2) || ((int)value2 == 308 && Input.GetKey((KeyCode)307)));
			Target target = Hovered.Current();
			if (target == null)
			{
				_panel.Hide();
			}
			else
			{
				_panel.Show(target);
			}
		}

		private unsafe static string KeyName(KeyCode k)
		{
			//IL_0000: 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_0024: Expected I4, but got Unknown
			switch (k - 303)
			{
			case 2:
			case 3:
				return "Ctrl";
			case 4:
			case 5:
				return "Alt";
			case 0:
			case 1:
				return "Shift";
			default:
				return ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString();
			}
		}

		private bool Russian()
		{
			if (_lang.Value != Language.Auto)
			{
				return _lang.Value == Language.Russian;
			}
			Localization instance = Localization.instance;
			if (instance != null)
			{
				return instance.GetSelectedLanguage() == "Russian";
			}
			return false;
		}
	}
	public enum Origin
	{
		Owned,
		Crafting,
		Trader
	}
	public class Target
	{
		public ItemData Item;

		public int Quality;

		public float WorldLevel;

		public Origin From;

		public GameObject GameTooltip;

		public RectTransform Anchor;

		public RectTransform Beside;

		public bool Fresh => From != Origin.Owned;
	}
	public static class Hovered
	{
		private class Source
		{
			public ItemData Item;

			public bool Trader;
		}

		private static readonly Dictionary<UITooltip, Source> Tips = new Dictionary<UITooltip, Source>();

		public static readonly List<string> Hooked = new List<string>();

		public static readonly List<string> Failed = new List<string>();

		public static Action Refresh;

		public static void Patch(Harmony h)
		{
			Hook(h, typeof(InventoryGrid), "CreateItemTooltip", "AfterItemTooltip");
			Hook(h, typeof(StoreGui), "FillList", "AfterStoreFill");
			Hook(h, typeof(UITooltip), "LateUpdate", "AfterTooltipLate");
		}

		private static void Hook(Harmony h, Type type, string method, string postfix)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			string text = type.Name + "." + method;
			try
			{
				MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					Failed.Add(text + " — метода нет");
					return;
				}
				h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Hovered), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Hooked.Add(text);
			}
			catch (Exception ex)
			{
				Failed.Add(text + " — " + ex.GetType().Name + ": " + ex.Message);
			}
		}

		private static void AfterItemTooltip(ItemData item, UITooltip tooltip)
		{
			if ((Object)(object)tooltip == (Object)null)
			{
				return;
			}
			if (!Tips.TryGetValue(tooltip, out var value))
			{
				value = new Source();
				Tips[tooltip] = value;
				if (Tips.Count > 1024)
				{
					Sweep();
				}
			}
			value.Item = item;
			value.Trader = false;
		}

		private static void AfterStoreFill(StoreGui __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_trader == (Object)null)
			{
				return;
			}
			List<TradeItem> availableItems = __instance.m_trader.GetAvailableItems();
			List<GameObject> itemList = __instance.m_itemList;
			if (availableItems == null || itemList == null)
			{
				return;
			}
			int num = Mathf.Min(availableItems.Count, itemList.Count);
			for (int i = 0; i < num; i++)
			{
				GameObject val = itemList[i];
				TradeItem val2 = availableItems[i];
				if (!((Object)(object)val == (Object)null) && val2 != null && !((Object)(object)val2.m_prefab == (Object)null))
				{
					UITooltip component = val.GetComponent<UITooltip>();
					if (!((Object)(object)component == (Object)null))
					{
						Tips[component] = new Source
						{
							Item = val2.m_prefab.m_itemData,
							Trader = true
						};
					}
				}
			}
		}

		private static void AfterTooltipLate(UITooltip __instance)
		{
			if (Refresh == null || (Object)(object)__instance != (Object)(object)UITooltip.m_current)
			{
				return;
			}
			GameObject tooltip = UITooltip.m_tooltip;
			if (!((Object)(object)tooltip == (Object)null) && tooltip.activeInHierarchy)
			{
				CanvasGroup component = tooltip.GetComponent<CanvasGroup>();
				if ((!((Object)(object)component != (Object)null) || !(component.alpha <= 0f)) && Tips.TryGetValue(__instance, out var value) && value.Item != null)
				{
					Refresh();
				}
			}
		}

		private static void Sweep()
		{
			List<UITooltip> list = new List<UITooltip>();
			foreach (KeyValuePair<UITooltip, Source> tip in Tips)
			{
				if ((Object)(object)tip.Key == (Object)null)
				{
					list.Add(tip.Key);
				}
			}
			foreach (UITooltip item in list)
			{
				Tips.Remove(item);
			}
		}

		public static Target Current()
		{
			UITooltip current = UITooltip.m_current;
			GameObject tooltip = UITooltip.m_tooltip;
			if ((Object)(object)current != (Object)null && (Object)(object)tooltip != (Object)null && tooltip.activeInHierarchy && Tips.TryGetValue(current, out var value) && value.Item != null)
			{
				RectTransform anchor = (RectTransform)((tooltip.transform.childCount > 0) ? /*isinst with value type is only supported in some contexts*/: /*isinst with value type is only supported in some contexts*/);
				return new Target
				{
					Item = value.Item,
					Quality = value.Item.m_quality,
					WorldLevel = (value.Trader ? Game.m_worldLevel : value.Item.m_worldLevel),
					From = (value.Trader ? Origin.Trader : Origin.Owned),
					GameTooltip = tooltip,
					Anchor = anchor
				};
			}
			return Recipe();
		}

		private static Target Recipe()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00ce: 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)
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null || !InventoryGui.IsVisible())
			{
				return null;
			}
			if ((Object)(object)instance.m_crafting == (Object)null || !((Component)instance.m_crafting).gameObject.activeInHierarchy)
			{
				return null;
			}
			List<RecipeDataPair> availableRecipes = instance.m_availableRecipes;
			if (availableRecipes == null)
			{
				return null;
			}
			Canvas componentInParent = ((Component)instance.m_crafting).GetComponentInParent<Canvas>();
			Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			Vector2 val2 = Vector2.op_Implicit(Input.mousePosition);
			foreach (RecipeDataPair item in availableRecipes)
			{
				RecipeDataPair current = item;
				GameObject interfaceElement = ((RecipeDataPair)(ref current)).InterfaceElement;
				if ((Object)(object)interfaceElement == (Object)null || !interfaceElement.activeInHierarchy)
				{
					continue;
				}
				Transform transform = interfaceElement.transform;
				RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (!((Object)(object)val3 == (Object)null) && RectTransformUtility.RectangleContainsScreenPoint(val3, val2, val))
				{
					RectTransform val4 = (RectTransform)(((Object)(object)instance.m_recipeListRoot != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
					if ((Object)(object)val4 != (Object)null && !RectTransformUtility.RectangleContainsScreenPoint(val4, val2, val))
					{
						return null;
					}
					Recipe recipe = ((RecipeDataPair)(ref current)).Recipe;
					if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null)
					{
						return null;
					}
					ItemData itemData = ((RecipeDataPair)(ref current)).ItemData;
					ItemData val5 = itemData ?? recipe.m_item.m_itemData;
					if (val5 == null || val5.m_shared == null)
					{
						return null;
					}
					int num = ((itemData == null) ? 1 : (itemData.m_quality + 1));
					num = Mathf.Clamp(num, 1, Mathf.Max(1, val5.m_shared.m_maxQuality));
					return new Target
					{
						Item = val5,
						Quality = num,
						WorldLevel = Game.m_worldLevel,
						From = Origin.Crafting,
						Anchor = val3,
						Beside = instance.m_crafting
					};
				}
			}
			return null;
		}
	}
	public enum Better
	{
		Higher,
		Lower,
		None
	}
	public class Stat
	{
		public string Key;

		public int Order;

		public string Label;

		public float Value;

		public string Text;

		public Better Dir;

		public Func<float, string> Delta;
	}
	public class Detail
	{
		public string Key;

		public string Name;

		public string Title;

		public string Sub;

		public string Body;
	}
	public static class ItemStats
	{
		private static readonly string[] OrderKeys = new string[38]
		{
			"damage", "slash", "blunt", "pierce", "fire", "frost", "lightning", "poison", "spirit", "chop",
			"pickaxe", "tooltier", "armor", "block", "parry", "deflect", "knockback", "backstab", "stamina", "eitr",
			"health", "eitrregen", "adrenaline", "res_header", "res_blunt", "res_slash", "res_pierce", "res_fire", "res_frost", "res_lightning",
			"res_poison", "res_spirit", "movement", "durability", "weight", "effect", "adreffect", "set"
		};

		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		public static bool Wearable(ItemType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected I4, but got Unknown
			switch (t - 3)
			{
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 6:
			case 8:
			case 11:
			case 12:
			case 14:
			case 15:
			case 16:
			case 17:
			case 19:
			case 21:
				return true;
			default:
				return false;
			}
		}

		private static bool InHands(ItemType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected I4, but got Unknown
			if (t - 3 > 1)
			{
				switch (t - 14)
				{
				case 0:
				case 1:
				case 5:
				case 6:
				case 8:
					break;
				default:
					return false;
				}
			}
			return true;
		}

		public static ItemData Equipped(Player p, ItemType t)
		{
			//IL_000b: 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_0045: Invalid comparison between Unknown and I4
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected I4, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Invalid comparison between Unknown and I4
			if ((Object)(object)p == (Object)null)
			{
				return null;
			}
			if (InHands(t))
			{
				if (((Humanoid)p).m_rightItem != null)
				{
					return ((Humanoid)p).m_rightItem;
				}
				ItemData leftItem = ((Humanoid)p).m_leftItem;
				if (leftItem != null && InHands(leftItem.m_shared.m_itemType))
				{
					return leftItem;
				}
				return null;
			}
			if ((int)t <= 17)
			{
				switch (t - 5)
				{
				default:
					if ((int)t != 17)
					{
						break;
					}
					return ((Humanoid)p).m_shoulderItem;
				case 0:
				{
					ItemData leftItem2 = ((Humanoid)p).m_leftItem;
					if (leftItem2 == null || (int)leftItem2.m_shared.m_itemType != 5)
					{
						return null;
					}
					return leftItem2;
				}
				case 1:
					return ((Humanoid)p).m_helmetItem;
				case 2:
					return ((Humanoid)p).m_chestItem;
				case 6:
					return ((Humanoid)p).m_legItem;
				case 4:
					return ((Humanoid)p).m_ammoItem;
				case 3:
				case 5:
					break;
				}
			}
			else
			{
				if ((int)t == 18)
				{
					return ((Humanoid)p).m_utilityItem;
				}
				if ((int)t == 24)
				{
					return ((Humanoid)p).m_trinketItem;
				}
			}
			return null;
		}

		private static int OrderOf(string key)
		{
			int num = Array.IndexOf(OrderKeys, key);
			if (num >= 0)
			{
				return num;
			}
			return OrderKeys.Length;
		}

		private static string Num(float v)
		{
			float num = Mathf.Round(v * 10f) / 10f;
			if (!Mathf.Approximately(num, Mathf.Round(num)))
			{
				return num.ToString("0.0", Inv);
			}
			return Mathf.RoundToInt(num).ToString(Inv);
		}

		private static string Signed(string body, float v)
		{
			return ((v > 0f) ? "+" : ((v < 0f) ? "−" : "")) + body;
		}

		private static string Pct(float v)
		{
			return Num(v * 100f) + "%";
		}

		private static Stat Numeric(List<Stat> list, string key, string label, float value, Better dir, Func<float, string> fmt = null)
		{
			if (fmt == null)
			{
				fmt = Num;
			}
			Stat stat = new Stat
			{
				Key = key,
				Order = OrderOf(key),
				Label = label,
				Value = value,
				Dir = dir,
				Delta = (float d) => Signed(fmt(Mathf.Abs(d)), d)
			};
			stat.Text = ((key == "movement" || key == "eitrregen") ? Signed(fmt(Mathf.Abs(value)), value) : fmt(value));
			list.Add(stat);
			return stat;
		}

		private static void Words(List<Stat> list, string key, string label, string text)
		{
			if (!string.IsNullOrEmpty(text))
			{
				list.Add(new Stat
				{
					Key = key,
					Order = OrderOf(key),
					Label = label,
					Text = text,
					Dir = Better.None
				});
			}
		}

		private static string Localized(StatusEffect se)
		{
			if ((Object)(object)se == (Object)null || string.IsNullOrEmpty(se.m_name))
			{
				return null;
			}
			return Localization.instance.Localize(se.m_name);
		}

		public static List<Stat> Read(ItemData d, int quality, float worldLevel)
		{
			//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_002a: 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_0035: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Invalid comparison between Unknown and I4
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Invalid comparison between Unknown and I4
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Invalid comparison between Unknown and I4
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Invalid comparison between Unknown and I4
			List<Stat> list = new List<Stat>();
			if (d == null || d.m_shared == null)
			{
				return list;
			}
			SharedData shared = d.m_shared;
			ItemType itemType = shared.m_itemType;
			quality = Mathf.Max(1, quality);
			int num;
			if (!InHands(itemType))
			{
				num = (((int)itemType == 9) ? 1 : 0);
				if (num == 0)
				{
					goto IL_0186;
				}
			}
			else
			{
				num = 1;
			}
			DamageTypes damage = d.GetDamage(quality, worldLevel);
			Dmg(list, "damage", L.StDamage, damage.m_damage);
			Dmg(list, "slash", L.StSlash, damage.m_slash);
			Dmg(list, "blunt", L.StBlunt, damage.m_blunt);
			Dmg(list, "pierce", L.StPierce, damage.m_pierce);
			Dmg(list, "fire", L.StFire, damage.m_fire);
			Dmg(list, "frost", L.StFrost, damage.m_frost);
			Dmg(list, "lightning", L.StLightning, damage.m_lightning);
			Dmg(list, "poison", L.StPoison, damage.m_poison);
			Dmg(list, "spirit", L.StSpirit, damage.m_spirit);
			Dmg(list, "chop", L.StChop, damage.m_chop);
			Dmg(list, "pickaxe", L.StPickaxe, damage.m_pickaxe);
			if (shared.m_toolTier > 0 && (damage.m_chop > 0f || damage.m_pickaxe > 0f))
			{
				Numeric(list, "tooltier", L.StToolTier, shared.m_toolTier, Better.Higher);
			}
			goto IL_0186;
			IL_0186:
			if (num != 0 || (int)itemType == 5)
			{
				float baseBlockPower = d.GetBaseBlockPower(quality);
				if (baseBlockPower > 0f)
				{
					Numeric(list, "block", L.StBlock, baseBlockPower, Better.Higher);
				}
				if (shared.m_timedBlockBonus > 1f)
				{
					Numeric(list, "parry", L.StParry, shared.m_timedBlockBonus, Better.Higher, (float v) => "×" + Num(v));
				}
			}
			if ((int)itemType == 5)
			{
				float deflectionForce = d.GetDeflectionForce(quality);
				if (deflectionForce > 0f)
				{
					Numeric(list, "deflect", L.StDeflect, deflectionForce, Better.Higher);
				}
			}
			if (InHands(itemType))
			{
				if (shared.m_attackForce > 0f)
				{
					Numeric(list, "knockback", L.StKnockback, shared.m_attackForce, Better.Higher);
				}
				if (shared.m_backstabBonus > 1f)
				{
					Numeric(list, "backstab", L.StBackstab, shared.m_backstabBonus, Better.Higher, (float v) => "×" + Num(v));
				}
				Attack attack = shared.m_attack;
				if (attack != null)
				{
					if (attack.m_attackStamina > 0f)
					{
						Numeric(list, "stamina", L.StStamina, attack.m_attackStamina, Better.Lower);
					}
					if (attack.m_attackEitr > 0f)
					{
						Numeric(list, "eitr", L.StEitr, attack.m_attackEitr, Better.Lower);
					}
					if (attack.m_attackHealth > 0f)
					{
						Numeric(list, "health", L.StHealth, attack.m_attackHealth, Better.Lower);
					}
				}
			}
			float armor = d.GetArmor(quality, worldLevel);
			if (armor > 0f)
			{
				Numeric(list, "armor", L.StArmor, armor, Better.Higher);
			}
			if (!Mathf.Approximately(shared.m_eitrRegenModifier, 0f))
			{
				Numeric(list, "eitrregen", L.StEitrRegen, shared.m_eitrRegenModifier, Better.Higher, Pct);
			}
			if ((int)itemType == 24 && shared.m_maxAdrenaline > 0f)
			{
				Numeric(list, "adrenaline", L.StAdrenaline, shared.m_maxAdrenaline, Better.Lower);
			}
			Resistances(list, shared.m_damageModifiers);
			if (!Mathf.Approximately(shared.m_movementModifier, 0f))
			{
				Numeric(list, "movement", L.StMovement, shared.m_movementModifier, Better.Higher, Pct);
			}
			if (shared.m_useDurability)
			{
				Numeric(list, "durability", L.StDurability, d.GetMaxDurability(quality), Better.Higher);
			}
			if (shared.m_weight > 0f)
			{
				Numeric(list, "weight", L.StWeight, shared.m_weight, Better.Lower);
			}
			Words(list, "effect", L.StEffect, Localized(shared.m_equipStatusEffect));
			if ((int)itemType == 24)
			{
				Words(list, "adreffect", L.StEffect, Localized(shared.m_fullAdrenalineSE));
			}
			if ((Object)(object)shared.m_setStatusEffect != (Object)null && shared.m_setSize > 1)
			{
				string text = Localized(shared.m_setStatusEffect);
				if (text != null)
				{
					Words(list, "set", L.StSet, text + " (" + shared.m_setSize + ")");
				}
			}
			return list;
		}

		public static List<Detail> Details(ItemData d, int quality, Player p)
		{
			//IL_006c: 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_00bf: Invalid comparison between Unknown and I4
			List<Detail> list = new List<Detail>();
			if (d == null || d.m_shared == null)
			{
				return list;
			}
			SharedData s = d.m_shared;
			quality = Mathf.Max(1, quality);
			float skill = (((Object)(object)p != (Object)null) ? ((Character)p).GetSkillLevel(s.m_skillType) : 0f);
			string text = Localized(s.m_equipStatusEffect);
			if (text != null)
			{
				Add(list, "effect", text, L.StEffect, null, Safe(() => d.GetStatusEffectTooltip(quality, skill)));
			}
			if ((int)s.m_itemType == 24)
			{
				string text2 = Localized(s.m_fullAdrenalineSE);
				if (text2 != null)
				{
					Add(list, "adreffect", text2, L.StAdrenaline, null, Safe(() => s.m_fullAdrenalineSE.GetTooltipString()));
				}
			}
			if ((Object)(object)s.m_setStatusEffect != (Object)null && s.m_setSize > 1)
			{
				string text3 = Localized(s.m_setStatusEffect);
				if (text3 != null)
				{
					int worn = (((Object)(object)p != (Object)null && !string.IsNullOrEmpty(s.m_setName)) ? ((Humanoid)p).GetSetCount(s.m_setName) : 0);
					Add(list, "set", text3, L.StSet, L.DetWorn(worn, s.m_setSize), Safe(() => d.GetSetStatusEffectTooltip(quality, skill)));
				}
			}
			return list;
		}

		private static void Add(List<Detail> list, string key, string name, string kind, string sub, string body)
		{
			list.Add(new Detail
			{
				Key = key,
				Name = name,
				Title = kind + " · " + name,
				Sub = sub,
				Body = (string.IsNullOrEmpty(body) ? L.DetNoText : Localization.instance.Localize(body).Trim())
			});
		}

		private static string Safe(Func<string> read)
		{
			try
			{
				return read();
			}
			catch (Exception ex)
			{
				HoverComparePlugin.Log.LogWarning((object)("описание эффекта не прочиталось: " + ex.Message));
				return null;
			}
		}

		private static void Dmg(List<Stat> list, string key, string label, float v)
		{
			if (v > 0f)
			{
				Numeric(list, key, label, v, Better.Higher);
			}
		}

		public static int Rank(DamageModifier m)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			return (m - 1) switch
			{
				5 => -3, 
				1 => -2, 
				7 => -1, 
				6 => 1, 
				0 => 2, 
				4 => 3, 
				2 => 4, 
				3 => 4, 
				_ => 0, 
			};
		}

		public static string RankName(int r)
		{
			return r switch
			{
				-3 => L.ModVeryWeak, 
				-2 => L.ModWeak, 
				-1 => L.ModSlightlyWeak, 
				1 => L.ModSlightlyResistant, 
				2 => L.ModResistant, 
				3 => L.ModVeryResistant, 
				4 => L.ModImmune, 
				_ => L.ModNormal, 
			};
		}

		private static string DamageName(DamageType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0005: 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_001d: Expected I4, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			if ((int)t <= 64)
			{
				switch (t - 1)
				{
				default:
					if ((int)t != 32)
					{
						if ((int)t != 64)
						{
							break;
						}
						return L.StFrost;
					}
					return L.StFire;
				case 0:
					return L.StBlunt;
				case 1:
					return L.StSlash;
				case 3:
					return L.StPierce;
				case 2:
					break;
				}
			}
			else
			{
				if ((int)t == 128)
				{
					return L.StLightning;
				}
				if ((int)t == 256)
				{
					return L.StPoison;
				}
				if ((int)t == 512)
				{
					return L.StSpirit;
				}
			}
			return null;
		}

		private unsafe static void Resistances(List<Stat> list, List<DamageModPair> mods)
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			if (mods == null)
			{
				return;
			}
			foreach (DamageModPair mod in mods)
			{
				string text = DamageName(mod.m_type);
				if (text == null)
				{
					continue;
				}
				int num = Rank(mod.m_modifier);
				if (num != 0)
				{
					DamageType type = mod.m_type;
					string key = "res_" + ((object)(*(DamageType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
					list.Add(new Stat
					{
						Key = key,
						Order = OrderOf(key),
						Label = "  " + text,
						Value = num,
						Text = RankName(num),
						Dir = Better.Higher,
						Delta = (float d) => (!(d > 0f)) ? ((!(d < 0f)) ? "=" : "−") : "+"
					});
				}
			}
		}

		public static Stat Absent(Stat like)
		{
			bool flag = like.Key.StartsWith("res_");
			return new Stat
			{
				Key = like.Key,
				Order = like.Order,
				Label = like.Label,
				Value = 0f,
				Dir = like.Dir,
				Delta = like.Delta,
				Text = ((like.Dir == Better.None) ? "—" : (flag ? L.ModNormal : "—"))
			};
		}

		public static Stat ResistHeader()
		{
			return new Stat
			{
				Key = "res_header",
				Order = OrderOf("res_header"),
				Label = L.StResist,
				Text = "",
				Dir = Better.None
			};
		}
	}
	public static class Rivals
	{
		public static List<ItemData> For(Player p, ItemData hovered, bool fresh, int max, bool widen)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			List<ItemData> list = new List<ItemData>();
			if ((Object)(object)p == (Object)null || hovered == null || hovered.m_shared == null)
			{
				return list;
			}
			Add(Occupant(p, hovered.m_shared.m_itemType), any: true);
			Inventory inventory = ((Humanoid)p).GetInventory();
			if (inventory != null)
			{
				foreach (ItemData allItem in inventory.GetAllItems())
				{
					Add(allItem, widen);
				}
			}
			list.Sort(delegate(ItemData a, ItemData b)
			{
				bool flag = Worn(p, a);
				bool flag2 = Worn(p, b);
				if (flag != flag2)
				{
					if (!flag)
					{
						return 1;
					}
					return -1;
				}
				return (a.m_quality != b.m_quality) ? b.m_quality.CompareTo(a.m_quality) : string.CompareOrdinal(a.m_shared.m_name, b.m_shared.m_name);
			});
			if (list.Count > max)
			{
				list.RemoveRange(max, list.Count - max);
			}
			return list;
			void Add(ItemData x, bool any)
			{
				if (x != null && x.m_shared != null && !list.Contains(x) && !Excluded(x) && (x != hovered || fresh) && (any ? SameGroup(hovered, x) : SameClass(hovered, x)))
				{
					list.Add(x);
				}
			}
		}

		public static bool Excluded(ItemData d)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			SharedData shared = d.m_shared;
			if ((int)shared.m_itemType == 19)
			{
				return true;
			}
			if ((int)shared.m_skillType == 104)
			{
				return true;
			}
			if ((shared.m_name ?? "").IndexOf("scythe", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
			return (((Object)(object)d.m_dropPrefab != (Object)null) ? ((Object)d.m_dropPrefab).name : "").IndexOf("Scythe", StringComparison.OrdinalIgnoreCase) >= 0;
		}

		public static ItemData Occupant(Player p, ItemType t)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			ItemData val = ItemStats.Equipped(p, t);
			if (val != null)
			{
				return val;
			}
			if (Weapon(t) || (int)t == 15 || (int)t == 19)
			{
				if (((Humanoid)p).m_hiddenRightItem != null)
				{
					return ((Humanoid)p).m_hiddenRightItem;
				}
				ItemData hiddenLeftItem = ((Humanoid)p).m_hiddenLeftItem;
				if (hiddenLeftItem != null && Weapon(hiddenLeftItem.m_shared.m_itemType))
				{
					return hiddenLeftItem;
				}
			}
			if ((int)t == 5)
			{
				ItemData hiddenLeftItem2 = ((Humanoid)p).m_hiddenLeftItem;
				if (hiddenLeftItem2 != null && (int)hiddenLeftItem2.m_shared.m_itemType == 5)
				{
					return hiddenLeftItem2;
				}
			}
			return null;
		}

		public static bool Widens(ItemType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Weapon(t);
		}

		public static bool SameGroup(ItemData a, ItemData b)
		{
			//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_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_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			ItemType itemType = a.m_shared.m_itemType;
			ItemType itemType2 = b.m_shared.m_itemType;
			if (Weapon(itemType) || (int)itemType == 15 || (int)itemType == 19)
			{
				if (!Weapon(itemType2) && (int)itemType2 != 15)
				{
					return (int)itemType2 == 19;
				}
				return true;
			}
			return SameClass(a, b);
		}

		public static bool Worn(Player p, ItemData x)
		{
			if (!x.m_equipped && x != ((Humanoid)p).m_hiddenRightItem)
			{
				return x == ((Humanoid)p).m_hiddenLeftItem;
			}
			return true;
		}

		public static bool Weapon(ItemType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_0005: 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_0009: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)t <= 14)
			{
				if (t - 3 <= 1 || (int)t == 14)
				{
					goto IL_001c;
				}
			}
			else if ((int)t == 20 || (int)t == 22)
			{
				goto IL_001c;
			}
			return false;
			IL_001c:
			return true;
		}

		public static bool SameClass(ItemData a, ItemData b)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			SharedData shared = a.m_shared;
			SharedData shared2 = b.m_shared;
			ItemType itemType = shared.m_itemType;
			ItemType itemType2 = shared2.m_itemType;
			if (Weapon(itemType))
			{
				if (!Weapon(itemType2))
				{
					return false;
				}
				if ((int)shared.m_skillType != 0)
				{
					return shared.m_skillType == shared2.m_skillType;
				}
				return shared.m_name == shared2.m_name;
			}
			if ((int)itemType != 9)
			{
				if ((int)itemType == 15 || (int)itemType == 19)
				{
					if (itemType2 == itemType)
					{
						return shared.m_name == shared2.m_name;
					}
					return false;
				}
				return itemType == itemType2;
			}
			if (itemType2 == itemType)
			{
				return shared.m_ammoType == shared2.m_ammoType;
			}
			return false;
		}
	}
	internal static class Build
	{
		public const string Version = "0.5.1";
	}
}
namespace HoverCompare.Ui
{
	public class ComparePanel
	{
		private struct Cell
		{
			public string Text;

			public Color Color;

			public Cell(string t, Color c)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Text = t;
				Color = c;
			}
		}

		private class Line
		{
			public string Label;

			public bool Header;

			public bool Differs;

			public Cell Mine;

			public Cell[] Was;

			public Cell[] Now;

			public Cell[] Delta;
		}

		private class Card
		{
			private readonly RectTransform _rt;

			private readonly RectTransform _list;

			private readonly RectTransform _notesBox;

			private readonly bool _rival;

			private readonly float _fs;

			private readonly float _rowH;

			private readonly Image _icon;

			private readonly TextMeshProUGUI _name;

			private readonly TextMeshProUGUI _tag;

			private readonly TextMeshProUGUI _sub;

			private readonly List<Row> _rows = new List<Row>();

			private readonly List<TextMeshProUGUI> _notes = new List<TextMeshProUGUI>();

			public Card(Transform parent, bool rival, float fs)
			{
				//IL_0067: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Expected O, but got Unknown
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Expected O, but got Unknown
				_rival = rival;
				_fs = fs;
				_rowH = Mathf.Round(fs * 1.3f);
				_rt = UiKit.Rect(parent, rival ? "rival" : "hovered");
				UiKit.Box((Transform)(object)_rt, "bg", UiKit.FieldSprite, Back);
				UiKit.Frame(_rt, new Color(0.93f, 0.77f, 0.38f, 0.28f));
				int num = Mathf.RoundToInt(fs * 0.6f);
				UiKit.Vertical(_rt, 2f, new RectOffset(num, num, num / 2 + 2, num / 2 + 4));
				RectTransform val = UiKit.Row((Transform)(object)_rt, "head", Mathf.Round(fs * 1.7f));
				UiKit.Horizontal(val, Mathf.Round(fs * 0.4f));
				if (rival)
				{
					_icon = UiKit.Icon((Transform)(object)val, null, Mathf.Round(fs * 1.4f));
				}
				_name = UiKit.Label((Transform)(object)val, "name", "", fs + 2f, UiKit.Gold, (TextAlignmentOptions)513);
				LayoutElement obj = ((Component)_name).gameObject.AddComponent<LayoutElement>();
				obj.flexibleWidth = 1f;
				obj.minWidth = 0f;
				_tag = UiKit.Label((Transform)(object)val, "tag", "", fs - 3f, UiKit.Dim, (TextAlignmentOptions)260);
				((Component)_tag).gameObject.AddComponent<LayoutElement>().minWidth = 0f;
				_sub = UiKit.Label((Transform)(object)_rt, "sub", "", fs - 3f, UiKit.Dim, (TextAlignmentOptions)513);
				LayoutElement obj2 = ((Component)_sub).gameObject.AddComponent<LayoutElement>();
				obj2.minHeight = (obj2.preferredHeight = Mathf.Round((fs - 3f) * 1.3f));
				UiKit.Separator((Transform)(object)_rt);
				_list = UiKit.Rect((Transform)(object)_rt, "stats");
				UiKit.Vertical(_list, 0f);
				_notesBox = UiKit.Rect((Transform)(object)_rt, "notes");
				UiKit.Vertical(_notesBox, 2f, new RectOffset(0, 0, Mathf.RoundToInt(fs * 0.4f), 0));
				UiKit.Separator((Transform)(object)_notesBox);
				((Component)_notesBox).gameObject.SetActive(false);
			}

			public void Visible(bool on)
			{
				if (((Component)_rt).gameObject.activeSelf != on)
				{
					((Component)_rt).gameObject.SetActive(on);
				}
			}

			public void Head(Sprite icon, string name, string tag, string sub)
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_icon != (Object)null)
				{
					_icon.sprite = icon;
					((Graphic)_icon).color = (((Object)(object)icon != (Object)null) ? Color.white : Color.clear);
				}
				((TMP_Text)_name).text = name;
				((TMP_Text)_tag).text = tag;
				((TMP_Text)_sub).text = ((sub.Length > 0) ? sub : " ");
				((Component)_name).GetComponent<LayoutElement>().preferredWidth = Mathf.Min(((TMP_Text)_name).GetPreferredValues(name).x + 2f, _fs * 14f);
				((Component)_tag).GetComponent<LayoutElement>().preferredWidth = ((tag.Length > 0) ? (((TMP_Text)_tag).GetPreferredValues(tag).x + 2f) : 0f);
			}

			public void Rows(List<Line> lines, int which, bool labels)
			{
				while (_rows.Count < lines.Count)
				{
					_rows.Add(new Row((Transform)(object)_list, _rival, _fs, _rowH));
				}
				for (int i = 0; i < _rows.Count; i++)
				{
					if (i < lines.Count)
					{
						_rows[i].Show(lines[i], which, labels || !_rival);
					}
					else
					{
						_rows[i].Hide();
					}
				}
				float[] widths = new float[5];
				for (int j = 0; j < lines.Count; j++)
				{
					_rows[j].Measure(widths);
				}
				for (int k = 0; k < lines.Count; k++)
				{
					_rows[k].Fit(widths);
				}
			}

			public void Notes(List<KeyValuePair<string, Color>> notes)
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				int num = notes?.Count ?? 0;
				((Component)_notesBox).gameObject.SetActive(num > 0);
				while (_notes.Count < num)
				{
					TextMeshProUGUI val = UiKit.Label((Transform)(object)_notesBox, "note", "", _fs - 2f, UiKit.Dim, (TextAlignmentOptions)513);
					((TMP_Text)val).textWrappingMode = (TextWrappingModes)1;
					((TMP_Text)val).overflowMode = (TextOverflowModes)0;
					_notes.Add(val);
				}
				for (int i = 0; i < _notes.Count; i++)
				{
					bool flag = i < num;
					if (flag)
					{
						((TMP_Text)_notes[i]).text = notes[i].Key;
						((Graphic)_notes[i]).color = notes[i].Value;
					}
					if (((Component)_notes[i]).gameObject.activeSelf != flag)
					{
						((Component)_notes[i]).gameObject.SetActive(flag);
					}
				}
			}
		}

		private class DetailsBox
		{
			private class Section
			{
				private readonly GameObject _sep;

				private readonly TextMeshProUGUI _title;

				private readonly TextMeshProUGUI _sub;

				private readonly TextMeshProUGUI _body;

				public Section(Transform parent, float fs)
				{
					//IL_0022: 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_006c: 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)
					RectTransform val = UiKit.Row(parent, "gap", 1f);
					((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = UiKit.Line;
					_sep = ((Component)val).gameObject;
					_title = UiKit.Label(parent, "title", "", fs, UiKit.Gold, (TextAlignmentOptions)513);
					_sub = UiKit.Label(parent, "sub", "", fs - 3f, UiKit.Dim, (TextAlignmentOptions)513);
					_body = UiKit.Label(parent, "body", "", fs - 2f, UiKit.Ink, (TextAlignmentOptions)513);
					((TMP_Text)_body).textWrappingMode = (TextWrappingModes)1;
					((TMP_Text)_body).overflowMode = (TextOverflowModes)0;
					((TMP_Text)_body).richText = true;
				}

				public void Show(Detail d, bool separated)
				{
					_sep.SetActive(separated);
					((TMP_Text)_title).text = d.Title;
					((Component)_title).gameObject.SetActive(true);
					((TMP_Text)_sub).text = d.Sub ?? "";
					((Component)_sub).gameObject.SetActive(!string.IsNullOrEmpty(d.Sub));
					((TMP_Text)_body).text = d.Body;
					((Component)_body).gameObject.SetActive(true);
				}

				public void Hide()
				{
					_sep.SetActive(false);
					((Component)_title).gameObject.SetActive(false);
					((Component)_sub).gameObject.SetActive(false);
					((Component)_body).gameObject.SetActive(false);
				}
			}

			private readonly RectTransform _rt;

			private readonly LayoutElement _le;

			private readonly float _fs;

			private readonly List<Section> _sections = new List<Section>();

			public DetailsBox(Transform parent, float fs)
			{
				//IL_0039: 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_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Expected O, but got Unknown
				_fs = fs;
				_rt = UiKit.Rect(parent, "details");
				UiKit.Box((Transform)(object)_rt, "bg", UiKit.FieldSprite, Back);
				UiKit.Frame(_rt, new Color(0.93f, 0.77f, 0.38f, 0.28f));
				int num = Mathf.RoundToInt(fs * 0.6f);
				UiKit.Vertical(_rt, Mathf.Round(fs * 0.3f), new RectOffset(num, num, num / 2 + 2, num / 2 + 4));
				_le = ((Component)_rt).gameObject.AddComponent<LayoutElement>();
				((Component)_rt).gameObject.SetActive(false);
			}

			public void Visible(bool on)
			{
				if (((Component)_rt).gameObject.activeSelf != on)
				{
					((Component)_rt).gameObject.SetActive(on);
				}
			}

			public void Width(float w)
			{
				LayoutElement le = _le;
				float minWidth = (_le.preferredWidth = w);
				le.minWidth = minWidth;
			}

			public void Fill(List<Detail> list)
			{
				while (_sections.Count < list.Count)
				{
					_sections.Add(new Section((Transform)(object)_rt, _fs));
				}
				for (int i = 0; i < _sections.Count; i++)
				{
					if (i < list.Count)
					{
						_sections[i].Show(list[i], i > 0);
					}
					else
					{
						_sections[i].Hide();
					}
				}
			}
		}

		private class Row
		{
			public const int Columns = 5;

			private readonly GameObject _go;

			private readonly TextMeshProUGUI[] _cells = (TextMeshProUGUI[])(object)new TextMeshProUGUI[5];

			private readonly LayoutElement[] _le = (LayoutElement[])(object)new LayoutElement[5];

			public Row(Transform parent, bool rival, float fs, float h)
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = UiKit.Row(parent, "stat", h);
				_go = ((Component)val).gameObject;
				UiKit.Horizontal(val, Mathf.Round(fs * 0.45f));
				Make(val, 0, (TextAlignmentOptions)513, fs, UiKit.Dim);
				Make(val, 1, (TextAlignmentOptions)516, fs, UiKit.Ink);
				if (rival)
				{
					Make(val, 2, (TextAlignmentOptions)514, fs, UiKit.Dim);
					Make(val, 3, (TextAlignmentOptions)516, fs, UiKit.Ink);
					Make(val, 4, (TextAlignmentOptions)516, fs, UiKit.Dim);
				}
			}

			private void Make(RectTransform rt, int i, TextAlignmentOptions align, float fs, Color c)
			{
				//IL_0019: 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)
				TextMeshProUGUI val = UiKit.Label((Transform)(object)rt, "c" + i, "", fs, c, align);
				_cells[i] = val;
				LayoutElement val2 = ((Component)val).gameObject.AddComponent<LayoutElement>();
				val2.flexibleWidth = 0f;
				_le[i] = val2;
			}

			private void Set(int i, string text, Color c)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)_cells[i] == (Object)null))
				{
					((TMP_Text)_cells[i]).text = text;
					((Graphic)_cells[i]).color = c;
				}
			}

			public void Show(Line ln, int which, bool labels)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: 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_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				Set(0, ln.Label, ln.Header ? UiKit.Gold : UiKit.Dim);
				if (((Component)_cells[0]).gameObject.activeSelf != labels)
				{
					((Component)_cells[0]).gameObject.SetActive(labels);
				}
				if (which < 0)
				{
					Set(1, ln.Mine.Text, ln.Mine.Color);
				}
				else if (ln.Header)
				{
					Set(1, "", UiKit.Ink);
					Set(2, "", UiKit.Dim);
					Set(3, "", UiKit.Ink);
					Set(4, "", UiKit.Dim);
				}
				else
				{
					Set(1, ln.Was[which].Text, ln.Was[which].Color);
					Set(2, "→", UiKit.Dim);
					Set(3, ln.Now[which].Text, ln.Now[which].Color);
					Set(4, ln.Delta[which].Text, ln.Delta[which].Color);
				}
				if (!_go.activeSelf)
				{
					_go.SetActive(true);
				}
			}

			public void Measure(float[] widths)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < 5; i++)
				{
					TextMeshProUGUI val = _cells[i];
					if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeSelf && !string.IsNullOrEmpty(((TMP_Text)val).text))
					{
						widths[i] = Mathf.Max(widths[i], ((TMP_Text)val).GetPreferredValues(((TMP_Text)val).text).x);
					}
				}
			}

			public void Fit(float[] widths)
			{
				for (int i = 0; i < 5; i++)
				{
					if (!((Object)(object)_le[i] == (Object)null))
					{
						float num = Mathf.Ceil(widths[i]) + 2f;
						LayoutElement obj = _le[i];
						float minWidth = (_le[i].preferredWidth = num);
						obj.minWidth = minWidth;
					}
				}
			}

			public void Hide()
			{
				if (_go.activeSelf)
				{
					_go.SetActive(false);
				}
			}
		}

		public static bool Compact;

		public static int MaxCards = 3;

		public static bool HideGameTooltip = true;

		public static float TextScale = 1.5f;

		public static bool Widen;

		public static string WidenKey = "Ctrl";

		public static bool DetailsHeld;

		public static string DetailsKey = "Alt";

		private const float Gap = 6f;

		private const float Margin = 8f;

		private static readonly Color Good = new Color(0.56f, 0.86f, 0.42f);

		private static readonly Color Bad = new Color(0.94f, 0.44f, 0.36f);

		private static readonly Color Back = new Color(0.08f, 0.07f, 0.06f, 0.96f);

		private GameObject _root;

		private RectTransform _rt;

		private RectTransform _row;

		private Card _mine;

		private DetailsBox _details;

		private bool _hasDetails;

		private bool _detailsOpen;

		private readonly List<Card> _rivals = new List<Card>();

		private float _fs;

		private ItemData _item;

		private int _q;

		private Origin _from;

		private readonly List<ItemData> _shown = new List<ItemData>();

		private readonly List<int> _shownQ = new List<int>();

		private bool _compact;

		private bool _ru;

		private bool _widen;

		private string _worn;

		private float _width;

		private CanvasGroup _hidden;

		private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4];

		public void Hide()
		{
			Reveal();
			if ((Object)(object)_root != (Object)null && _root.activeSelf)
			{
				_root.SetActive(false);
			}
			_item = null;
		}

		public void Drop()
		{
			Reveal();
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)_root);
			}
			_root = null;
			_mine = null;
			_rivals.Clear();
			_item = null;
		}

		public void Show(Target t)
		{
			//IL_0032: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//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_0116: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (t == null || t.Item == null || t.Item.m_shared == null || (Object)(object)localPlayer == (Object)null || !ItemStats.Wearable(t.Item.m_shared.m_itemType) || Rivals.Excluded(t.Item))
			{
				Hide();
			}
			else if (UiKit.Init())
			{
				float num = FontSize();
				if ((Object)(object)_root == (Object)null || !Mathf.Approximately(num, _fs))
				{
					Drop();
					_fs = num;
					Build();
				}
				if (!_root.activeSelf)
				{
					_root.SetActive(true);
				}
				bool widen = Widen && Rivals.Widens(t.Item.m_shared.m_itemType);
				List<ItemData> rivals = Rivals.For(localPlayer, t.Item, t.Fresh, Mathf.Max(1, MaxCards), widen);
				RectTransform val = (RectTransform)UiKit.CanvasRoot;
				Rect rect = val.rect;
				if (Changed(t, rivals, localPlayer, widen, ((Rect)(ref rect)).width))
				{
					rect = val.rect;
					Fill(t, rivals, localPlayer, widen, ((Rect)(ref rect)).width);
					rect = val.rect;
					Remember(t, rivals, localPlayer, widen, ((Rect)(ref rect)).width);
					_detailsOpen = false;
				}
				bool flag = DetailsHeld && _hasDetails;
				if (flag != _detailsOpen)
				{
					_details.Visible(flag);
					_detailsOpen = flag;
					LayoutRebuilder.ForceRebuildLayoutImmediate(_rt);
				}
				if (HideGameTooltip)
				{
					Conceal(t.GameTooltip);
				}
				else
				{
					Reveal();
				}
				if (!_root.activeSelf)
				{
					_root.SetActive(true);
				}
				_root.transform.SetAsLastSibling();
				Place(t);
			}
		}

		private static float FontSize()
		{
			InventoryGui instance = InventoryGui.instance;
			return Mathf.Clamp(Mathf.Round((((Object)(object)instance != (Object)null && (Object)(object)instance.m_recipeDecription != (Object)null) ? instance.m_recipeDecription.fontSize : 18f) * TextScale), 12f, 44f);
		}

		private void Conceal(GameObject tip)
		{
			if ((Object)(object)tip == (Object)null)
			{
				Reveal();
				return;
			}
			CanvasGroup val = tip.GetComponent<CanvasGroup>();
			if ((Object)(object)val == (Object)null)
			{
				val = tip.AddComponent<CanvasGroup>();
			}
			if ((Object)(object)_hidden != (Object)null && (Object)(object)_hidden != (Object)(object)val)
			{
				Reveal();
			}
			val.alpha = 0f;
			_hidden = val;
		}

		private void Reveal()
		{
			if ((Object)(object)_hidden != (Object)null)
			{
				_hidden.alpha = 1f;
			}
			_hidden = null;
		}

		private static string WornPrint(Player p)
		{
			return Id(((Humanoid)p).m_rightItem) + Id(((Humanoid)p).m_leftItem) + Id(((Humanoid)p).m_hiddenRightItem) + Id(((Humanoid)p).m_hiddenLeftItem) + Id(((Humanoid)p).m_helmetItem) + Id(((Humanoid)p).m_chestItem) + Id(((Humanoid)p).m_legItem) + Id(((Humanoid)p).m_shoulderItem) + Id(((Humanoid)p).m_utilityItem) + Id(((Humanoid)p).m_trinketItem);
		}

		private static string Id(ItemData d)
		{
			if (d != null)
			{
				return ((object)d).GetHashCode() + ":" + d.m_quality + "|";
			}
			return "-|";
		}

		private bool Changed(Target t, List<ItemData> rivals, Player p, bool widen, float width)
		{
			if (t.Item != _item || t.Quality != _q || t.From != _from)
			{
				return true;
			}
			if (Compact != _compact || L.Ru != _ru || widen != _widen)
			{
				return true;
			}
			if (!Mathf.Approximately(width, _width))
			{
				return true;
			}
			if (WornPrint(p) != _worn)
			{
				return true;
			}
			if (rivals.Count != _shown.Count)
			{
				return true;
			}
			for (int i = 0; i < rivals.Count; i++)
			{
				if (rivals[i] != _shown[i] || rivals[i].m_quality != _shownQ[i])
				{
					return true;
				}
			}
			return false;
		}

		private void Remember(Target t, List<ItemData> rivals, Player p, bool widen, float width)
		{
			_item = t.Item;
			_q = t.Quality;
			_from = t.From;
			_compact = Compact;
			_ru = L.Ru;
			_widen = widen;
			_width = width;
			_worn = WornPrint(p);
			_shown.Clear();
			_shownQ.Clear();
			foreach (ItemData rival in rivals)
			{
				_shown.Add(rival);
				_shownQ.Add(rival.m_quality);
			}
		}

		private void Fill(Target t, List<ItemData> rivals, Player p, bool widen, float width)
		{
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			List<Stat> mine = ItemStats.Read(t.Item, t.Quality, t.WorldLevel);
			List<List<Stat>> list = new List<List<Stat>>();
			foreach (ItemData rival in rivals)
			{
				list.Add(ItemStats.Read(rival, rival.m_quality, rival.m_worldLevel));
			}
			List<Line> list2 = Lines(t.Item, mine, rivals, list, p);
			List<Line> list3 = new List<Line>();
			int num = 0;
			bool flag = Compact && rivals.Count > 0;
			foreach (Line item in list2)
			{
				if (flag && !item.Header && !item.Differs)
				{
					num++;
				}
				else
				{
					list3.Add(item);
				}
			}
			int num2 = list3.FindIndex((Line x) => x.Header);
			if (num2 >= 0 && (num2 == list3.Count - 1 || list3[num2 + 1].Label.Trim() == L.SetIfWorn || !list3[num2 + 1].Label.StartsWith("  ")))
			{
				list3.RemoveAt(num2);
			}
			_mine.Head(null, Name(t.Item), OriginText(t, p), Level(t.Item, t.Quality));
			_mine.Rows(list3, -1, labels: true);
			while (_rivals.Count < rivals.Count)
			{
				_rivals.Add(new Card((Transform)(object)_row, rival: true, _fs));
			}
			for (int num3 = 0; num3 < _rivals.Count; num3++)
			{
				if (num3 >= rivals.Count)
				{
					_rivals[num3].Visible(on: false);
					continue;
				}
				ItemData val = rivals[num3];
				Card card = _rivals[num3];
				card.Head(val.GetIcon(), Name(val), Rivals.Worn(p, val) ? L.Equipped : L.InInventory, Level(val, val.m_quality));
				card.Rows(list3, num3, labels: true);
				card.Notes(null);
				card.Visible(on: true);
			}
			List<Detail> list4 = DetailsOf(t, rivals, p);
			_hasDetails = list4.Count > 0 && DetailsKey.Length > 0;
			_details.Fill(list4);
			_details.Visible(on: false);
			int num4 = rivals.Count;
			float num5 = width - 16f;
			_mine.Notes(Notes(t, p, rivals.Count, num, flag, list3, widen, 0, list4));
			LayoutRebuilder.ForceRebuildLayoutImmediate(_rt);
			Rect rect = _rt.rect;
			if (((Rect)(ref rect)).width > num5)
			{
				for (int num6 = 0; num6 < rivals.Count; num6++)
				{
					_rivals[num6].Rows(list3, num6, labels: false);
				}
				LayoutRebuilder.ForceRebuildLayoutImmediate(_rt);
			}
			while (true)
			{
				rect = _rt.rect;
				if (!(((Rect)(ref rect)).width > num5) || num4 <= 0)
				{
					break;
				}
				_rivals[--num4].Visible(on: false);
				_mine.Notes(Notes(t, p, rivals.Count, num, flag, list3, widen, rivals.Count - num4, list4));
				LayoutRebuilder.ForceRebuildLayoutImmediate(_rt);
			}
			DetailsBox details = _details;
			rect = _row.rect;
			details.Width(((Rect)(ref rect)).width);
		}

		private static List<Detail> DetailsOf(Target t, List<ItemData> rivals, Player p)
		{
			List<Detail> list = ItemStats.Details(t.Item, t.Quality, p);
			HashSet<string> hashSet = new HashSet<string>();
			foreach (Detail item in list)
			{
				hashSet.Add(item.Key + "|" + item.Name);
			}
			foreach (ItemData rival in rivals)
			{
				string text = (Rivals.Worn(p, rival) ? L.DetOf(Name(rival)) : L.DetIn(Name(rival)));
				foreach (Detail item2 in ItemStats.Details(rival, rival.m_quality, p))
				{
					if (hashSet.Add(item2.Key + "|" + item2.Name))
					{
						item2.Sub = (string.IsNullOrEmpty(item2.Sub) ? text : (text + " · " + item2.Sub));
						list.Add(item2);
					}
				}
			}
			return list;
		}

		private List<KeyValuePair<string, Color>> Notes(Target t, Player p, int rivals, int hidden, bool compact, List<Line> shown, bool widen, int noRoom, List<Detail> details)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<string, Color>> notes = new List<KeyValuePair<string, Color>>();
			string text = HandsNote(t.Item.m_shared.m_itemType, p);
			if (text.Length > 0)
			{
				Add(text, Bad);
			}
			if (rivals == 0)
			{
				if (t.From != Origin.Owned || !Rivals.Worn(p, t.Item))
				{
					Add(Slotted(t.Item.m_shared.m_itemType) ? L.NothingEquipped : L.NoSameClass, UiKit.Dim);
				}
			}
			else if (compact && hidden > 0)
			{
				Add(shown.Exists((Line x) => !x.Header) ? string.Format(L.SameHidden, hidden) : L.AllSame, UiKit.Dim);
			}
			if (noRoom > 0)
			{
				Add(string.Format(L.NoRoom, noRoom), UiKit.Dim);
			}
			if (Rivals.Widens(t.Item.m_shared.m_itemType))
			{
				Add(widen ? L.Widened : string.Format(L.WidenHint, WidenKey), UiKit.Dim);
			}
			if (details.Count > 0 && DetailsKey.Length > 0)
			{
				Add(L.DetHint(DetailsKey, details.Exists((Detail x) => x.Key == "set"), details.Exists((Detail x) => x.Key != "set")), UiKit.Dim);
			}
			return notes;
			void Add(string s, Color c)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				notes.Add(new KeyValuePair<string, Color>(s, c));
			}
		}

		private static string Name(ItemData d)
		{
			return Localization.instance.Localize(d.m_shared.m_name);
		}

		private static string Level(ItemData d, int q)
		{
			if (d.m_shared.m_maxQuality <= 1)
			{
				return "";
			}
			return L.LevelShort + q;
		}

		private static string OriginText(Target t, Player p)
		{
			switch (t.From)
			{
			case Origin.Crafting:
				if (t.Quality <= t.Item.m_quality || ((Humanoid)p).GetInventory() == null || !((Humanoid)p).GetInventory().ContainsItem(t.Item))
				{
					return L.Crafted;
				}
				return L.Upgraded;
			case Origin.Trader:
				return L.ForSale;
			default:
				if (!Rivals.Worn(p, t.Item))
				{
					return "";
				}
				return L.Equipped;
			}
		}

		private static bool Slotted(ItemType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0012: 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_0017: Invalid comparison between Unknown and I4
			//IL_0005: 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_0009: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)t <= 11)
			{
				if (t - 6 <= 1 || (int)t == 11)
				{
					goto IL_001e;
				}
			}
			else if (t - 17 <= 1 || (int)t == 24)
			{
				goto IL_001e;
			}
			return false;
			IL_001e:
			return true;
		}

		private static string HandsNote(ItemType t, Player p)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			ItemData val = ((Humanoid)p).m_leftItem ?? ((Humanoid)p).m_hiddenLeftItem;
			ItemData val2 = ((Humanoid)p).m_rightItem ?? ((Humanoid)p).m_hiddenRightItem;
			ItemType val3 = (ItemType)((val != null) ? ((int)val.m_shared.m_itemType) : 0);
			ItemType val4 = (ItemType)((val2 != null) ? ((int)val2.m_shared.m_itemType) : 0);
			if (((int)t == 14 || (int)t == 22 || (int)t == 4) && (int)val3 == 5)
			{
				return L.ShieldOff;
			}
			if ((int)t == 5 && ((int)val4 == 14 || (int)val3 == 22 || (int)val3 == 4))
			{
				return L.TwoHandOff;
			}
			return "";
		}

		private static List<Line> Lines(ItemData hovered, List<Stat> mine, List<ItemData> rivals, List<List<Stat>> theirs, Player p)
		{
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Stat> dictionary = new Dictionary<string, Stat>();
			foreach (Stat item2 in mine)
			{
				dictionary[item2.Key] = item2;
			}
			List<Dictionary<string, Stat>> list = new List<Dictionary<string, Stat>>();
			List<Stat> list2 = new List<Stat>(mine);
			HashSet<string> hashSet = new HashSet<string>(dictionary.Keys);
			foreach (List<Stat> their in theirs)
			{
				Dictionary<string, Stat> dictionary2 = new Dictionary<string, Stat>();
				foreach (Stat item3 in their)
				{
					dictionary2[item3.Key] = item3;
					if (hashSet.Add(item3.Key))
					{
						list2.Add(item3);
					}
				}
				list.Add(dictionary2);
			}
			list2.Sort((Stat x, Stat y) => (x.Order == y.Order) ? string.CompareOrdinal(x.Key, y.Key) : x.Order.CompareTo(y.Order));
			int count = theirs.Count;
			List<Line> list3 = new List<Line>();
			bool flag = false;
			foreach (Stat item4 in list2)
			{
				if (!flag && item4.Key.StartsWith("res_"))
				{
					Line item = new Line
					{
						Label = L.StResist,
						Header = true,
						Mine = new Cell("", UiKit.Ink),
						Was = new Cell[count],
						Now = new Cell[count],
						Delta = new Cell[count]
					};
					list3.Add(item);
					flag = true;
				}
				if (item4.Key == "set")
				{
					list3.Add(SetLine(hovered, rivals, p));
					continue;
				}
				dictionary.TryGetValue(item4.Key, out var value);
				value = value ?? ItemStats.Absent(item4);
				Line line = new Line
				{
					Label = item4.Label,
					Mine = new Cell(value.Text ?? "—", UiKit.Ink),
					Was = new Cell[count],
					Now = new Cell[count],
					Delta = new Cell[count]
				};
				for (int num = 0; num < count; num++)
				{
					list[num].TryGetValue(item4.Key, out var value2);
					value2 = value2 ?? ItemStats.Absent(item4);
					line.Was[num] = new Cell(value2.Text ?? "—", UiKit.Ink);
					if (value.Dir == Better.None)
					{
						bool flag2 = value.Text == value2.Text;
						if (!flag2)
						{
							line.Differs = true;
						}
						line.Now[num] = new Cell(value.Text ?? "—", UiKit.Ink);
						line.Delta[num] = new Cell(flag2 ? "=" : "~", UiKit.Dim);
						continue;
					}
					float num2 = value.Value - value2.Value;
					if (Mathf.Abs(num2) < 0.005f)
					{
						line.Now[num] = new Cell(value.Text ?? "—", UiKit.Ink);
						line.Delta[num] = new Cell("=", UiKit.Dim);
						continue;
					}
					line.Differs = true;
					Color c = (((value.Dir == Better.Higher) ? (num2 > 0f) : (num2 < 0f)) ? Good : Bad);
					line.Now[num] = new Cell(value.Text ?? "—", c);
					line.Delta[num] = new Cell((value.Delta != null) ? value.Delta(num2) : ((num2 > 0f) ? "+" : "−"), c);
				}
				list3.Add(line);
			}
			return list3;
		}

		private static bool HasSet(ItemData d)
		{
			SharedData shared = d.m_shared;
			if (!string.IsNullOrEmpty(shared.m_setName) && shared.m_setSize > 1)
			{
				return (Object)(object)shared.m_setStatusEffect != (Object)null;
			}
			return false;
		}

		private static int CountWith(Player p, string set, ItemData wearing)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			int num = ((Humanoid)p).GetSetCount(set);
			ItemData val = Rivals.Occupant(p, wearing.m_shared.m_itemType);
			if (val != null && val.m_shared.m_setName == set)
			{
				num--;
			}
			if (wearing.m_shared.m_setName == set)
			{
				num++;
			}
			return num;
		}

		private static string SetText(Player p, ItemData d)
		{
			if (!HasSet(d))
			{
				return "—";
			}
			SharedData shared = d.m_shared;
			return Localization.instance.Localize(shared.m_setStatusEffect.m_name) + " " + CountWith(p, shared.m_setName, d) + "/" + shared.m_setSize;
		}

		private static bool SetActive(Player p, ItemData d)
		{
			if (HasSet(d))
			{
				return CountWith(p, d.m_shared.m_setName, d) >= d.m_shared.m_setSize;
			}
			return false;
		}

		private static Line SetLine(ItemData hovered, List<ItemData> rivals, Player p)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			int count = rivals.Count;
			string text = SetText(p, hovered);
			bool flag = SetActive(p, hovered);
			Line line = new Line
			{
				Label = L.SetIfWorn,
				Mine = new Cell(text, flag ? Good : UiKit.Ink),
				Was = new Cell[count],
				Now = new Cell[count],
				Delta = new Cell[count]
			};
			for (int i = 0; i < count; i++)
			{
				ItemData d = rivals[i];
				string text2 = SetText(p, d);
				bool flag2 = SetActive(p, d);
				line.Was[i] = new Cell(text2, flag2 ? Good : UiKit.Ink);
				if (flag && !flag2)
				{
					line.Now[i] = new Cell(text, Good);
					line.Delta[i] = new Cell("+", Good);
					line.Differs = true;
					continue;
				}
				if (flag2 && !flag)
				{
					line.Now[i] = new Cell(text, Bad);
					line.Delta[i] = new Cell("−", Bad);
					line.Differs = true;
					continue;
				}
				bool flag3 = text2 == text;
				if (!flag3)
				{
					line.Differs = true;
				}
				line.Now[i] = new Cell(text, UiKit.Ink);
				line.Delta[i] = new Cell(flag3 ? "=" : "~", UiKit.Dim);
			}
			return line;
		}

		private static Rect Local(RectTransform canvas, RectTransform rt)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0039: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			rt.GetWorldCorners(Corners);
			Vector2 val = Vector2.op_Implicit(((Transform)canvas).InverseTransformPoint(Corners[0]));
			Vector2 val2 = Vector2.op_Implicit(((Transform)canvas).InverseTransformPoint(Corners[2]));
			return Rect.MinMaxRect(val.x, val.y, val2.x, val2.y);
		}

		private void Place(Target t)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//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_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_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (RectTransform)UiKit.CanvasRoot;
			Rect rect = val.rect;
			Rect rect2 = _rt.rect;
			Vector2 size = ((Rect)(ref rect2)).size;
			Rect val2 = Local(val, t.Anchor);
			float yMax = ((Rect)(ref val2)).yMax;
			float num;
			if ((Object)(object)t.Beside != (Object)null)
			{
				Rect val3 = Local(val, t.Beside);
				num = ((Rect)(ref val3)).xMin - 6f - size.x;
				if (num < ((Rect)(ref rect)).xMin + 8f)
				{
					num = ((Rect)(ref val3)).xMax + 6f;
				}
			}
			else if (HideGameTooltip)
			{
				num = ((Rect)(ref val2)).xMin;
			}
			else
			{
				num = ((Rect)(ref val2)).xMax + 6f;
				if (num + size.x > ((Rect)(ref rect)).xMax - 8f)
				{
					num = ((Rect)(ref val2)).xMin - 6f - size.x;
				}
			}
			num = Mathf.Clamp(num, ((Rect)(ref rect)).xMin + 8f, Mathf.Max(((Rect)(ref rect)).xMin + 8f, ((Rect)(ref rect)).xMax - 8f - size.x));
			yMax = Mathf.Min(yMax, ((Rect)(ref rect)).yMax - 8f);
			if (yMax - size.y < ((Rect)(ref rect)).yMin + 8f)
			{
				yMax = ((Rect)(ref rect)).yMin + 8f + size.y;
			}
			_rt.anchoredPosition = new Vector2(num, yMax);
		}

		private void Build()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject("HoverCompare", new Type[1] { typeof(RectTransform) });
			_root.transform.SetParent(UiKit.CanvasRoot, false);
			_rt = (RectTransform)_root.transform;
			RectTransform rt = _rt;
			RectTransform rt2 = _rt;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			rt2.anchorMax = val;
			rt.anchorMin = val;
			_rt.pivot = new Vector2(0f, 1f);
			CanvasGroup obj = _root.AddComponent<CanvasGroup>();
			obj.blocksRaycasts = false;
			obj.interactable = false;
			VerticalLayoutGroup obj2 = _root.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 6f;
			((LayoutGroup)obj2).childAlignment = (TextAnchor)0;
			bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = childControlWidth;
			childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false);
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = childControlWidth;
			ContentSizeFitter obj3 = _root.AddComponent<ContentSizeFitter>();
			obj3.horizontalFit = (FitMode)2;
			obj3.verticalFit = (FitMode)2;
			_row = UiKit.Rect((Transform)(object)_rt, "cards");
			HorizontalLayoutGroup obj4 = ((Component)_row).gameObject.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj4).spacing = 6f;
			((LayoutGroup)obj4).childAlignment = (TextAnchor)0;
			childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = childControlWidth;
			childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false);
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = childControlWidth;
			_mine = new Card((Transform)(object)_row, rival: false, _fs);
			_details = new DetailsBox((Transform)(object)_rt, _fs);
			_root.SetActive(false);
		}
	}
	public static class L
	{
		public static bool Ru;

		public static string DetNoText => T("The game gives no description.", "Игра описания не даёт.");

		public static string ModImmune => T("Immune", "Иммунитет");

		public static string ModNormal => T("Normal", "Обычно");

		public static string ModResistant => T("Resistant", "Устойчив");

		public static string ModSlightlyResistant => T("Slightly resistant", "Слегка устойчив");

		public static string ModSlightlyWeak => T("Slightly weak", "Слегка уязвим");

		public static string ModVeryResistant => T("Very resistant", "Очень устойчив");

		public static string ModVeryWeak => T("Very weak", "Очень уязвим");

		public static string ModWeak => T("Weak", "Уязвим");

		public static string StAdrenaline => T("Adrenaline needed", "Нужно адреналина");

		public static string StArmor => T("Armor", "Броня");

		public static string StBackstab => T("Backstab", "Удар в спину");

		public static string StBlock => T("Block", "Блок");

		public static string StBlunt => T("Blunt", "Дробящий");

		public static string StChop => T("Chop", "Рубка");

		public static string StDamage => T("Damage", "Урон");

		public static string StDeflect => T("Knockback on block", "Отбрасывание блоком");

		public static string StDurability => T("Durability", "Прочность");

		public static string StEffect => T("Effect", "Эффект");

		public static string StEitr => T("Eitr per attack", "Эйтр на удар");

		public static string StEitrRegen => T("Eitr regen", "Восстановление эйтра");

		public static string StFire => T("Fire", "Огонь");

		public static string StFrost => T("Frost", "Мороз");

		public static string StHealth => T("Health per attack", "Здоровье на удар");

		public static string StKnockback => T("Knockback", "Отбрасывание");

		public static string StLightning => T("Lightning", "Молния");

		public static string StMovement => T("Movement", "Скорость");

		public static string StParry => T("Parry bonus", "Парирование");

		public static string StPickaxe => T("Pickaxe", "Добыча");

		public static string StPierce => T("Pierce", "Колющий");

		public static string StPoison => T("Poison", "Яд");

		public static string StResist => T("Resistances", "Сопротивления");

		public static string StSet => T("Set bonus", "Комплект");

		public static string StSlash => T("Slash", "Рубящий");

		public static string StSpirit => T("Spirit", "Дух");

		public static string StStamina => T("Stamina per attack", "Выносливость на удар");

		public static string StToolTier => T("Tool tier", "Уровень инструмента");

		public static string StWeight => T("Weight", "Вес");

		public static string Equipped => T("Equipped", "Надето");

		public static string InInventory => T("In inventory", "В инвентаре");

		public static string Crafted => T("Crafted", "Создаётся");

		public static string Upgraded => T("Upgraded", "После улучшения");

		public static string ForSale => T("For sale", "Продаётся");

		public static string NothingEquipped => T("Nothing worn in this slot", "В этом слоте ничего не надето");

		public static string NoSameClass => T("Nothing of this kind to compare with", "Сравнить не с чем: таких вещей нет");

		public static string SameHidden => T("{0} more stats are the same", "Ещё совпадает: {0}");

		public static string AllSame => T("All stats are the same", "Все характеристики совпадают");

		public static string ShieldOff => T("Your shield will be unequipped", "Щит придётся снять");

		public static string TwoHandOff => T("Your two-handed weapon will be unequipped", "Двуручное оружие придётся снять");

		public static string SetIfWorn => T("Set if worn", "Комплект, если надеть");

		public static string LevelShort => T("lvl ", "ур. ");

		public static string WidenHint => T("Hold {0} to compare with every weapon", "Зажмите {0} — сравнить со всем оружием");

		public static string Widened => T("Comparing with every weapon", "Сравнение со всем оружием");

		public static string NoRoom => T("{0} more did not fit on screen", "Не поместилось на экран: {0}");

		public static string DetWorn(int worn, int size)
		{
			return T("Worn now: " + worn + " of " + size, "Сейчас надето " + worn + " из " + size);
		}

		private static string T(string en, string ru)
		{
			if (!Ru)
			{
				return en;
			}
			return ru;
		}

		public static string DetHint(string key, bool set, bool effect)
		{
			if (set && effect)
			{
				return T("Hold " + key + ": details", "Зажмите " + key + " — подробности");
			}
			if (set)
			{
				return T("Hold " + key + ": set bonus", "Зажмите " + key + " — бонус комплекта");
			}
			return T("Hold " + key + ": effect", "Зажмите " + key + " — эффект");
		}

		public static string DetOf(string item)
		{
			return T("On what you wear: " + item, "У надетого: " + item);
		}

		public static string DetIn(string item)
		{
			return T("On " + item + " in your inventory", "У вещи в инвентаре: " + item);
		}
	}
	public static class UiKit
	{
		public static TMP_FontAsset Font;

		public static Sprite FieldSprite;

		public static Transform CanvasRoot;

		public static readonly Color Ink = new Color(0.9f, 0.86f, 0.76f);

		public static readonly Color Dim = new Color(0.6f, 0.57f, 0.51f);

		public static readonly Color Gold = new Color(0.93f, 0.77f, 0.38f);

		public static readonly Color Line = new Color(1f, 1f, 1f, 0.1f);

		public static bool Ready { get; private set; }

		public static bool Init()
		{
			if (Ready && (Object)(object)CanvasRoot != (Object)null)
			{
				return true;
			}
			Ready = false;
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			Canvas componentInParent = ((Component)instance).GetComponentInParent<Canvas>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return false;
			}
			CanvasRoot = ((Component)componentInParent).transform;
			if ((Object)(object)instance.m_recipeName != (Object)null)
			{
				Font = instance.m_recipeName.font;
			}
			if ((Object)(object)Font == (Object)null)
			{
				TMP_Text componentInChildren = ((Component)CanvasRoot).GetComponentInChildren<TMP_Text>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					Font = componentInChildren.font;
				}
			}
			FieldSprite = Best(((Component)CanvasRoot).GetComponentsInChildren<Image>(true), "darken", "interior", "text_field", "bkg", "field");
			Ready = true;
			HoverComparePlugin.Log.LogInfo((object)string.Format("интерфейс: шрифт {0}, плашка {1}", ((Object)(object)Font != (Object)null) ? ((Object)Font).name : "НЕ НАЙДЕН", ((Object)(object)FieldSprite != (Object)null) ? ((Object)FieldSprite).name : "нет"));
			return true;
		}

		private static Sprite Best(Image[] all, params string[] prefer)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			Sprite result = null;
			int num = int.MaxValue;
			float num2 = -1f;
			foreach (Image val in all)
			{
				Sprite sprite = val.sprite;
				if ((Object)(object)sprite == (Object)null || sprite.border == Vector4.zero || ((Object)sprite).name.ToLowerInvariant().Contains("mask") || ((Object)val).name.ToLowerInvariant().Contains("mask") || (Object)(object)((Component)val).GetComponent<Mask>() != (Object)null)
				{
					continue;
				}
				string text = ((Object)sprite).name.ToLowerInvariant();
				int num3 = -1;
				for (int j = 0; j < prefer.Length; j++)
				{
					if (text.Contains(prefer[j]))
					{
						num3 = j;
						break;
					}
				}
				if (num3 >= 0)
				{
					Rect rect = ((Graphic)val).rectTransform.rect;
					float num4 = Mathf.Abs(((Rect)(ref rect)).width * ((Rect)(ref rect)).height);
					if (num3 < num || (num3 == num && num4 > num2))
					{
						result = sprite;
						num = num3;
						num2 = num4;
					}
				}
			}
			return result;
		}

		public static RectTransform Rect(Transform parent, string name)
		{
			//IL_0014: 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_002c: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent(parent, false);
			return val;
		}

		public static RectTransform Row(Transform parent, string name, float height)
		{
			RectTransform obj = Rect(parent, name);
			LayoutElement obj2 = ((Component)obj).gameObject.AddComponent<LayoutElement>();
			float minHeight = (obj2.preferredHeight = height);
			obj2.minHeight = minHeight;
			obj2.flexibleHeight = 0f;
			return obj;
		}

		public static Image Box(Transform parent, string name, Sprite sprite, Color tint)
		{
			//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_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Rect(parent, name);
			((Component)obj).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			Stretch(obj);
			Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
			obj2.sprite = sprite;
			obj2.type = (Type)(((Object)(object)sprite != (Object)null && sprite.border != Vector4.zero) ? 1 : 0);
			((Graphic)obj2).color = tint;
			((Graphic)obj2).raycastTarget = false;
			return obj2;
		}

		public static void Stretch(RectTransform rt)
		{
			//IL_0001: 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_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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			Vector2 offsetMin = (rt.offsetMax = Vector2.zero);
			rt.offsetMin = offsetMin;
		}

		public static TextMeshProUGUI Label(Transform parent, string name, string text, float size, Color color, TextAlignmentOptions align = (TextAlignmentOptions)513)
		{
			//IL_0046: 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)
			RectTransform obj = Rect(parent, name);
			((Component)obj).gameObject.SetActive(false);
			TextMeshProUGUI val = ((Component)obj).gameObject.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)Font != (Object)null)
			{
				((TMP_Text)val).font = Font;
			}
			((TMP_Text)val).text = text;
			((TMP_Text)val).fontSize = size;
			((Graphic)val).color = color;
			((TMP_Text)val).alignment = align;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val).overflowMode = (TextOverflowModes)1;
			((Graphic)val).rayc