Decompiled source of AAA Crafting v1.5.8

AzuAntiArthriticCrafting.dll

Decompiled 3 weeks 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.Reflection.Emit;
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;
using AzuAntiArthriticCrafting.Compatibility.CraftFromContainers;
using AzuAntiArthriticCrafting.Compatibility.OdinsCraftyBoxes;
using AzuAntiArthriticCrafting.Compatibility.TillValhalla;
using AzuAntiArthriticCrafting.Patches;
using AzuAntiArthriticCrafting.RecipeTracking;
using AzuAntiArthriticCrafting.RecipeTracking.Favoriting;
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.5.8")]
[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.5.8.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<5be4dba9-e8bf-483f-9f7e-f9efc37a087c>Embedded]
	internal sealed class <5be4dba9-e8bf-483f-9f7e-f9efc37a087c>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<5be4dba9-e8bf-483f-9f7e-f9efc37a087c>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <143c8e00-5ca3-4f07-b27d-18b506ed291b>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <143c8e00-5ca3-4f07-b27d-18b506ed291b>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <143c8e00-5ca3-4f07-b27d-18b506ed291b>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<5be4dba9-e8bf-483f-9f7e-f9efc37a087c>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
public static class InventoryGui_DoCrafting_Patch
{
	public static bool callingDoCrafting = false;

	public static int cachedMaxSockets = 3;

	public static int cachedLimitNumberOfSockets = 0;

	public static int[] cachedSocketLimits;

	public static void Prefix(InventoryGui __instance, Player player)
	{
		callingDoCrafting = true;
	}
}
[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")]
internal static class InventoryGuiUpdateRecipePatch
{
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	private static void Postfix(InventoryGui __instance, Player player)
	{
		if (!InventoryGui_DoCrafting_Patch.callingDoCrafting)
		{
			return;
		}
		int num = HaveRequirementItemsTranspiler.GetCurrentCraftAmount() - 1;
		if (!__instance.InCraftTab() && !__instance.InUpradeTab() && Jewelcrafting.API.IsLoaded() && Jewelcrafting.API.IsLoaded())
		{
			Transform val = Utils.FindChild(((Component)__instance.m_tabUpgrade).transform.parent, "UPGRADE(Clone)", (IterativeSearchType)0);
			if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogDebug((object)"Upgrade tab is active, setting desired amount to respect socket limits.");
				num = 0;
			}
		}
		for (int i = 0; i < num; i++)
		{
			InventoryGui_DoCrafting_Patch.callingDoCrafting = false;
			__instance.DoCrafting(player);
		}
		InventoryGui_DoCrafting_Patch.callingDoCrafting = false;
	}
}
namespace LocalizationManager
{
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[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;

		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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, [<2a416125-2835-4f78-94bf-b7d1a49fc56c>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, [<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>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: <143c8e00-5ca3-4f07-b27d-18b506ed291b>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;
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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
{
	public class NoCostReqHandler : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler
	{
		private bool isHovering;

		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(1)]
		internal Requirement m_requirement;

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
		public void OnPointerEnter(PointerEventData eventData)
		{
			isHovering = true;
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
		public void OnPointerExit(PointerEventData eventData)
		{
			isHovering = false;
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 1 && isHovering)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null) && m_requirement != null && (localPlayer.NoCostCheat() || ZoneSystem.instance.GetGlobalKey((GlobalKeys)19)) && ZNet.instance.LocalPlayerIsAdminOrHost())
				{
					int num = m_requirement.m_amount * HaveRequirementItemsTranspiler.GetCurrentCraftAmount();
					Vector2i val = default(Vector2i);
					((Vector2i)(ref val))..ctor(-1, -1);
					long playerID = localPlayer.GetPlayerID();
					string playerName = localPlayer.GetPlayerName();
					((Humanoid)localPlayer).GetInventory().AddItem(((Object)((Component)m_requirement.m_resItem).gameObject).name, num, m_requirement.m_resItem.m_itemData.m_quality, m_requirement.m_resItem.m_itemData.m_variant, playerID, playerName, val, false);
				}
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Azumatt.AzuAntiArthriticCrafting", "AzuAntiArthriticCrafting", "1.5.8")]
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	public class AzuAntiArthriticCraftingPlugin : BaseUnityPlugin
	{
		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(2)]
			public string Category;

			[UsedImplicitly]
			[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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(", ", UnityInput.Current.SupportedKeyCodes);
			}
		}

		internal const string ModName = "AzuAntiArthriticCrafting";

		internal const string ModVersion = "1.5.8";

		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");

		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(2)]
		internal static AssetBundle Asset;

		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(2)]
		internal static AssetBundle Asset2;

		public static readonly ManualLogSource AntiArthriticCraftingLogger;

		private static readonly ConfigSync ConfigSync;

		public static GameObject RecipeTrackerUIPrefab;

		public static BaseUnityPlugin RandyInstance;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<Toggle> ResetCraftingValueOnRecChange;

		public static ConfigEntry<Toggle> KGPaginator;

		public static ConfigEntry<Toggle> FavoritesToggleButton;

		public static ConfigEntry<Toggle> FavoritesStars;

		public static ConfigEntry<Toggle> OverrideCraftingDuration;

		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<KeyboardShortcut> ToggleUIKeyBind;

		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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Expected O, but got Unknown
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Expected O, but got Unknown
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Expected O, but got Unknown
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Expected O, but got Unknown
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Expected O, but got Unknown
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Expected O, but got Unknown
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Expected O, but got Unknown
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Expected O, but got Unknown
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Expected O, but got Unknown
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Expected O, but got Unknown
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Expected O, but got Unknown
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Expected O, but got Unknown
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: 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 += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>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);
					}
				}
			};
			FavoritesToggleButton = config("1 - Crafting Tweaks", "Favorite Toggle Button", Toggle.On, "If enabled, the favorite toggle buttons will be enabled allowing you to have a buttons to toggle showing favorites in addition to the keybind. If disabled, the buttons will be disabled", synchronizedSetting: false);
			FavoritesStars = config("1 - Crafting Tweaks", "Favorite Stars", Toggle.On, "If enabled, the favorite stars will be enabled allowing you to favorite recipes. If disabled, the favorite stars will be disabled. Requires restart", synchronizedSetting: false);
			OverrideCraftingDuration = config("2 - Game", "Override Crafting Speed", Toggle.Off, new ConfigDescription("If enabled, the crafting speed will be overridden by the value set in Crafting Speed. If disabled, the crafting speed will be vanilla and multiplied by the amounts you wish to craft. Default is off.", (AcceptableValueBase)null, Array.Empty<object>()));
			CraftingDuration = config("2 - Game", "Crafting Speed", 2f, new ConfigDescription("Change the speed at which it takes to craft items. Override Crafting Speed option must be on for this to take effect. 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 += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>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 += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>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 when hovering recipe icons in the crafting menu. [Default: LeftControl]", synchronizedSetting: false);
			ToggleUIKeyBind = config<KeyboardShortcut>("4 - Keys", "Toggle RecipeUI", new KeyboardShortcut((KeyCode)304, (KeyCode[])(object)new KeyCode[1] { (KeyCode)280 }), "The key to toggle the RecipeUI. [Default: LeftShift + PageUp]", synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			RecipeTrackerPanelPosition.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			RecipeTrackerPanelScale.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerItemNameMin.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerItemNameMax.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerReqNameMin.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeTrackerReqNameMax.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			HeaderGlowColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			HeaderBraidColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeContainerBackgroundColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			ItemNameColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeNameColorComplete.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeNameColorInComplete.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeCompleteColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeIncompleteRightColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			RecipeIncompleteLeftColor.SettingChanged += [<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdateAllRecipesOnChange();
			};
			LoadAssets();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

		[return: <143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(2)]
		private static AssetBundle GetAssetBundleFromResources(string filename)
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				AntiArthriticCraftingLogger.LogIfBuildDebug("Checking for " + filename + "\nAvailable resources: " + string.Join(", ", manifestResourceNames));
				string text = manifestResourceNames.SingleOrDefault([<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (string str) => str.EndsWith(filename, StringComparison.OrdinalIgnoreCase));
				if (text == null)
				{
					AntiArthriticCraftingLogger.LogError((object)("Resource '" + filename + "' not found in embedded resources."));
					throw new InvalidOperationException("Resource '" + filename + "' not found.");
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				if (stream != null)
				{
					AntiArthriticCraftingLogger.LogIfBuildDebug("Successfully loaded resource: " + text);
					return AssetBundle.LoadFromStream(stream);
				}
				AntiArthriticCraftingLogger.LogError((object)("Failed to load asset bundle stream for resource: " + text));
				throw new InvalidOperationException("Failed to load asset bundle stream for resource: " + text);
			}
			catch (Exception ex)
			{
				AntiArthriticCraftingLogger.LogError((object)("Error loading AssetBundle '" + filename + "': " + ex.Message));
				throw;
			}
		}

		private static byte[] ReadEmbeddedFileBytes(string name)
		{
			try
			{
				using MemoryStream memoryStream = new MemoryStream();
				string name2 = Assembly.GetExecutingAssembly().GetName().Name + "." + name;
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name2);
				if (stream == null)
				{
					AntiArthriticCraftingLogger.LogError((object)("Embedded file '" + name + "' not found."));
					throw new InvalidOperationException("Embedded file '" + name + "' not found.");
				}
				stream.CopyTo(memoryStream);
				AntiArthriticCraftingLogger.LogIfBuildDebug("Successfully read embedded file: " + name);
				return memoryStream.ToArray();
			}
			catch (Exception ex)
			{
				AntiArthriticCraftingLogger.LogError((object)("Error reading embedded file '" + name + "': " + ex.Message));
				throw;
			}
		}

		internal static Sprite loadSprite(string name, bool isEmbed = false)
		{
			//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)
			Texture2D val = loadTexture(name, isEmbed);
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
		}

		internal static Texture2D loadTexture(string name, bool isEmbed = false)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			Texture2D val = new Texture2D(0, 0);
			if (isEmbed)
			{
				ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("assets." + name));
			}
			else
			{
				string directoryName = Path.GetDirectoryName(Paths.ConfigPath);
				if (directoryName == null)
				{
					return val;
				}
				List<string> list = Directory.GetFiles(directoryName, "AAA_favorite.png", SearchOption.AllDirectories).OrderBy(Path.GetFileName).ToList();
				try
				{
					byte[] array = File.ReadAllBytes(list.Find((string x) => x.Contains(name)));
					ImageConversion.LoadImage(val, array);
				}
				catch (Exception arg)
				{
					AntiArthriticCraftingLogger.LogWarning((object)$"The file {name} couldn't be found in the directory path {directoryName}. Please make sure you are naming the file AAA_favorite.png and it is located somewhere in the BepInEx/config folder.\n{arg}");
					val = null;
				}
			}
			return val;
		}

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

		public static void LoadAssets()
		{
			Asset = GetAssetBundleFromResources("paginator");
			Asset2 = GetAssetBundleFromResources("aaarecipetracker");
			if ((Object)(object)Asset2 != (Object)null)
			{
				GameObject val = Asset2.LoadAsset<GameObject>("AAARecipeTrackerUI");
				if ((Object)(object)val != (Object)null)
				{
					RecipeTrackerUIPrefab = Object.Instantiate<GameObject>(val);
					Object.DontDestroyOnLoad((Object)(object)RecipeTrackerUIPrefab);
					RecipeTrackerUIPrefab.SetActive(false);
					AssetBundle asset = Asset2;
					if (asset != null)
					{
						asset.Unload(false);
					}
				}
				else
				{
					AntiArthriticCraftingLogger.LogError((object)"Failed to load RecipeTrackerUI prefab");
				}
			}
			else
			{
				AntiArthriticCraftingLogger.LogError((object)"Failed to load Recipe Tracker bundle.");
			}
		}

		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("aedenthorn.CraftFromContainers", out var value2);
			Chainloader.PluginInfos.TryGetValue("com.odinplusqol.mod", out var value3);
			Chainloader.PluginInfos.TryGetValue("kwilson.TillValhalla", out var value4);
			Chainloader.PluginInfos.TryGetValue("randyknapp.mods.improvedbuildhud", out var value5);
			if (value != null && (Object)(object)value.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"AzuCraftyBoxes detected.");
				CfcLoaded = true;
			}
			if (value3 != null && (Object)(object)value3.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"OdinPlusQOL detected.");
				CfcLoaded = true;
			}
			if (value2 != null && (Object)(object)value2.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"CraftFromContainers detected.");
				CfcLoaded = true;
			}
			if (value4 != null && (Object)(object)value4.Instance != (Object)null)
			{
				AntiArthriticCraftingLogger.LogDebug((object)"TillValhalla detected.");
				CfcLoaded = true;
			}
			if (value5 != null && (Object)(object)value5.Instance != (Object)null)
			{
				RandyInstance = value5.Instance;
			}
		}

		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<[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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<[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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;
			Asset2 = null;
			AntiArthriticCraftingLogger = Logger.CreateLogSource("AzuAntiArthriticCrafting");
			ConfigSync = new ConfigSync("Azumatt.AzuAntiArthriticCrafting")
			{
				DisplayName = "AzuAntiArthriticCrafting",
				CurrentVersion = "1.5.8",
				MinimumRequiredVersion = "1.5.8"
			};
			RecipeTrackerUIPrefab = null;
			RandyInstance = null;
			_serverConfigLocked = null;
			ResetCraftingValueOnRecChange = null;
			KGPaginator = null;
			FavoritesToggleButton = null;
			FavoritesStars = null;
			OverrideCraftingDuration = null;
			CraftingDuration = null;
			RequirementTextFormatting = null;
			InputEnabledText = null;
			InputDisabledText = null;
			InputTextColor = null;
			MinusKeybind = null;
			ToggleUIKeyBind = 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;
		}
	}
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	public static class LoggingExtensions
	{
		public static void LogIfBuildDebug(this ManualLogSource logger, string message)
		{
		}

		public static void LogErrorIfBuildDebug(this ManualLogSource logger, string message)
		{
		}
	}
	public class ScrollableInputField : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(1)]
		public TMP_InputField inputField;

		private bool isHovering;

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

		private void Update()
		{
			InventoryGui.instance.m_multiCrafting = false;
			InventoryGui.instance.m_multiCraftAmount = 1;
			if (!isHovering)
			{
				return;
			}
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (axis != 0f)
			{
				int maxCraftAmount = GetMaxCraftAmount();
				int num = ((!Input.GetKey((KeyCode)304)) ? 1 : 10);
				bool key = Input.GetKey((KeyCode)306);
				if (key)
				{
					num = maxCraftAmount;
				}
				int num2 = (int)(Mathf.Sign(axis) * (float)num);
				if (!int.TryParse(inputField.text, out var result))
				{
					result = 1;
				}
				int num3 = result + num2;
				if (key)
				{
					num3 = Mathf.Clamp(num3, 1, maxCraftAmount - 1);
				}
				Recipe recipe = ((RecipeDataPair)(ref InventoryGui.instance.m_selectedRecipe)).Recipe;
				ItemData itemData = ((RecipeDataPair)(ref InventoryGui.instance.m_selectedRecipe)).ItemData;
				int num4 = ((itemData == null) ? 1 : (itemData.m_quality + 1));
				if ((Object)(object)recipe != (Object)null && Player.m_localPlayer.HaveRequirementItems(recipe, false, num4, 1))
				{
					((Selectable)InventoryGui.instance.m_craftButton).interactable = true;
				}
				inputField.text = Mathf.Max(1, num3).ToString();
			}
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
		public void OnPointerEnter(PointerEventData eventData)
		{
			isHovering = true;
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
		public void OnPointerExit(PointerEventData eventData)
		{
			isHovering = false;
		}

		private int GetMaxCraftAmount()
		{
			return CalculateMaxCraftAmount();
		}

		public static int CalculateMaxCraftAmount()
		{
			int num = 999;
			Recipe recipe = ((RecipeDataPair)(ref InventoryGui.instance.m_selectedRecipe)).Recipe;
			if ((Object)(object)recipe != (Object)null)
			{
				num = int.MaxValue;
				Requirement[] resources = recipe.m_resources;
				foreach (Requirement obj in resources)
				{
					int availableItems = AzuAntiArthriticCrafting.Utilities.Utilities.GetAvailableItems(obj.m_resItem.m_itemData.m_shared.m_name);
					int amount = obj.m_amount;
					if (amount > 0)
					{
						num = Mathf.Min(num, availableItems / amount);
					}
				}
			}
			return Mathf.Clamp(num, 1, 999);
		}
	}
}
namespace AzuAntiArthriticCrafting.Utilities
{
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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;
					AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogErrorIfBuildDebug("Mapped original name " + item + " [" + fileNameWithoutExtension + "] to " + ((Object)allLoadedAssetBundle).name);
				}
			}
		}

		internal static void MapBundlesToAssemblies()
		{
			List<Assembly> list = Chainloader.PluginInfos.Select([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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: <143c8e00-5ca3-4f07-b27d-18b506ed291b>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
	{
		[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(1)]
		private RectTransform _window;

		private Vector2 _delta;

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>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;
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>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;
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>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;
			}
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>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;
		}
	}
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	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 AddCompToRequirement(Transform elementRoot, Requirement requirement)
		{
			NoCostReqHandler component = ((Component)elementRoot).GetComponent<NoCostReqHandler>();
			if ((Object)(object)component == (Object)null)
			{
				component = ((Component)elementRoot).gameObject.AddComponent<NoCostReqHandler>();
				component.m_requirement = requirement;
			}
			else
			{
				component.m_requirement = requirement;
			}
		}

		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();
			}
		}

		[<2a416125-2835-4f78-94bf-b7d1a49fc56c>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()
		{
			if (InventoryGuiShowCraftingPanelPatch.CurrentCraftAmount <= 0)
			{
				InventoryGuiShowCraftingPanelPatch.CraftAmountInputField.text = "";
				CancelCrafting();
			}
			else
			{
				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 UpdateRequirementLabelsRandy(Transform elementRoot, Requirement req, int quality)
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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;
			ConfigEntry<string> val = default(ConfigEntry<string>);
			if (num <= 0)
			{
				InventoryGui.HideRequirement(elementRoot);
			}
			else if (!((Object)(object)AzuAntiArthriticCraftingPlugin.RandyInstance == (Object)null) && AzuAntiArthriticCraftingPlugin.RandyInstance.Config.TryGetEntry<string>("General", "Inventory Amount Format", ref val) && !string.IsNullOrWhiteSpace(val.Value))
			{
				string text = string.Format(val.Value, availableItems);
				ConfigEntry<string> val2 = default(ConfigEntry<string>);
				if (AzuAntiArthriticCraftingPlugin.RandyInstance.Config.TryGetEntry<string>("General", "Inventory Amount Color", ref val2) && !string.IsNullOrWhiteSpace(val2.Value))
				{
					text = "<color=" + val2.Value + ">" + text + "</color>";
				}
				((TMP_Text)component).text = $"{num} {text}";
				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([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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([<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (Container c) => c.GetInventory().CountItems(itemName, -1, true));
			}
			return num;
		}

		public static void CreatePaginator(InventoryGui inventoryGui)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Expected O, but got Unknown
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: 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");
				}
			}
			AssetBundle asset = AzuAntiArthriticCraftingPlugin.Asset;
			PaginatorPatches.CraftingWindowPaginator = Object.Instantiate<GameObject>((asset != null) ? asset.LoadAsset<GameObject>("Pagination") : null, Auga.API.IsLoaded() ? val3.transform : ((Component)inventoryGui.m_crafting).transform);
			if ((Object)(object)PaginatorPatches.CraftingWindowPaginator != (Object)null)
			{
				((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>)([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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);
					}
				});
			}
			else
			{
				AzuAntiArthriticCraftingPlugin.AntiArthriticCraftingLogger.LogError((object)"PaginatorPatches.CraftingWindowPaginator is null");
			}
		}

		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]));
		}
	}
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	public class RequirementInformation
	{
		public string name;

		public int RequiredAmount;

		public RequirementInformation(int reqAmount, string itemName)
		{
			RequiredAmount = reqAmount;
			name = itemName;
		}
	}
}
namespace AzuAntiArthriticCrafting.RecipeTracking
{
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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 void CreateButtons(Hud __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)((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe != (Object)null)
				{
					_recipeTrackerUI.AddSelectedRecipe(((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe);
				}
			});
			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)((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe != (Object)null)
				{
					_recipeTrackerUI.RemoveSelectedRecipe(((RecipeDataPair)(ref __instance.m_selectedRecipe)).Recipe);
				}
			});
			return RemoveButton;
		}

		public static GameObject AddPlusButton(Hud __instance, Transform iconTransform, RectTransform iconRectTransform)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			GameObject obj = Object.Instantiate<GameObject>(((Component)InventoryGui.instance.m_craftButton).gameObject, iconTransform);
			((Object)obj).name = "AddToRecipeTracker";
			SetupButton(obj, iconRectTransform, "+", (UnityAction)delegate
			{
				if ((Object)(object)__instance.m_hoveredPiece != (Object)null)
				{
					Recipe val = ScriptableObject.CreateInstance<Recipe>();
					val.m_item = __instance.m_hoveredPiece.m_resources[0].m_resItem;
					val.m_amount = 1;
					val.m_enabled = true;
					val.m_craftingStation = __instance.m_hoveredPiece.m_craftingStation;
					val.m_repairStation = __instance.m_hoveredPiece.m_craftingStation;
					val.m_minStationLevel = 1;
					val.m_requireOnlyOneIngredient = false;
					val.m_resources = __instance.m_hoveredPiece.m_resources;
					_recipeTrackerUI.AddSelectedRecipe(val);
				}
			});
			return obj;
		}

		public static GameObject AddMinusButton(Hud __instance, Transform iconTransform, RectTransform iconRectTransform)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			RemoveButton = Object.Instantiate<GameObject>(((Component)InventoryGui.instance.m_craftButton).gameObject, iconTransform);
			((Object)RemoveButton).name = "RemoveFromRecipeTracker";
			SetupButton(RemoveButton, iconRectTransform, "-", (UnityAction)delegate
			{
				_ = (Object)(object)__instance.m_hoveredPiece != (Object)null;
			});
			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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			RecipeButtonElement trigger = ((Component)recipeIcon).gameObject.GetComponent<RecipeButtonElement>() ?? ((Component)recipeIcon).gameObject.AddComponent<RecipeButtonElement>();
			Entry val = new Entry
			{
				eventID = (EventTriggerType)0
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)([<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (BaseEventData data) =>
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				trigger.hovering = true;
				if (!AzuAntiArthriticCraftingPlugin.MinusKeybind.Value.IsKeyHeld())
				{
					addButton.SetActive(true);
				}
				else
				{
					removeButton.SetActive(true);
				}
			}));
			((EventTrigger)trigger).triggers.Add(val);
			Entry val2 = new Entry
			{
				eventID = (EventTriggerType)1
			};
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)([<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (BaseEventData data) =>
			{
				trigger.hovering = false;
				addButton.SetActive(false);
				removeButton.SetActive(false);
			}));
			((EventTrigger)trigger).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>)([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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>)([<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(0)] (BaseEventData data) =>
			{
				removeButton.SetActive(false);
			}));
			obj.triggers.Add(val2);
		}
	}
	public class RecipeButtonElement : EventTrigger
	{
		public bool hovering;

		private void Update()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			if (hovering)
			{
				if (Input.GetKeyDown((KeyCode)306))
				{
					ExecuteEvents.Execute<IPointerExitHandler>(((Component)this).gameObject, (BaseEventData)new PointerEventData(EventSystem.current), ExecuteEvents.pointerExitHandler);
					ExecuteEvents.Execute<IPointerEnterHandler>(((Component)this).gameObject, (BaseEventData)new PointerEventData(EventSystem.current), ExecuteEvents.pointerEnterHandler);
				}
				else if (Input.GetKeyUp((KeyCode)306))
				{
					ExecuteEvents.Execute<IPointerExitHandler>(((Component)this).gameObject, (BaseEventData)new PointerEventData(EventSystem.current), ExecuteEvents.pointerExitHandler);
					ExecuteEvents.Execute<IPointerEnterHandler>(((Component)this).gameObject, (BaseEventData)new PointerEventData(EventSystem.current), ExecuteEvents.pointerEnterHandler);
				}
			}
			else
			{
				ExecuteEvents.Execute<IPointerExitHandler>(((Component)this).gameObject, (BaseEventData)new PointerEventData(EventSystem.current), ExecuteEvents.pointerExitHandler);
			}
		}
	}
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	public class RecipeTrackerUI : MonoBehaviour
	{
		public static bool ShouldShowUI = true;

		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; } = null;


		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()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (AzuAntiArthriticCraftingPlugin.ToggleUIKeyBind.Value.IsKeyDown())
			{
				ShouldShowUI = !ShouldShowUI;
			}
			if (RecipeUIs.Count <= 0 || !ShouldShowUI)
			{
				ToggleUI(toggle: false);
			}
		}

		private void CheckNearbyMonsters()
		{
			//IL_0022: 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 = ShouldShowUI;
			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)
			{
				ToggleUI(toggle: false);
			}
			else if (RecipeUIs.Count > 0 && flag)
			{
				ToggleUI(toggle: 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: <143c8e00-5ca3-4f07-b27d-18b506ed291b>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([<2a416125-2835-4f78-94bf-b7d1a49fc56c>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);
				}
			}
		}

		public void ToggleUI(bool toggle)
		{
			AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.SetActive(toggle);
		}

		public void ToggleUI()
		{
			AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.SetActive(!AzuAntiArthriticCraftingPlugin.RecipeTrackerUIPrefab.activeSelf);
		}
	}
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>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>");
			}
		}
	}
	[<143c8e00-5ca3-4f07-b27d-18b506ed291b>Nullable(0)]
	[HarmonyPatch(typeof(Hud), "Awake")]
	[<2a416125-2835-4f78-94bf-b7d1a49fc56c>NullableContext(1)]
	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>();