Decompiled source of MyLittleUI v1.1.20

MyLittleUI.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using AzuExtendedPlayerInventory;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using ExtraSlotsAPI;
using GUIFramework;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("My Little UI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("My Little UI")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("345181bf-e9ed-4c88-a4f4-38450f53cc41")]
[assembly: AssemblyFileVersion("1.1.20")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.20.0")]
[module: UnverifiableCode]
namespace MyLittleUI
{
	internal class AmmoCountIcon
	{
		public class ElementExtraData
		{
			public TMP_Text m_ammo;

			public Image m_icon;

			public Image m_bait;

			public ItemData m_item;

			public void UpdateState(ElementData elementData)
			{
				if (m_item == null)
				{
					TMP_Text ammo = m_ammo;
					if (ammo != null)
					{
						((Component)ammo).gameObject.SetActive(false);
					}
					Image icon = m_icon;
					if (icon != null)
					{
						((Component)icon).gameObject.SetActive(false);
					}
					Image bait = m_bait;
					if (bait != null)
					{
						((Component)bait).gameObject.SetActive(false);
					}
					return;
				}
				ItemData currentAmmo = GetCurrentAmmo();
				int num = ((currentAmmo != null) ? ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(currentAmmo.m_shared.m_name, -1, true) : 0);
				TMP_Text ammo2 = m_ammo;
				if (ammo2 != null)
				{
					((Component)ammo2).gameObject.SetActive(MyLittleUI.ammoCountEnabled.Value && num > 0);
				}
				if (num > 0)
				{
					TMP_Text ammo3 = m_ammo;
					if (ammo3 != null)
					{
						ammo3.SetText(num.ToString());
					}
				}
				Sprite val = ((currentAmmo != null) ? currentAmmo.GetIcon() : null);
				Image icon2 = m_icon;
				if (icon2 != null)
				{
					((Component)icon2).gameObject.SetActive(MyLittleUI.ammoIconEnabled.Value && (Object)(object)val != (Object)null);
				}
				if ((Object)(object)val != (Object)null && (Object)(object)m_icon != (Object)null)
				{
					m_icon.overrideSprite = val;
				}
				ItemData currentBait = GetCurrentBait();
				Sprite val2 = ((currentBait != null) ? currentBait.GetIcon() : null);
				Image bait2 = m_bait;
				if (bait2 != null)
				{
					((Component)bait2).gameObject.SetActive(MyLittleUI.baitIconEnabled.Value && (Object)(object)val2 != (Object)null);
				}
				if ((Object)(object)val2 != (Object)null && (Object)(object)m_bait != (Object)null)
				{
					m_bait.overrideSprite = val2;
				}
				int num2 = ((currentBait != null) ? ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(currentBait.m_shared.m_name, -1, true) : 0);
				if (num2 > 0 && MyLittleUI.baitCountEnabled.Value && !((Component)elementData.m_amount).gameObject.activeSelf)
				{
					((Component)elementData.m_amount).gameObject.SetActive(true);
					elementData.m_amount.SetText(num2.ToString());
				}
			}

			private ItemData GetCurrentAmmo()
			{
				if (m_item == null || Utility.IsNullOrWhiteSpace(m_item.m_shared.m_ammoType) || IsBaitAmmo() || IsAmmo())
				{
					return null;
				}
				ItemData ammoItem = ((Humanoid)Player.m_localPlayer).GetAmmoItem();
				if (ammoItem == null || ammoItem.m_shared.m_ammoType != m_item.m_shared.m_ammoType || !((Humanoid)Player.m_localPlayer).GetInventory().ContainsItem(ammoItem))
				{
					ammoItem = ((Humanoid)Player.m_localPlayer).GetInventory().GetAmmoItem(m_item.m_shared.m_ammoType, (string)null);
				}
				return ammoItem;
			}

			private ItemData GetCurrentBait()
			{
				if (m_item == null || Utility.IsNullOrWhiteSpace(m_item.m_shared.m_ammoType) || !IsBaitAmmo() || IsAmmo())
				{
					return null;
				}
				ItemData ammoItem = ((Humanoid)Player.m_localPlayer).GetAmmoItem();
				if (ammoItem == null || ammoItem.m_shared.m_ammoType != m_item.m_shared.m_ammoType || !((Humanoid)Player.m_localPlayer).GetInventory().ContainsItem(ammoItem))
				{
					ammoItem = ((Humanoid)Player.m_localPlayer).GetInventory().GetAmmoItem(m_item.m_shared.m_ammoType, (string)null);
				}
				return ammoItem;
			}

			private bool IsAmmo()
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Invalid comparison between Unknown and I4
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Invalid comparison between Unknown and I4
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Invalid comparison between Unknown and I4
				return (int)m_item.m_shared.m_itemType == 9 || (int)m_item.m_shared.m_itemType == 23 || (int)m_item.m_shared.m_itemType == 2;
			}

			private bool IsBaitAmmo()
			{
				return m_item.m_shared.m_ammoType == "$item_fishingbait";
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "OnEnable")]
		public static class HotkeyBar_OnEnable_AddCustomElementsToHotkeyPrefab
		{
			private static void FillFields(RectTransform rtSource, RectTransform rtDestination)
			{
				//IL_0003: 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)
				rtDestination.anchoredPosition = rtSource.anchoredPosition;
				rtDestination.sizeDelta = rtSource.sizeDelta;
			}

			public static void Postfix(HotkeyBar __instance)
			{
				if (!((Object)(object)__instance.m_elementPrefab == (Object)null))
				{
					isDirty[__instance] = false;
					elementPrefab = __instance.m_elementPrefab;
					int num = __instance.m_elementPrefab.transform.Find("icon").GetSiblingIndex() + 1;
					Transform obj = __instance.m_elementPrefab.transform.Find("MLUI_AmmoAmount");
					ammoCount = ((obj != null) ? ((Component)obj).gameObject : null);
					if ((Object)(object)ammoCount == (Object)null)
					{
						GameObject gameObject = ((Component)__instance.m_elementPrefab.transform.Find("amount")).gameObject;
						ammoCount = Object.Instantiate<GameObject>(gameObject);
						((Object)ammoCount).name = "MLUI_AmmoAmount";
						ammoCount.transform.SetParent(__instance.m_elementPrefab.transform);
						ammoCount.transform.SetSiblingIndex(num);
						num++;
						ammoCount.SetActive(false);
						FillFields(gameObject.GetComponent<RectTransform>(), ammoCount.GetComponent<RectTransform>());
					}
					Transform obj2 = __instance.m_elementPrefab.transform.Find("MLUI_AmmoIcon");
					ammoIcon = ((obj2 != null) ? ((Component)obj2).gameObject : null);
					if ((Object)(object)ammoIcon == (Object)null)
					{
						GameObject gameObject2 = ((Component)__instance.m_elementPrefab.transform.Find("icon")).gameObject;
						ammoIcon = Object.Instantiate<GameObject>(gameObject2);
						((Object)ammoIcon).name = "MLUI_AmmoIcon";
						ammoIcon.transform.SetParent(__instance.m_elementPrefab.transform);
						ammoIcon.transform.SetSiblingIndex(num);
						num++;
						ammoIcon.SetActive(false);
						FillFields(gameObject2.GetComponent<RectTransform>(), ammoIcon.GetComponent<RectTransform>());
					}
					Transform obj3 = __instance.m_elementPrefab.transform.Find("MLUI_AmmoBait");
					ammoBait = ((obj3 != null) ? ((Component)obj3).gameObject : null);
					if ((Object)(object)ammoBait == (Object)null)
					{
						GameObject gameObject3 = ((Component)__instance.m_elementPrefab.transform.Find("icon")).gameObject;
						ammoBait = Object.Instantiate<GameObject>(gameObject3);
						((Object)ammoBait).name = "MLUI_AmmoBait";
						ammoBait.transform.SetParent(__instance.m_elementPrefab.transform);
						ammoBait.transform.SetSiblingIndex(num);
						ammoBait.SetActive(false);
						FillFields(gameObject3.GetComponent<RectTransform>(), ammoBait.GetComponent<RectTransform>());
					}
					UpdateVisibility();
				}
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "Update")]
		public static class HotkeyBar_Update_UpdateAmmoIconCountDirtyState
		{
			[HarmonyPriority(0)]
			[HarmonyBefore(new string[] { "Azumatt.AzuExtendedPlayerInventory", "shudnal.ExtraSlots" })]
			public static void Prefix(HotkeyBar __instance)
			{
				if (MyLittleUI.modEnabled.Value && GeneralExtensions.GetValueSafe<HotkeyBar, bool>(isDirty, __instance))
				{
					isDirty[__instance] = false;
					if (__instance.m_elements.Count > 0)
					{
						__instance.UpdateIcons((Player)null);
					}
				}
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
		public static class HotkeyBar_UpdateIcons_UpdateAmmoCountAndIcon
		{
			[HarmonyPriority(0)]
			[HarmonyAfter(new string[] { "Azumatt.AzuExtendedPlayerInventory", "shudnal.ExtraSlots" })]
			public static void Postfix(HotkeyBar __instance, Player player)
			{
				if (!MyLittleUI.modEnabled.Value)
				{
					return;
				}
				if (!elementExtraDatas.ContainsKey(__instance))
				{
					elementExtraDatas.Add(__instance, new Dictionary<ElementData, ElementExtraData>());
				}
				Dictionary<ElementData, ElementExtraData> dictionary = elementExtraDatas[__instance];
				if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead())
				{
					dictionary.Clear();
					return;
				}
				if (dictionary.Count != __instance.m_elements.Count)
				{
					dictionary.Clear();
				}
				if (dictionary.Count > 0 && __instance.m_elements.Count > 0 && !dictionary.ContainsKey(__instance.m_elements[0]))
				{
					dictionary.Clear();
				}
				if (dictionary.Count == 0)
				{
					for (int i = 0; i < __instance.m_elements.Count; i++)
					{
						ElementData val = __instance.m_elements[i];
						ElementExtraData value = new ElementExtraData
						{
							m_ammo = ((Component)val.m_go.transform.Find("MLUI_AmmoAmount")).GetComponent<TMP_Text>(),
							m_icon = ((Component)val.m_go.transform.Find("MLUI_AmmoIcon")).GetComponent<Image>(),
							m_bait = ((Component)val.m_go.transform.Find("MLUI_AmmoBait")).GetComponent<Image>()
						};
						dictionary.Add(val, value);
					}
				}
				int num = 0;
				for (int j = 0; j < __instance.m_elements.Count; j++)
				{
					ElementData val2 = __instance.m_elements[j];
					ElementExtraData elementExtraData = dictionary[val2];
					if (elementExtraData == null)
					{
						continue;
					}
					if (!val2.m_used || num > __instance.m_items.Count)
					{
						elementExtraData.m_item = null;
					}
					else
					{
						elementExtraData.m_item = __instance.m_items[num];
						if ((Object)(object)elementExtraData.m_item.GetIcon() != (Object)(object)val2.m_icon.sprite)
						{
							elementExtraData.m_item = null;
						}
						num++;
					}
					elementExtraData.UpdateState(val2);
				}
			}
		}

		internal const string objectAmmoName = "MLUI_AmmoAmount";

		internal const string objectIconName = "MLUI_AmmoIcon";

		internal const string objectBaitName = "MLUI_AmmoBait";

		internal static GameObject elementPrefab;

		internal static GameObject ammoCount;

		internal static GameObject ammoIcon;

		internal static GameObject ammoBait;

		internal static readonly Dictionary<HotkeyBar, bool> isDirty = new Dictionary<HotkeyBar, bool>();

		internal static readonly Dictionary<HotkeyBar, Dictionary<ElementData, ElementExtraData>> elementExtraDatas = new Dictionary<HotkeyBar, Dictionary<ElementData, ElementExtraData>>();

		public static void UpdateVisibility()
		{
			//IL_0012: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ammoCount.GetComponent<RectTransform>();
			component.anchoredPosition = MyLittleUI.ammoCountPosition.Value;
			TMP_Text component2 = ammoCount.GetComponent<TMP_Text>();
			component2.fontSize = MyLittleUI.ammoCountFontSize.Value;
			((Graphic)component2).color = ((MyLittleUI.ammoCountColor.Value == Color.clear) ? ((Graphic)((Component)elementPrefab.transform.Find("amount")).GetComponent<TMP_Text>()).color : MyLittleUI.ammoCountColor.Value);
			component2.horizontalAlignment = MyLittleUI.ammoCountAlignment.Value;
			RectTransform component3 = ammoIcon.GetComponent<RectTransform>();
			component3.anchoredPosition = MyLittleUI.ammoIconPosition.Value;
			component3.sizeDelta = MyLittleUI.ammoIconSize.Value;
			RectTransform component4 = ammoBait.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0.5f, 0f);
			component4.anchorMax = new Vector2(1f, 0.5f);
			foreach (HotkeyBar item in isDirty.Keys.ToList())
			{
				isDirty[item] = true;
			}
		}
	}
	internal class ChestItem
	{
		public int m_stack;

		public int m_value;

		public string m_name;

		public float m_weight;

		public ItemType m_itemType;

		public ChestItem(ItemData itemData)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			m_name = itemData.m_shared.m_name;
			m_itemType = itemData.m_shared.m_itemType;
		}
	}
	internal static class ChestHoverText
	{
		[HarmonyPatch(typeof(Container), "OnContainerChanged")]
		private static class Container_OnContainerChanged_HoverCacheReset
		{
			private static void Postfix(Container __instance)
			{
				if (MyLittleUI.modEnabled.Value)
				{
					ResetCache(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(Container), "GetHoverText")]
		private static class Container_GetHoverText_Duration
		{
			private static readonly StringBuilder result = new StringBuilder();

			private static void ReorderItemList(ref List<ChestItem> itemsInChest)
			{
				if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Position)
				{
					return;
				}
				if (MyLittleUI.chestContentSortDir.Value == MyLittleUI.ContentSortDir.Desc)
				{
					if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Name)
					{
						itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_name).ToList();
					}
					else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Weight)
					{
						itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_weight).ToList();
					}
					else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Amount)
					{
						itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_stack).ToList();
					}
					else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Value)
					{
						itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_value).ToList();
					}
				}
				else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Name)
				{
					itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_name).ToList();
				}
				else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Weight)
				{
					itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_weight).ToList();
				}
				else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Amount)
				{
					itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_stack).ToList();
				}
				else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Value)
				{
					itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_value).ToList();
				}
			}

			private static void AddChestContent(Container container)
			{
				//IL_0118: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Expected I4, but got Unknown
				if (container.GetInventory().NrOfItems() == 0)
				{
					return;
				}
				result.Append("\n");
				List<ChestItem> itemsInChest = new List<ChestItem>();
				foreach (ItemData itemData in container.GetInventory().GetAllItemsInGridOrder())
				{
					ChestItem chestItem = itemsInChest.Find((ChestItem item) => item.m_name == itemData.m_shared.m_name);
					if (chestItem == null)
					{
						chestItem = new ChestItem(itemData);
						itemsInChest.Add(chestItem);
					}
					chestItem.m_stack += itemData.m_stack;
					chestItem.m_value += itemData.GetValue();
					chestItem.m_weight += itemData.GetWeight(-1);
				}
				ReorderItemList(ref itemsInChest);
				string itemFormat = "<color=#" + ColorUtility.ToHtmlStringRGBA(MyLittleUI.chestContentItemColor.Value) + ">{0}</color>";
				string amountFormat = "<color=#" + ColorUtility.ToHtmlStringRGBA(MyLittleUI.chestContentAmountColor.Value) + ">{0}</color>";
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				int num4 = 0;
				int num5 = 0;
				for (int i = 0; i < itemsInChest.Count; i++)
				{
					ChestItem chestItem2 = itemsInChest[i];
					if (i < MyLittleUI.chestContentLinesToShow.Value)
					{
						AddItemLine(chestItem2.m_name, chestItem2.m_stack);
						continue;
					}
					ItemType itemType = chestItem2.m_itemType;
					ItemType val = itemType;
					switch (val - 1)
					{
					case 1:
						num3++;
						break;
					case 0:
						num5++;
						break;
					case 2:
					case 3:
					case 4:
					case 13:
					case 14:
					case 18:
					case 19:
					case 21:
						num4++;
						break;
					case 5:
					case 6:
					case 9:
					case 10:
					case 11:
					case 16:
					case 17:
						num2++;
						break;
					default:
						num++;
						break;
					}
				}
				if (num + num2 + num3 + num4 + num5 != 0)
				{
					result.Append("\n+");
					if (num4 != 0)
					{
						AddItemLine("$radial_handitems", num4);
					}
					if (num2 != 0)
					{
						AddItemLine("$radial_armor_utility", num2);
					}
					if (num3 != 0)
					{
						AddItemLine("$radial_consumables", num3);
					}
					if (num5 != 0)
					{
						AddItemLine("$hud_crafting", num5);
					}
					if (num != 0)
					{
						AddItemLine("$hud_misc", num);
					}
				}
				void AddItemLine(string itemName, int amount)
				{
					result.AppendFormat("\n" + MyLittleUI.chestContentEntryFormat.Value, string.Format(itemFormat, itemName), string.Format(amountFormat, amount));
				}
			}

			private static void Postfix(Container __instance, ref string __result, bool ___m_checkGuardStone, string ___m_name, Inventory ___m_inventory)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				if (!MyLittleUI.modEnabled.Value || (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.Vanilla && MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.Vanilla) || (Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid() || (___m_checkGuardStone && !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, false, false)))
				{
					return;
				}
				string key = ((object)__instance.m_nview.GetZDO()).ToString();
				if (hoverTextCache.TryGetValue(key, out var value))
				{
					__result = value;
					return;
				}
				result.Clear();
				string @string = __instance.m_nview.GetZDO().GetString(ZDOVars.s_text, "");
				if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.Vanilla || !MyLittleUI.chestCustomName.Value || Utility.IsNullOrWhiteSpace(@string))
				{
					result.Append(___m_name);
				}
				else if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.CustomName)
				{
					result.Append(@string);
				}
				else if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.TypeThenCustomName)
				{
					result.Append(___m_name);
					result.Append(" (");
					result.Append(@string);
					result.Append(")");
				}
				else if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.CustomNameThenType)
				{
					result.Append(@string);
					result.Append(" (");
					result.Append(___m_name);
					result.Append(")");
				}
				if (__instance.CheckAccess(Game.instance.GetPlayerProfile().GetPlayerID()))
				{
					result.Append(" ");
					if (MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.Percentage)
					{
						result.Append($"{___m_inventory.SlotsUsedPercentage():F0}%");
					}
					else if (MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.FreeSlots)
					{
						result.Append($"{___m_inventory.GetEmptySlots()}");
					}
					else if (MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.ItemsMaxRoom)
					{
						result.Append($"{___m_inventory.NrOfItems()}/{___m_inventory.GetWidth() * ___m_inventory.GetHeight()}");
					}
					else if (___m_inventory.NrOfItems() == 0)
					{
						result.Append("( $piece_container_empty )");
					}
					result.Append("\n[<color=#ffff00ff><b>$KEY_Use</b></color>] $piece_container_open");
					if (MyLittleUI.chestShowHoldToStack.Value)
					{
						result.Append(" $msg_stackall_hover");
					}
					if (MyLittleUI.chestShowRename.Value)
					{
						if (!ZInput.IsNonClassicFunctionality() || !ZInput.IsGamepadActive())
						{
							result.Append("\n[<color=#ffff00ff><b>$KEY_AltPlace + $KEY_Use</b></color>] $hud_rename");
						}
						else
						{
							result.Append("\n[<color=#ffff00ff><b>$KEY_JoyAltKeys + $KEY_Use</b></color>] $hud_rename");
						}
					}
					if (MyLittleUI.chestContentEnabled.Value)
					{
						AddChestContent(__instance);
					}
				}
				__result = Localization.instance.Localize(result.ToString());
				hoverTextCache.Add(key, __result);
			}
		}

		[HarmonyPatch(typeof(Container), "Interact")]
		private class Container_Interact_ChestRename
		{
			private static bool Prefix(Container __instance, Humanoid character, bool hold, bool alt, bool ___m_checkGuardStone)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				if (!MyLittleUI.modEnabled.Value)
				{
					return true;
				}
				if (!MyLittleUI.chestCustomName.Value)
				{
					return true;
				}
				if (!alt)
				{
					return true;
				}
				if (hold)
				{
					return true;
				}
				if (___m_checkGuardStone && !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false))
				{
					((Character)character).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null);
					return true;
				}
				long playerID = Game.instance.GetPlayerProfile().GetPlayerID();
				if (!__instance.CheckAccess(playerID))
				{
					((Character)character).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null);
					return true;
				}
				textInputForContainer = __instance;
				TextInput.instance.Show("$hud_rename " + __instance.m_name, __instance.m_nview.GetZDO().GetString(ZDOVars.s_text, ""), 32);
				return false;
			}
		}

		[HarmonyPatch(typeof(TextInput), "setText")]
		private class TextInput_setText_ChestRename
		{
			private static void Postfix(string text)
			{
				if (MyLittleUI.modEnabled.Value && !((Object)(object)textInputForContainer == (Object)null))
				{
					textInputForContainer.m_nview.GetZDO().Set(ZDOVars.s_text, text);
					textInputForContainer.OnContainerChanged();
					textInputForContainer = null;
				}
			}
		}

		[HarmonyPatch(typeof(TextInput), "Hide")]
		private class TextInput_Hide_ChestRename
		{
			private static void Postfix()
			{
				if (MyLittleUI.modEnabled.Value && !((Object)(object)textInputForContainer == (Object)null))
				{
					textInputForContainer = null;
				}
			}
		}

		private static Container textInputForContainer;

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

		internal static void ResetCache(Container container)
		{
			if (!((Object)(object)container == (Object)null) && !((Object)(object)container.m_nview == (Object)null) && container.m_nview.IsValid())
			{
				hoverTextCache.Remove(((object)container.m_nview.GetZDO()).ToString());
			}
		}

		internal static void ResetHoverCache()
		{
			hoverTextCache.Clear();
		}
	}
	public static class CraftFilter
	{
		[HarmonyPatch(typeof(InventoryGui), "Awake")]
		public static class StoreGui_Awake_InitializePanel
		{
			[HarmonyPriority(800)]
			private static void Postfix()
			{
				InitFilterField();
				UpdateVisibility();
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "Show")]
		public static class InventoryGui_Show_ClearCache
		{
			public static void Postfix()
			{
				ClearText();
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "OnDestroy")]
		public static class InventoryGui_OnDestroy_ClearCache
		{
			public static void Postfix()
			{
				recipeCache.Clear();
			}
		}

		[HarmonyPatch(typeof(Chat), "HasFocus")]
		public static class Chat_HasFocus_FocusOverride
		{
			public static void Postfix(ref bool __result)
			{
				__result = __result || (MyLittleUI.modEnabled.Value && MyLittleUI.craftingFilterEnabled.Value && ((TMP_InputField)playerFilter).isFocused);
			}
		}

		[HarmonyPatch(typeof(Player), "GetAvailableRecipes")]
		public static class Player_GetAvailableRecipes_FilterRecipeList
		{
			[HarmonyPriority(0)]
			public static void Postfix(ref List<Recipe> available)
			{
				if (MyLittleUI.modEnabled.Value && MyLittleUI.craftingFilterEnabled.Value && applyFilter)
				{
					Stopwatch stopwatch = Stopwatch.StartNew();
					CollectionExtensions.Do<Recipe>((IEnumerable<Recipe>)available, (Action<Recipe>)CacheRecipe);
					MyLittleUI.LogInfo($"Recipe cache: verified {recipeCache.Count} in {(double)stopwatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0:F2} ms");
					stopwatch.Restart();
					MyLittleUI.LogInfo($"Recipe filter: removed {available.RemoveAll((Recipe recipe) => !FitsFilterString(recipe))} in {(double)stopwatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0:F2} ms");
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")]
		public static class InventoryGui_UpdateRecipe_HandleFieldFocus
		{
			public static void Postfix()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Invalid comparison between Unknown and I4
				if (!MyLittleUI.modEnabled.Value || !MyLittleUI.craftingFilterEnabled.Value)
				{
					return;
				}
				bool flag = (int)ZInput.InputLayout == 1;
				bool button = ZInput.GetButton("JoyLBumper");
				bool button2 = ZInput.GetButton("JoyLTrigger");
				if (((TMP_InputField)playerFilter).isFocused)
				{
					if (ZInput.GetButtonDown("Chat") || ZInput.GetButtonDown("Block") || ZInput.GetButtonDown("Console") || ZInput.GetButtonDown("Escape") || ZInput.GetButtonDown("Inventory") || (ZInput.GetButtonDown("JoyChat") && ZInput.GetButton("JoyAltKeys") && !(flag && button2) && !(!flag && button)))
					{
						((TMP_InputField)playerFilter).DeactivateInputField(false);
					}
				}
				else if ((Object)(object)Player.m_localPlayer != (Object)null && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && !Menu.IsVisible() && (ZInput.GetButtonDown("Chat") || (ZInput.GetButtonDown("JoyChat") && ZInput.GetButton("JoyAltKeys") && !(flag && button2) && !(!flag && button))))
				{
					playerFilter.ActivateInputField();
				}
			}
		}

		private const float fieldHeight = 32f;

		private static Vector2 listAnchorMin = new Vector2(-1f, -1f);

		private static readonly Dictionary<Recipe, string> recipeCache = new Dictionary<Recipe, string>();

		private static GuiInputField playerFilter;

		private static string[] filterString = Array.Empty<string>();

		private static bool applyFilter;

		private static readonly StringBuilder sb = new StringBuilder();

		private static readonly StringBuilder sbItem = new StringBuilder();

		private static void InitFilterField()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)InventoryGui.instance.m_recipeListScroll).transform.parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)TextInput.instance.m_inputField).gameObject, ((Transform)val).parent);
			((Object)val2).name = "MLUI_FilterField";
			val2.transform.SetSiblingIndex(((Transform)val).GetSiblingIndex() + 1);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			Rect rect = val.rect;
			component.sizeDelta = new Vector2(((Rect)(ref rect)).width, 32f);
			component.anchoredPosition = new Vector2(val.anchoredPosition.x, 4f);
			component.pivot = Vector2.zero;
			GuiInputField component2 = val2.GetComponent<GuiInputField>();
			component2.VirtualKeyboardTitle = "$menu_filter";
			((Component)((Component)component2).transform.Find("Text Area/Placeholder")).GetComponent<TMP_Text>().SetText(Localization.instance.Localize("$menu_filter"));
			((TMP_InputField)component2).restoreOriginalTextOnEscape = false;
			Button val3 = Object.Instantiate<Button>(InventoryGui.instance.m_splitOkButton, val2.transform);
			((Object)val3).name = "ClearTextButton";
			((UnityEventBase)val3.onClick).RemoveAllListeners();
			((UnityEvent)val3.onClick).AddListener(new UnityAction(ClearText));
			RectTransform component3 = ((Component)val3).GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(1f, 0.5f);
			component3.anchorMax = new Vector2(1f, 0.5f);
			component3.sizeDelta = Vector2.one * 28f;
			component3.anchoredPosition = new Vector2(-16f, 0f);
			TextMeshProUGUI component4 = ((Component)((Component)val3).transform.Find("Text")).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component4).SetText("✖");
			((TMP_Text)component4).margin = Vector4.one * -2f;
			((Component)val3).transform.Find("gamepad_hint").localPosition = new Vector3(-0.75f, 23.8f, 0f);
			playerFilter = component2;
			((UnityEvent<string>)(object)((TMP_InputField)playerFilter).onValueChanged).AddListener((UnityAction<string>)delegate
			{
				UpdateFilterString();
				StartPanelUpdate();
			});
		}

		public static void UpdateVisibility()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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)
			GuiInputField obj = playerFilter;
			if (obj != null)
			{
				GameObject gameObject = ((Component)obj).gameObject;
				if (gameObject != null)
				{
					gameObject.SetActive(MyLittleUI.modEnabled.Value && MyLittleUI.craftingFilterEnabled.Value);
				}
			}
			Transform parent = ((Component)InventoryGui.instance.m_recipeListScroll).transform.parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if (listAnchorMin.x == -1f)
			{
				listAnchorMin = val.anchorMin;
			}
			val.anchorMin = (((Behaviour)playerFilter).isActiveAndEnabled ? (listAnchorMin + new Vector2(0f, 0.05f)) : listAnchorMin);
		}

		public static void UpdateFilterString()
		{
			GuiInputField obj = playerFilter;
			if (applyFilter = !string.IsNullOrWhiteSpace((obj != null) ? ((TMP_InputField)obj).text : null))
			{
				GuiInputField obj2 = playerFilter;
				filterString = ((obj2 != null) ? ((TMP_InputField)obj2).text.ToLower().Split(new char[1] { ' ' }, StringSplitOptions.None) : null);
			}
		}

		public static void ClearText()
		{
			applyFilter = false;
			if (Object.op_Implicit((Object)(object)playerFilter))
			{
				((TMP_InputField)playerFilter).text = "";
			}
		}

		private static string GetItemFullString(ItemDrop itemDrop)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			sbItem.Clear();
			sbItem.Append(((Object)itemDrop).name);
			sbItem.Append(' ');
			sbItem.Append(itemDrop.m_itemData.m_shared.m_itemType);
			sbItem.Append(' ');
			sbItem.Append(itemDrop.m_itemData.m_shared.m_setName);
			sbItem.Append(' ');
			sbItem.Append(itemDrop.m_itemData.m_shared.m_name);
			sbItem.Append(' ');
			sbItem.Append(Localization.instance.Localize(itemDrop.m_itemData.m_shared.m_name));
			sbItem.Append(' ');
			sbItem.Append(itemDrop.m_itemData.GetTooltip(-1));
			return sbItem.ToString();
		}

		private static void CacheRecipe(Recipe recipe)
		{
			if (!recipeCache.ContainsKey(recipe))
			{
				sb.Clear();
				sb.Append(((Object)recipe).name);
				sb.Append(' ');
				sb.Append(GetItemFullString(recipe.m_item));
				sb.Append(' ');
				CollectionExtensions.Do<Requirement>((IEnumerable<Requirement>)recipe.m_resources, (Action<Requirement>)delegate(Requirement req)
				{
					sb.Append(GetItemFullString(req.m_resItem));
					sb.Append(' ');
				});
				recipeCache[recipe] = sb.ToString().ToLower();
			}
		}

		private static bool FitsFilterString(Recipe recipe)
		{
			return recipeCache.ContainsKey(recipe) && filterString.All((string substr) => recipeCache[recipe].Contains(substr));
		}

		private static void StartPanelUpdate()
		{
			((MonoBehaviour)MyLittleUI.instance).CancelInvoke("UpdateCraftingPanel");
			((MonoBehaviour)MyLittleUI.instance).Invoke("UpdateCraftingPanel", ((float)recipeCache.Count == 0f) ? 0.4f : 0.2f);
		}

		public static void UpdateCraftingPanel()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)InventoryGui.instance))
			{
				InventoryGui.instance.UpdateCraftingPanel(true);
				InventoryGui.instance.m_moveItemEffects.Create(((Component)Player.m_localPlayer).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
			}
		}
	}
	internal static class InfoBlocks
	{
		[HarmonyPatch(typeof(EnvMan), "UpdateTriggers")]
		public static class EnvMan_UpdateTriggers_UpdateDayTime
		{
			private static int Fraction(float dayFraction)
			{
				return (int)(dayFraction * (float)((MyLittleUI.clockTimeType.Value == MyLittleUI.ClockTimeType.Fuzzy && fuzzyTime != null && fuzzyTime.Length != 0) ? 40 : 1000));
			}

			public static void Postfix(float oldDayFraction, float newDayFraction, Biome biome)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Invalid comparison between Unknown and I4
				if (MyLittleUI.modEnabled.Value && !((Object)(object)Player.m_localPlayer == (Object)null) && (int)biome != 0 && (Fraction(oldDayFraction) != Fraction(newDayFraction) || newDayFraction < oldDayFraction))
				{
					UpdateClock();
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		public static class Hud_Awake_AddInfoBlocks
		{
			public static void Postfix(Hud __instance)
			{
				if (MyLittleUI.modEnabled.Value)
				{
					if (!Object.op_Implicit((Object)(object)__instance.m_rootObject.transform.Find("MyLittleUI_Parent")))
					{
						AddInfoBlocks(__instance.m_rootObject.transform);
						InventoryPanel.AddBlock(parentObject);
					}
					UpdateVisibility();
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "OnDestroy")]
		public static class Hud_OnDestroy_Clear
		{
			public static void Postfix()
			{
				if (MyLittleUI.modEnabled.Value)
				{
					WeatherForecast.windList.Clear();
					WeatherForecast.winds.Clear();
					WeatherForecast.windsTransition.Clear();
					parentObject = null;
					clockObject = null;
					clockDayObject = null;
					clockTimeObject = null;
					dayText = null;
					timeText = null;
					forecastObject = null;
					windsObject = null;
					windTemplate = null;
					windsProgress = null;
					windsProgressRect = null;
					windsObjectRect = null;
					weatherText = null;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnSpawned")]
		public static class Player_OnSpawned_UpdateInfoBlocksVisibility
		{
			public static void Postfix()
			{
				if (MyLittleUI.modEnabled.Value)
				{
					UpdateVisibility();
				}
			}
		}

		[HarmonyPatch(typeof(Minimap), "SetMapMode")]
		public static class Minimap_SetMapMode_UpdateInfoBlocksVisibility
		{
			public static void Postfix()
			{
				if (MyLittleUI.modEnabled.Value)
				{
					UpdateInfoBlocksVisibility();
				}
			}
		}

		private const string objectRootName = "MyLittleUI_Parent";

		private const string objectClockName = "Clock";

		private const string objectClockDayName = "Day";

		private const string objectClockTimeName = "Time";

		private const string objectForecastName = "Forecast";

		private const string objectForecastWeatherText = "weather_text";

		private const string objectForecastWeatherIcon = "weather_icon";

		private const string objectWindsName = "Winds";

		private const string objectWindsTemplateName = "WindElement";

		private const string objectWindsProgressName = "WindProgress";

		public static GameObject parentObject;

		public static GameObject clockObject;

		public static GameObject clockDayObject;

		public static GameObject clockTimeObject;

		public static TMP_Text dayText;

		public static TMP_Text timeText;

		private static Image minimapBackground;

		private static Image clockBackground;

		private static Image forecastBackground;

		private static Image windsBackground;

		private static Image windsProgressBackground;

		public static GameObject forecastObject;

		public static GameObject windsObject;

		public static GameObject windTemplate;

		private static GameObject windsProgress;

		public static RectTransform windsProgressRect;

		public static RectTransform windsObjectRect;

		public static TMP_Text weatherText;

		public static Image weatherIcon;

		private static string[] fuzzyTime;

		private static void AddInfoBlocks(Transform parentTransform)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)Minimap.instance?.m_biomeNameSmall))
			{
				MyLittleUI.LogInfo("Minimap is not initialized, skipping clock init");
				return;
			}
			parentObject = new GameObject("MyLittleUI_Parent", new Type[1] { typeof(RectTransform) })
			{
				layer = MyLittleUI.layerUI
			};
			parentObject.transform.SetParent(parentTransform, false);
			RectTransform component = parentObject.GetComponent<RectTransform>();
			component.anchoredPosition = Vector2.zero;
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			clockObject = new GameObject("Clock", new Type[1] { typeof(RectTransform) })
			{
				layer = MyLittleUI.layerUI
			};
			clockObject.transform.SetParent(parentObject.transform, false);
			UpdateDayTimeBackground();
			clockDayObject = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_biomeNameSmall).gameObject, clockObject.transform);
			((Object)clockDayObject).name = "Day";
			dayText = clockDayObject.GetComponent<TMP_Text>();
			dayText.text = "Day 0";
			dayText.textWrappingMode = (TextWrappingModes)0;
			dayText.verticalAlignment = (VerticalAlignmentOptions)512;
			clockTimeObject = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_biomeNameSmall).gameObject, clockObject.transform);
			((Object)clockTimeObject).name = "Time";
			timeText = clockTimeObject.GetComponent<TMP_Text>();
			timeText.text = "Time";
			timeText.textWrappingMode = (TextWrappingModes)0;
			timeText.verticalAlignment = (VerticalAlignmentOptions)512;
			forecastObject = new GameObject("Forecast", new Type[1] { typeof(RectTransform) })
			{
				layer = MyLittleUI.layerUI
			};
			forecastObject.transform.SetParent(parentObject.transform, false);
			UpdateForecastBackground();
			weatherText = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_biomeNameSmall).gameObject, forecastObject.transform).GetComponent<TMP_Text>();
			weatherText.text = "0:00";
			weatherText.textWrappingMode = (TextWrappingModes)0;
			weatherText.verticalAlignment = (VerticalAlignmentOptions)512;
			weatherText.horizontalAlignment = (HorizontalAlignmentOptions)1;
			((Object)((Component)weatherText).gameObject).name = "weather_text";
			weatherIcon = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_windMarker).gameObject, forecastObject.transform).GetComponent<Image>();
			((Object)((Component)weatherIcon).gameObject).name = "weather_icon";
			windsObject = new GameObject("Winds", new Type[1] { typeof(RectTransform) })
			{
				layer = MyLittleUI.layerUI
			};
			windsObject.transform.SetParent(parentObject.transform, false);
			windsObjectRect = windsObject.GetComponent<RectTransform>();
			windTemplate = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_windMarker).gameObject, parentObject.transform);
			((Object)windTemplate).name = "WindElement";
			UpdateWindsBackground();
			UpdateWindsBlock();
			MyLittleUI.LogInfo("Info blocks added to hud");
		}

		internal static void UpdateForecastBackground()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)forecastObject))
			{
				return;
			}
			if ((Object)(object)minimapBackground == (Object)null)
			{
				Minimap instance = Minimap.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject smallRoot = instance.m_smallRoot;
					obj = ((smallRoot != null) ? smallRoot.GetComponent<Image>() : null);
				}
				minimapBackground = (Image)obj;
			}
			if ((Object)(object)forecastBackground == (Object)null)
			{
				forecastBackground = forecastObject.AddComponent<Image>();
			}
			((Behaviour)forecastBackground).enabled = (Object)(object)minimapBackground != (Object)null && MyLittleUI.forecastShowBackground.Value;
			if (((Behaviour)forecastBackground).enabled)
			{
				((Graphic)forecastBackground).color = GetBackgroundColor(MyLittleUI.forecastBackgroundColor.Value);
				forecastBackground.sprite = minimapBackground.sprite;
				forecastBackground.type = minimapBackground.type;
			}
		}

		internal static void UpdateForecastBlock()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_012a: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)forecastObject))
			{
				forecastObject.SetActive(MyLittleUI.forecastEnabled.Value);
				((Graphic)weatherText).color = ((MyLittleUI.forecastFontColor.Value == Color.clear) ? ((Graphic)((Component)Minimap.instance.m_biomeNameSmall).GetComponent<TMP_Text>()).color : MyLittleUI.forecastFontColor.Value);
				weatherText.fontSizeMin = ((MyLittleUI.forecastFontSize.Value == 0f) ? ((Component)Minimap.instance.m_biomeNameSmall).GetComponent<TMP_Text>().fontSizeMin : MyLittleUI.forecastFontSize.Value);
				weatherText.fontSize = ((MyLittleUI.forecastFontSize.Value == 0f) ? weatherText.fontSizeMin : MyLittleUI.forecastFontSize.Value);
				RectTransform component = forecastObject.GetComponent<RectTransform>();
				component.anchorMin = Vector2.one;
				component.anchorMax = Vector2.one;
				component.anchoredPosition = (Game.m_noMap ? MyLittleUI.forecastPositionNomap.Value : MyLittleUI.forecastPosition.Value);
				component.sizeDelta = MyLittleUI.forecastSize.Value;
				float y = MyLittleUI.forecastSize.Value.y;
				RectTransform component2 = ((Component)weatherText).GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(0f, 0.5f);
				component2.anchorMax = new Vector2(0f, 0.5f);
				component2.anchoredPosition = new Vector2(y + MyLittleUI.forecastTextPadding.Value, 1f);
				component2.sizeDelta = Vector2.zero;
				RectTransform component3 = ((Component)weatherIcon).GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(0f, 0.5f);
				component3.anchorMax = new Vector2(0f, 0.5f);
				component3.sizeDelta = Vector2.one * y;
				component3.anchoredPosition = new Vector2(y / 2f, 0f);
			}
		}

		internal static void UpdateWindsBackground()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)windsObject))
			{
				return;
			}
			if ((Object)(object)minimapBackground == (Object)null)
			{
				Minimap instance = Minimap.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject smallRoot = instance.m_smallRoot;
					obj = ((smallRoot != null) ? smallRoot.GetComponent<Image>() : null);
				}
				minimapBackground = (Image)obj;
			}
			if ((Object)(object)windsBackground == (Object)null)
			{
				windsBackground = windsObject.AddComponent<Image>();
			}
			((Behaviour)windsBackground).enabled = (Object)(object)minimapBackground != (Object)null && MyLittleUI.windsShowBackground.Value;
			if (((Behaviour)windsBackground).enabled)
			{
				((Graphic)windsBackground).color = GetBackgroundColor(MyLittleUI.windsBackgroundColor.Value);
				windsBackground.sprite = minimapBackground.sprite;
				windsBackground.type = minimapBackground.type;
			}
			if ((Object)(object)windsProgressBackground == (Object)null)
			{
				windsProgress = new GameObject("WindProgress", new Type[1] { typeof(RectTransform) })
				{
					layer = MyLittleUI.layerUI
				};
				windsProgress.transform.SetParent(windsObject.transform, false);
				windsProgressRect = windsProgress.GetComponent<RectTransform>();
				windsProgressRect.anchoredPosition = Vector2.zero;
				windsProgressRect.anchorMin = Vector2.zero;
				windsProgressRect.anchorMax = Vector2.one;
				windsProgressRect.sizeDelta = Vector2.zero;
				windsProgressBackground = windsProgress.AddComponent<Image>();
			}
			((Behaviour)windsProgressBackground).enabled = (Object)(object)minimapBackground != (Object)null && MyLittleUI.windsShowProgress.Value;
			if (((Behaviour)windsProgressBackground).enabled)
			{
				((Graphic)windsProgressBackground).color = GetBackgroundColor(MyLittleUI.windsProgressColor.Value);
				windsProgressBackground.sprite = minimapBackground.sprite;
				windsProgressBackground.type = minimapBackground.type;
			}
		}

		private static Color GetBackgroundColor(Color color)
		{
			//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			if (color == Color.clear)
			{
				return ((Graphic)minimapBackground).color;
			}
			if (color.a != 0f && color.r == 0f && color.g == 0f && color.b == 0f)
			{
				return new Color(((Graphic)minimapBackground).color.r, ((Graphic)minimapBackground).color.g, ((Graphic)minimapBackground).color.b, color.a);
			}
			return color;
		}

		internal static void UpdateWindsBlock(bool forceRebuildList = false)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0084: 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_00a7: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)windsObject))
			{
				windsObject.SetActive(MyLittleUI.windsEnabled.Value);
				windTemplate.SetActive(false);
				windsObjectRect.anchorMin = Vector2.one;
				windsObjectRect.anchorMax = Vector2.one;
				windsObjectRect.anchoredPosition = GetWindsPosition();
				windsObjectRect.sizeDelta = GetWindsSize();
				RectTransform component = windTemplate.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.zero;
				Image component2 = windTemplate.GetComponent<Image>();
				if (((Graphic)component2).color != MyLittleUI.windsArrowColor.Value)
				{
					((Graphic)component2).color = MyLittleUI.windsArrowColor.Value;
					forceRebuildList = true;
				}
				if (forceRebuildList)
				{
					WeatherForecast.UpdateNextWinds(forceRebuildList);
				}
			}
		}

		internal static Vector2 GetWindsSize()
		{
			//IL_0019: 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_001e: 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)
			return Game.m_noMap ? MyLittleUI.windsSizeNomap.Value : MyLittleUI.windsSize.Value;
		}

		private static Vector2 GetWindsPosition()
		{
			//IL_0019: 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_001e: 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)
			return Game.m_noMap ? MyLittleUI.windsPositionNomap.Value : MyLittleUI.windsPosition.Value;
		}

		internal static void UpdateDayTimeBackground()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)clockObject))
			{
				return;
			}
			if ((Object)(object)minimapBackground == (Object)null)
			{
				Minimap instance = Minimap.instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					GameObject smallRoot = instance.m_smallRoot;
					obj = ((smallRoot != null) ? smallRoot.GetComponent<Image>() : null);
				}
				minimapBackground = (Image)obj;
			}
			if ((Object)(object)clockBackground == (Object)null)
			{
				clockBackground = clockObject.AddComponent<Image>();
			}
			((Behaviour)clockBackground).enabled = (Object)(object)minimapBackground != (Object)null && MyLittleUI.clockShowBackground.Value;
			if (((Behaviour)clockBackground).enabled)
			{
				((Graphic)clockBackground).color = GetBackgroundColor(MyLittleUI.clockBackgroundColor.Value);
				clockBackground.sprite = minimapBackground.sprite;
				clockBackground.type = minimapBackground.type;
			}
		}

		internal static void UpdateDayTimeText()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)clockObject))
			{
				clockObject.SetActive(MyLittleUI.clockShowTime.Value || MyLittleUI.clockShowDay.Value);
				clockTimeObject.SetActive(MyLittleUI.clockShowTime.Value);
				clockDayObject.SetActive(MyLittleUI.clockShowDay.Value);
				timeText.horizontalAlignment = (HorizontalAlignmentOptions)((!MyLittleUI.clockShowDay.Value) ? 2 : (MyLittleUI.clockSwapDayTime.Value ? 1 : 4));
				((Graphic)timeText).color = ((MyLittleUI.clockFontColor.Value == Color.clear) ? ((Graphic)((Component)Minimap.instance.m_biomeNameSmall).GetComponent<TMP_Text>()).color : MyLittleUI.clockFontColor.Value);
				timeText.fontSizeMin = ((MyLittleUI.clockFontSize.Value == 0f) ? ((Component)Minimap.instance.m_biomeNameSmall).GetComponent<TMP_Text>().fontSizeMin : MyLittleUI.clockFontSize.Value);
				timeText.fontSize = ((MyLittleUI.clockFontSize.Value == 0f) ? timeText.fontSizeMin : MyLittleUI.clockFontSize.Value);
				dayText.horizontalAlignment = (HorizontalAlignmentOptions)((!MyLittleUI.clockShowTime.Value) ? 2 : ((!MyLittleUI.clockSwapDayTime.Value) ? 1 : 4));
				((Graphic)dayText).color = ((MyLittleUI.clockFontColor.Value == Color.clear) ? ((Graphic)timeText).color : MyLittleUI.clockFontColor.Value);
				dayText.fontSizeMin = ((MyLittleUI.clockFontSize.Value == 0f) ? timeText.fontSizeMin : MyLittleUI.clockFontSize.Value);
				dayText.fontSize = ((MyLittleUI.clockFontSize.Value == 0f) ? dayText.fontSizeMin : MyLittleUI.clockFontSize.Value);
				RectTransform component = clockObject.GetComponent<RectTransform>();
				component.anchorMin = Vector2.one;
				component.anchorMax = Vector2.one;
				component.anchoredPosition = MyLittleUI.clockPosition.Value;
				component.sizeDelta = MyLittleUI.clockSize.Value;
				RectTransform component2 = clockDayObject.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.anchoredPosition = new Vector2((float)((!MyLittleUI.clockSwapDayTime.Value) ? 1 : (-1)) * ((MyLittleUI.clockShowDay.Value && MyLittleUI.clockShowTime.Value) ? MyLittleUI.clockTextPadding.Value : 0f), 1f);
				component2.sizeDelta = Vector2.zero;
				RectTransform component3 = clockTimeObject.GetComponent<RectTransform>();
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.anchoredPosition = new Vector2((float)(MyLittleUI.clockSwapDayTime.Value ? 1 : (-1)) * ((MyLittleUI.clockShowDay.Value && MyLittleUI.clockShowTime.Value) ? MyLittleUI.clockTextPadding.Value : 0f), 1f);
				component3.sizeDelta = Vector2.zero;
			}
		}

		internal static void UpdateInfoBlocksVisibility()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			GameObject obj = parentObject;
			if (obj != null)
			{
				obj.SetActive(MyLittleUI.modEnabled.Value && Object.op_Implicit((Object)(object)Minimap.instance) && (int)Minimap.instance.m_mode != 2);
			}
		}

		internal static void UpdateVisibility()
		{
			UpdateInfoBlocksVisibility();
			UpdateDayTimeText();
			UpdateClock();
			UpdateForecastBlock();
			UpdateWindsBlock();
			WeatherForecast.UpdateWeather();
			WeatherForecast.UpdateNextWinds();
		}

		internal static void UpdateClock()
		{
			if (Object.op_Implicit((Object)(object)EnvMan.instance) && Object.op_Implicit((Object)(object)clockObject) && clockObject.activeSelf)
			{
				TMP_Text obj = dayText;
				if (obj != null)
				{
					obj.SetText(Localization.instance.Localize("$msg_newday", new string[1] { EnvMan.instance.GetCurrentDay().ToString() }));
				}
				TMP_Text obj2 = timeText;
				if (obj2 != null)
				{
					obj2.SetText(GetTimeString());
				}
				UpdateDayTimeBackground();
			}
		}

		internal static void FuzzyWordsOnChange()
		{
			fuzzyTime = null;
			UpdateClock();
		}

		internal static string GetTimeString()
		{
			if (MyLittleUI.clockTimeType.Value == MyLittleUI.ClockTimeType.Fuzzy)
			{
				if (fuzzyTime == null)
				{
					fuzzyTime = (from str in MyLittleUI.clockFuzzy.Value.Split(new char[1] { ',' })
						select str.Trim()).ToArray();
				}
				if (fuzzyTime.Length != 0)
				{
					float num = EnvMan.instance.m_smoothDayFraction + (float)(1 / (fuzzyTime.Length * 2));
					return (num >= 1f) ? fuzzyTime[0] : fuzzyTime[Mathf.Clamp((int)(num * (float)fuzzyTime.Length), 0, fuzzyTime.Length - 1)];
				}
			}
			else if (MyLittleUI.clockTimeType.Value == MyLittleUI.ClockTimeType.RealTime)
			{
				return DateTime.Now.ToString(MyLittleUI.clockTimeFormat24h.Value ? "HH:mm" : "hh:mm tt");
			}
			float smoothDayFraction = EnvMan.instance.m_smoothDayFraction;
			int num2 = Mathf.CeilToInt(smoothDayFraction * 24f);
			int num3 = 5 * (Mathf.CeilToInt((smoothDayFraction * 24f - (float)num2) * 60f) / 5);
			DateTime minValue = DateTime.MinValue;
			return minValue.AddMonths(2).AddDays(EnvMan.instance.GetCurrentDay()).AddHours(num2)
				.AddMinutes(num3)
				.ToString(MyLittleUI.clockTimeFormat24h.Value ? "HH:mm" : "hh:mm tt");
		}
	}
	internal static class InventoryCharacterStats
	{
		[HarmonyPatch(typeof(InventoryGui), "UpdateCharacterStats")]
		private class InventoryGui_UpdateCharacterStats_CharacterStats
		{
			private static void Postfix(InventoryGui __instance, Player player, TextsDialog ___m_textsDialog)
			{
				if (!MyLittleUI.modEnabled.Value || (!MyLittleUI.statsCharacterArmor.Value && !MyLittleUI.statsCharacterEffects.Value))
				{
					return;
				}
				if ((MyLittleUI.statsCharacterArmor.Value && (Object)(object)characterStatsTooltip == (Object)null) || (MyLittleUI.statsCharacterEffects.Value && (Object)(object)characterEffectsTooltip == (Object)null))
				{
					InitCharacterTooltips(__instance, player);
				}
				if (ZNet.instance.GetTimeSeconds() - totalSecondTooltipWasUpdated > 3.0)
				{
					totalSecondTooltipWasUpdated = ZNet.instance.GetTimeSeconds();
					if (MyLittleUI.statsCharacterArmor.Value)
					{
						characterStatsTooltip.m_text = TooltipStats(player);
					}
					if (MyLittleUI.statsCharacterEffects.Value)
					{
						characterEffectsTooltip.m_text = TooltipEffects(player, ___m_textsDialog);
					}
				}
			}
		}

		[HarmonyPatch]
		public static class Humanoid_TooltipUpdate
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(Humanoid), "EquipItem", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(Humanoid), "UnequipItem", (Type[])null, (Type[])null);
			}

			private static void Postfix(Humanoid __instance)
			{
				if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					totalSecondTooltipWasUpdated = 0.0;
				}
			}
		}

		[HarmonyPatch(typeof(SEMan), "RemoveAllStatusEffects")]
		private class SEMan_RemoveAllStatusEffects_TooltipUpdate
		{
			private static void Postfix(SEMan __instance)
			{
				if (MyLittleUI.modEnabled.Value && (MyLittleUI.statsCharacterArmor.Value || MyLittleUI.statsCharacterEffects.Value))
				{
					Player localPlayer = Player.m_localPlayer;
					if (__instance == ((localPlayer != null) ? ((Character)localPlayer).GetSEMan() : null))
					{
						totalSecondTooltipWasUpdated = 0.0;
					}
				}
			}
		}

		[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[]
		{
			typeof(StatusEffect),
			typeof(bool),
			typeof(int),
			typeof(float)
		})]
		private class SEMan_AddStatusEffect_TooltipUpdate
		{
			private static void Postfix(SEMan __instance, StatusEffect __result)
			{
				if (MyLittleUI.modEnabled.Value && (MyLittleUI.statsCharacterArmor.Value || MyLittleUI.statsCharacterEffects.Value) && (Object)(object)__result != (Object)null)
				{
					Player localPlayer = Player.m_localPlayer;
					if (__instance == ((localPlayer != null) ? ((Character)localPlayer).GetSEMan() : null))
					{
						totalSecondTooltipWasUpdated = 0.0;
					}
				}
			}
		}

		[HarmonyPatch(typeof(SEMan), "RemoveStatusEffect", new Type[]
		{
			typeof(int),
			typeof(bool)
		})]
		private class SEMan_RemoveStatusEffect_TooltipUpdate
		{
			private static void Postfix(SEMan __instance, bool __result)
			{
				if (MyLittleUI.modEnabled.Value && (MyLittleUI.statsCharacterArmor.Value || MyLittleUI.statsCharacterEffects.Value) && __result)
				{
					Player localPlayer = Player.m_localPlayer;
					if (__instance == ((localPlayer != null) ? ((Character)localPlayer).GetSEMan() : null))
					{
						totalSecondTooltipWasUpdated = 0.0;
					}
				}
			}
		}

		private static UITooltip characterStatsTooltip;

		private static UITooltip characterEffectsTooltip;

		private static double totalSecondTooltipWasUpdated = 0.0;

		private static readonly StringBuilder sb = new StringBuilder();

		private static readonly Dictionary<SkillType, float> skills = new Dictionary<SkillType, float>();

		private static readonly Dictionary<DamageType, DamageModifier> mods = new Dictionary<DamageType, DamageModifier>();

		private static SE_Stats stats;

		private static void ClearStats(this SE_Stats statsEffect)
		{
			foreach (FieldInfo declaredField in AccessTools.GetDeclaredFields(typeof(SE_Stats)))
			{
				declaredField.SetValue(statsEffect, null);
			}
			statsEffect.m_mods = new List<DamageModPair>();
			statsEffect.m_healthOverTimeInterval = 5f;
			statsEffect.m_healthRegenMultiplier = 1f;
			statsEffect.m_staminaRegenMultiplier = 1f;
			statsEffect.m_eitrRegenMultiplier = 1f;
			statsEffect.m_damageModifier = 1f;
		}

		public static void UpdateTooltipState()
		{
			if ((Object)(object)characterStatsTooltip != (Object)null)
			{
				((Behaviour)characterStatsTooltip).enabled = MyLittleUI.statsCharacterArmor.Value;
			}
			if ((Object)(object)characterEffectsTooltip != (Object)null)
			{
				((Behaviour)characterEffectsTooltip).enabled = MyLittleUI.statsCharacterEffects.Value;
			}
		}

		private static void InitCharacterTooltips(InventoryGui __instance, Player player)
		{
			UITooltip component = __instance.m_containerGrid.m_elementPrefab.GetComponent<UITooltip>();
			if ((Object)(object)characterStatsTooltip == (Object)null)
			{
				characterStatsTooltip = InitTooltip(component, __instance.m_armor, player.GetPlayerName(), __instance.m_containerGrid.m_tooltipAnchor);
			}
			if ((Object)(object)characterEffectsTooltip == (Object)null)
			{
				characterEffectsTooltip = InitTooltip(component, __instance.m_weight, "$inventory_activeeffects", __instance.m_containerGrid.m_tooltipAnchor);
			}
			MyLittleUI.LogInfo("Character inventory stats patched");
		}

		private static UITooltip InitTooltip(UITooltip prefabTooltip, TMP_Text text, string topic, RectTransform tooltipAnchor)
		{
			FieldInfo[] fields = ((object)prefabTooltip).GetType().GetFields();
			UITooltip val = ((Component)text.transform.parent).gameObject.AddComponent<UITooltip>();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(val, fieldInfo.GetValue(prefabTooltip));
			}
			val.m_topic = topic;
			val.m_anchor = tooltipAnchor;
			val.m_gamepadFocusObject = null;
			return val;
		}

		private static void AddRegenStat(ref float stat, float multiplier)
		{
			if (multiplier > 1f)
			{
				stat += multiplier - 1f;
			}
			else
			{
				stat *= multiplier;
			}
		}

		private static bool ShouldOverride(DamageModifier a, DamageModifier b)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			if ((int)a == 4)
			{
				return false;
			}
			if ((int)b == 3)
			{
				return true;
			}
			if ((int)a == 5 && (int)b == 1)
			{
				return false;
			}
			if ((int)a == 6 && (int)b == 2)
			{
				return false;
			}
			if (((int)a == 1 || (int)a == 5 || (int)a == 3) && ((int)b == 2 || (int)b == 6))
			{
				return false;
			}
			return true;
		}

		private static string TooltipModifierColored(string tooltip, float value)
		{
			string arg = ((value >= 0f) ? "#00FF00" : "#FF0000");
			return $"{tooltip}: <color={arg}>{value:P0}</color>\n";
		}

		private static string TooltipEffects(Player player, TextsDialog textsDialog)
		{
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: 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_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Expected O, but got Unknown
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Expected O, but got Unknown
			sb.Clear();
			for (int i = 0; i < player.m_equipmentModifierValues.Length; i++)
			{
				if (player.m_equipmentModifierValues[i] != 0f)
				{
					sb.Append(TooltipModifierColored(Player.s_equipmentModifierTooltips[i], player.m_equipmentModifierValues[i]));
				}
			}
			skills.Clear();
			mods.Clear();
			if ((Object)(object)stats == (Object)null)
			{
				ScriptableObject obj = ScriptableObject.CreateInstance("SE_Stats");
				stats = (SE_Stats)(object)((obj is SE_Stats) ? obj : null);
			}
			else
			{
				stats.ClearStats();
			}
			SkillType key;
			foreach (StatusEffect item in ((Character)player).GetSEMan().GetStatusEffects().ToList())
			{
				SE_Stats val = (SE_Stats)(object)((item is SE_Stats) ? item : null);
				if (val != null)
				{
					SE_Stats obj2 = stats;
					obj2.m_jumpStaminaUseModifier += val.m_jumpStaminaUseModifier;
					SE_Stats obj3 = stats;
					obj3.m_runStaminaDrainModifier += val.m_runStaminaDrainModifier;
					SE_Stats obj4 = stats;
					obj4.m_healthOverTime += val.m_healthOverTime;
					SE_Stats obj5 = stats;
					obj5.m_staminaOverTime += val.m_staminaOverTime;
					SE_Stats obj6 = stats;
					obj6.m_eitrOverTime += val.m_eitrOverTime;
					AddRegenStat(ref stats.m_healthRegenMultiplier, val.m_healthRegenMultiplier);
					AddRegenStat(ref stats.m_staminaRegenMultiplier, val.m_staminaRegenMultiplier);
					if (((Character)player).GetMaxEitr() > 0f)
					{
						AddRegenStat(ref stats.m_eitrRegenMultiplier, val.m_eitrRegenMultiplier);
					}
					SE_Stats obj7 = stats;
					obj7.m_addMaxCarryWeight += val.m_addMaxCarryWeight;
					SE_Stats obj8 = stats;
					obj8.m_noiseModifier += val.m_noiseModifier;
					SE_Stats obj9 = stats;
					obj9.m_stealthModifier += val.m_stealthModifier;
					SE_Stats obj10 = stats;
					obj10.m_speedModifier += val.m_speedModifier;
					SE_Stats obj11 = stats;
					obj11.m_maxMaxFallSpeed += val.m_maxMaxFallSpeed;
					SE_Stats obj12 = stats;
					obj12.m_fallDamageModifier += val.m_fallDamageModifier;
					if (skills.ContainsKey(val.m_skillLevel))
					{
						Dictionary<SkillType, float> dictionary = skills;
						key = val.m_skillLevel;
						dictionary[key] += val.m_skillLevelModifier;
					}
					else
					{
						skills.Add(val.m_skillLevel, val.m_skillLevelModifier);
					}
					if (skills.ContainsKey(val.m_skillLevel2))
					{
						Dictionary<SkillType, float> dictionary = skills;
						key = val.m_skillLevel2;
						dictionary[key] += val.m_skillLevelModifier2;
					}
					else
					{
						skills.Add(val.m_skillLevel2, val.m_skillLevelModifier2);
					}
					foreach (DamageModPair mod in val.m_mods)
					{
						if (mods.ContainsKey(mod.m_type))
						{
							if (ShouldOverride(mods[mod.m_type], mod.m_modifier))
							{
								mods[mod.m_type] = mod.m_modifier;
							}
						}
						else
						{
							mods[mod.m_type] = mod.m_modifier;
						}
					}
				}
				else
				{
					string text = item.GetTooltipString();
					if (!Utility.IsNullOrWhiteSpace(item.m_tooltip))
					{
						text = text.Replace(item.m_tooltip, "");
					}
					if (!Utility.IsNullOrWhiteSpace(text))
					{
						sb.Append("\n");
						sb.Append("<color=orange>" + item.m_name + "</color>");
						sb.Append(text);
					}
				}
			}
			foreach (ItemData equippedItem in ((Humanoid)player).GetInventory().GetEquippedItems())
			{
				if (equippedItem == null || equippedItem.m_shared.m_damageModifiers.Count == 0)
				{
					continue;
				}
				foreach (DamageModPair damageModifier in equippedItem.m_shared.m_damageModifiers)
				{
					if (mods.ContainsKey(damageModifier.m_type))
					{
						if (ShouldOverride(mods[damageModifier.m_type], damageModifier.m_modifier))
						{
							mods[damageModifier.m_type] = damageModifier.m_modifier;
						}
					}
					else
					{
						mods[damageModifier.m_type] = damageModifier.m_modifier;
					}
				}
			}
			foreach (KeyValuePair<DamageType, DamageModifier> mod2 in mods)
			{
				stats.m_mods.Add(new DamageModPair
				{
					m_modifier = mod2.Value,
					m_type = mod2.Key
				});
			}
			if (((Character)player).GetMaxEitr() > 0f)
			{
				SE_Stats obj13 = stats;
				obj13.m_eitrRegenMultiplier += player.GetEquipmentEitrRegenModifier();
			}
			string tooltipString = ((StatusEffect)stats).GetTooltipString();
			if (!Utility.IsNullOrWhiteSpace(tooltipString))
			{
				sb.Append("\n");
				sb.Append(tooltipString);
			}
			foreach (KeyValuePair<SkillType, float> skill in skills)
			{
				if (skill.Value != 0f)
				{
					StringBuilder stringBuilder = sb;
					key = skill.Key;
					stringBuilder.AppendFormat("\n{0} <color=orange>{1}</color>", "$skill_" + ((object)(SkillType)(ref key)).ToString().ToLower(), skill.Value.ToString("+0;-0"));
				}
			}
			if ((Object)(object)MyLittleUI.epicLootPlugin != (Object)null && MyLittleUI.statsCharacterEffectsMagic.Value)
			{
				Type type = AccessTools.TypeByName("EpicLoot.TextsDialog_UpdateTextsList_Patch");
				if (type != null)
				{
					MethodInfo methodInfo = AccessTools.Method(type, "AddMagicEffectsPage", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						List<TextInfo> collection = textsDialog.m_texts.ToList();
						textsDialog.m_texts.Clear();
						textsDialog.m_texts.Add(new TextInfo("", ""));
						textsDialog.m_texts.Add(new TextInfo("", ""));
						methodInfo.Invoke(methodInfo, new object[2] { textsDialog, player });
						TextInfo val2 = textsDialog.m_texts[2];
						textsDialog.m_texts.Clear();
						textsDialog.m_texts.AddRange(collection);
						sb.Append("\n");
						sb.Append(val2.m_topic);
						sb.Append("\n");
						sb.Append(string.Join("\n", from line in val2.m_text.Split(new char[1] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
							where LineIsValid(line)
							select line).Replace("<size=20>", "").Replace("</size>", ""));
					}
				}
			}
			return Localization.instance.Localize(sb.ToString()).Trim();
			static bool LineIsValid(string line)
			{
				return line != "" && !line.StartsWith(" <") && !line.StartsWith("\n") && !Utility.IsNullOrWhiteSpace(line);
			}
		}

		private static string TooltipStats(Player player)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			sb.Clear();
			sb.AppendFormat("$item_armor: <color=orange>{0}</color>", ((Character)player).GetBodyArmor());
			ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
			if (currentWeapon != null)
			{
				DamageTypes damage = currentWeapon.GetDamage(currentWeapon.m_quality, (float)Game.m_worldLevel);
				if ((int)currentWeapon.m_shared.m_skillType == 8 && ((Humanoid)player).GetAmmoItem() != null)
				{
					((DamageTypes)(ref damage)).Add(((Humanoid)player).GetAmmoItem().GetDamage(), 1);
				}
				sb.Append("\n");
				ItemData.AddHandedTip(currentWeapon, sb);
				sb.Append(((DamageTypes)(ref damage)).GetTooltipString(currentWeapon.m_shared.m_skillType) ?? "");
				sb.Append($"\n$item_knockback: <color=orange>{currentWeapon.m_shared.m_attackForce}</color>");
				sb.Append($"\n$item_backstab: <color=orange>{currentWeapon.m_shared.m_backstabBonus}x</color>");
			}
			ItemData currentBlocker = ((Humanoid)player).GetCurrentBlocker();
			if (currentBlocker != null)
			{
				int quality = currentBlocker.m_quality;
				sb.Append("\n");
				sb.Append($"\n$item_blockpower: <color=orange>{currentBlocker.GetBlockPowerTooltip(quality):0}</color>");
				if (currentBlocker.m_shared.m_timedBlockBonus > 1f)
				{
					sb.Append($"\n$item_blockforce: <color=orange>{currentBlocker.GetDeflectionForce(quality)}</color>");
					sb.Append($"\n$item_parrybonus: <color=orange>{currentBlocker.m_shared.m_timedBlockBonus}x</color>");
				}
				string damageModifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(currentBlocker.m_shared.m_damageModifiers);
				if (damageModifiersTooltipString.Length > 0)
				{
					sb.Append(damageModifiersTooltipString);
				}
			}
			return Localization.instance.Localize(sb.ToString()).Trim();
		}
	}
	internal static class ItemIcon
	{
		private static class DefaultQualityStyle
		{
			public static bool initialized;

			public static TextWrappingModes textWrappingMode;

			public static float fontSize;

			public static Color color;

			public static bool isRightToLeftText;

			public static float lineSpacing;

			public static float characterSpacing;

			public static void Save(TMP_Text quality)
			{
				//IL_0008: 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_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)
				initialized = true;
				textWrappingMode = quality.textWrappingMode;
				fontSize = quality.fontSize;
				color = ((Graphic)quality).color;
				isRightToLeftText = quality.isRightToLeftText;
				lineSpacing = quality.lineSpacing;
				characterSpacing = quality.characterSpacing;
			}

			public static void Load(TMP_Text quality)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				quality.textWrappingMode = textWrappingMode;
				quality.fontSize = fontSize;
				((Graphic)quality).color = color;
				quality.isRightToLeftText = isRightToLeftText;
				quality.lineSpacing = lineSpacing;
				quality.characterSpacing = characterSpacing;
			}

			public static bool IsTextWasChanged(TMP_Text quality)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				return quality.textWrappingMode != textWrappingMode || quality.fontSize != fontSize || ((Graphic)quality).color != color || quality.isRightToLeftText != isRightToLeftText || quality.lineSpacing != lineSpacing || quality.lineSpacing != characterSpacing;
			}
		}

		[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
		private class InventoryGrid_UpdateGui_DurabilityAndScale
		{
			private static readonly HashSet<ItemData> filterItemQuality = new HashSet<ItemData>();

			private static readonly HashSet<ItemData> hideItemQuality = new HashSet<ItemData>();

			private static bool IsEAQSEquipmentGrid(InventoryGrid grid)
			{
				return ((Object)grid).name == "EquipmentSlotGrid";
			}

			private static bool IsEAQSQuickSlotGrid(InventoryGrid grid)
			{
				return ((Object)grid).name == "QuickSlotGrid";
			}

			private static IEnumerable<ItemData> GetAzuEPIEqupmentSlotsItems()
			{
				return from func in AzuExtendedPlayerInventory.API.GetSlots().GetItemFuncs
					where func != null
					select func(Player.m_localPlayer) into item
					where item != null
					select item;
			}

			private static void FillItemsToFilter()
			{
				if (AzuExtendedPlayerInventory.API.IsLoaded())
				{
					if (MyLittleUI.itemQualityIgnoreCustomSlots.Value)
					{
						CollectionExtensions.Do<ItemData>(GetAzuEPIEqupmentSlotsItems(), (Action<ItemData>)delegate(ItemData item)
						{
							filterItemQuality.Add(item);
						});
					}
					else if (MyLittleUI.itemQualityIgnoreCustomEquipmentSlots.Value)
					{
						CollectionExtensions.DoIf<ItemData>(GetAzuEPIEqupmentSlotsItems(), (Func<ItemData, bool>)((ItemData item) => item.IsEquipable()), (Action<ItemData>)delegate(ItemData item)
						{
							filterItemQuality.Add(item);
						});
					}
				}
				if (!ExtraSlotsAPI.API.IsReady())
				{
					return;
				}
				if (MyLittleUI.itemQualityIgnoreCustomSlots.Value)
				{
					CollectionExtensions.Do<ItemData>((IEnumerable<ItemData>)ExtraSlotsAPI.API.GetAllExtraSlotsItems(), (Action<ItemData>)delegate(ItemData item)
					{
						filterItemQuality.Add(item);
					});
				}
				else if (MyLittleUI.itemQualityIgnoreCustomEquipmentSlots.Value)
				{
					CollectionExtensions.Do<ItemData>((IEnumerable<ItemData>)ExtraSlotsAPI.API.GetEquipmentSlotsItems(), (Action<ItemData>)delegate(ItemData item)
					{
						filterItemQuality.Add(item);
					});
				}
			}

			private static void FillItemsToHide()
			{
				if (AzuExtendedPlayerInventory.API.IsLoaded())
				{
					CollectionExtensions.Do<ItemData>(GetAzuEPIEqupmentSlotsItems(), (Action<ItemData>)delegate(ItemData item)
					{
						hideItemQuality.Add(item);
					});
				}
				if (ExtraSlotsAPI.API.IsReady())
				{
					CollectionExtensions.Do<ItemData>((IEnumerable<ItemData>)ExtraSlotsAPI.API.GetEquipmentSlotsItems(), (Action<ItemData>)delegate(ItemData item)
					{
						hideItemQuality.Add(item);
					});
				}
			}

			private static bool IgnoreItemQuality(InventoryGrid grid, ItemData item)
			{
				return filterItemQuality.Contains(item) || (MyLittleUI.itemQualityIgnoreCustomEquipmentSlots.Value && IsEAQSEquipmentGrid(grid)) || (MyLittleUI.itemQualityIgnoreCustomSlots.Value && (IsEAQSQuickSlotGrid(grid) || IsEAQSEquipmentGrid(grid)));
			}

			private static bool HideEquipmentSlotsQuality(InventoryGrid grid, ItemData item)
			{
				return IsEAQSEquipmentGrid(grid) || hideItemQuality.Contains(item);
			}

			[HarmonyPriority(0)]
			[HarmonyAfter(new string[] { "Azumatt.AzuExtendedPlayerInventory", "shudnal.ExtraSlots" })]
			private static void Postfix(InventoryGrid __instance, Inventory ___m_inventory, List<Element> ___m_elements)
			{
				if (!MyLittleUI.modEnabled.Value)
				{
					return;
				}
				filterItemQuality.Clear();
				if (MyLittleUI.itemQualityIgnoreCustomEquipmentSlots.Value || MyLittleUI.itemQualityIgnoreCustomSlots.Value)
				{
					FillItemsToFilter();
				}
				hideItemQuality.Clear();
				if (MyLittleUI.itemQualityHideCustomEquipmentSlots.Value)
				{
					FillItemsToHide();
				}
				int width = ___m_inventory.GetWidth();
				foreach (ItemData allItem in ___m_inventory.GetAllItems())
				{
					int num = allItem.m_gridPos.y * width + allItem.m_gridPos.x;
					if (0 <= num && num < ___m_elements.Count)
					{
						Element val = ___m_elements[num];
						UpdateItemIcon(val.m_durability, val.m_icon, val.m_equiped);
						if (HideEquipmentSlotsQuality(__instance, allItem) || (MyLittleUI.itemQualityHideLvl1.Value && allItem.m_quality < 2))
						{
							val.m_quality.SetText("");
						}
						else if (!IgnoreItemQuality(__instance, allItem))
						{
							UpdateItemQuality(val.m_quality, allItem.m_quality);
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
		private class HotkeyBar_UpdateIcons_DurabilityAndScale
		{
			[HarmonyPriority(0)]
			[HarmonyAfter(new string[] { "Azumatt.AzuExtendedPlayerInventory", "shudnal.ExtraSlots" })]
			private static void Postfix(HotkeyBar __instance, Player player)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				if (!MyLittleUI.modEnabled.Value || !Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead())
				{
					return;
				}
				foreach (ElementData element in __instance.m_elements)
				{
					UpdateItemIcon(element.m_durability, element.m_icon, (MyLittleUI.itemEquippedColor.Value != Color.clear) ? element.m_equiped.GetComponent<Image>() : null);
				}
			}
		}

		private static Vector3 itemIconScaleOriginal = Vector3.zero;

		private static Color itemEquippedColorOriginal = Color.clear;

		private static Gradient gradient;

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

		private static void UpdateItemIcon(GuiBar durability, Image icon, Image equiped)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			if (itemIconScaleOriginal == Vector3.zero)
			{
				itemIconScaleOriginal = ((Component)icon).transform.localScale;
			}
			((Component)icon).transform.localScale = itemIconScaleOriginal * Mathf.Clamp(MyLittleUI.itemIconScale.Value, 0.2f, 2f);
			if ((Object)(object)equiped != (Object)null)
			{
				if (itemEquippedColorOriginal == Color.clear)
				{
					itemEquippedColorOriginal = ((Graphic)equiped).color;
				}
				if (MyLittleUI.itemEquippedColor.Value != Color.clear)
				{
					((Graphic)equiped).color = MyLittleUI.itemEquippedColor.Value;
				}
				else if (itemEquippedColorOriginal != Color.clear)
				{
					((Graphic)equiped).color = itemEquippedColorOriginal;
				}
			}
			if (!MyLittleUI.durabilityEnabled.Value || !((Object)(object)durability != (Object)null))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)durability.m_barImage) && Object.op_Implicit((Object)(object)durability.m_bar))
			{
				durability.m_barImage = ((Component)durability.m_bar).GetComponent<Image>();
			}
			UpdateGradient(force: false);
			if (durability.GetSmoothValue() >= 1f)
			{
				if (durability.GetColor() == Color.red)
				{
					durability.SetColor(MyLittleUI.durabilityBroken.Value);
				}
				else if (durability.GetColor() != Color.clear)
				{
					((Component)durability).gameObject.SetActive(false);
				}
			}
			else
			{
				durability.SetColor(gradient.Evaluate(durability.GetSmoothValue()));
			}
		}

		public static void UpdateGradient(bool force = true)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			if (gradient == null || force)
			{
				gradient = new Gradient();
				gradient.SetKeys((GradientColorKey[])(object)new GradientColorKey[4]
				{
					new GradientColorKey(MyLittleUI.durabilityBroken.Value, 0f),
					new GradientColorKey(MyLittleUI.durabilityAtRisk.Value, 0.33f),
					new GradientColorKey(MyLittleUI.durabilityWorn.Value, 0.66f),
					new GradientColorKey(MyLittleUI.durabilityFine.Value, 1f)
				}, Array.Empty<GradientAlphaKey>());
			}
		}

		private static char GetQualitySymbol()
		{
			return Utility.IsNullOrWhiteSpace(MyLittleUI.itemQualitySymbol.Value) ? '★' : MyLittleUI.itemQualitySymbol.Value[0];
		}

		public static void FillItemQualityCache()
		{
			StringBuilder stringBuilder = new StringBuilder();
			qualityCache.Clear();
			int num = Math.Min(MyLittleUI.itemQualityMax.Value, MyLittleUI.itemQualityColumns.Value * MyLittleUI.itemQualityRows.Value);
			for (int i = 1; i <= num; i++)
			{
				stringBuilder.Append(GetQualitySymbol());
				qualityCache.Add(i, stringBuilder.ToString());
				if (i % MyLittleUI.itemQualityColumns.Value == 0)
				{
					stringBuilder.Append("\n");
				}
			}
		}

		private static void UpdateItemQuality(TMP_Text quality, int m_quality)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!MyLittleUI.itemQuality.Value || !((Behaviour)quality).enabled)
			{
				return;
			}
			if (!DefaultQualityStyle.initialized)
			{
				DefaultQualityStyle.Save(quality);
			}
			if (!qualityCache.ContainsKey(m_quality))
			{
				if (DefaultQualityStyle.IsTextWasChanged(quality))
				{
					DefaultQualityStyle.Load(quality);
				}
				return;
			}
			quality.text = qualityCache[m_quality];
			quality.textWrappingMode = (TextWrappingModes)3;
			quality.fontSize = MyLittleUI.itemQualitySymbolSize.Value;
			((Graphic)quality).color = MyLittleUI.itemQualitySymbolColor.Value;
			quality.isRightToLeftText = true;
			quality.lineSpacing = MyLittleUI.itemQualityLineSpacing.Value;
			quality.characterSpacing = MyLittleUI.itemQualityCharacterSpacing.Value;
		}
	}
	public static class ItemTooltip
	{
		[HarmonyPatch(typeof(InventoryGui), "Awake")]
		private class InventoryGui_Awake_ItemTooltipCraftingFontSize
		{
			private static void Postfix(InventoryGui __instance)
			{
				TMP_Text recipeDecription = __instance.m_recipeDecription;
				TextMeshProUGUI val = ((recipeDecription != null) ? ((Component)recipeDecription).GetComponent<TextMeshProUGUI>() : null);
				if ((Object)(object)val != (Object)null)
				{
					((TMP_Text)val).fontSizeMin = 12f;
				}
			}
		}

		[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]