Decompiled source of AAA Crafting v1.4.0

AzuAntiArthriticCrafting.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Auga;
using AzuAntiArthriticCrafting.Compatibility.CraftFromContainers;
using AzuAntiArthriticCrafting.Compatibility.OdinsCraftyBoxes;
using AzuAntiArthriticCrafting.Compatibility.TillValhalla;
using AzuAntiArthriticCrafting.Patches;
using AzuAntiArthriticCrafting.RecipeTracking;
using AzuAntiArthriticCrafting.Utilities;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Fishlabs;
using HarmonyLib;
using JetBrains.Annotations;
using Jewelcrafting;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using YamlDotNet.Serialization;

[assembly: AssemblyFileVersion("1.4.0")]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyProduct("AzuAntiArthriticCrafting")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("AzuAntiArthriticCrafting")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<e7667753-97bd-4df1-8d85-39a5cc47b083>Embedded]
	internal sealed class <e7667753-97bd-4df1-8d85-39a5cc47b083>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<e7667753-97bd-4df1-8d85-39a5cc47b083>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <05e991e4-b7cc-41dd-b4b9-187b564228c5>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <05e991e4-b7cc-41dd-b4b9-187b564228c5>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <05e991e4-b7cc-41dd-b4b9-187b564228c5>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<e7667753-97bd-4df1-8d85-39a5cc47b083>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace LocalizationManager
{
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	[PublicAPI]
	public class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

		private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts;

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

		private static readonly List<WeakReference<Localization>> localizationObjects;

		[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static readonly List<string> fileExtensions;

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		private static void UpdatePlaceholderText(Localization localization, string key)
		{
			localizationLanguage.TryGetValue(localization, out var value);
			string text = loadedTexts[value][key];
			if (PlaceholderProcessors.TryGetValue(key, out var value2))
			{
				text = value2.Aggregate(text, [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] [return: <05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(1)] (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdatePlaceholder();
			};
			if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
			{
				UpdatePlaceholder();
			}
			void UpdatePlaceholder()
			{
				PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value);
				UpdatePlaceholderText(Localization.instance, key);
			}
		}

		public static void AddText(string key, string text)
		{
			List<WeakReference<Localization>> list = new List<WeakReference<Localization>>();
			foreach (WeakReference<Localization> localizationObject in localizationObjects)
			{
				if (localizationObject.TryGetTarget(out var target))
				{
					Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)];
					if (!target.m_translations.ContainsKey(key))
					{
						dictionary[key] = text;
						target.AddWord(key, text);
					}
				}
				else
				{
					list.Add(localizationObject);
				}
			}
			foreach (WeakReference<Localization> item in list)
			{
				localizationObjects.Remove(item);
			}
		}

		public static void Load()
		{
			LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage());
		}

		private static void LoadLocalization(Localization __instance, string language)
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			if (!localizationLanguage.Remove(__instance))
			{
				localizationObjects.Add(new WeakReference<Localization>(__instance));
			}
			localizationLanguage.Add(__instance, language);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories)
				where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0
				select f)
			{
				string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1];
				if (dictionary.ContainsKey(text))
				{
					Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped."));
				}
				else
				{
					dictionary[text] = item;
				}
			}
			byte[] array = LoadTranslationFromAssembly("English");
			if (array == null)
			{
				throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml.");
			}
			Dictionary<string, string> dictionary2 = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array));
			if (dictionary2 == null)
			{
				throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty.");
			}
			string text2 = null;
			if (language != "English")
			{
				if (dictionary.ContainsKey(language))
				{
					text2 = File.ReadAllText(dictionary[language]);
				}
				else
				{
					byte[] array2 = LoadTranslationFromAssembly(language);
					if (array2 != null)
					{
						text2 = Encoding.UTF8.GetString(array2);
					}
				}
			}
			if (text2 == null && dictionary.ContainsKey("English"))
			{
				text2 = File.ReadAllText(dictionary["English"]);
			}
			if (text2 != null)
			{
				foreach (KeyValuePair<string, string> item2 in ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>())
				{
					dictionary2[item2.Key] = item2.Value;
				}
			}
			loadedTexts[language] = dictionary2;
			foreach (KeyValuePair<string, string> item3 in dictionary2)
			{
				UpdatePlaceholderText(__instance, item3.Key);
			}
		}

		static Localizer()
		{
			//IL_004d: 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_008c: Expected O, but got Unknown
			PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>();
			loadedTexts = new Dictionary<string, Dictionary<string, string>>();
			localizationLanguage = new ConditionalWeakTable<Localization, string>();
			localizationObjects = new List<WeakReference<Localization>>();
			fileExtensions = new List<string> { ".json", ".yml" };
			new Harmony("org.bepinex.helpers.LocalizationManager").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		[return: <05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
		private static byte[] LoadTranslationFromAssembly(string language)
		{
			foreach (string fileExtension in fileExtensions)
			{
				byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
				if (array != null)
				{
					return array;
				}
			}
			return null;
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
}
namespace AzuAntiArthriticCrafting
{
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	[BepInPlugin("Azumatt.AzuAntiArthriticCrafting", "AzuAntiArthriticCrafting", "1.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	public class AzuAntiArthriticCraftingPlugin : BaseUnityPlugin
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
			[UsedImplicitly]
			public string Category;

			[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
		private class AcceptableShortcuts : AcceptableValueBase
		{
			public AcceptableShortcuts()
				: base(typeof(KeyboardShortcut))
			{
			}

			public override object Clamp(object value)
			{
				return value;
			}

			public override bool IsValid(object value)
			{
				return true;
			}

			public override string ToDescriptionString()
			{
				return "# Acceptable values: " + string.Join(", ", KeyboardShortcut.AllKeyCodes);
			}
		}

		internal const string ModName = "AzuAntiArthriticCrafting";

		internal const string ModVersion = "1.4.0";

		internal const string Author = "Azumatt";

		private const string ModGUID = "Azumatt.AzuAntiArthriticCrafting";

		private static string ConfigFileName = "Azumatt.AzuAntiArthriticCrafting.cfg";

		private static string ConfigFileFullPath;

		internal static string ConnectionError;

		internal static bool CfcLoaded;

		private readonly Harmony _harmony = new Harmony("Azumatt.AzuAntiArthriticCrafting");

		internal static AssetBundle Asset;

		public static readonly ManualLogSource AntiArthriticCraftingLogger;

		private static readonly ConfigSync ConfigSync;

		public static GameObject RecipeTrackerUIPrefab;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<Toggle> ResetCraftingValueOnRecChange;

		public static ConfigEntry<Toggle> KGPaginator;

		public static ConfigEntry<float> CraftingDuration;

		public static ConfigEntry<string> RequirementTextFormatting;

		public static ConfigEntry<string> InputEnabledText;

		public static ConfigEntry<string> InputDisabledText;

		public static ConfigEntry<Color> InputTextColor;

		public static ConfigEntry<KeyboardShortcut> MinusKeybind;

		public static ConfigEntry<Color> HeaderGlowColor;

		public static ConfigEntry<Color> HeaderBraidColor;

		public static ConfigEntry<Color> RecipeContainerBackgroundColor;

		public static ConfigEntry<Color> ItemNameColor;

		public static ConfigEntry<Color> RecipeNameColorComplete;

		public static ConfigEntry<Color> RecipeNameColorInComplete;

		public static ConfigEntry<Color> RecipeCompleteColor;

		public static ConfigEntry<Color> RecipeIncompleteRightColor;

		public static ConfigEntry<Color> RecipeIncompleteLeftColor;

		public static ConfigEntry<Vector2> RecipeTrackerPanelScale;

		public static ConfigEntry<float> RecipeTrackerItemNameMin;

		public static ConfigEntry<float> RecipeTrackerItemNameMax;

		public static ConfigEntry<float> RecipeTrackerReqNameMin;

		public static ConfigEntry<float> RecipeTrackerReqNameMax;

		public static ConfigEntry<Vector2> RecipeTrackerPanelPosition;

		public void Awake()
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Expected O, but got Unknown
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Expected O, but got Unknown
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Expected O, but got Unknown
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Expected O, but got Unknown
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Expected O, but got Unknown
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Expected O, but got Unknown
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Expected O, but got Unknown
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Expected O, but got Unknown
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Expected O, but got Unknown
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Expected O, but got Unknown
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Expected O, but got Unknown
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			ResetCraftingValueOnRecChange = config("1 - Crafting Tweaks", "Reset Crafting Value", Toggle.On, "If enabled, the crafting amount will be reset when the recipe is changed and when crafting completes. If disabled, the crafting amount will not be reset and will keep your previous amount");
			KGPaginator = config("1 - Crafting Tweaks", "KG Paginator", Toggle.On, "If enabled, the KG paginator will be enabled. If disabled, the KG paginator will be disabled", synchronizedSetting: false);
			KGPaginator.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				if ((Object)(object)PaginatorPatches.CraftingWindowPaginator != (Object)null)
				{
					PaginatorPatches.CraftingWindowPaginator.gameObject.SetActive(KGPaginator.Value == Toggle.On);
				}
				else
				{
					AzuAntiArthriticCrafting.Utilities.Utilities.CreatePaginator(InventoryGui.instance);
					if (PaginatorPatches.CraftingWindowPaginator != null)
					{
						PaginatorPatches.CraftingWindowPaginator.gameObject.SetActive(KGPaginator.Value == Toggle.On);
					}
				}
			};
			RequirementTextFormatting = config("1 - Crafting Tweaks", "Requirement Text Formatting", "{0}/{1}", "{0} is the available amount the player has\n{1} is the requirement amount to make the item.", synchronizedSetting: false);
			CraftingDuration = config("2 - Game", "Crafting Speed", 2f, new ConfigDescription("Change the speed at which it takes to craft items. This value is in seconds. To craft faster, make this value smaller. To craft slower, make this value larger. Default is 2 seconds.", (AcceptableValueBase)null, Array.Empty<object>()));
			InputEnabledText = config("3 - Input Tweaks", "Placeholder Text (Enabled)", "Enter Amount...", new ConfigDescription("Change the placeholder text for the input field. Default is \"Enter Amount...\"", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4
				}
			}), synchronizedSetting: false);
			InputDisabledText = config("3 - Input Tweaks", "Placeholder Text (Disabled)", "Disabled", new ConfigDescription("Change the placeholder text for the input field when it is disabled. Default is \"Disabled\"", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3
				}
			}), synchronizedSetting: false);
			InputEnabledText.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				if (!((Object)(object)InventoryGui.instance == (Object)null) && (Object)(object)InventoryGuiShowCraftingPanelPatch.placeholderText != (Object)null)
				{
					((TMP_Text)InventoryGuiShowCraftingPanelPatch.placeholderText).text = InputEnabledText.Value;
				}
			};
			InputTextColor = config<Color>("3 - Input Tweaks", "Input Text Color", new Color(1f, 61f / 85f, 49f / 136f, 1f), new ConfigDescription("Change the placeholder text for the input field. Default is \"Enter Amount...\"", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2
				}
			}), synchronizedSetting: false);
			InputTextColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)InventoryGui.instance == (Object)null) && !((Object)(object)InventoryGuiShowCraftingPanelPatch.CraftAmountInputField == (Object)null))
				{
					((Graphic)InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.textComponent).color = InputTextColor.Value;
					if (!((Object)(object)InventoryGuiShowCraftingPanelPatch.placeholderText == (Object)null))
					{
						((Graphic)InventoryGuiShowCraftingPanelPatch.placeholderText).color = InputTextColor.Value;
					}
				}
			};
			MinusKeybind = config<KeyboardShortcut>("4 - Keys", "Show Minus Button", new KeyboardShortcut((KeyCode)306, Array.Empty<KeyCode>()), "The key to hold down to show the minus button instead of the plus. [Default: LeftControl]");
			RecipeTrackerPanelPosition = config<Vector2>("5 - Recipe Tracker (Position)", "Recipe Tracker Position", new Vector2(783f, 265f), new ConfigDescription("Change the anchored position of the recipe tracker panel. Default is 816, 184.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerPanelPosition.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)HudAwakePatch.RecipeTrackerUI == (Object)null))
				{
					((Component)HudAwakePatch.RecipeTrackerUI).GetComponent<RectTransform>().anchoredPosition = RecipeTrackerPanelPosition.Value;
				}
			};
			HeaderGlowColor = config<Color>("5 - Recipe Tracker (Color)", "Header Glow Color", new Color(0.58f, 0.235f, 0.19f, 1f), new ConfigDescription("Change the color of the header glow. Default is dark red.", (AcceptableValueBase)null, Array.Empty<object>()));
			HeaderBraidColor = config<Color>("5 - Recipe Tracker (Color)", "Header Braid Color", new Color(1f, 0.717f, 0.356f, 1f), new ConfigDescription("Change the color of the header braid (decoration). Default is mustard yellow.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeContainerBackgroundColor = config<Color>("5 - Recipe Tracker (Color)", "Recipe Container Background Color", new Color(0f, 0f, 0f, 0.5f), new ConfigDescription("Change the color of the recipe container background. Default is semi-transparent black.", (AcceptableValueBase)null, Array.Empty<object>()));
			ItemNameColor = config<Color>("5 - Recipe Tracker (Color)", "Item Name Color (Color)", new Color(1f, 61f / 85f, 49f / 136f, 1f), new ConfigDescription("Change the color of the item name. Default is yellow.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeNameColorComplete = config<Color>("5 - Recipe Tracker (Color)", "Recipe Complete Name Color", Color.white, new ConfigDescription("Change the color of the item name. Default is yellow.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeNameColorInComplete = config<Color>("5 - Recipe Tracker (Color)", "Recipe Incomplete Name Color", new Color(1f, 1f, 1f, 0.192f), new ConfigDescription("Change the color of the item name. Default is yellow.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeCompleteColor = config<Color>("5 - Recipe Tracker (Color)", "Recipe Complete Color", new Color(0f, 1f, 0.44f, 0.37f), new ConfigDescription("Change the color of the text when the requirement is met. Default is green.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeIncompleteRightColor = config<Color>("5 - Recipe Tracker (Color)", "Recipe Incomplete Right Color", new Color(1f, 0.31f, 0f, 1f), new ConfigDescription("Change the color of the text when the requirement is not met. Default is red.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeIncompleteLeftColor = config<Color>("5 - Recipe Tracker (Color)", "Recipe Incomplete Left Color", Color.white, new ConfigDescription("Change the color of the text when the requirement is not met. Default is red.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerPanelScale = config<Vector2>("5 - Recipe Tracker (Sizes)", "Recipe Tracker Panel Scale", new Vector2(0.75f, 0.75f), new ConfigDescription("Change the scale of the recipe tracker panel. Default is 1.0f.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerItemNameMin = config("5 - Recipe Tracker (Sizes)", "Recipe Tracker Item Name Min", 12f, new ConfigDescription("Change the minimum size of the recipe tracker item name. Default is 12.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerItemNameMax = config("5 - Recipe Tracker (Sizes)", "Recipe Tracker Item Name Max", 20f, new ConfigDescription("Change the maximum size of the recipe tracker item name. Default is 20.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerReqNameMin = config("5 - Recipe Tracker (Sizes)", "Recipe Tracker Req Name Min", 12f, new ConfigDescription("Change the minimum size of the recipe tracker requirement name. Default is 12.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerReqNameMax = config("5 - Recipe Tracker (Sizes)", "Recipe Tracker Req Name Max", 20f, new ConfigDescription("Change the maximum size of the recipe tracker requirement name. Default is 20.", (AcceptableValueBase)null, Array.Empty<object>()));
			RecipeTrackerPanelScale.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerItemNameMin.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerItemNameMax.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerReqNameMin.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerReqNameMax.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			HeaderGlowColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			HeaderBraidColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeContainerBackgroundColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			ItemNameColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeNameColorComplete.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeNameColorInComplete.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeCompleteColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeIncompleteRightColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeIncompleteLeftColor.SettingChanged += [<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			LoadAssets();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

		private static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		public void UpdateAllRecipesOnChange()
		{
			if (!((Object)(object)RecipeTrackerUIPrefab == (Object)null))
			{
				RecipeTrackerUI.Instance.UpdateAllRecipes();
			}
		}

		public static void LoadAssets()
		{
			Asset = GetAssetBundleFromResources("paginator");
			AssetBundle assetBundleFromResources = GetAssetBundleFromResources("aaa_recipetracker");
			RecipeTrackerUIPrefab = Object.Instantiate<GameObject>(assetBundleFromResources.LoadAsset<GameObject>("AAA_RecipeTrackerUI"));
			Object.DontDestroyOnLoad((Object)(object)RecipeTrackerUIPrefab);
			RecipeTrackerUIPrefab.SetActive(false);
			if (assetBundleFromResources != null)
			{
				assetBundleFromResources.Unload(false);
			}
		}

		private void Start()
		{
			AssetLoadTracker.MapPrefabsToBundles();
			AssetLoadTracker.MapBundlesToAssemblies();
			if (Jewelcrafting.API.IsLoaded())
			{
				Jewelcrafting.API.OnItemBreak(AzuAntiArthriticCrafting.Utilities.Utilities.OnItemBreak);
			}
			Chainloader.PluginInfos.TryGetValue("Azumatt.AzuCraftyBoxes", out var value);
			Chainloader.PluginInfos.TryGetValue("odinplusqol.OdinsCraftyBoxes", out var value2);
			Chainloader.PluginInfos.TryGetValue("aedenthorn.CraftFromContainers", out var value3);
			Chainloader.PluginInfos.TryGetValue("com.odinplusqol.mod", out var value4);
			Chainloader.PluginInfos.TryGetValue("kwilson.TillValhalla", out var value5);
			if (value2 != null && (Object)(object)value2.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"OdinsCraftyBoxes detected.");
				CfcLoaded = true;
			}
			if (value != null && (Object)(object)value.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"AzuCraftyBoxes detected.");
				CfcLoaded = true;
			}
			if (value4 != null && (Object)(object)value4.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"OdinPlusQOL detected.");
				CfcLoaded = true;
			}
			if (value3 != null && (Object)(object)value3.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"CraftFromContainers detected.");
				CfcLoaded = true;
			}
			if (value5 != null && (Object)(object)value5.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"TillValhalla detected.");
				CfcLoaded = true;
			}
		}

		private void Update()
		{
			InventoryGuiShowCraftingPanelPatch.Update();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				AntiArthriticCraftingLogger.LogDebug((object)"ReadConfigValues called");
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				AntiArthriticCraftingLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				AntiArthriticCraftingLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		private ConfigEntry<T> config<[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			ConfigSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		static AzuAntiArthriticCraftingPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			Asset = null;
			AntiArthriticCraftingLogger = Logger.CreateLogSource("AzuAntiArthriticCrafting");
			ConfigSync = new ConfigSync("Azumatt.AzuAntiArthriticCrafting")
			{
				DisplayName = "AzuAntiArthriticCrafting",
				CurrentVersion = "1.4.0",
				MinimumRequiredVersion = "1.4.0"
			};
			RecipeTrackerUIPrefab = null;
			_serverConfigLocked = null;
			ResetCraftingValueOnRecChange = null;
			KGPaginator = null;
			CraftingDuration = null;
			RequirementTextFormatting = null;
			InputEnabledText = null;
			InputDisabledText = null;
			InputTextColor = null;
			MinusKeybind = null;
			HeaderGlowColor = null;
			HeaderBraidColor = null;
			RecipeContainerBackgroundColor = null;
			ItemNameColor = null;
			RecipeNameColorComplete = null;
			RecipeNameColorInComplete = null;
			RecipeCompleteColor = null;
			RecipeIncompleteRightColor = null;
			RecipeIncompleteLeftColor = null;
			RecipeTrackerPanelScale = null;
			RecipeTrackerItemNameMin = null;
			RecipeTrackerItemNameMax = null;
			RecipeTrackerReqNameMin = null;
			RecipeTrackerReqNameMax = null;
			RecipeTrackerPanelPosition = null;
		}
	}
	public static class KeyboardExtensions
	{
		public static bool IsKeyDown(this KeyboardShortcut shortcut)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey))
			{
				return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
			}
			return false;
		}

		public static bool IsKeyHeld(this KeyboardShortcut shortcut)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey))
			{
				return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
			}
			return false;
		}
	}
	public static class LoggingExtensions
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public static void LogIfBuildDebug(this ManualLogSource logger, string message)
		{
		}
	}
	public class ScrollableInputField : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(1)]
		public TMP_InputField inputField;

		private bool isHovering;

		private void Awake()
		{
			inputField = ((Component)this).gameObject.GetComponent<TMP_InputField>();
		}

		private void Update()
		{
			if (isHovering)
			{
				float axis = Input.GetAxis("Mouse ScrollWheel");
				int num = ((!Input.GetKey((KeyCode)304)) ? 1 : 10);
				int num2 = (int)(Mathf.Sign(axis) * (float)num);
				if (axis != 0f)
				{
					inputField.text = (int.TryParse(inputField.text, out var result) ? Mathf.Max(1, result + num2).ToString() : (0f + Mathf.Sign(axis)).ToString());
				}
			}
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public void OnPointerEnter(PointerEventData eventData)
		{
			isHovering = true;
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public void OnPointerExit(PointerEventData eventData)
		{
			isHovering = false;
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("AzuAntiArthriticCrafting_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_AzuAntiArthriticCrafting_Version);
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogInfo((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("1.4.0");
			peer.m_rpc.Invoke("AzuAntiArthriticCrafting_VersionCheck", new object[1] { val });
		}
	}
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "AzuAntiArthriticCraftingRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + AzuAntiArthriticCraftingPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_AzuAntiArthriticCrafting_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogInfo((object)("Version check, local: 1.4.0,  remote: " + text));
			if (text != "1.4.0")
			{
				AzuAntiArthriticCraftingPlugin.ConnectionError = "AzuAntiArthriticCrafting Installed: 1.4.0\n Needed: " + text;
				if (ZNet.instance.IsServer())
				{
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting..."));
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogInfo((object)"Received same version from server!");
			}
			else
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
				ValidatedPeers.Add(rpc);
			}
		}
	}
}
namespace AzuAntiArthriticCrafting.Utilities
{
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	public class AssetLoadTracker
	{
		private static readonly Dictionary<string, string> PrefabToBundleMapping = new Dictionary<string, string>();

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

		internal static void MapPrefabsToBundles()
		{
			foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
			{
				foreach (string item in from name in allLoadedAssetBundle.GetAllAssetNames()
					where name.EndsWith(".prefab")
					select name)
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item);
					PrefabToBundleMapping[fileNameWithoutExtension] = ((Object)allLoadedAssetBundle).name;
				}
			}
		}

		internal static void MapBundlesToAssemblies()
		{
			List<Assembly> list = Chainloader.PluginInfos.Select([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (KeyValuePair<string, PluginInfo> keyValuePair) => ((object)keyValuePair.Value.Instance).GetType().Assembly).ToList();
			foreach (string bundleName in PrefabToBundleMapping.Values.Distinct())
			{
				foreach (Assembly item in list)
				{
					try
					{
						if (item.GetManifestResourceNames().Any([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (string resourceName) => resourceName.EndsWith(bundleName)))
						{
							BundleToAssemblyMapping[bundleName] = item;
							break;
						}
					}
					catch (Exception arg)
					{
						AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)$"Error while getting manifest resource names for assembly {item.GetName().Name}: {arg}");
					}
				}
			}
		}

		[return: <05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
		public static Assembly GetAssemblyForPrefab(string prefabName)
		{
			if (PrefabToBundleMapping.TryGetValue(prefabName, out var value) && BundleToAssemblyMapping.TryGetValue(value, out var value2))
			{
				return value2;
			}
			return null;
		}

		public static string GetBundleForPrefab(string prefabName)
		{
			if (!PrefabToBundleMapping.TryGetValue(prefabName, out var value))
			{
				return "";
			}
			return value;
		}
	}
	public class DragWindowCntrl : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(1)]
		private RectTransform _window;

		private Vector2 _delta;

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public static void ApplyDragWindowCntrl(GameObject go)
		{
			go.AddComponent<DragWindowCntrl>();
		}

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_window = (RectTransform)((Component)this).transform;
		}

		private void Start()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Vector2 value = AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelPosition.Value;
			_window.anchoredPosition = value;
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0011: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)_window).parent;
			Vector2 val = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), eventData.position, eventData.pressEventCamera, ref val);
			_delta = val - _window.anchoredPosition;
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public void OnDrag(PointerEventData eventData)
		{
			//IL_0011: 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_0027: 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_0031: 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)
			Transform parent = ((Transform)_window).parent;
			Vector2 val = default(Vector2);
			if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((parent is RectTransform) ? parent : null), eventData.position, eventData.pressEventCamera, ref val))
			{
				Vector2 anchoredPosition = val - _delta;
				_window.anchoredPosition = anchoredPosition;
			}
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		public void OnEndDrag(PointerEventData eventData)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelPosition.Value = _window.anchoredPosition;
		}

		public void ResetToDefaultPosition()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			_window.anchoredPosition = AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelPosition.Value;
		}
	}
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	public abstract class Utilities
	{
		private static string _name = "";

		public static string Name
		{
			get
			{
				return _name;
			}
			set
			{
				if (!(Name == value))
				{
					_name = value;
					UnityEvent onRecipeChange = InventoryGuiShowCraftingPanelPatch.OnRecipeChange;
					if (onRecipeChange != null)
					{
						onRecipeChange.Invoke();
					}
					ClearRequirements();
				}
			}
		}

		public static void ResetAacCrafting()
		{
			if (AzuAntiArthriticCraftingPlugin.ResetCraftingValueOnRecChange.Value == AzuAntiArthriticCraftingPlugin.Toggle.On)
			{
				InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text = "";
			}
			CancelCrafting();
		}

		public static void CancelCrafting()
		{
			InventoryGuiShowCraftingPanelPatch.WasCrafting = false;
			if (Object.op_Implicit((Object)(object)InventoryGui.instance) && InventoryGui.instance.InCraftTab())
			{
				if (AzuAntiArthriticCraftingPlugin.ResetCraftingValueOnRecChange.Value == AzuAntiArthriticCraftingPlugin.Toggle.Off)
				{
					InventoryGuiShowCraftingPanelPatch.OnCraftAmountChanged(InventoryGui.instance, InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text);
				}
				UnblockInput();
			}
		}

		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(2)]
		public static bool OnItemBreak(ItemData containerItem)
		{
			CancelCrafting();
			return true;
		}

		public static void OnCraftButtonPressed()
		{
			StartCraftingLogic();
			BlockInput(upgradeTab: false);
		}

		public static void OnCraftCancelledButtonPressed()
		{
			CancelCrafting();
		}

		public static void TabCraftPressed()
		{
			UnblockInput();
			ResetAacCrafting();
		}

		public static void UpgradeTabPressed()
		{
			BlockInput(upgradeTab: true);
			ResetAacCrafting();
		}

		public static void StartCraftingLogic()
		{
			InventoryGuiShowCraftingPanelPatch.WasCrafting = true;
			InventoryGuiShowCraftingPanelPatch.WaitUpdates = 5;
		}

		public static void BlockInput(bool upgradeTab)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			InputField val = (((Object)(object)InventoryGuiShowCraftingPanelPatch.CraftAmountInputField != (Object)null) ? ((Component)InventoryGuiShowCraftingPanelPatch.CraftAmountInputField).GetComponent<InputField>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				((Selectable)val).interactable = false;
				((Behaviour)val).enabled = false;
				if (upgradeTab)
				{
					InventoryGuiShowCraftingPanelPatch.aacParent.SetActive(false);
				}
				else
				{
					UpdatePlaceholder(val, AzuAntiArthriticCraftingPlugin.InputDisabledText.Value, Color.red);
				}
			}
		}

		public static void UnblockInput()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			InputField val = (((Object)(object)InventoryGuiShowCraftingPanelPatch.CraftAmountInputField != (Object)null) ? ((Component)InventoryGuiShowCraftingPanelPatch.CraftAmountInputField).GetComponent<InputField>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				InventoryGuiShowCraftingPanelPatch.aacParent.SetActive(true);
				((Selectable)val).interactable = true;
				((Behaviour)val).enabled = true;
				UpdatePlaceholder(val, AzuAntiArthriticCraftingPlugin.InputEnabledText.Value, Color.white);
			}
		}

		private static void UpdatePlaceholder(InputField inputField, string text, Color color)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			TMP_Text val = (((Object)(object)inputField.placeholder != (Object)null) ? ((Component)inputField.placeholder).GetComponent<TMP_Text>() : null);
			if ((Object)(object)val != (Object)null)
			{
				val.text = text;
				((Graphic)val).color = color;
			}
		}

		public static void ClearRequirements()
		{
			InventoryGuiShowCraftingPanelPatch.IsRecipeReady = false;
			InventoryGuiShowCraftingPanelPatch.CurrentRequirements.Clear();
		}

		public static void AddRequirement(string itemname, int requiredAmount)
		{
			if (InventoryGuiShowCraftingPanelPatch.CurrentRequirements.ContainsKey(itemname))
			{
				InventoryGuiShowCraftingPanelPatch.IsRecipeReady = true;
				return;
			}
			RequirementInformation value = new RequirementInformation(requiredAmount, itemname);
			InventoryGuiShowCraftingPanelPatch.CurrentRequirements[itemname] = value;
		}

		internal static void OnDecrementButtonPressed()
		{
			if (!int.TryParse(InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text, out var result))
			{
				result = 1;
			}
			if (Input.GetKey((KeyCode)306))
			{
				InventoryGuiShowCraftingPanelPatch.OnCraftAmountChanged(InventoryGui.instance, "1");
				result = 1;
			}
			else
			{
				int num = -1;
				if (Input.GetKey((KeyCode)304))
				{
					num = -10;
				}
				InventoryGuiShowCraftingPanelPatch.OnCraftAmountChanged(InventoryGui.instance, num.ToString());
				result += num;
			}
			result = Math.Max(1, result);
			InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text = result.ToString();
		}

		internal static void OnIncrementButtonPressed()
		{
			if (!int.TryParse(InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text, out var result))
			{
				result = 1;
			}
			int num = 1;
			if (Input.GetKey((KeyCode)306))
			{
				num = 100;
				InventoryGuiShowCraftingPanelPatch.OnCraftAmountChanged(InventoryGui.instance, num.ToString());
				result = 100;
			}
			else if (Input.GetKey((KeyCode)304))
			{
				num = 10;
				InventoryGuiShowCraftingPanelPatch.OnCraftAmountChanged(InventoryGui.instance, num.ToString());
				result += num;
			}
			result = Math.Max(1, result);
			InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text = result.ToString();
			InventoryGuiShowCraftingPanelPatch.OnCraftAmountChanged(InventoryGui.instance, num.ToString());
		}

		internal static void UpdateRequirementLabels(Transform elementRoot, Requirement req, int quality)
		{
			//IL_00b6: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			InventoryGuiSetupRequirementPatch.inCrafting = true;
			TextMeshProUGUI component = ((Component)((Component)elementRoot).transform.Find("res_amount")).GetComponent<TextMeshProUGUI>();
			int availableItems = GetAvailableItems(req.m_resItem.m_itemData.m_shared.m_name);
			int num = req.GetAmount(quality) * InventoryGuiShowCraftingPanelPatch.CurrentCraftAmount;
			if (num <= 0)
			{
				InventoryGui.HideRequirement(elementRoot);
			}
			else if (!Chainloader.PluginInfos.ContainsKey("Azumatt.AzuCraftyBoxes"))
			{
				((TMP_Text)component).text = string.Format(AzuAntiArthriticCraftingPlugin.RequirementTextFormatting.Value, availableItems, num);
				if (availableItems < num)
				{
					((Graphic)component).color = (((double)Mathf.Sin(Time.time * 10f) > 0.0) ? Color.red : Color.white);
				}
				else
				{
					((Graphic)component).color = Color.white;
				}
			}
		}

		public static int GetAvailableItems(string itemName)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return 0;
			}
			int num = 0;
			if (AzuAntiArthriticCraftingPlugin.CfcLoaded)
			{
				num = GetItemsInCloseContainers(itemName);
			}
			return ((Humanoid)localPlayer).GetInventory().CountItems(itemName, -1, true) + num;
		}

		public static int GetItemsInCloseContainers(string itemName)
		{
			//IL_002d: 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)
			int num = 0;
			if (CFCPlugin.IsLoaded() && CFCPlugin.ModEnabled().Value)
			{
				num += BepInExPlugin.GetNearbyContainers(((Component)Player.m_localPlayer).transform.position).Sum([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (Container c) => c.GetInventory().CountItems(itemName, -1, true));
			}
			if (CraftyBoxesPlugin.IsLoaded() && CraftyBoxesPlugin.ModEnabled().Value)
			{
				num += CraftyBoxes.GetNearbyContainers(((Component)Player.m_localPlayer).transform.position).Sum([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (Container c) => c.GetInventory().CountItems(itemName, -1, true));
			}
			if (TillValhallaPlugin.IsLoaded() && TillValhallaPlugin.CFCEnabled().Value && TillValhallaPlugin.GetCraftingRange().Value > 0)
			{
				num += TillValhalla.GetNearbyChests(((Component)Player.m_localPlayer).gameObject, Math.Min(50, Math.Max(1, TillValhallaPlugin.GetCraftingRange().Value))).Sum([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (Container c) => c.GetInventory().CountItems(itemName, -1, true));
			}
			return num;
		}

		public static void CreatePaginator(InventoryGui inventoryGui)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: 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_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Expected O, but got Unknown
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Expected O, but got Unknown
			GameObject val2 = null;
			GameObject val3 = null;
			GameObject val4 = null;
			if (Auga.API.IsLoaded())
			{
				val2 = GameObject.Find("_GameMain/LoadingGUI/PixelFix/IngameGui/Inventory_screen/root/RightPanel/TabContent/TabContent_Crafting/RightColumn/CraftButton");
				val3 = GameObject.Find("_GameMain/LoadingGUI/PixelFix/IngameGui/Inventory_screen/root/RightPanel/TabContent/TabContent_Crafting");
				val4 = GameObject.Find("_GameMain/LoadingGUI/PixelFix/IngameGui/AugaTextInput(Clone)/panel/TextField");
				if ((Object)(object)val2 == (Object)null)
				{
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogWarning((object)"augaCraftButton is null");
				}
				if ((Object)(object)val3 == (Object)null)
				{
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogWarning((object)"augaCrafting is null");
				}
				if ((Object)(object)val4 == (Object)null)
				{
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogWarning((object)"textInput is null");
				}
			}
			PaginatorPatches.CraftingWindowPaginator = Object.Instantiate<GameObject>(AzuAntiArthriticCraftingPlugin.Asset.LoadAsset<GameObject>("Pagination"), Auga.API.IsLoaded() ? val3.transform : ((Component)inventoryGui.m_crafting).transform);
			((Transform)PaginatorPatches.CraftingWindowPaginator.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(Auga.API.IsLoaded() ? new Vector2(-185f, 360f) : new Vector2(-200f, -35f));
			if (!Auga.API.IsLoaded())
			{
				((Transform)((Component)inventoryGui.m_craftingStationName).GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(new Vector2(-412f, -35f));
			}
			PaginatorPatches.CraftingWindowInputField = PaginatorPatches.CraftingWindowPaginator.GetComponentInChildren<TMP_InputField>();
			if (Auga.API.IsLoaded())
			{
				((Component)PaginatorPatches.CraftingWindowInputField).gameObject.GetComponent<Image>().sprite = ((val4 != null) ? val4.GetComponent<Image>().sprite : null);
			}
			PaginatorPatches.CraftingWindowInputField.fontAsset = (((Object)(object)val2 == (Object)null) ? ((TMP_Text)((Component)((Component)inventoryGui.m_craftButton).transform.Find("Text")).GetComponentInChildren<TextMeshProUGUI>()).font : TMP_FontAsset.CreateFontAsset(((Component)val4.transform.Find("Placeholder")).GetComponent<Text>().font));
			((UnityEvent<string>)(object)PaginatorPatches.CraftingWindowInputField.onValueChanged).AddListener((UnityAction<string>)([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (string val) =>
			{
				if (InventoryGui.instance.m_animator.GetBool(PaginatorPatches.Visible))
				{
					PaginatorPatches.CraftingWindowPage = 1;
					inventoryGui.UpdateCraftingPanel(false);
				}
			}));
			PaginatorPatches.MaxPageText = ((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Page")).GetComponent<TextMeshProUGUI>();
			RectTransform component = ((Component)PaginatorPatches.MaxPageText).GetComponent<RectTransform>();
			((Transform)component).localPosition = ((Transform)component).localPosition + new Vector3(0f, -53.9f, 0f);
			((TMP_Text)PaginatorPatches.MaxPageText).transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
			((TMP_Text)PaginatorPatches.MaxPageText).font = (((Object)(object)val2 == (Object)null) ? ((TMP_Text)((Component)((Component)inventoryGui.m_craftButton).transform.Find("Text")).GetComponentInChildren<TextMeshProUGUI>()).font : ((TMP_Text)((Component)val2.transform.Find("Label")).GetComponentInChildren<TextMeshProUGUI>()).font);
			((Behaviour)((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Right")).GetComponent<Image>()).enabled = !Auga.API.IsLoaded();
			((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Right")).GetComponent<Image>().sprite = (((Object)(object)val2 == (Object)null) ? ((Component)inventoryGui.m_craftButton).GetComponent<Image>().sprite : val2.GetComponentInChildren<Image>().sprite);
			((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Right")).GetComponent<Image>().type = (Type)2;
			((Behaviour)((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Left")).GetComponent<Image>()).enabled = !Auga.API.IsLoaded();
			((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Left")).GetComponent<Image>().sprite = (((Object)(object)val2 == (Object)null) ? ((Component)inventoryGui.m_craftButton).GetComponent<Image>().sprite : null);
			((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Left")).GetComponent<Image>().type = (Type)2;
			((Component)Utils.FindChild(PaginatorPatches.CraftingWindowPaginator.transform.Find("Right"), "MinimalUI", (IterativeSearchType)0)).gameObject.SetActive(!Auga.API.IsLoaded());
			((Component)Utils.FindChild(PaginatorPatches.CraftingWindowPaginator.transform.Find("Left"), "MinimalUI", (IterativeSearchType)0)).gameObject.SetActive(!Auga.API.IsLoaded());
			((UnityEvent)((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Right")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				int num = (PaginatorPatches.InventoryGuiUpdateRecipeListPatch.RecipesCount - 1) / (Auga.API.IsLoaded() ? 20 : 16) + 1;
				if (PaginatorPatches.CraftingWindowPage < num)
				{
					PaginatorPatches.CraftingWindowPage++;
					inventoryGui.UpdateCraftingPanel(false);
				}
			});
			((UnityEvent)((Component)PaginatorPatches.CraftingWindowPaginator.transform.Find("Left")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				if (PaginatorPatches.CraftingWindowPage > 1)
				{
					PaginatorPatches.CraftingWindowPage--;
					inventoryGui.UpdateCraftingPanel(false);
				}
			});
		}

		internal static Vector2 StringToVector2(string s)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(s))
			{
				throw new ArgumentException("AAA_Crafting Recipe Tracker Position Input string is null or empty.");
			}
			string[] array = s.Substring(1, s.Length - 2).Split(new char[1] { ',' });
			if (array.Length != 2)
			{
				throw new FormatException("AAA_Crafting Recipe Tracker Position Input string was not in a correct format.");
			}
			return new Vector2(float.Parse(array[0]), float.Parse(array[1]));
		}
	}
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	public class RequirementInformation
	{
		public string name;

		public int RequiredAmount;

		public RequirementInformation(int reqAmount, string itemName)
		{
			RequiredAmount = reqAmount;
			name = itemName;
		}
	}
}
namespace AzuAntiArthriticCrafting.RecipeTracking
{
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	public class ButtonCreator
	{
		private static RecipeTrackerUI _recipeTrackerUI;

		public static GameObject AddButton;

		public static GameObject RemoveButton;

		public ButtonCreator(RecipeTrackerUI trackerUI)
		{
			_recipeTrackerUI = trackerUI;
		}

		public static void CreateButtons(InventoryGui __instance, Transform iconTransform, RectTransform iconRectTransform, out GameObject addButton, out GameObject removeButton)
		{
			addButton = AddPlusButton(__instance, iconTransform, iconRectTransform);
			removeButton = AddMinusButton(__instance, iconTransform, iconRectTransform);
		}

		public static GameObject AddPlusButton(InventoryGui __instance, Transform iconTransform, RectTransform iconRectTransform)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			AddButton = Object.Instantiate<GameObject>(((Component)__instance.m_craftButton).gameObject, iconTransform);
			((Object)AddButton).name = "AddToRecipeTracker";
			SetupButton(AddButton, iconRectTransform, "+", (UnityAction)delegate
			{
				if ((Object)(object)__instance.m_selectedRecipe.Key != (Object)null)
				{
					_recipeTrackerUI.AddSelectedRecipe(__instance.m_selectedRecipe.Key);
				}
			});
			return AddButton;
		}

		public static GameObject AddMinusButton(InventoryGui __instance, Transform iconTransform, RectTransform iconRectTransform)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			RemoveButton = Object.Instantiate<GameObject>(((Component)__instance.m_craftButton).gameObject, iconTransform);
			((Object)RemoveButton).name = "RemoveFromRecipeTracker";
			SetupButton(RemoveButton, iconRectTransform, "-", (UnityAction)delegate
			{
				if ((Object)(object)__instance.m_selectedRecipe.Key != (Object)null)
				{
					_recipeTrackerUI.RemoveSelectedRecipe(__instance.m_selectedRecipe.Key);
				}
			});
			return RemoveButton;
		}

		public static GameObject AddMinusButtonForUI(InventoryGui __instance, Recipe recipe, Transform iconTransform, RectTransform iconRectTransform)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			GameObject obj = Object.Instantiate<GameObject>(((Component)__instance.m_craftButton).gameObject, iconTransform);
			((Object)obj).name = recipe.m_item.m_itemData.m_shared.m_name + "_RemoveFromRecipeTracker";
			Button val = default(Button);
			if (obj.TryGetComponent<Button>(ref val) && !((Selectable)val).interactable)
			{
				((Selectable)val).interactable = true;
			}
			SetupButton(obj, iconRectTransform, "-", (UnityAction)delegate
			{
				if ((Object)(object)recipe != (Object)null)
				{
					RecipeTrackerUI.Instance.RemoveSelectedRecipe(recipe);
				}
			});
			return obj;
		}

		private static void SetupButton(GameObject button, RectTransform iconRectTransform, string buttonText, UnityAction action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			RectTransform component = button.GetComponent<RectTransform>();
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = iconRectTransform.sizeDelta;
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			Button component2 = button.GetComponent<Button>();
			component2.onClick = new ButtonClickedEvent();
			((UnityEvent)component2.onClick).AddListener(action);
			TextMeshProUGUI componentInChildren = button.GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).text = buttonText;
			}
			button.SetActive(false);
		}

		public static void CreateHoverEventHandler(Image recipeIcon, GameObject addButton, GameObject removeButton)
		{
			//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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_005e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			EventTrigger obj = ((Component)recipeIcon).gameObject.GetComponent<EventTrigger>() ?? ((Component)recipeIcon).gameObject.AddComponent<EventTrigger>();
			Entry val = new Entry
			{
				eventID = (EventTriggerType)0
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (BaseEventData data) =>
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				if (!AzuAntiArthriticCraftingPlugin.MinusKeybind.Value.IsKeyHeld())
				{
					addButton.SetActive(true);
				}
				else
				{
					removeButton.SetActive(true);
				}
			}));
			obj.triggers.Add(val);
			Entry val2 = new Entry
			{
				eventID = (EventTriggerType)1
			};
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (BaseEventData data) =>
			{
				addButton.SetActive(false);
				removeButton.SetActive(false);
			}));
			obj.triggers.Add(val2);
		}

		public static void CreateHoverEventHandlerForUI(Image recipeIcon, GameObject removeButton)
		{
			//IL_0027: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0057: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			EventTrigger obj = ((Component)recipeIcon).gameObject.GetComponent<EventTrigger>() ?? ((Component)recipeIcon).gameObject.AddComponent<EventTrigger>();
			Entry val = new Entry
			{
				eventID = (EventTriggerType)0
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (BaseEventData data) =>
			{
				removeButton.SetActive(true);
			}));
			obj.triggers.Add(val);
			Entry val2 = new Entry
			{
				eventID = (EventTriggerType)1
			};
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (BaseEventData data) =>
			{
				removeButton.SetActive(false);
			}));
			obj.triggers.Add(val2);
		}
	}
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	public class RecipeTrackerUI : MonoBehaviour
	{
		public readonly List<RecipeUI> RecipeUIs = new List<RecipeUI>();

		[Header("RecipeUIRoot")]
		public GameObject recipeUIRoot;

		public Canvas recipeUIPrefab;

		public GameObject recipeUIPanel;

		public RectTransform recipeUIPanelRect;

		[Header("Header")]
		public GameObject header;

		public Image headerBraidImage;

		public Image headerImage;

		public Image headerGlow;

		public TMP_Text headerText;

		[Header("Content")]
		public GameObject recipesContainer;

		public VerticalLayoutGroup recipesContainerLayoutGroup;

		public RectTransform recipesContainerRect;

		[Header("RecipeStub")]
		public GameObject recipeStub;

		public VerticalLayoutGroup recipeStubLayoutGroup;

		public GameObject recipeStubHeader;

		public HorizontalLayoutGroup recipeStubHeaderLayoutGroup;

		public Image recipeStubRecipeImage;

		public TMP_Text recipeStubNameText;

		public GameObject recipeReqContainerStub;

		public VerticalLayoutGroup recipeReqContainerStubLayoutGroup;

		public ContentSizeFitter recipeReqContainerStubCsf;

		public GameObject recipeRequirementStub;

		public TMP_Text recipeRequirementStubText;

		public static RecipeTrackerUI Instance { get; private set; }

		private void Awake()
		{
			//IL_0052: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			((Component)this).gameObject.AddComponent<Localize>();
			Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(UpdateAllRecipes));
			((MonoBehaviour)this).InvokeRepeating("CheckNearbyMonsters", 0f, 5f);
			((Graphic)headerGlow).color = AzuAntiArthriticCraftingPlugin.HeaderGlowColor.Value;
			((Graphic)headerBraidImage).color = AzuAntiArthriticCraftingPlugin.HeaderBraidColor.Value;
			((Graphic)recipesContainer.GetComponent<Image>()).color = AzuAntiArthriticCraftingPlugin.RecipeContainerBackgroundColor.Value;
			((Transform)recipeUIPanelRect).localScale = Vector2.op_Implicit(new Vector2(AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelScale.Value.x, AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelScale.Value.y));
		}

		private void OnDestroy()
		{
			Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(UpdateAllRecipes));
		}

		private void Update()
		{
			if (RecipeUIs.Count <= 0)
			{
				AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.SetActive(false);
			}
		}

		private void CheckNearbyMonsters()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			bool flag = true;
			List<Character> list = new List<Character>();
			Character.GetCharactersInRange(((Component)localPlayer).transform.position, 30f, list);
			foreach (Character item in from character in list
				where (Object)(object)character != (Object)null && Object.op_Implicit((Object)(object)((Component)character).GetComponent<MonsterAI>())
				where ((BaseAI)((Component)character).GetComponent<MonsterAI>()).IsAlerted()
				select character)
			{
				_ = item;
				flag = false;
			}
			if (!flag)
			{
				AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.SetActive(false);
			}
			else if (RecipeUIs.Count > 0)
			{
				AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.SetActive(true);
			}
		}

		public IEnumerable<Recipe> GetAllRecipes()
		{
			foreach (RecipeUI recipeUI in RecipeUIs)
			{
				yield return recipeUI.Recipe;
			}
		}

		public void AddSelectedRecipe(Recipe recipe)
		{
			if ((Object)(object)AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab == (Object)null)
			{
				return;
			}
			AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.SetActive(true);
			((Component)HudAwakePatch.RecipeTrackerUI).gameObject.SetActive(true);
			if (RecipeUIs.Exists((RecipeUI r) => (Object)(object)r.Recipe == (Object)(object)recipe))
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Recipe is already being tracked.");
				return;
			}
			RecipeUI recipeUI = null;
			try
			{
				recipeUI = CreateRecipePanel(recipe);
				GameObject removeButton = ButtonCreator.AddMinusButtonForUI(InventoryGui.instance, recipe, ((Component)recipeUI.recipeStubRecipeImage).transform, ((Component)recipeUI.recipeStubRecipeImage).GetComponent<RectTransform>());
				ButtonCreator.CreateHoverEventHandlerForUI(recipeUI.recipeStubRecipeImage, removeButton);
			}
			catch (Exception ex)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)("Error creating recipe panel: " + ex.Message));
			}
			if (!((Object)(object)recipeUI == (Object)null))
			{
				RecipeUIs.Add(recipeUI);
				Requirement[] resources = recipe.m_resources;
				foreach (Requirement val in resources)
				{
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Updating requirement: " + val.m_resItem.m_itemData.m_shared.m_name);
					recipeUI.UpdateRequirement(val, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(val.m_resItem.m_itemData.m_shared.m_name, -1, true), recipeUI);
				}
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Added recipe: " + Localization.instance.Localize(recipe.m_item.m_itemData.m_shared.m_name) + " [" + recipe.m_item.m_itemData.m_shared.m_name + "]");
			}
		}

		public void RemoveSelectedRecipe(Recipe recipe)
		{
			RecipeUI recipeUI = RecipeUIs.Find((RecipeUI r) => (Object)(object)r.Recipe == (Object)(object)recipe);
			if ((Object)(object)recipeUI != (Object)null)
			{
				Requirement[] resources = recipe.m_resources;
				foreach (Requirement val in resources)
				{
					recipeUI.UpdateRequirement(val, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(val.m_resItem.m_itemData.m_shared.m_name, -1, true), recipeUI);
				}
				Object.Destroy((Object)(object)recipeUI.recipeStub);
				RecipeUIs.Remove(recipeUI);
			}
		}

		[return: <05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
		private RecipeUI CreateRecipePanel(Recipe recipe)
		{
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)recipe == (Object)null)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"Recipe is null in CreateRecipePanel");
				return null;
			}
			if ((Object)(object)recipeStub == (Object)null)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"recipeStub is null in CreateRecipePanel");
				return null;
			}
			if ((Object)(object)recipesContainer == (Object)null)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"recipesContainer is null in CreateRecipePanel");
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(recipeStub, recipesContainer.transform);
			if ((Object)(object)val == (Object)null)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"Failed to instantiate recipeStub in CreateRecipePanel");
				return null;
			}
			((Object)val).name = recipe.m_item.m_itemData.m_shared.m_name + "_RecipeStub";
			RecipeUI component = val.GetComponent<RecipeUI>();
			if ((Object)(object)component == (Object)null)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"Failed to get RecipeUI component in CreateRecipePanel");
				return null;
			}
			component.Recipe = recipe;
			component.RecipeMultiplier = ((InventoryGuiShowCraftingPanelPatch.CurrentCraftAmount <= 1) ? 1 : InventoryGuiShowCraftingPanelPatch.CurrentCraftAmount);
			component.recipeStubRecipeImage.sprite = recipe.m_item.m_itemData.m_shared.m_icons[0];
			((Object)component.recipeStubNameText).name = recipe.m_item.m_itemData.m_shared.m_name + "_RecipeNameText";
			string text = ((component.RecipeMultiplier > 1) ? $" x{component.RecipeMultiplier}" : "");
			component.recipeStubNameText.text = Localization.instance.Localize(recipe.m_item.m_itemData.m_shared.m_name) + text;
			((Object)component.recipeReqContainerStub).name = recipe.m_item.m_itemData.m_shared.m_name + "_RequirementsContainer";
			try
			{
				foreach (Requirement item in recipe.m_resources.Where([<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(0)] (Requirement r) => r.m_amount > 0))
				{
					if (item == null)
					{
						AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"Requirement is null");
						continue;
					}
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug($"Requirement: {((Object)item.m_resItem).name} {item.m_amount}");
					GameObject val2 = Object.Instantiate<GameObject>(recipeRequirementStub, component.recipeReqContainerStub.transform);
					((Object)val2).name = item.m_resItem.m_itemData.m_shared.m_name + "_Text";
					TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
					int num = ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(item.m_resItem.m_itemData.m_shared.m_name, -1, true);
					bool num2 = num >= item.m_amount * component.RecipeMultiplier;
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug($"CurrentAmount: {num} RequirementAmount: {item.m_amount} Multiplier: {component.RecipeMultiplier}");
					Color val3 = (num2 ? Color.green : Color.red);
					string text2 = (num2 ? "✓ " : "");
					string text3 = ColorUtility.ToHtmlStringRGBA(val3);
					string text4 = ColorUtility.ToHtmlStringRGBA(((Graphic)((Component)InventoryGui.instance.m_craftButton).GetComponentInChildren<TextMeshProUGUI>()).color);
					((TMP_Text)component2).text = $"<color=#{text4}>{text2}{Localization.instance.Localize(item.m_resItem.m_itemData.m_shared.m_name)}</color> <color=#{text3}>({num}/{item.m_amount * component.RecipeMultiplier})</color>";
					try
					{
						component.RequirementTexts.Add(item, component2);
					}
					catch (ArgumentException)
					{
						AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"Couldn't add requirement text to dictionary");
					}
					val2.SetActive(true);
				}
			}
			catch (Exception ex2)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)("Error creating requirements: " + ex2.Message));
			}
			if ((Object)(object)val == (Object)null)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"RecipePanel is null");
			}
			else
			{
				val.SetActive(true);
			}
			return component;
		}

		public void UpdateAllRecipes()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_005e: 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)
			((Graphic)headerGlow).color = AzuAntiArthriticCraftingPlugin.HeaderGlowColor.Value;
			((Graphic)headerBraidImage).color = AzuAntiArthriticCraftingPlugin.HeaderBraidColor.Value;
			((Graphic)recipesContainer.GetComponent<Image>()).color = AzuAntiArthriticCraftingPlugin.RecipeContainerBackgroundColor.Value;
			((Transform)recipeUIPanelRect).localScale = Vector2.op_Implicit(new Vector2(AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelScale.Value.x, AzuAntiArthriticCraftingPlugin.RecipeTrackerPanelScale.Value.y));
			foreach (RecipeUI recipeUI in RecipeUIs)
			{
				Requirement[] resources = recipeUI.Recipe.m_resources;
				foreach (Requirement val in resources)
				{
					recipeUI.UpdateRequirement(val, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(val.m_resItem.m_itemData.m_shared.m_name, -1, true), recipeUI);
				}
			}
		}
	}
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	public class RecipeUI : MonoBehaviour
	{
		public Dictionary<Requirement, TextMeshProUGUI> RequirementTexts = new Dictionary<Requirement, TextMeshProUGUI>();

		public static RecipeUI Instance;

		public GameObject recipeStub;

		public VerticalLayoutGroup recipeStubLayoutGroup;

		public GameObject recipeStubHeader;

		public HorizontalLayoutGroup recipeStubHeaderLayoutGroup;

		public Image recipeStubRecipeImage;

		public TMP_Text recipeStubNameText;

		public GameObject recipeReqContainerStub;

		public VerticalLayoutGroup recipeReqContainerStubLayoutGroup;

		public ContentSizeFitter recipeReqContainerStubCsf;

		public GameObject recipeRequirementStub;

		public TMP_Text recipeRequirementStubText;

		public Recipe Recipe { get; set; }

		public int RecipeMultiplier { get; set; }

		private void Awake()
		{
			Instance = this;
		}

		public void UpdateRequirement(Requirement requirement, int currentAmount, RecipeUI recipeUI = null)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)recipeUI == (Object)null)
			{
				recipeUI = this;
			}
			recipeStubNameText.fontSizeMin = AzuAntiArthriticCraftingPlugin.RecipeTrackerItemNameMin.Value;
			recipeStubNameText.fontSizeMax = AzuAntiArthriticCraftingPlugin.RecipeTrackerItemNameMax.Value;
			string text = ((recipeUI.RecipeMultiplier > 1) ? $" x{recipeUI.RecipeMultiplier}" : "");
			recipeStubNameText.text = "<color=#" + ColorUtility.ToHtmlStringRGBA(AzuAntiArthriticCraftingPlugin.ItemNameColor.Value) + ">" + Localization.instance.Localize(Recipe.m_item.m_itemData.m_shared.m_name) + text + "</color>";
			if (RequirementTexts.TryGetValue(requirement, out var value))
			{
				((TMP_Text)value).fontSizeMin = AzuAntiArthriticCraftingPlugin.RecipeTrackerReqNameMin.Value;
				((TMP_Text)value).fontSizeMax = AzuAntiArthriticCraftingPlugin.RecipeTrackerReqNameMax.Value;
				bool flag = currentAmount >= requirement.m_amount * recipeUI.RecipeMultiplier;
				((TMP_Text)value).text = (flag ? $"<color=#{ColorUtility.ToHtmlStringRGBA(AzuAntiArthriticCraftingPlugin.RecipeNameColorComplete.Value)}>{Localization.instance.Localize(requirement.m_resItem.m_itemData.m_shared.m_name)}</color> <color=#{ColorUtility.ToHtmlStringRGBA(AzuAntiArthriticCraftingPlugin.RecipeCompleteColor.Value)}>({currentAmount}/{requirement.m_amount * recipeUI.RecipeMultiplier})</color>" : $"<color=#{ColorUtility.ToHtmlStringRGBA(AzuAntiArthriticCraftingPlugin.RecipeNameColorInComplete.Value)}>{Localization.instance.Localize(requirement.m_resItem.m_itemData.m_shared.m_name)}</color> <color=#{ColorUtility.ToHtmlStringRGBA(AzuAntiArthriticCraftingPlugin.RecipeIncompleteLeftColor.Value)}>({currentAmount}/</color><color=#{ColorUtility.ToHtmlStringRGBA(AzuAntiArthriticCraftingPlugin.RecipeIncompleteRightColor.Value)}>{requirement.m_amount * recipeUI.RecipeMultiplier})</color>");
			}
		}
	}
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[HarmonyPatch(typeof(Hud), "Awake")]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	internal static class HudAwakePatch
	{
		internal static RecipeTrackerUI RecipeTrackerUI;

		private static void Postfix(Hud __instance)
		{
			if (!((Object)(object)AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab == (Object)null))
			{
				AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.transform.SetParent(__instance.m_rootObject.transform, false);
				RecipeTrackerUI = ((Component)Utils.FindChild(AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.transform, "RecipeTrackerPanel", (IterativeSearchType)0)).GetComponent<RecipeTrackerUI>();
				DragWindowCntrl.ApplyDragWindowCntrl(((Component)RecipeTrackerUI).gameObject);
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Awake")]
	internal static class InventoryGuiAwakePatch
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(InventoryGui __instance)
		{
			Transform transform = ((Component)__instance.m_recipeIcon).transform;
			RectTransform component = ((Component)transform).GetComponent<RectTransform>();
			ButtonCreator.CreateButtons(__instance, transform, component, out var addButton, out var removeButton);
			ButtonCreator.CreateHoverEventHandler(__instance.m_recipeIcon, addButton, removeButton);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "SetRecipe")]
	internal static class InventoryGuiSetRecipePatch
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(InventoryGui __instance)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			if ((Object)(object)HudAwakePatch.RecipeTrackerUI == (Object)null || (Object)(object)ButtonCreator.AddButton == (Object)null || (Object)(object)ButtonCreator.RemoveButton == (Object)null)
			{
				return;
			}
			Button component = ButtonCreator.AddButton.GetComponent<Button>();
			Button component2 = ButtonCreator.RemoveButton.GetComponent<Button>();
			if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
			{
				return;
			}
			if ((Object)(object)__instance.m_selectedRecipe.Key == (Object)null)
			{
				((UnityEventBase)component.onClick).RemoveAllListeners();
				((UnityEventBase)component2.onClick).RemoveAllListeners();
				return;
			}
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				HudAwakePatch.RecipeTrackerUI.AddSelectedRecipe(__instance.m_selectedRecipe.Key);
			});
			((UnityEventBase)component2.onClick).RemoveAllListeners();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				HudAwakePatch.RecipeTrackerUI.RemoveSelectedRecipe(__instance.m_selectedRecipe.Key);
			});
		}
	}
	[HarmonyPatch(typeof(Humanoid), "DropItem")]
	internal static class HumanoidDropItemPatch
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(Humanoid __instance, ItemData item, int amount, ref bool __result)
		{
			if (!__result || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)HudAwakePatch.RecipeTrackerUI == (Object)null || !((Character)__instance).IsPlayer() || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Player dropped an item");
			foreach (RecipeUI allRecipeUI in RecipeTrackerUI.Instance.RecipeUIs)
			{
				if (allRecipeUI.Recipe.m_resources.Any((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == item.m_shared.m_name))
				{
					allRecipeUI.Recipe.m_resources.Where((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == item.m_shared.m_name).ToList().ForEach(delegate(Requirement r)
					{
						allRecipeUI.UpdateRequirement(r, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(item.m_shared.m_name, -1, true), allRecipeUI);
					});
				}
			}
		}
	}
	[HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })]
	internal static class InventoryAddItemPatch
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(Inventory __instance, ItemData item, ref bool __result)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || __instance.m_inventory != ((Humanoid)Player.m_localPlayer).GetInventory().m_inventory || !__result)
			{
				return;
			}
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Item name is " + item.m_shared.m_name + ".");
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Adding " + item.m_shared.m_name + " to tracker");
			foreach (RecipeUI allRecipeUI in RecipeTrackerUI.Instance.RecipeUIs)
			{
				if (allRecipeUI.Recipe.m_resources.Any((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == item.m_shared.m_name))
				{
					allRecipeUI.Recipe.m_resources.Where((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == item.m_shared.m_name).ToList().ForEach(delegate(Requirement r)
					{
						allRecipeUI.UpdateRequirement(r, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(item.m_shared.m_name, -1, true), allRecipeUI);
					});
				}
			}
		}
	}
	[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
	{
		typeof(ItemData),
		typeof(int),
		typeof(int),
		typeof(int)
	})]
	internal static class InventoryAddItemPatchDataIntIntInt
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(Inventory __instance, ItemData item, int amount, int x, int y, ref bool __result)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || __instance.m_inventory != ((Humanoid)Player.m_localPlayer).GetInventory().m_inventory || !__result)
			{
				return;
			}
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Item name is " + item.m_shared.m_name + ".");
			foreach (RecipeUI allRecipeUI in RecipeTrackerUI.Instance.RecipeUIs)
			{
				if (allRecipeUI.Recipe.m_resources.Any((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == item.m_shared.m_name))
				{
					allRecipeUI.Recipe.m_resources.Where((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == item.m_shared.m_name).ToList().ForEach(delegate(Requirement r)
					{
						allRecipeUI.UpdateRequirement(r, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(item.m_shared.m_name, -1, true), allRecipeUI);
					});
				}
			}
		}
	}
	[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
	{
		typeof(string),
		typeof(int),
		typeof(int),
		typeof(int),
		typeof(long),
		typeof(string),
		typeof(bool)
	})]
	internal static class InventoryAddItemPatchStringIntIntIntLongStringBool
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(Inventory __instance, string name, int stack, int quality, int variant, long crafterID, string crafterName, ref ItemData __result, bool pickedUp = false)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null || __instance.m_inventory != ((Humanoid)Player.m_localPlayer).GetInventory().m_inventory || __result == null)
			{
				return;
			}
			AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogIfBuildDebug("Result name is " + __result.m_shared.m_name);
			foreach (RecipeUI allRecipeUI in RecipeTrackerUI.Instance.RecipeUIs)
			{
				ItemData result = __result;
				if (allRecipeUI.Recipe.m_resources.Any((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == result.m_shared.m_name))
				{
					allRecipeUI.Recipe.m_resources.Where((Requirement r) => r.m_resItem.m_itemData.m_shared.m_name == result.m_shared.m_name).ToList().ForEach(delegate(Requirement r)
					{
						allRecipeUI.UpdateRequirement(r, ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(result.m_shared.m_name, -1, true), allRecipeUI);
					});
				}
			}
		}
	}
	[HarmonyPatch(typeof(Minimap), "SetMapMode")]
	internal static class MinimapSetMapModePatch
	{
		[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
		private static void Postfix(Minimap __instance)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			if (!((Object)(object)HudAwakePatch.RecipeTrackerUI == (Object)null))
			{
				if ((int)__instance.m_mode == 2)
				{
					((Component)HudAwakePatch.RecipeTrackerUI).gameObject.SetActive(false);
				}
				else
				{
					((Component)HudAwakePatch.RecipeTrackerUI).gameObject.SetActive(RecipeTrackerUI.Instance.RecipeUIs.Count > 0);
				}
			}
		}
	}
}
namespace AzuAntiArthriticCrafting.Patches
{
	[<8e5c7dfa-2e8c-44cb-842d-fc77a2459604>NullableContext(1)]
	[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(0)]
	[HarmonyPatch(typeof(InventoryGui), "Awake")]
	[HarmonyAfter(new string[] { "randyknapp.mods.auga" })]
	public static class InventoryGuiShowCraftingPanelPatch
	{
		public static UnityEvent OnRecipeChange = new UnityEvent();

		public static int CurrentItemOrigCraftAmount = 0;

		public static int CurrentCraftAmount;

		public static int HeldCraftingAmount;

		internal static readonly Dictionary<string, RequirementInformation> CurrentRequirements = new Dictionary<string, RequirementInformation>();

		public static GameObject aacParent = null;

		public static TMP_InputField CraftAmountInputField = null;

		[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
		public static TextMeshProUGUI placeholderText = null;

		[<05e991e4-b7cc-41dd-b4b9-187b564228c5>Nullable(2)]
		public static TextMeshProUGUI textComponent = null;

		public static GameObject aaaCraftingArea = null;

		public static GameObject aacIncrementButton = null;

		public static GameObject aacDecrementButton = null;

		public static bool IsRecipeReady = false;

		public static bool WasCrafting;

		private static bool firstShow = true;

		internal static int WaitUpdates;

		[HarmonyPriority(0)]
		public static void Postfix(InventoryGui __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			GameObject val = null;
			val = ((!Auga.API.IsLoaded()) ? ((Component)__instance.m_craftButton).gameObject : GameObject.Find("_GameMain/LoadingGUI/PixelFix/IngameGui/Inventory_screen/root/RightPanel/TabContent/TabContent_Crafting/RightColumn/CraftButton"));
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (!Auga.API.IsLoaded())
			{
				RectTransform val2 = (RectTransform)val.transform.parent;
				if (!Object.op_Implicit((Object)(object)val2))
				{
					return;
				}
				((HorizontalOrVerticalLayoutGroup)((Component)val2).gameObject.AddComponent<HorizontalLayoutGroup>()).reverseArrangement = true;
			}
			if ((Object)(object)CraftAmountInputField == (Object)null)
			{
				CreateCraftingInputField(__instance);
			}
			CurrentCraftAmount = 1;
			OnRecipeChange.AddListener(new UnityAction(AzuAntiArthriticCrafting.Utilities.Utilities.ResetAacCrafting));
			((UnityEvent)val.GetComponent<Button>().onClick).AddListener(new UnityAction(AzuAntiArthriticCrafting.Utilities.Utilities.OnCraftButtonPressed));
			((UnityEvent)__instance.m_craftCancel