Decompiled source of Quads Quality Of Life v1.13.6

plugins/QualityOfLife.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DHack.Shared;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (Claude Code).")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QualityOfLife
{
	internal static class Categories
	{
		public const string Weapons = "Weapons";

		public const string BowsAmmo = "Bows & Ammo";

		public const string Shields = "Shields";

		public const string Armor = "Armor & Capes";

		public const string Trinkets = "Trinkets & Utility";

		public const string Tools = "Tools";

		public const string Food = "Food";

		public const string Potions = "Potions & Mead";

		public const string Fish = "Fish";

		public const string Trophies = "Trophies";

		public const string Ores = "Ores";

		public const string Metals = "Metals";

		public const string LegacyOresAndMetals = "Ores & Metals";

		public const string Materials = "Materials";

		public const string Misc = "Everything else";

		public static readonly string[] All = new string[14]
		{
			"Weapons", "Bows & Ammo", "Shields", "Armor & Capes", "Trinkets & Utility", "Tools", "Food", "Potions & Mead", "Fish", "Trophies",
			"Ores", "Metals", "Materials", "Everything else"
		};

		private static readonly Dictionary<string, string> Keys = new Dictionary<string, string>
		{
			{ "Weapons", "weapons" },
			{ "Bows & Ammo", "bows" },
			{ "Shields", "shields" },
			{ "Armor & Capes", "armor" },
			{ "Trinkets & Utility", "trinkets" },
			{ "Tools", "tools" },
			{ "Food", "food" },
			{ "Potions & Mead", "potions" },
			{ "Fish", "fish" },
			{ "Trophies", "trophies" },
			{ "Ores", "ores" },
			{ "Metals", "metals" },
			{ "Materials", "materials" },
			{ "Everything else", "misc" }
		};

		private const string CatKey = "qualityoflife_cat_";

		private static readonly HashSet<string> MetalBars = new HashSet<string> { "copper", "tin", "bronze", "iron", "silver", "blackmetal", "flametal" };

		public static string Display(string category)
		{
			if (!Keys.TryGetValue(category, out var value))
			{
				return category;
			}
			return Translations.T("qualityoflife_cat_" + value);
		}

		public static string HelpOf(string category)
		{
			if (!Keys.TryGetValue(category, out var value))
			{
				return "";
			}
			return Translations.T("qualityoflife_cat_" + value + "_help");
		}

		private static string Plain(string itemName)
		{
			string text = (itemName ?? "").ToLowerInvariant();
			if (!text.StartsWith("$item_"))
			{
				return text;
			}
			return text.Substring(6);
		}

		private static bool IsOre(string plain)
		{
			if (!plain.EndsWith("ore") || plain.EndsWith("core"))
			{
				return plain.EndsWith("scrap");
			}
			return true;
		}

		public static string Of(SharedData s)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected I4, but got Unknown
			ItemType itemType = s.m_itemType;
			switch (itemType - 1)
			{
			case 2:
			case 13:
			case 14:
			case 19:
			case 21:
				return "Weapons";
			case 3:
			case 8:
			case 22:
				return "Bows & Ammo";
			case 4:
				return "Shields";
			case 5:
			case 6:
			case 10:
			case 16:
				return "Armor & Capes";
			case 17:
			case 23:
				return "Trinkets & Utility";
			case 18:
				return "Tools";
			case 20:
				return "Fish";
			case 12:
				return "Trophies";
			case 1:
				if (s.m_isDrink || (!(s.m_food > 0f) && !(s.m_foodStamina > 0f) && !(s.m_foodEitr > 0f)))
				{
					return "Potions & Mead";
				}
				return "Food";
			case 0:
			{
				string text = Plain(s.m_name);
				if (IsOre(text))
				{
					return "Ores";
				}
				if (!MetalBars.Contains(text))
				{
					return "Materials";
				}
				return "Metals";
			}
			default:
				return "Everything else";
			}
		}
	}
	internal class ChestRules
	{
		public readonly HashSet<string> Categories = new HashSet<string>();

		public readonly HashSet<string> Items = new HashSet<string>();

		private static readonly int Key = StringExtensionMethods.GetStableHashCode("DHack_StackRules");

		private static readonly FieldInfo NView = AccessTools.Field(typeof(Container), "m_nview");

		public bool IsEmpty
		{
			get
			{
				if (Categories.Count == 0)
				{
					return Items.Count == 0;
				}
				return false;
			}
		}

		private static ZDO ZdoOf(Container chest)
		{
			object? value = NView.GetValue(chest);
			object? obj = ((value is ZNetView) ? value : null);
			if (obj == null)
			{
				return null;
			}
			return ((ZNetView)obj).GetZDO();
		}

		public static bool OnTheMove(Container chest)
		{
			if ((Object)(object)chest != (Object)null)
			{
				if (!((Object)(object)((Component)chest).GetComponentInParent<Vagon>() != (Object)null))
				{
					return (Object)(object)((Component)chest).GetComponentInParent<Ship>() != (Object)null;
				}
				return true;
			}
			return false;
		}

		public static ChestRules Read(Container chest)
		{
			ChestRules chestRules = new ChestRules();
			if (OnTheMove(chest))
			{
				return chestRules;
			}
			ZDO obj = ZdoOf(chest);
			string text = ((obj != null) ? obj.GetString(Key, "") : null) ?? "";
			string[] array = text.Split(new char[1] { '|' });
			foreach (string text2 in array)
			{
				if (text2.Length < 2)
				{
					continue;
				}
				HashSet<string> hashSet = (text2.StartsWith("C=") ? chestRules.Categories : (text2.StartsWith("I=") ? chestRules.Items : null));
				if (hashSet == null)
				{
					continue;
				}
				string[] array2 = text2.Substring(2).Split(new char[1] { ',' });
				foreach (string text3 in array2)
				{
					if (text3.Length != 0)
					{
						if (hashSet == chestRules.Categories && text3 == "Ores & Metals")
						{
							hashSet.Add("Ores");
							hashSet.Add("Metals");
						}
						else
						{
							hashSet.Add(text3);
						}
					}
				}
			}
			return chestRules;
		}

		public static bool Write(Container chest, ChestRules rules)
		{
			object? value = NView.GetValue(chest);
			ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
			ZDO val2 = ((val != null) ? val.GetZDO() : null);
			if (val2 == null)
			{
				return false;
			}
			bool flag = (Object)(object)chest == (Object)(object)Plugin.OpenChest() && val.IsOwner();
			if (ContainerRegistry.InUse(chest) && !flag)
			{
				return false;
			}
			ContainerRegistry.TakeOwnership(chest);
			string text = (rules.IsEmpty ? "" : ("C=" + string.Join(",", rules.Categories.OrderBy((string x) => x).ToArray()) + "|I=" + string.Join(",", rules.Items.OrderBy((string x) => x).ToArray())));
			val2.Set(Key, text);
			return true;
		}

		public static void ForgetOnMover(Container chest)
		{
			if (OnTheMove(chest))
			{
				object? value = NView.GetValue(chest);
				ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
				ZDO val2 = (((Object)(object)val != (Object)null && val.IsValid()) ? val.GetZDO() : null);
				if (val2 != null && val.IsOwner() && !ContainerRegistry.InUse(chest) && val2.GetString(Key, "").Length != 0)
				{
					val2.Set(Key, "");
				}
			}
		}

		public bool WantsItem(string itemName)
		{
			return Items.Contains(itemName);
		}

		public bool WantsCategory(string category)
		{
			return Categories.Contains(category);
		}
	}
	internal static class ContainerRegistry
	{
		private static readonly List<Container> All = new List<Container>();

		private static readonly Dictionary<Container, KeyValuePair<uint, float>> Seen = new Dictionary<Container, KeyValuePair<uint, float>>();

		private const float SettleSeconds = 3f;

		private static readonly FieldInfo NView = AccessTools.Field(typeof(Container), "m_nview");

		private static readonly MethodInfo Load = AccessTools.Method(typeof(Container), "Load", (Type[])null, (Type[])null);

		public static void Register(Container c)
		{
			if ((Object)(object)c != (Object)null && !((Object)c).name.StartsWith("piece_recycler") && !All.Contains(c))
			{
				All.Add(c);
			}
		}

		public static void Seed()
		{
			Container[] array = Object.FindObjectsOfType<Container>();
			foreach (Container c in array)
			{
				Register(c);
			}
		}

		public static List<Container> Alive()
		{
			All.RemoveAll((Container c) => (Object)(object)c == (Object)null);
			return All;
		}

		public static void Clear()
		{
			All.Clear();
			Seen.Clear();
		}

		public static void Watch(Container c)
		{
			object? value = NView.GetValue(c);
			ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
			if (!((Object)(object)val == (Object)null) && val.IsValid())
			{
				uint dataRevision = val.GetZDO().DataRevision;
				if (!Seen.TryGetValue(c, out var value2))
				{
					Seen[c] = new KeyValuePair<uint, float>(dataRevision, float.NegativeInfinity);
				}
				else if (value2.Key != dataRevision)
				{
					Seen[c] = new KeyValuePair<uint, float>(dataRevision, Time.time);
				}
			}
		}

		public static bool Busy(Container c)
		{
			if (InUse(c))
			{
				return true;
			}
			object? value = NView.GetValue(c);
			ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
			if ((Object)(object)val == (Object)null || !val.IsValid() || val.IsOwner())
			{
				return false;
			}
			uint dataRevision = val.GetZDO().DataRevision;
			if (!Seen.TryGetValue(c, out var value2))
			{
				return false;
			}
			if (value2.Key == dataRevision)
			{
				return Time.time - value2.Value < 3f;
			}
			return true;
		}

		public static bool InUse(Container c)
		{
			if (c.IsInUse())
			{
				return true;
			}
			object? value = NView.GetValue(c);
			ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
			if ((Object)(object)val != (Object)null && val.IsValid() && !val.IsOwner())
			{
				return val.GetZDO().GetInt(ZDOVars.s_inUse, 0) == 1;
			}
			return false;
		}

		public static void Reload(Container c)
		{
			Load?.Invoke(c, null);
		}

		public static void TakeOwnership(Container c)
		{
			object? value = NView.GetValue(c);
			ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
			if (!((Object)(object)val == (Object)null) && val.IsValid() && !val.IsOwner())
			{
				val.ClaimOwnership();
				Reload(c);
			}
		}
	}
	[HarmonyPatch(typeof(Container), "Awake")]
	internal static class Container_Awake
	{
		private static void Postfix(Container __instance)
		{
			ContainerRegistry.Register(__instance);
		}
	}
	internal static class GameKeys
	{
		private static readonly HashSet<string> Essential = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
		{
			"Forward", "Backward", "Left", "Right", "Use", "Jump", "Inventory", "Tab", "Escape", "Map",
			"Chat", "Run", "Crouch", "Attack", "SecondaryAttack", "Block", "AltPlace", "LShift", "Console", "BuildMenu",
			"Remove", "MapZoomIn", "MapZoomOut", "Hotbar1", "Hotbar2", "Hotbar3", "Hotbar4", "Hotbar5", "Hotbar6", "Hotbar7",
			"Hotbar8", "TabRight", "ChatUp", "ChatDown"
		};

		private unsafe static string PathOf(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_0036: 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_003b: Expected I4, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected I4, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Invalid comparison between Unknown and I4
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			//IL_008a: 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_00a2: Expected I4, but got Unknown
			if ((int)key >= 97 && (int)key <= 122)
			{
				return "<Keyboard>/" + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
			}
			if ((int)key >= 48 && (int)key <= 57)
			{
				return "<Keyboard>/" + (key - 48);
			}
			if ((int)key >= 282 && (int)key <= 293)
			{
				return "<Keyboard>/" + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
			}
			if ((int)key <= 279)
			{
				if ((int)key == 96)
				{
					return "<Keyboard>/backquote";
				}
				if ((int)key == 127)
				{
					return "<Keyboard>/delete";
				}
				switch (key - 277)
				{
				case 0:
					return "<Keyboard>/insert";
				case 1:
					return "<Keyboard>/home";
				case 2:
					return "<Keyboard>/end";
				}
			}
			else
			{
				switch (key - 304)
				{
				default:
					if ((int)key != 326)
					{
						if ((int)key != 327)
						{
							break;
						}
						return "<Mouse>/forwardButton";
					}
					return "<Mouse>/backButton";
				case 4:
					return "<Keyboard>/leftAlt";
				case 3:
					return "<Keyboard>/rightAlt";
				case 2:
					return "<Keyboard>/leftCtrl";
				case 0:
					return "<Keyboard>/leftShift";
				case 1:
					break;
				}
			}
			return null;
		}

		public static List<string> Free(string owner, IEnumerable<KeyValuePair<KeyCode, string>> keys)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Invalid comparison between Unknown and I4
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			ZInput instance = ZInput.instance;
			if (instance == null)
			{
				return list;
			}
			if (!(AccessTools.Field(typeof(ZInput), "m_buttons")?.GetValue(instance) is Dictionary<string, ButtonDef> dictionary))
			{
				return list;
			}
			string text = "DHack.FreedGameKeys." + owner;
			HashSet<string> hashSet = new HashSet<string>(PlayerPrefs.GetString(text, "").Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries));
			bool flag = false;
			foreach (KeyValuePair<KeyCode, string> key in keys)
			{
				string text2 = PathOf(key.Key);
				if (text2 == null)
				{
					continue;
				}
				foreach (ButtonDef item2 in dictionary.Values.ToList())
				{
					if (item2 == null || !item2.Rebindable || (int)item2.Source == 180 || !string.Equals(item2.GetActionPath(true), text2, StringComparison.OrdinalIgnoreCase))
					{
						continue;
					}
					if (Essential.Contains(item2.Name))
					{
						Debug.LogWarning((object)$"[{owner}] {key.Key} ({key.Value}) is also the game's {item2.Name} key; that one is left as it is. Choose another key in the mod's settings.");
						continue;
					}
					string item = item2.Name + ":" + text2.ToLowerInvariant();
					if (!hashSet.Contains(item))
					{
						item2.Rebind("");
						hashSet.Add(item);
						flag = true;
						list.Add(Translations.T("qualityoflife_key_unbound", owner, key.Key, key.Value, Nice(item2.Name), Game("$menu_settings"), Game("$settings_controls")));
					}
				}
			}
			if (flag)
			{
				instance.Save();
				PlayerPrefs.SetString(text, string.Join("|", hashSet.ToArray()));
				PlayerPrefs.Save();
				foreach (string item3 in list)
				{
					Debug.Log((object)("[" + owner + "] " + item3));
				}
			}
			return list;
		}

		public static List<string> GiveBack(string owner, IEnumerable<KeyCode> inUse)
		{
			List<string> list = new List<string>();
			ZInput instance = ZInput.instance;
			if (instance == null)
			{
				return list;
			}
			if (!(AccessTools.Field(typeof(ZInput), "m_buttons")?.GetValue(instance) is Dictionary<string, ButtonDef> dictionary))
			{
				return list;
			}
			string text = "DHack.FreedGameKeys." + owner;
			HashSet<string> hashSet = new HashSet<string>(PlayerPrefs.GetString(text, "").Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> hashSet2 = new HashSet<string>(from p in inUse.Select(PathOf)
				where p != null
				select p.ToLowerInvariant());
			bool flag = false;
			foreach (string item in hashSet.ToList())
			{
				int num = item.IndexOf(':');
				if (num <= 0)
				{
					continue;
				}
				string text2 = item.Substring(0, num);
				string text3 = item.Substring(num + 1);
				if (!hashSet2.Contains(text3))
				{
					hashSet.Remove(item);
					flag = true;
					if (dictionary.TryGetValue(text2, out var value) && value != null && string.IsNullOrEmpty(value.GetActionPath(true)))
					{
						value.Rebind(text3);
						list.Add(Translations.T("qualityoflife_key_back", owner, Nice(text2), text3.Substring(text3.IndexOf('/') + 1).ToUpperInvariant()));
					}
				}
			}
			if (flag)
			{
				instance.Save();
				PlayerPrefs.SetString(text, string.Join("|", hashSet.ToArray()));
				PlayerPrefs.Save();
				foreach (string item2 in list)
				{
					Debug.Log((object)("[" + owner + "] " + item2));
				}
			}
			return list;
		}

		private static string Nice(string name)
		{
			return name switch
			{
				"AutoPickup" => Game("$settings_autopickup"), 
				"ToggleWalk" => Game("$settings_walk"), 
				"AutoRun" => Game("$settings_autorun"), 
				"OpenRadial" => Game("$settings_radial"), 
				"TabLeft" => Translations.T("qualityoflife_key_previous_tab"), 
				"OpenEmote" => Game("$radial_emotes"), 
				"GP" => Game("$settings_gp"), 
				_ => name, 
			};
		}

		private static string Game(string key)
		{
			if (Localization.instance == null)
			{
				return key;
			}
			return Localization.instance.Localize(key);
		}
	}
	internal static class GameUi
	{
		private const string CanvasName = "QualityOfLifeCanvas";

		internal static Func<bool> IsOpen = () => false;

		internal static Func<bool> Typing = () => false;

		internal static TMP_FontAsset Norse;

		internal static TMP_FontAsset Serif;

		internal static TMP_FontAsset Sans;

		private static Image _panel;

		private static Image _sunken;

		private static Image _braid;

		private static Button _button;

		private static Button _tab;

		private static GameObject _cell;

		private static float _cellSpace = 70f;

		internal static readonly Color Warm = new Color(1f, 0.86f, 0.55f);

		internal static readonly Color Text = new Color(0.94f, 0.9f, 0.82f);

		internal static readonly Color Dim = new Color(0.75f, 0.72f, 0.66f);

		internal static readonly Color Gold = new Color(1f, 0.78f, 0.3f);

		internal static readonly Color Warn = new Color(1f, 0.55f, 0.35f);

		internal static readonly Color Good = new Color(0.6f, 0.9f, 0.55f);

		private static Canvas _canvas;

		internal static Transform Canvas
		{
			get
			{
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Expected O, but got Unknown
				if ((Object)(object)_canvas != (Object)null)
				{
					Match();
					return ((Component)_canvas).transform;
				}
				InventoryGui instance = InventoryGui.instance;
				if ((Object)(object)instance == (Object)null)
				{
					return null;
				}
				foreach (Transform item in (from Transform t in (IEnumerable)((Component)instance).transform.parent
					where ((Object)t).name == "QualityOfLifeCanvas"
					select t).ToList())
				{
					Object.Destroy((Object)(object)((Component)item).gameObject);
				}
				Canvas val = ((Component)instance).GetComponentInChildren<Canvas>(true) ?? ((Component)instance).GetComponentInParent<Canvas>();
				GameObject val2 = new GameObject("QualityOfLifeCanvas", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(((Component)instance).transform.parent, false);
				_canvas = val2.AddComponent<Canvas>();
				_canvas.renderMode = (RenderMode)0;
				_canvas.sortingOrder = (((Object)(object)val != (Object)null) ? val.sortingOrder : 0) + 5;
				val2.AddComponent<CanvasScaler>();
				val2.AddComponent<GraphicRaycaster>();
				Match();
				return ((Component)_canvas).transform;
			}
		}

		internal static float CellSpace => _cellSpace;

		internal static Transform HudRoot
		{
			get
			{
				if (!((Object)(object)Hud.instance != (Object)null) || !((Object)(object)Hud.instance.m_rootObject != (Object)null))
				{
					return null;
				}
				return Hud.instance.m_rootObject.transform;
			}
		}

		private static void Match()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			InventoryGui instance = InventoryGui.instance;
			CanvasScaler val = (((Object)(object)_canvas != (Object)null) ? ((Component)_canvas).GetComponent<CanvasScaler>() : null);
			CanvasScaler val2 = (((Object)(object)instance != (Object)null) ? (((Component)instance).GetComponentInChildren<CanvasScaler>(true) ?? ((Component)instance).GetComponentInParent<CanvasScaler>()) : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
			{
				val.uiScaleMode = val2.uiScaleMode;
				val.referenceResolution = val2.referenceResolution;
				val.screenMatchMode = val2.screenMatchMode;
				val.matchWidthOrHeight = val2.matchWidthOrHeight;
				val.scaleFactor = val2.scaleFactor;
				val.referencePixelsPerUnit = val2.referencePixelsPerUnit;
			}
		}

		internal static void Destroy()
		{
			if ((Object)(object)_canvas != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_canvas).gameObject);
			}
			_canvas = null;
			_panel = null;
			_button = null;
			_cell = null;
			IsOpen = () => false;
			Typing = () => false;
		}

		internal static bool Ready()
		{
			if ((Object)(object)_button != (Object)null && (Object)(object)_panel != (Object)null && (Object)(object)_cell != (Object)null)
			{
				return true;
			}
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			Transform root = ((Component)instance).transform;
			_panel = Find<Image>("root/Crafting/Bkg") ?? Find<Image>("root/Player/Bkg");
			_sunken = Find<Image>("root/Player/sunken");
			_braid = Find<Image>("root/Crafting/BraidLineHorisontalMedium");
			_button = Find<Button>("root/Player/Container/TakeAll");
			_tab = Find<Button>("root/Crafting/TabsButtons/Craft");
			TMP_Text obj = Find<TMP_Text>("root/Crafting/topic");
			Norse = ((obj != null) ? obj.font : null);
			TMP_Text obj2 = Find<TMP_Text>("root/Crafting/TabsButtons/Craft/Text");
			Serif = ((obj2 != null) ? obj2.font : null);
			TMP_Text obj3 = Find<TMP_Text>("root/Crafting/Decription/Description");
			Sans = ((obj3 != null) ? obj3.font : null) ?? Serif;
			InventoryGrid playerGrid = instance.m_playerGrid;
			if ((Object)(object)playerGrid != (Object)null)
			{
				_cell = playerGrid.m_elementPrefab;
				_cellSpace = ((playerGrid.m_elementSpace > 1f) ? playerGrid.m_elementSpace : 70f);
			}
			if ((Object)(object)_button == (Object)null || (Object)(object)_panel == (Object)null || (Object)(object)_cell == (Object)null)
			{
				Debug.LogWarning((object)"QualityOfLifeCanvas: the game's interface was not found where expected (a game update moved it?)");
			}
			if ((Object)(object)_button != (Object)null && (Object)(object)_panel != (Object)null)
			{
				return (Object)(object)_cell != (Object)null;
			}
			return false;
			T Find<T>(string path) where T : Component
			{
				Transform val = root.Find(path);
				if (!((Object)(object)val != (Object)null))
				{
					return default(T);
				}
				return ((Component)val).GetComponent<T>();
			}
		}

		internal static RectTransform Rect(Transform parent, string name, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent(parent, false);
			Vector2 anchorMin = (val2.anchorMax = anchor);
			val2.anchorMin = anchorMin;
			val2.pivot = pivot;
			val2.anchoredPosition = pos;
			val2.sizeDelta = size;
			return val2;
		}

		internal static RectTransform Window(string name, Vector2 size)
		{
			//IL_0010: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Rect(Canvas, name, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, size);
			Copy(_panel, ((Component)val).gameObject.AddComponent<Image>());
			return val;
		}

		internal static RectTransform Over(RectTransform panel, string name, Vector2 minSize)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)panel).parent;
			foreach (Transform item in (from Transform t in (IEnumerable)parent
				where ((Object)t).name == name
				select t).ToList())
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			panel.GetWorldCorners(array);
			Vector2 val = Vector2.op_Implicit(parent.InverseTransformPoint(array[0]));
			Vector2 val2 = Vector2.op_Implicit(parent.InverseTransformPoint(array[2]));
			Transform val3 = ((Transform)panel).Find("Bkg");
			RectTransform val4 = (RectTransform)(object)((val3 is RectTransform) ? val3 : null);
			if (val4 != null)
			{
				val4.GetWorldCorners(array);
				val = Vector2.Min(val, Vector2.op_Implicit(parent.InverseTransformPoint(array[0])));
				val2 = Vector2.Max(val2, Vector2.op_Implicit(parent.InverseTransformPoint(array[2])));
			}
			Vector2 size = Vector2.Max(val2 - val, minSize);
			Rect rect = ((RectTransform)parent).rect;
			RectTransform val5 = Rect(parent, name, new Vector2(0.5f, 0.5f), new Vector2(0f, 1f), new Vector2(val.x, val2.y) - ((Rect)(ref rect)).center, size);
			((Transform)val5).SetSiblingIndex(((Transform)panel).GetSiblingIndex() + 1);
			Copy(_panel, ((Component)val5).gameObject.AddComponent<Image>());
			return val5;
		}

		internal static RectTransform Stretch(RectTransform r, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			r.anchorMin = Vector2.zero;
			r.anchorMax = Vector2.one;
			r.pivot = new Vector2(0.5f, 0.5f);
			r.offsetMin = offsetMin;
			r.offsetMax = offsetMax;
			return r;
		}

		internal static RectTransform Tag(Transform parent, string text, Vector2 pos, float height, float fontSize, Color fill, Color textColor, Vector2? anchor = null)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00d0: 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)
			Vector2 val = (Vector2)(((??)anchor) ?? new Vector2(0f, 1f));
			RectTransform val2 = Rect(parent, "Tag", val, val, pos, new Vector2(height, height));
			Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
			((Graphic)val3).color = fill;
			((Graphic)val3).raycastTarget = false;
			TMP_Text val4 = Label((Transform)(object)val2, text, Vector2.zero, new Vector2(height, height), fontSize, textColor, Sans, (TextAlignmentOptions)514, (Vector2?)new Vector2(0.5f, 0.5f));
			val4.enableWordWrapping = false;
			Stretch((RectTransform)val4.transform, Vector2.zero, Vector2.zero);
			float num = Mathf.Max(3f, height * 0.3f);
			val2.sizeDelta = new Vector2(Mathf.Max(height, val4.GetPreferredValues(text, 1000f, 0f).x + num * 2f), height);
			return val2;
		}

		internal static TMP_InputField Field(Transform parent, string text, string placeholder, Vector2 pos, Vector2 size, float fontSize = 18f)
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Box(parent, pos, size);
			((Object)val).name = "Field";
			GameObject gameObject = ((Component)val).gameObject;
			gameObject.SetActive(false);
			RectTransform val2 = Stretch(Rect((Transform)(object)val, "Text Area", Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero), new Vector2(10f, 3f), new Vector2(-10f, -3f));
			((Component)val2).gameObject.AddComponent<RectMask2D>();
			TMP_Text val3 = Label((Transform)(object)val2, placeholder, Vector2.zero, size, fontSize, new Color(Dim.r, Dim.g, Dim.b, 0.6f), Sans, (TextAlignmentOptions)4097);
			TMP_Text val4 = Label((Transform)(object)val2, "", Vector2.zero, size, fontSize, Text, Sans, (TextAlignmentOptions)4097);
			TMP_Text[] array = (TMP_Text[])(object)new TMP_Text[2] { val3, val4 };
			foreach (TMP_Text val5 in array)
			{
				Stretch((RectTransform)val5.transform, Vector2.zero, Vector2.zero);
				val5.enableWordWrapping = false;
				val5.overflowMode = (TextOverflowModes)0;
			}
			val4.richText = false;
			TMP_InputField val6 = gameObject.AddComponent<TMP_InputField>();
			((Selectable)val6).transition = (Transition)0;
			((Selectable)val6).targetGraphic = (Graphic)(object)gameObject.GetComponent<Image>();
			val6.textViewport = val2;
			val6.textComponent = val4;
			val6.placeholder = (Graphic)(object)val3;
			val6.lineType = (LineType)0;
			val6.richText = false;
			val6.customCaretColor = true;
			val6.caretColor = Text;
			val6.caretWidth = 2;
			val6.selectionColor = new Color(Gold.r, Gold.g, Gold.b, 0.35f);
			val6.text = text ?? "";
			gameObject.SetActive(true);
			return val6;
		}

		internal static RectTransform Box(Transform parent, Vector2 pos, Vector2 size)
		{
			//IL_0010: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Rect(parent, "Box", new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size);
			Image val2 = ((Component)val).gameObject.AddComponent<Image>();
			if ((Object)(object)_sunken != (Object)null)
			{
				Copy(_sunken, val2);
			}
			else
			{
				((Graphic)val2).color = new Color(0f, 0f, 0f, 0.35f);
			}
			return val;
		}

		internal static void Braid(Transform parent, Vector2 pos, float width)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_braid == (Object)null))
			{
				Vector2 anchor = new Vector2(0.5f, 1f);
				Vector2 pivot = new Vector2(0.5f, 0.5f);
				Rect rect = ((Graphic)_braid).rectTransform.rect;
				float num;
				if (!(((Rect)(ref rect)).height > 1f))
				{
					num = 16f;
				}
				else
				{
					rect = ((Graphic)_braid).rectTransform.rect;
					num = ((Rect)(ref rect)).height;
				}
				RectTransform val = Rect(parent, "Braid", anchor, pivot, pos, new Vector2(width, num));
				Copy(_braid, ((Component)val).gameObject.AddComponent<Image>());
			}
		}

		private static void Copy(Image from, Image to)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)from == (Object)null))
			{
				to.sprite = from.sprite;
				to.type = from.type;
				((Graphic)to).material = ((Graphic)from).material;
				((Graphic)to).color = ((Graphic)from).color;
				to.pixelsPerUnitMultiplier = from.pixelsPerUnitMultiplier;
				to.fillCenter = from.fillCenter;
			}
		}

		internal static TMP_Text Label(Transform parent, string text, Vector2 pos, Vector2 size, float fontSize, Color color, TMP_FontAsset font = null, TextAlignmentOptions align = (TextAlignmentOptions)257, Vector2? anchor = null)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = (Vector2)(((??)anchor) ?? new Vector2(0f, 1f));
			RectTransform val2 = Rect(parent, "Text", val, val, pos, size);
			bool activeSelf = ((Component)val2).gameObject.activeSelf;
			((Component)val2).gameObject.SetActive(false);
			TextMeshProUGUI val3 = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).font = font ?? Sans;
			((Component)val2).gameObject.SetActive(activeSelf);
			((TMP_Text)val3).fontSize = fontSize;
			((Graphic)val3).color = color;
			((TMP_Text)val3).alignment = align;
			((TMP_Text)val3).richText = true;
			((TMP_Text)val3).enableWordWrapping = true;
			((TMP_Text)val3).overflowMode = (TextOverflowModes)0;
			((TMP_Text)val3).text = text;
			((Graphic)val3).raycastTarget = false;
			return (TMP_Text)(object)val3;
		}

		internal static Button Button(Transform parent, string text, Vector2 pos, Vector2 size, Action click, bool enabled = true, float fontSize = 18f)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			Button val = Clone(_button, parent, text, pos, size, fontSize);
			((Selectable)val).interactable = enabled;
			((Graphic)Label(val)).color = (enabled ? Text : Dim);
			((UnityEvent)val.onClick).AddListener((UnityAction)delegate
			{
				click();
			});
			return val;
		}

		internal static Button Tab(Transform parent, string text, Vector2 pos, Vector2 size, bool chosen, Action click, float fontSize = 18f)
		{
			//IL_001e: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			Button val = Clone(_tab ?? _button, parent, text, pos, size, fontSize);
			Transform val2 = ((Component)val).transform.Find("Selected");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).gameObject.SetActive(false);
			}
			((Selectable)val).interactable = !chosen;
			((Graphic)Label(val)).color = (chosen ? Gold : Text);
			((UnityEvent)val.onClick).AddListener((UnityAction)delegate
			{
				click();
			});
			return val;
		}

		internal static TMP_Text Label(Button b)
		{
			return ((IEnumerable<TMP_Text>)((Component)b).GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Component)t).gameObject.activeSelf));
		}

		private static Button Clone(Button template, Transform parent, string text, Vector2 pos, Vector2 size, float fontSize)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false);
			((Object)val).name = "Button";
			val.SetActive(true);
			foreach (Transform item in ((IEnumerable)val.transform).Cast<Transform>().ToList())
			{
				if (((Object)item).name.StartsWith("gamepad_hint"))
				{
					Object.Destroy((Object)(object)((Component)item).gameObject);
				}
			}
			UIGamePad[] componentsInChildren = val.GetComponentsInChildren<UIGamePad>(true);
			foreach (UIGamePad val2 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val2);
			}
			ButtonTextColor[] componentsInChildren2 = val.GetComponentsInChildren<ButtonTextColor>(true);
			foreach (ButtonTextColor val3 in componentsInChildren2)
			{
				Object.Destroy((Object)(object)val3);
			}
			RectTransform val4 = (RectTransform)val.transform;
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(0f, 1f);
			val4.anchorMax = val5;
			val4.anchorMin = val5;
			val4.pivot = new Vector2(0f, 1f);
			val4.anchoredPosition = pos;
			val4.sizeDelta = size;
			Button component = val.GetComponent<Button>();
			component.onClick = new ButtonClickedEvent();
			TMP_Text val6 = ((IEnumerable<TMP_Text>)val.GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Object)t).name == "Text"));
			if ((Object)(object)val6 == (Object)null)
			{
				val6 = Label(val.transform, text, Vector2.zero, size, fontSize, Text, Serif, (TextAlignmentOptions)514, (Vector2?)new Vector2(0.5f, 0.5f));
				((RectTransform)val6.transform).pivot = new Vector2(0.5f, 0.5f);
			}
			val6.text = text;
			val6.fontSize = fontSize;
			val6.enableAutoSizing = false;
			val6.enableWordWrapping = false;
			val6.overflowMode = (TextOverflowModes)1;
			RectTransform val7 = (RectTransform)val6.transform;
			val7.anchorMin = Vector2.zero;
			val7.anchorMax = Vector2.one;
			val7.offsetMin = new Vector2(4f, 0f);
			val7.offsetMax = new Vector2(-4f, 0f);
			val6.alignment = (TextAlignmentOptions)514;
			TMP_Text[] componentsInChildren3 = val.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val8 in componentsInChildren3)
			{
				if ((Object)(object)val8 != (Object)(object)val6)
				{
					((Component)val8).gameObject.SetActive(false);
				}
			}
			return component;
		}

		internal static Image Icon(Transform parent, Vector2 pos, Vector2 size, Sprite sprite)
		{
			//IL_0010: 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_0024: 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)
			Image val = ((Component)Rect(parent, "Icon", new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size)).gameObject.AddComponent<Image>();
			val.sprite = sprite;
			val.preserveAspect = true;
			((Graphic)val).raycastTarget = false;
			((Behaviour)val).enabled = (Object)(object)sprite != (Object)null;
			return val;
		}

		internal static float Chip(Transform parent, Vector2 pos, ItemData item, string amount, float size = 28f, float fontSize = 17f)
		{
			//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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			Image val = Icon(parent, pos, new Vector2(size, size), item.GetIcon());
			((Graphic)val).raycastTarget = true;
			UITooltip val2 = ((!((Object)(object)_cell != (Object)null)) ? null : _cell.GetComponent<InventoryElement>()?.m_tooltip);
			if ((Object)(object)val2 != (Object)null)
			{
				UITooltip val3 = ((Component)val).gameObject.AddComponent<UITooltip>();
				val3.m_tooltipPrefab = val2.m_tooltipPrefab;
				val3.Set(item.m_shared.m_name, item.GetTooltip(-1), (RectTransform)null, default(Vector2));
			}
			TMP_Text val4 = Label(parent, amount, new Vector2(pos.x + size + 3f, pos.y - (size - fontSize * 1.3f) / 2f), new Vector2(80f, size), fontSize, Text, null, (TextAlignmentOptions)257);
			val4.enableWordWrapping = false;
			float x = val4.GetPreferredValues(amount, 200f, 0f).x;
			((RectTransform)val4.transform).sizeDelta = new Vector2(x + 2f, size);
			return size + 3f + x + 12f;
		}

		internal static RectTransform Bar(Transform parent, Vector2 pos, Vector2 size, float fraction, Color fill, string text, float fontSize = 15f)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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)
			RectTransform val = Box(parent, pos, size);
			RectTransform val2 = Rect((Transform)(object)val, "Fill", new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(2f, 2f), new Vector2(0f, 0f));
			val2.anchorMax = new Vector2(0f, 1f);
			val2.offsetMax = new Vector2(2f + (size.x - 4f) * Mathf.Clamp01(fraction), -2f);
			Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
			((Graphic)val3).color = new Color(fill.r * 0.8f, fill.g * 0.8f, fill.b * 0.8f, 0.9f);
			((Graphic)val3).raycastTarget = false;
			if (!string.IsNullOrEmpty(text))
			{
				bool[] array = new bool[2] { true, false };
				foreach (bool flag in array)
				{
					TMP_Text val4 = Label((Transform)(object)val, text, new Vector2(flag ? 1f : 0f, flag ? (-1f) : 0f), size, fontSize, (Color)(flag ? new Color(0f, 0f, 0f, 0.85f) : Color.white), Sans, (TextAlignmentOptions)514);
					val4.enableWordWrapping = false;
				}
			}
			return val;
		}

		internal static InventoryElement Cell(Transform parent, Vector2 pos, ItemData item, string amount, bool selected, Action click)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00a0: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(_cell, parent, false);
			((Object)val).name = "Cell";
			val.SetActive(true);
			UIDragHandler[] componentsInChildren = val.GetComponentsInChildren<UIDragHandler>(true);
			foreach (UIDragHandler val2 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val2);
			}
			UIGamePad[] componentsInChildren2 = val.GetComponentsInChildren<UIGamePad>(true);
			foreach (UIGamePad val3 in componentsInChildren2)
			{
				Object.Destroy((Object)(object)val3);
			}
			RectTransform val4 = (RectTransform)val.transform;
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(0f, 1f);
			val4.anchorMax = val5;
			val4.anchorMin = val5;
			val4.pivot = new Vector2(0f, 1f);
			val4.anchoredPosition = pos;
			InventoryElement component = val.GetComponent<InventoryElement>();
			component.Initialize(0, 0);
			Transform val6 = val.transform.Find("binding");
			if ((Object)(object)val6 != (Object)null)
			{
				TMP_Text component2 = ((Component)val6).GetComponent<TMP_Text>();
				if (component2 != null)
				{
					((Behaviour)component2).enabled = false;
				}
			}
			((Behaviour)component.m_icon).enabled = true;
			component.m_icon.sprite = item.GetIcon();
			((Graphic)component.m_icon).color = Color.white;
			bool flag = item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability();
			((Component)component.m_durability).gameObject.SetActive(flag);
			if (flag)
			{
				component.m_durability.SetValue(item.GetDurabilityPercentage());
			}
			((Behaviour)component.m_equiped).enabled = item.m_equipped;
			((Behaviour)component.m_queued).enabled = false;
			((Behaviour)component.m_noteleport).enabled = false;
			((Behaviour)component.m_food).enabled = false;
			((Behaviour)component.m_quality).enabled = amount == null && item.m_shared.m_maxQuality > 1;
			if (((Behaviour)component.m_quality).enabled)
			{
				component.m_quality.text = item.m_quality.ToString();
			}
			((Behaviour)component.m_amount).enabled = amount != null || item.m_shared.m_maxStackSize > 1;
			component.m_amount.text = amount ?? $"{item.m_stack}/{item.m_shared.m_maxStackSize}";
			if ((Object)(object)component.m_selected != (Object)null)
			{
				component.m_selected.SetActive(selected);
			}
			UITooltip tooltip = component.m_tooltip;
			string name = item.m_shared.m_name;
			string tooltip2 = item.GetTooltip(-1);
			val5 = default(Vector2);
			tooltip.Set(name, tooltip2, (RectTransform)null, val5);
			UIInputHandler componentInChildren = val.GetComponentInChildren<UIInputHandler>(true);
			if ((Object)(object)componentInChildren != (Object)null && click != null)
			{
				componentInChildren.m_onLeftClick = delegate
				{
					click();
				};
			}
			return component;
		}

		internal static RectTransform Scroll(RectTransform box, float inset)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: 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_02b6: Expected O, but got Unknown
			InventoryGui gui = InventoryGui.instance;
			ScrollRect val = (((Object)(object)gui != (Object)null) ? ((IEnumerable<ScrollRect>)((Component)gui).GetComponentsInChildren<ScrollRect>(true)).FirstOrDefault((Func<ScrollRect, bool>)((ScrollRect s) => (Object)(object)s.content == (Object)(object)gui.m_recipeListRoot)) : null);
			Scrollbar val2 = (((Object)(object)gui != (Object)null) ? gui.m_recipeListScroll : null);
			float num;
			if (!((Object)(object)val2 != (Object)null))
			{
				num = 0f;
			}
			else
			{
				Rect rect = ((RectTransform)((Component)val2).transform).rect;
				num = Mathf.Max(8f, ((Rect)(ref rect)).width);
			}
			float num2 = num;
			RectTransform val3 = Rect((Transform)(object)box, "View", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(inset, 0f - inset), box.sizeDelta - new Vector2(inset * 2f + ((num2 > 0f) ? (num2 + 4f) : 0f), inset * 2f));
			((Component)val3).gameObject.AddComponent<RectMask2D>();
			Image val4 = ((Component)val3).gameObject.AddComponent<Image>();
			((Graphic)val4).color = Color.clear;
			RectTransform val5 = Rect((Transform)(object)val3, "Content", new Vector2(0f, 1f), new Vector2(0f, 1f), Vector2.zero, new Vector2(val3.sizeDelta.x, 0f));
			ScrollRect val6 = ((Component)val3).gameObject.AddComponent<ScrollRect>();
			val6.content = val5;
			val6.viewport = val3;
			val6.horizontal = false;
			val6.movementType = (MovementType)2;
			val6.scrollSensitivity = (((Object)(object)val != (Object)null && val.scrollSensitivity > 0f) ? val.scrollSensitivity : 300f);
			val6.inertia = false;
			if ((Object)(object)val2 != (Object)null)
			{
				GameObject val7 = Object.Instantiate<GameObject>(((Component)val2).gameObject, (Transform)(object)box, false);
				((Object)val7).name = "Scrollbar";
				val7.SetActive(true);
				UIGamePad[] componentsInChildren = val7.GetComponentsInChildren<UIGamePad>(true);
				foreach (UIGamePad val8 in componentsInChildren)
				{
					Object.Destroy((Object)(object)val8);
				}
				RectTransform val9 = (RectTransform)val7.transform;
				val9.anchorMin = new Vector2(1f, 0f);
				val9.anchorMax = new Vector2(1f, 1f);
				val9.pivot = new Vector2(1f, 0.5f);
				val9.sizeDelta = new Vector2(num2, (0f - inset) * 2f);
				val9.anchoredPosition = new Vector2((0f - inset) * 0.5f, 0f);
				Scrollbar component = val7.GetComponent<Scrollbar>();
				component.onValueChanged = new ScrollEvent();
				val6.verticalScrollbar = component;
				val6.verticalScrollbarVisibility = (ScrollbarVisibility)1;
			}
			return val5;
		}
	}
	[HarmonyPatch(typeof(PlayerController), "TakeInput")]
	internal static class GameUi_PlayerControllerTakeInput
	{
		private static void Postfix(ref bool __result)
		{
			if (GameUi.IsOpen())
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "TakeInput")]
	internal static class GameUi_PlayerTakeInput
	{
		private static void Postfix(ref bool __result)
		{
			if (GameUi.IsOpen())
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	internal static class GameUi_UpdateMouseCapture
	{
		private static bool Prefix()
		{
			if (!GameUi.IsOpen())
			{
				return true;
			}
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
			return false;
		}
	}
	[HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")]
	internal static class GameUi_ScrollWheel
	{
		private static void Postfix(ref float __result)
		{
			if (GameUi.IsOpen())
			{
				__result = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(Menu), "Update")]
	internal static class GameUi_EscapeCloses
	{
		internal static Action Close = delegate
		{
		};

		private static bool Prefix()
		{
			if (!GameUi.IsOpen())
			{
				return true;
			}
			if (!ZInput.GetKeyDown((KeyCode)27, true) && !ZInput.GetButtonDown("JoyMenu"))
			{
				return true;
			}
			Close();
			return false;
		}
	}
	[HarmonyPatch(typeof(Minimap), "InTextInput")]
	internal static class GameUi_InTextInput
	{
		private static void Postfix(ref bool __result)
		{
			if (GameUi.Typing())
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Update")]
	internal static class GameUi_TypingInInventory
	{
		private static void Prefix()
		{
			if (GameUi.Typing())
			{
				ZInput.ResetButtonStatus("Use");
				ZInput.ResetButtonStatus("Inventory");
			}
		}
	}
	[BepInPlugin("com.quad.qualityoflife", "QualityOfLife", "1.13.6")]
	public class Plugin : BaseUnityPlugin
	{
		private class ItemEntry
		{
			public string Name;

			public string Display;

			public string Category;

			public Sprite Icon;

			public int Rank;
		}

		private class ItemRow
		{
			public RectTransform Root;

			public TMP_Text Header;

			public TMP_Text Name;

			public Button Toggle;

			public Image Icon;

			public int Index = -1;
		}

		private class DisplayRow
		{
			public ItemEntry Item;

			public string Header;
		}

		[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
		internal static class CameraZoom
		{
			internal static readonly FieldRef<GameCamera, float> Distance = AccessTools.FieldRefAccess<GameCamera, float>("m_distance");

			internal static bool Saved;

			internal static float Max;

			internal static float MaxBoat;

			internal static float Sens;

			private static void Prefix(GameCamera __instance)
			{
				if (_zoomEnabled == null)
				{
					return;
				}
				if (!_zoomEnabled.Value)
				{
					if (Saved)
					{
						RestoreCamera();
					}
					return;
				}
				if (!Saved)
				{
					Max = __instance.m_maxDistance;
					MaxBoat = __instance.m_maxDistanceBoat;
					Sens = __instance.m_zoomSens;
					Saved = true;
				}
				__instance.m_maxDistance = Mathf.Max(Max, _zoomMax.Value);
				__instance.m_maxDistanceBoat = Mathf.Max(MaxBoat, _zoomMaxBoat.Value);
				__instance.m_zoomSens = Sens * Mathf.Max(1f, Distance.Invoke(__instance) / Mathf.Max(1f, Max));
			}
		}

		private class Moved
		{
			public Container Chest;

			public ItemData Item;

			public Vector2i Slot;

			public ItemData Deposited;
		}

		[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
		internal static class InventoryGui_DoCrafting_KeepTags
		{
			internal class Note
			{
				public ItemData Old;

				public Vector2i Slot;

				public string Name;

				public readonly List<KeyValuePair<string, string>> Tags = new List<KeyValuePair<string, string>>();
			}

			private static readonly string[] Ours = new string[2] { "DHack.QuickStack.Keep", "DHack.QuickSwap" };

			private static void Prefix(ItemData ___m_craftUpgradeItem, out Note __state)
			{
				//IL_0045: 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)
				__state = null;
				if (___m_craftUpgradeItem?.m_customData == null)
				{
					return;
				}
				string[] ours = Ours;
				foreach (string key in ours)
				{
					if (___m_craftUpgradeItem.m_customData.TryGetValue(key, out var value))
					{
						if (__state == null)
						{
							__state = new Note
							{
								Old = ___m_craftUpgradeItem,
								Slot = ___m_craftUpgradeItem.m_gridPos,
								Name = ___m_craftUpgradeItem.m_shared.m_name
							};
						}
						__state.Tags.Add(new KeyValuePair<string, string>(key, value));
					}
				}
			}

			private static void Postfix(Player player, Note __state)
			{
				if (__state == null || (Object)(object)player == (Object)null)
				{
					return;
				}
				Inventory inventory = ((Humanoid)player).GetInventory();
				if (inventory == null || inventory.ContainsItem(__state.Old))
				{
					return;
				}
				ItemData itemAt = inventory.GetItemAt(__state.Slot.x, __state.Slot.y);
				if (itemAt == null || itemAt == __state.Old || itemAt.m_shared.m_name != __state.Name)
				{
					return;
				}
				if (itemAt.m_customData == null)
				{
					itemAt.m_customData = new Dictionary<string, string>();
				}
				foreach (KeyValuePair<string, string> tag in __state.Tags)
				{
					if (!itemAt.m_customData.ContainsKey(tag.Key))
					{
						itemAt.m_customData[tag.Key] = tag.Value;
					}
				}
			}
		}

		internal static bool RulesWindowOpen;

		private Container _rulesChest;

		private ChestRules _rules;

		private int _rulesTab;

		private string _search = "";

		private List<ItemEntry> _items = new List<ItemEntry>();

		private static readonly FieldInfo CurrentContainerField = AccessTools.Field(typeof(InventoryGui), "m_currentContainer");

		private const string AssignName = "QoLAssignChest";

		private RectTransform _assignRow;

		private string _assignShown = "";

		private Container _summaryChest;

		private List<KeyValuePair<string, Color>> _summaryChips;

		private string _summarySig = "";

		private float _nextSummary;

		private static readonly Color CategoryChip = new Color(0.55f, 0.42f, 0.16f, 0.97f);

		private static readonly Color ItemChip = new Color(0.2f, 0.32f, 0.45f, 0.97f);

		private Container _hoverChest;

		private string _hoverText = "";

		private float _nextHover;

		private const string RulesWindowName = "QoLAssignMenu";

		private const float RulesPad = 26f;

		private const float RowH = 32f;

		private RectTransform _rulesWindow;

		private RectTransform _rulesList;

		private TMP_Text _rulesAway;

		private TMP_Text _noItems;

		private TMP_InputField _searchField;

		private bool _rulesDocked;

		private bool _rulesDirty;

		private float _rulesOpenedAt;

		private int _awayShown = -1;

		private int _rowsFirst = -1;

		private readonly float[] _rulesScroll = new float[2];

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

		private List<DisplayRow> _display = new List<DisplayRow>();

		private string _displayFor;

		private ConfigEntry<bool> _pushEnabled;

		private ConfigEntry<KeyCode> _pushKey;

		private ConfigEntry<float> _pushStrength;

		private ConfigEntry<float> _pushMaxSpeed;

		private ConfigEntry<float> _pushRange;

		private ConfigEntry<float> _pushSeconds;

		private Ship _pushing;

		private float _pushUntil;

		private static ConfigEntry<bool> _zoomEnabled;

		private static ConfigEntry<float> _zoomMax;

		private static ConfigEntry<float> _zoomMaxBoat;

		public const string Guid = "com.quad.qualityoflife";

		public const string OldGuid = "com.dhack.qualityoflife";

		public const string Name = "QualityOfLife";

		public const string Version = "1.13.6";

		private ConfigEntry<bool> _quickSetEnabled;

		private ConfigEntry<bool> _showBadges;

		private ConfigEntry<bool> _hammerEnabled;

		private ConfigEntry<bool> _showMessages;

		private ConfigEntry<KeyboardShortcut> _quickSetKey;

		private ConfigEntry<KeyboardShortcut> _hammerKey;

		internal static Plugin Instance;

		internal static ServerSettings Synced;

		private Harmony _harmony;

		private float _uiRetryAt;

		private bool _uiFailed;

		private bool _keysChecked;

		private bool _keysWatched;

		private readonly List<string> _keyNotes = new List<string>();

		private Coroutine _running;

		private const string HammerName = "$item_hammer";

		private List<ItemData> _hammerBefore;

		internal static ConfigEntry<bool> PlantNeedsRoom;

		private const string Tag = "DHack.QuickSwap";

		private List<ItemData> _quickBefore;

		private bool _quickSwapped;

		private static readonly FieldInfo ElementsField = AccessTools.Field(typeof(InventoryGrid), "m_elements");

		private const string QuickBadgeName = "QoLQuickBadge";

		private const string KeepBadgeName = "QoLKeepBadge";

		private static readonly Color QuickBadgeFill = new Color(0.95f, 0.78f, 0.3f, 0.95f);

		private static readonly Color QuickBadgeText = new Color(0.1f, 0.07f, 0.02f);

		private static readonly Color KeepBadgeFill = new Color(0.65f, 0.15f, 0.15f, 0.95f);

		private readonly HashSet<int> _quickCells = new HashSet<int>();

		private const string KeepTag = "DHack.QuickStack.Keep";

		private ConfigEntry<bool> _stackEnabled;

		private ConfigEntry<bool> _protectHotbar;

		private ConfigEntry<bool> _showStackButtons;

		private ConfigEntry<bool> _showChestLabels;

		private ConfigEntry<bool> _playSounds;

		private ConfigEntry<float> _stackRadius;

		private ConfigEntry<KeyCode> _lockKey;

		private ConfigEntry<KeyCode> _stackKey;

		private ConfigEntry<KeyCode> _assignKey;

		private readonly List<Container> _stackChests = new List<Container>();

		private float _nextChestScan;

		private Action _pending;

		private static readonly MethodInfo CheckAccess = AccessTools.Method(typeof(Container), "CheckAccess", (Type[])null, (Type[])null);

		private readonly Dictionary<Container, ChestRules> _chestRules = new Dictionary<Container, ChestRules>();

		private List<Moved> _undo;

		private const string UnderName = "QoLUnderInventory";

		private RectTransform _underRow;

		private string _underShown = "";

		private ConfigEntry<bool> _shipPins;

		private ConfigEntry<PinType> _shipPinType;

		private readonly Dictionary<(long, uint), PinData> _shipPinsByZdo = new Dictionary<(long, uint), PinData>();

		private Minimap _shipPinsOn;

		private Dictionary<int, string> _shipKinds;

		private Sprite _shipIcon;

		private float _nextShipPinScan;

		private List<KeyValuePair<int, string>> _scanKinds;

		private int _scanKind;

		private int _scanIndex;

		private readonly List<ZDO> _scanList = new List<ZDO>();

		private readonly List<(ZDO zdo, int prefab, string name)> _scanFound = new List<(ZDO, int, string)>();

		private static readonly FieldInfo PinsField = AccessTools.Field(typeof(Minimap), "m_pins");

		private static readonly MethodInfo LoadImageMethod = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[2]
		{
			typeof(Texture2D),
			typeof(byte[])
		});

		private ConfigEntry<bool> _sortEnabled;

		private static readonly string[][] SlotMods = new string[5][]
		{
			new string[2] { "shudnal.ExtraSlots", "ExtraSlots" },
			new string[2] { "randyknapp.mods.equipmentandquickslots", "Equipment and Quick Slots" },
			new string[2] { "Azumatt.AzuExtendedPlayerInventory", "AzuExtendedPlayerInventory" },
			new string[2] { "aedenthorn.ExtendedPlayerInventory", "Extended Player Inventory" },
			new string[2] { "com.bruce.valheim.comfyquickslots", "ComfyQuickSlots" }
		};

		private static bool _slotModChecked;

		private static string _slotMod;

		private static readonly MethodInfo InventoryChanged = AccessTools.Method(typeof(Inventory), "Changed", (Type[])null, (Type[])null);

		internal static ConfigEntry<float> StationBuildRange;

		private bool Typing
		{
			get
			{
				if (RulesWindowOpen && (Object)(object)_searchField != (Object)null)
				{
					return _searchField.isFocused;
				}
				return false;
			}
		}

		private string NoItemsText
		{
			get
			{
				if (_search.Length <= 0)
				{
					return Translations.T("qualityoflife_no_items");
				}
				return Translations.T("qualityoflife_no_match");
			}
		}

		internal static Container OpenChest()
		{
			if (!((Object)(object)InventoryGui.instance != (Object)null))
			{
				return null;
			}
			object? obj = CurrentContainerField?.GetValue(InventoryGui.instance);
			return (Container)((obj is Container) ? obj : null);
		}

		private static bool Assignable(Container c)
		{
			if ((Object)(object)c != (Object)null && (Object)(object)((Component)c).GetComponentInParent<Piece>() != (Object)null && (Object)(object)((Component)c).GetComponentInParent<Character>() == (Object)null && (Object)(object)((Component)c).GetComponent<TombStone>() == (Object)null && !ChestRules.OnTheMove(c))
			{
				return !SpecialContainers.NotStorage(c);
			}
			return false;
		}

		private static Container LookedAtChest(Player p)
		{
			GameObject hoverObject = ((Humanoid)p).GetHoverObject();
			if (hoverObject == null)
			{
				return null;
			}
			return hoverObject.GetComponentInParent<Container>();
		}

		private void HandleAssignKey(Player player)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Container val = (InventoryGui.IsVisible() ? OpenChest() : LookedAtChest(player));
			if ((Object)(object)val == (Object)null)
			{
				Tell(player, Translations.T("qualityoflife_assign_look", _assignKey.Value));
			}
			else if (!Assignable(val))
			{
				Tell(player, ChestRules.OnTheMove(val) ? Translations.T("qualityoflife_assign_moving") : (((Object)((Component)val).gameObject).name.StartsWith("piece_ledgerchest", StringComparison.Ordinal) ? Translations.T("qualityoflife_assign_ledger") : Translations.T("qualityoflife_assign_cant_use")));
			}
			else if (!Usable(val))
			{
				Tell(player, Translations.T("qualityoflife_assign_cant_use"));
			}
			else if ((Object)(object)val != (Object)(object)OpenChest() && ContainerRegistry.InUse(val))
			{
				Tell(player, Translations.T("qualityoflife_assign_in_use"));
			}
			else
			{
				OpenRules(val, player);
			}
		}

		private void OpenRules(Container chest, Player player)
		{
			if (!((Object)(object)chest == (Object)null) && !((Object)(object)player == (Object)null) && GameUi.Ready())
			{
				if (RulesWindowOpen)
				{
					CloseRules();
				}
				InventoryGui instance = InventoryGui.instance;
				bool flag = InventoryGui.IsVisible() && (Object)(object)chest == (Object)(object)OpenChest() && (Object)(object)instance.m_crafting != (Object)null;
				if (!flag && InventoryGui.IsVisible())
				{
					instance.Hide();
				}
				_rulesChest = chest;
				_rules = ChestRules.Read(chest);
				_rulesTab = 0;
				_search = "";
				_rulesDocked = flag;
				_rulesScroll[0] = (_rulesScroll[1] = 0f);
				BuildItemList(player);
				RulesWindowOpen = true;
				_rulesOpenedAt = Time.unscaledTime;
				BuildRulesWindow();
			}
		}

		public static void CloseFromEscape()
		{
			Instance?.CloseRules();
		}

		private void CloseRules()
		{
			RulesWindowOpen = false;
			_rulesChest = null;
			if ((Object)(object)_rulesWindow != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_rulesWindow).gameObject);
			}
			_rulesWindow = null;
			_rulesList = null;
			_rulesAway = null;
			_searchField = null;
			_noItems = null;
			_rows.Clear();
			UITooltip.HideTooltip();
		}

		private bool UpdateRulesWindow(Player player)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if (!RulesWindowOpen)
			{
				return false;
			}
			bool flag = Time.unscaledTime > _rulesOpenedAt + 0.3f;
			int num;
			if (!((Object)(object)_rulesChest == (Object)null) && !((Object)(object)_rulesWindow == (Object)null) && _stackEnabled.Value && !Menu.IsVisible())
			{
				Vector3 val = ((Component)_rulesChest).transform.position - ((Component)player).transform.position;
				if (!(((Vector3)(ref val)).sqrMagnitude > 225f))
				{
					num = ((flag && !Typing && Input.GetKeyDown(_assignKey.Value)) ? 1 : 0);
					goto IL_009d;
				}
			}
			num = 1;
			goto IL_009d;
			IL_009d:
			bool flag2 = (byte)num != 0;
			if (!flag2 && _rulesDocked)
			{
				flag2 = !InventoryGui.IsVisible() || (Object)(object)OpenChest() != (Object)(object)_rulesChest;
			}
			else if (!flag2)
			{
				flag2 = flag && InventoryGui.IsVisible();
			}
			if (flag2)
			{
				CloseRules();
				return true;
			}
			int num2 = Mathf.RoundToInt(Vector3.Distance(((Component)_rulesChest).transform.position, ((Component)player).transform.position));
			if ((Object)(object)_rulesAway != (Object)null && num2 != _awayShown)
			{
				_awayShown = num2;
				_rulesAway.text = Localization.instance.Localize(_rulesChest.m_name) + "  ·  " + Translations.T("qualityoflife_m_away", num2);
			}
			if (_rulesDirty)
			{
				BuildRulesWindow();
			}
			else
			{
				if ((Object)(object)_rulesList != (Object)null)
				{
					_rulesScroll[_rulesTab] = _rulesList.anchoredPosition.y;
				}
				if (_rulesTab == 1)
				{
					UpdateItemRows();
				}
			}
			return true;
		}

		private void BuildItemList(Player player)
		{
			//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_0087: Invalid comparison between Unknown and I4
			List<ItemEntry> list = new List<ItemEntry>();
			if ((Object)(object)ObjectDB.instance != (Object)null)
			{
				HashSet<string> hashSet = new HashSet<string>();
				Inventory inventory = ((Humanoid)player).GetInventory();
				foreach (GameObject item in ObjectDB.instance.m_items)
				{
					ItemDrop val = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null);
					if (!((Object)(object)val == (Object)null))
					{
						SharedData shared = val.m_itemData.m_shared;
						if ((int)shared.m_itemType != 0 && (int)shared.m_itemType != 10 && hashSet.Add(shared.m_name) && (player.IsMaterialKnown(shared.m_name) || inventory.ContainsItemByName(shared.m_name) || _rules.Items.Contains(shared.m_name)))
						{
							list.Add(new ItemEntry
							{
								Name = shared.m_name,
								Display = Localization.instance.Localize(shared.m_name),
								Category = Categories.Of(shared),
								Icon = val.m_itemData.GetIcon(),
								Rank = Tiers.Rank(shared)
							});
						}
					}
				}
			}
			_items = (from i in list
				orderby Array.IndexOf(Categories.All, i.Category), i.Rank
				select i).ThenBy<ItemEntry, string>((ItemEntry i) => i.Display, StringComparer.OrdinalIgnoreCase).ToList();
			_displayFor = null;
		}

		private void SaveRules()
		{
			if (!((Object)(object)_rulesChest == (Object)null) && !ChestRules.Write(_rulesChest, _rules))
			{
				_rules = ChestRules.Read(_rulesChest);
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					Tell(Player.m_localPlayer, Translations.T("qualityoflife_save_in_use"));
				}
			}
		}

		private void ToggleCategory(string category)
		{
			if (RulesWindowOpen && _rules != null)
			{
				if (!_rules.Categories.Remove(category))
				{
					_rules.Categories.Add(category);
				}
				SaveRules();
				_rulesDirty = true;
			}
		}

		private void ToggleItem(string itemName)
		{
			if (RulesWindowOpen && _rules != null)
			{
				if (!_rules.Items.Remove(itemName))
				{
					_rules.Items.Add(itemName);
				}
				SaveRules();
				_rulesDirty = true;
			}
		}

		private void ClearRules()
		{
			if (RulesWindowOpen && _rules != null)
			{
				_rules.Categories.Clear();
				_rules.Items.Clear();
				SaveRules();
				_rulesDirty = true;
			}
		}

		private void UpdateAssignButton(InventoryGui gui)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			Container val = ((_stackEnabled.Value && (Object)(object)gui.m_container != (Object)null) ? OpenChest() : null);
			if ((Object)(object)val == (Object)null || !Assignable(val))
			{
				DestroyAssignRow();
				return;
			}
			if ((Object)(object)val != (Object)(object)_summaryChest || Time.unscaledTime >= _nextSummary)
			{
				_summaryChest = val;
				_summaryChips = (_showChestLabels.Value ? BuildChips(ChestRules.Read(val)) : null);
				_summarySig = ((_summaryChips == null) ? "-" : string.Join("|", _summaryChips.Select((KeyValuePair<string, Color> c) => c.Key).ToArray()));
				_nextSummary = Time.unscaledTime + 0.5f;
			}
			Rect rect = gui.m_container.rect;
			float num = Mathf.Max(220f, ((Rect)(ref rect)).width) - 16f;
			string text = ((Object)val).GetInstanceID() + "|" + Mathf.RoundToInt(num) + "|" + _summarySig + "|" + Localization.instance.GetSelectedLanguage();
			if ((Object)(object)_assignRow != (Object)null && text == _assignShown)
			{
				return;
			}
			DestroyAssignRow();
			foreach (Transform item in (from Transform t in (IEnumerable)gui.m_container
				where ((Object)t).name == "QoLAssignChest"
				select t).ToList())
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			_assignShown = text;
			_assignRow = GameUi.Rect((Transform)(object)gui.m_container, "QoLAssignChest", Vector2.zero, new Vector2(0f, 1f), new Vector2(8f, -6f), new Vector2(num, 30f));
			Container target = val;
			string text2 = Translations.T("qualityoflife_assign_title");
			Button val2 = GameUi.Button((Transform)(object)_assignRow, text2, Vector2.zero, new Vector2(220f, 30f), delegate
			{
				Player p = Player.m_localPlayer;
				_pending = delegate
				{
					OpenRules(target, p);
				};
			}, enabled: true, 15f);
			TMP_Text val3 = GameUi.Label(val2);
			float num2 = (((Object)(object)val3 != (Object)null) ? Mathf.Min(num, Mathf.Ceil(val3.GetPreferredValues(text2).x) + 24f) : 0f);
			if (num2 > 220f)
			{
				((RectTransform)((Component)val2).transform).sizeDelta = new Vector2(num2, 30f);
			}
			if (_summaryChips == null)
			{
				return;
			}
			if (_summaryChips.Count == 0)
			{
				TMP_Text val4 = GameUi.Label((Transform)(object)_assignRow, Translations.T("qualityoflife_receives_nothing"), new Vector2(0f, -36f), new Vector2(num, 20f), 13f, GameUi.Dim, null, (TextAlignmentOptions)257);
				val4.enableWordWrapping = false;
				return;
			}
			float num3 = 0f;
			float num4 = 36f;
			foreach (KeyValuePair<string, Color> summaryChip in _summaryChips)
			{
				RectTransform val5 = GameUi.Tag((Transform)(object)_assignRow, summaryChip.Key, new Vector2(num3, 0f - num4), 20f, 13f, summaryChip.Value, GameUi.Text);
				float x = val5.sizeDelta.x;
				if (num3 > 0f && num3 + x > num)
				{
					num3 = 0f;
					num4 += 24f;
					val5.anchoredPosition = new Vector2(num3, 0f - num4);
				}
				num3 += x + 4f;
			}
		}

		private void DestroyAssignRow()
		{
			if ((Object)(object)_assignRow != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_assignRow).gameObject);
			}
			_assignRow = null;
			_assignShown = "";
		}

		private static List<KeyValuePair<string, Color>> BuildChips(ChestRules rules)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<string, Color>> list = new List<KeyValuePair<string, Color>>();
			foreach (string item in Categories.All.Where(rules.Categories.Contains))
			{
				list.Add(new KeyValuePair<string, Color>(Categories.Display(item), CategoryChip));
			}
			List<string> list2 = rules.Items.Select(ItemDisplayName).OrderBy<string, string>((string n) => n, StringComparer.OrdinalIgnoreCase).ToList();
			foreach (string item2 in list2.Take(6))
			{
				list.Add(new KeyValuePair<string, Color>(item2, ItemChip));
			}
			if (list2.Count > 6)
			{
				list.Add(new KeyValuePair<string, Color>(Translations.T("qualityoflife_n_more", list2.Count - 6), ItemChip));
			}
			return list;
		}

		internal static string HoverSuffix(Container chest)
		{
			Plugin instance = Instance;
			if ((Object)(object)instance == (Object)null || !instance._stackEnabled.Value || !instance._showChestLabels.Value)
			{
				return "";
			}
			if (!Assignable(chest))
			{
				return "";
			}
			if ((Object)(object)chest == (Object)(object)instance._hoverChest && Time.unscaledTime < instance._nextHover)
			{
				return instance._hoverText;
			}
			try
			{
				ChestRules chestRules = ChestRules.Read(chest);
				string text = "";
				if (!chestRules.IsEmpty)
				{
					List<string> list = new List<string>(Categories.All.Where(chestRules.Categories.Contains).Select(Categories.Display));
					list.AddRange(chestRules.Items.Select(ItemDisplayName).OrderBy<string, string>((string n) => n, StringComparer.OrdinalIgnoreCase));
					text = "\n<color=#F2C75A>" + Translations.T("qualityoflife_receives") + "</color> " + string.Join(", ", list.Take(2).ToArray());
					if (list.Count > 2)
					{
						text = text + ",\n" + string.Join(", ", list.Skip(2).Take(3).ToArray());
						if (list.Count > 5)
						{
							text = text + " <color=#BBBBBB>" + Translations.T("qualityoflife_n_more", list.Count - 5) + "</color>";
						}
					}
				}
				instance._hoverChest = chest;
				instance._hoverText = text;
				instance._nextHover = Time.unscaledTime + 1f;
				return text;
			}
			catch (Exception)
			{
				return "";
			}
		}

		private static string ItemDisplayName(string itemName)
		{
			string text = Localization.instance.Localize(itemName);
			if (!string.IsNullOrEmpty(text) && !text.Contains("["))
			{
				return text;
			}
			string text2 = (itemName ?? "").Replace("$item_", "").Replace("$", "").Replace('_', ' ')
				.Trim();
			if (text2.Length <= 0)
			{
				return itemName;
			}
			return char.ToUpperInvariant(text2[0]) + text2.Substring(1);
		}

		private void BuildRulesWindow()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			_rulesDirty = false;
			if ((Object)(object)_rulesWindow != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_rulesWindow).gameObject);
			}
			_rulesWindow = null;
			_rulesList = null;
			_rulesAway = null;
			_searchField = null;
			_noItems = null;
			_rows.Clear();
			_rowsFirst = -1;
			_awayShown = -1;
			UITooltip.HideTooltip();
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)_rulesChest == (Object)null || _rules == null || (Object)(object)instance == (Object)null || !GameUi.Ready())
			{
				CloseRules();
				return;
			}
			if (_rulesDocked)
			{
				_rulesWindow = GameUi.Over(instance.m_crafting, "QoLAssignMenu", new Vector2(520f, 600f));
				goto IL_0166;
			}
			RectTransform val = (RectTransform)GameUi.Canvas;
			? val2;
			if ((Object)(object)val != (Object)null)
			{
				Rect rect = val.rect;
				if (((Rect)(ref rect)).height > 200f)
				{
					rect = val.rect;
					val2 = ((Rect)(ref rect)).size - new Vector2(40f, 40f);
					goto IL_012d;
				}
			}
			val2 = new Vector2(600f, 700f);
			goto IL_012d;
			IL_012d:
			Vector2 val3 = (Vector2)val2;
			_rulesWindow = GameUi.Window("QoLAssignMenu", new Vector2(Mathf.Min(600f, val3.x), Mathf.Min(700f, val3.y)));
			goto IL_0166;
			IL_0166:
			float x = _rulesWindow.sizeDelta.x;
			float y = _rulesWindow.sizeDelta.y;
			float num = x - 52f;
			Transform rulesWindow = (Transform)(object)_rulesWindow;
			TMP_Text val4 = GameUi.Label(rulesWindow, Translations.T("qualityoflife_assign_title"), new Vector2(26f, -18f), new Vector2(num - 120f, 40f), 30f, GameUi.Warm, GameUi.Norse, (TextAlignmentOptions)257);
			val4.enableWordWrapping = false;
			val4.enableAutoSizing = true;
			val4.fontSizeMin = 18f;
			val4.fontSizeMax = 30f;
			GameUi.Button(rulesWindow, Localization.instance.Localize("$menu_close"), new Vector2(x - 26f - 110f, -20f), new Vector2(110f, 36f), CloseRules);
			GameUi.Braid(rulesWindow, new Vector2(0f, -64f), num);
			float num2 = 76f;
			_rulesAway = GameUi.Label(rulesWindow, "", new Vector2(26f, 0f - num2), new Vector2(num, 24f), 17f, GameUi.Dim, null, (TextAlignmentOptions)257);
			_rulesAway.enableWordWrapping = false;
			num2 += 26f;
			string text = Translations.T("qualityoflife_assign_note");
			TMP_Text val5 = GameUi.Label(rulesWindow, text, new Vector2(26f, 0f - num2), new Vector2(num, 24f), 16f, GameUi.Dim, null, (TextAlignmentOptions)257);
			float y2 = val5.GetPreferredValues(text, num, 0f).y;
			((RectTransform)val5.transform).sizeDelta = new Vector2(num, y2);
			num2 += y2 + 12f;
			float num3 = (num - 8f) / 2f;
			string[] array = new string[2]
			{
				Translations.T("qualityoflife_tab_categories", _rules.Categories.Count),
				Translations.T("qualityoflife_tab_items", _rules.Items.Count)
			};
			for (int i = 0; i < 2; i++)
			{
				int tab = i;
				GameUi.Tab(rulesWindow, array[i], new Vector2(26f + (float)i * (num3 + 8f), 0f - num2), new Vector2(num3, 38f), _rulesTab == i, delegate
				{
					//IL_0034: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)(object)_rulesList != (Object)null)
					{
						_rulesScroll[_rulesTab] = _rulesList.anchoredPosition.y;
					}
					_rulesTab = tab;
					_rulesDirty = true;
				});
			}
			num2 += 48f;
			if (_rulesTab == 1)
			{
				TMP_Text val6 = GameUi.Label(rulesWindow, Translations.T("qualityoflife_search"), new Vector2(26f, 0f - num2 - 6f), new Vector2(80f, 26f), 18f, GameUi.Text, null, (TextAlignmentOptions)257);
				val6.enableAutoSizing = true;
				val6.fontSizeMin = 12f;
				val6.fontSizeMax = 18f;
				_searchField = GameUi.Field(rulesWindow, _search, Translations.T("qualityoflife_search_hint"), new Vector2(110f, 0f - num2), new Vector2(num - 84f - 100f, 34f));
				((UnityEvent<string>)(object)_searchField.onValueChanged).AddListener((UnityAction<string>)delegate(string text3)
				{
					_search = text3 ?? "";
				});
				GameUi.Button(rulesWindow, Translations.T("qualityoflife_clear"), new Vector2(x - 26f - 92f, 0f - num2), new Vector2(92f, 34f), delegate
				{
					if ((Object)(object)_searchField != (Object)null)
					{
						_searchField.text = "";
					}
				}, enabled: true, 16f);
				num2 += 44f;
			}
			float num4 = y - 26f - 40f;
			RectTransform box = GameUi.Box(rulesWindow, new Vector2(20f, 0f - num2), new Vector2(num + 12f, num4 - num2 - 10f));
			_rulesList = GameUi.Scroll(box, 8f);
			if (_rulesTab == 0)
			{
				BuildCategoryRows();
			}
			else
			{
				BuildItemRows();
			}
			string text2 = (_rules.IsEmpty ? Translations.T("qualityoflife_status_empty") : Translations.T("qualityoflife_status_saved"));
			TMP_Text val7 = GameUi.Label(rulesWindow, text2, new Vector2(26f, 0f - num4), new Vector2(num - 196f, 40f), 16f, GameUi.Dim, GameUi.Sans, (TextAlignmentOptions)4097);
			val7.enableAutoSizing = true;
			val7.fontSizeMin = 12f;
			val7.fontSizeMax = 16f;
			GameUi.Button(rulesWindow, Translations.T("qualityoflife_clear_all"), new Vector2(x - 26f - 180f, 0f - num4), new Vector2(180f, 40f), delegate
			{
				_pending = ClearRules;
			}, !_rules.IsEmpty, 17f);
		}

		private void RestoreScroll(float height)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			float y = ((RectTransform)((Transform)_rulesList).parent).sizeDelta.y;
			_rulesList.sizeDelta = new Vector2(_rulesList.sizeDelta.x, height);
			_rulesList.anchoredPosition = new Vector2(0f, Mathf.Clamp(_rulesScroll[_rulesTab], 0f, Mathf.Max(0f, height - y)));
		}

		private void BuildCategoryRows()
		{
			//IL_0006: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid I