Decompiled source of AzuAutoStore v3.0.6

AzuAutoStore.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using AzuAutoStore.APIs;
using AzuAutoStore.APIs.Compatibility.WardIsLove;
using AzuAutoStore.Interfaces;
using AzuAutoStore.Patches;
using AzuAutoStore.Patches.Favoriting;
using AzuAutoStore.Util;
using AzuExtendedPlayerInventory;
using Backpacks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemDataManager;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: AssemblyFileVersion("3.0.6")]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyProduct("AzuAutoStore")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("AzuAutoStore")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.6.0")]
[module: <e2367d8c-edf2-4d73-9797-331f60d5146a>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<a5d8f5b3-de54-4928-9553-700b2e071de5>Embedded]
	internal sealed class <a5d8f5b3-de54-4928-9553-700b2e071de5>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<a5d8f5b3-de54-4928-9553-700b2e071de5>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <b98913af-fa5d-4999-8d68-f6f19ee333f7>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <b98913af-fa5d-4999-8d68-f6f19ee333f7>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <b98913af-fa5d-4999-8d68-f6f19ee333f7>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<a5d8f5b3-de54-4928-9553-700b2e071de5>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<a5d8f5b3-de54-4928-9553-700b2e071de5>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <e2367d8c-edf2-4d73-9797-331f60d5146a>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <e2367d8c-edf2-4d73-9797-331f60d5146a>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LocalizationManager
{
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	[PublicAPI]
	public class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

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

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

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

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>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([<9904bf2f-0b27-48b2-bb88-8001f16bc687>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, [<9904bf2f-0b27-48b2-bb88-8001f16bc687>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, [<b98913af-fa5d-4999-8d68-f6f19ee333f7>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 += [<9904bf2f-0b27-48b2-bb88-8001f16bc687>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)
		{
			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 = 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 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: <b98913af-fa5d-4999-8d68-f6f19ee333f7>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;
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<9904bf2f-0b27-48b2-bb88-8001f16bc687>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 ItemDataManager
{
	[PublicAPI]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	public abstract class ItemData
	{
		internal static WeakReference<<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo> constructingInfo = null;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1 })]
		internal WeakReference<<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo> info;

		private static readonly FieldInfo parameterInfoClassImpl = AccessTools.DeclaredField(typeof(ParameterInfo), "ClassImpl");

		private static Dictionary<Type, Dictionary<string, FieldInfo>> serializedFields = new Dictionary<Type, Dictionary<string, FieldInfo>>();

		public string CustomDataKey { get; internal set; }

		protected virtual bool AllowStackingIdenticalValues { get; set; }

		public string Value
		{
			get
			{
				if (!Item.m_customData.TryGetValue(CustomDataKey, out var value))
				{
					return "";
				}
				return value;
			}
			set
			{
				Item.m_customData[CustomDataKey] = value;
			}
		}

		public string Key { get; internal set; }

		public bool IsCloned => Info.isCloned.Contains(CustomDataKey);

		public bool IsAlive
		{
			get
			{
				<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo target;
				return (info ?? constructingInfo).TryGetTarget(out target);
			}
		}

		public ItemData Item => Info.ItemData;

		public <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo Info
		{
			get
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				if (!(info ?? constructingInfo).TryGetTarget(out var target))
				{
					return new <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo(new ItemData());
				}
				return target;
			}
		}

		public virtual void FirstLoad()
		{
		}

		public virtual void Load()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			Dictionary<string, FieldInfo> dictionary = fetchSerializedFields();
			if (dictionary == null || dictionary.Count <= 0 || Value == "")
			{
				return;
			}
			List<object> list = new List<object>();
			string[] array = Value.Split(new char[1] { '|' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				if (array2.Length == 2 && dictionary.TryGetValue(array2[0], out var value))
				{
					ZPackage val = new ZPackage(array2[1]);
					ParameterInfo parameterInfo = (ParameterInfo)FormatterServices.GetUninitializedObject(typeof(ParameterInfo));
					parameterInfoClassImpl.SetValue(parameterInfo, value.FieldType);
					list.Clear();
					ZRpc.Deserialize(new ParameterInfo[2] { null, parameterInfo }, val, ref list);
					if (list.Count > 0)
					{
						value.SetValue(this, list[0]);
					}
				}
			}
		}

		public virtual void Save()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			Dictionary<string, FieldInfo> dictionary = fetchSerializedFields();
			if (dictionary == null || dictionary.Count <= 0)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			foreach (FieldInfo value in dictionary.Values)
			{
				ZPackage val = new ZPackage();
				ZRpc.Serialize(new object[1] { value.GetValue(this) }, ref val);
				stringBuilder.Append(value.Name);
				stringBuilder.Append(':');
				stringBuilder.Append(val.GetBase64());
				stringBuilder.Append('|');
			}
			int length = stringBuilder.Length - 1;
			stringBuilder.Length = length;
			Value = stringBuilder.ToString();
		}

		public virtual void Unload()
		{
		}

		public virtual void Upgraded()
		{
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(2)]
		public virtual string TryStack(ItemData data)
		{
			if (!AllowStackingIdenticalValues || !(data?.Value == Value))
			{
				return null;
			}
			return Value;
		}

		private Dictionary<string, FieldInfo> fetchSerializedFields()
		{
			Type type = GetType();
			if (serializedFields.TryGetValue(type, out var value))
			{
				return value;
			}
			return serializedFields[type] = (from f in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
				where f.GetCustomAttributes(typeof(SerializeField), inherit: true).Length != 0
				select f).ToDictionary([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (FieldInfo f) => f.Name, [<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (FieldInfo f) => f);
		}
	}
	public sealed class <d42e6be3-20b8-4ec7-a260-ee1ac75bae95>StringItemData : ItemData
	{
	}
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[PublicAPI]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	public class <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo : IEnumerable<ItemData>, IEnumerable
	{
		public static HashSet<Type> ForceLoadTypes;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		internal static string _modGuid;

		private static Dictionary<Type, HashSet<Type>> typeInheritorsCache;

		private static HashSet<string> knownTypes;

		private Dictionary<string, ItemData> data = new Dictionary<string, ItemData>();

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1 })]
		private WeakReference<<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo> selfReference;

		internal HashSet<string> isCloned = new HashSet<string>();

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		private static ItemData awakeningItem;

		private static Assembly primaryAssembly;

		private static Dictionary<Assembly, string> assemblyNameCache;

		private static Dictionary<Type, string> classKeyCache;

		private HashSet<string> fetchedClassKeys = new HashSet<string>();

		private static MethodInfo removeMethod;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		private static ItemData checkingForStackableItemData;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })]
		private static Dictionary<string, string> newValuesOnStackable;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		private static ItemData currentlyUpgradingItem;

		internal static string modGuid => _modGuid ?? (_modGuid = ((Func<string>)delegate
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			IEnumerable<TypeInfo> source;
			try
			{
				source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
			}
			catch (ReflectionTypeLoadException ex)
			{
				source = from t in ex.Types
					where t != null
					select t.GetTypeInfo();
			}
			return ((BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)))).Info.Metadata.GUID;
		})());

		public string Mod => modGuid;

		public ItemData ItemData { get; private set; }

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public string this[string key]
		{
			[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
			get
			{
				return Get<<d42e6be3-20b8-4ec7-a260-ee1ac75bae95>StringItemData>(key)?.Value;
			}
			[param: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
			set
			{
				GetOrCreate<<d42e6be3-20b8-4ec7-a260-ee1ac75bae95>StringItemData>(key).Value = value ?? "";
			}
		}

		internal static void addTypeToInheritorsCache(Type type, string typeKey)
		{
			if (!knownTypes.Contains(typeKey))
			{
				knownTypes.Add(typeKey);
				Type type2 = type;
				while ((object)type2 != null)
				{
					AddInterfaces(type2);
					type2 = type2.BaseType;
				}
			}
			void AddInterfaces(Type baseType)
			{
				if (!typeInheritorsCache.TryGetValue(baseType, out var value))
				{
					HashSet<Type> hashSet2 = (typeInheritorsCache[baseType] = new HashSet<Type>());
					value = hashSet2;
				}
				value.Add(type);
				Type[] interfaces = baseType.GetInterfaces();
				for (int i = 0; i < interfaces.Length; i++)
				{
					AddInterfaces(interfaces[i]);
				}
			}
		}

		private static string cachedAssemblyName(Assembly assembly)
		{
			if (assemblyNameCache.TryGetValue(assembly, out var value))
			{
				return value;
			}
			return assemblyNameCache[assembly] = assembly.GetName().Name;
		}

		internal static string classKey(Type type, string key)
		{
			if (!classKeyCache.TryGetValue(type, out var value))
			{
				value = type.FullName + ((type.Assembly != primaryAssembly) ? ("," + cachedAssemblyName(type.Assembly)) : "");
				addTypeToInheritorsCache(type, value);
			}
			if (key == "")
			{
				return value;
			}
			return value + "#" + key;
		}

		internal static string dataKey(string key)
		{
			return modGuid + "#" + key;
		}

		internal <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo(ItemData itemData)
		{
			ItemData = itemData;
			string text = dataKey("");
			foreach (string item in ItemData.m_customData.Keys.ToList())
			{
				if (!item.StartsWith(text))
				{
					continue;
				}
				string[] array = item.Substring(text.Length).Split(new char[1] { '#' }, 2);
				if (!knownTypes.Contains(array[0]))
				{
					Type type = Type.GetType(array[0]);
					if ((object)type != null && typeof(ItemData).IsAssignableFrom(type))
					{
						addTypeToInheritorsCache(type, array[0]);
					}
				}
			}
		}

		public T GetOrCreate<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)] T>(string key = "") where T : ItemData, new()
		{
			return Add<T>(key) ?? Get<T>(key);
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public T Add<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)] T>(string key = "") where T : ItemData, new()
		{
			string text = classKey(typeof(T), key);
			if (fetchedClassKeys.Contains(text) && data.ContainsKey(text))
			{
				return null;
			}
			string text2 = dataKey(text);
			if (ItemData.m_customData.ContainsKey(text2) || (awakeningItem != ItemData && data.ContainsKey(text)))
			{
				return null;
			}
			ItemData.m_customData[text2] = "";
			ItemDataManager.ItemData.constructingInfo = selfReference ?? (selfReference = new WeakReference<<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo>(this));
			T val = new T
			{
				info = selfReference,
				Key = key,
				CustomDataKey = text2
			};
			data[text] = val;
			val.Value = "";
			val.FirstLoad();
			return val;
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public T Get<T>(string key = "") where T : class
		{
			if (!typeInheritorsCache.TryGetValue(typeof(T), out var value))
			{
				if (!typeof(ItemData).IsAssignableFrom(typeof(T)) || typeof(T) == typeof(ItemData))
				{
					throw new Exception("Trying to get value from ItemDataManager for class not inheriting from ItemData");
				}
				return null;
			}
			foreach (Type item in value)
			{
				string text = classKey(item, key);
				if (data.TryGetValue(text, out var value2))
				{
					return (T)(object)value2;
				}
				if (!fetchedClassKeys.Contains(text) && awakeningItem != ItemData)
				{
					string text2 = dataKey(text);
					fetchedClassKeys.Add(text);
					if (ItemData.m_customData.ContainsKey(text2))
					{
						return (T)(object)constructDataObj(text2, text);
					}
				}
			}
			return null;
		}

		public Dictionary<string, T> GetAll<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)] T>() where T : ItemData
		{
			LoadAll();
			return data.Values.Where([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemData o) => o is T).ToDictionary([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemData o) => o.Key, [<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemData o) => (T)o);
		}

		public bool Remove(string key = "")
		{
			return Remove<<d42e6be3-20b8-4ec7-a260-ee1ac75bae95>StringItemData>(key);
		}

		public bool Remove<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)] T>(string key = "") where T : ItemData
		{
			string key2 = classKey(typeof(T), key);
			string key3 = dataKey(key2);
			if (ItemData.m_customData.Remove(key3))
			{
				if (data.TryGetValue(key2, out var value))
				{
					value.Unload();
					data.Remove(key2);
				}
				return true;
			}
			return false;
		}

		public bool Remove<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)] T>(T itemData) where T : ItemData
		{
			if (typeof(T) == itemData.GetType())
			{
				return Remove<T>(itemData.Key);
			}
			return (bool)removeMethod.MakeGenericMethod(itemData.GetType()).Invoke(this, new object[1] { itemData.Key });
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		private ItemData constructDataObj(string fullkey, string key)
		{
			string[] array = key.Split(new char[1] { '#' }, 2);
			Type type = Type.GetType(array[0]);
			if ((object)type == null || !typeof(ItemData).IsAssignableFrom(type))
			{
				return null;
			}
			ItemDataManager.ItemData.constructingInfo = selfReference ?? (selfReference = new WeakReference<<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo>(this));
			ItemData itemData = (ItemData)Activator.CreateInstance(type);
			data[key] = itemData;
			itemData.info = selfReference;
			itemData.Key = ((array.Length > 1) ? array[1] : "");
			itemData.CustomDataKey = fullkey;
			itemData.Load();
			return itemData;
		}

		public void Save()
		{
			foreach (ItemData value in data.Values)
			{
				value.Save();
			}
		}

		public void LoadAll()
		{
			if (awakeningItem == ItemData)
			{
				return;
			}
			string text = dataKey("");
			foreach (string item in ItemData.m_customData.Keys.ToList())
			{
				if (item.StartsWith(text))
				{
					string key = item.Substring(text.Length);
					if (!data.ContainsKey(key))
					{
						constructDataObj(item, key);
					}
				}
			}
		}

		public IEnumerator<ItemData> GetEnumerator()
		{
			LoadAll();
			return data.Values.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		private static void SavePrefix(ItemData __instance)
		{
			SaveItem(__instance);
		}

		private static void SaveInventoryPrefix(Inventory __instance)
		{
			foreach (ItemData item in __instance.m_inventory)
			{
				SaveItem(item);
			}
		}

		private static void SaveItem(ItemData item)
		{
			if (<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.itemInfo.TryGetValue(item, out var value))
			{
				value.Save();
			}
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(2)]
		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })]
		public Dictionary<string, string> IsStackableWithOtherInfo(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo info)
		{
			LoadAll();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			if (info != null)
			{
				info.LoadAll();
				foreach (string item in new HashSet<string>(info.data.Keys.Intersect(data.Keys)))
				{
					string text = data[item].TryStack(info.data[item]);
					if (text == null)
					{
						return null;
					}
					dictionary[item] = text;
				}
				foreach (KeyValuePair<string, ItemData> datum in info.data)
				{
					if (!dictionary.ContainsKey(datum.Key))
					{
						string text2 = info.data[datum.Key].TryStack(null);
						if (text2 == null)
						{
							return null;
						}
						dictionary[datum.Key] = text2;
					}
				}
			}
			foreach (KeyValuePair<string, ItemData> datum2 in data)
			{
				if (!dictionary.ContainsKey(datum2.Key))
				{
					string text3 = data[datum2.Key].TryStack(null);
					if (text3 == null)
					{
						return null;
					}
					dictionary[datum2.Key] = text3;
				}
			}
			return dictionary.ToDictionary([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (KeyValuePair<string, string> kv) => dataKey(kv.Key), [<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (KeyValuePair<string, string> kv) => kv.Value);
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(2)]
		private static void RegisterForceLoadedTypesAddItem(ItemData __result)
		{
			awakeningItem = null;
			if (__result != null)
			{
				RegisterForceLoadedTypes(__result);
			}
		}

		private static void RegisterForceLoadedTypes(ItemData itemData)
		{
			foreach (Type forceLoadType in ForceLoadTypes)
			{
				string key = classKey(forceLoadType, "");
				string text = dataKey(key);
				if (itemData.m_customData.ContainsKey(text))
				{
					<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2 = <6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(itemData);
					if (!<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2.data.ContainsKey(key))
					{
						<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2.constructDataObj(text, key);
					}
				}
			}
		}

		private static void ItemDropAwake(ItemDrop __instance)
		{
			GameObject dropPrefab = __instance.m_itemData.m_dropPrefab;
			if (dropPrefab != null && <6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.itemInfo.TryGetValue(dropPrefab.GetComponent<ItemDrop>().m_itemData, out var value))
			{
				<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(__instance.m_itemData).isCloned = new HashSet<string>(value.data.Values.Select([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemData i) => i.CustomDataKey));
			}
		}

		private static void ItemDropAwakeDelayed(ItemDrop __instance)
		{
			if (!ZNetView.m_forceDisableInit)
			{
				RegisterForceLoadedTypes(__instance.m_itemData);
			}
		}

		private static void ItemDataClonePrefix(ItemData __instance, ItemData __result)
		{
			SaveItem(__instance);
		}

		private static void ItemDataClonePostfix(ItemData __instance, ItemData __result)
		{
			if (<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.itemInfo.TryGetValue(__instance, out var value))
			{
				<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(__result).isCloned = new HashSet<string>(value.data.Values.Select([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemData i) => i.CustomDataKey));
			}
		}

		private static void ItemDataClonePostfixDelayed(ItemData __result)
		{
			RegisterForceLoadedTypes(__result);
		}

		private static void RegisterForceLoadedTypesOnPlayerLoaded(Player __instance)
		{
			foreach (Food food in __instance.m_foods)
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(food.m_name);
				if (itemPrefab.GetComponent<ItemDrop>().m_itemData == food.m_item)
				{
					food.m_item = food.m_item.Clone();
					food.m_item.m_dropPrefab = itemPrefab;
				}
				RegisterForceLoadedTypes(food.m_item);
			}
		}

		private static void SaveCheckingForStackableItemData(ItemData item)
		{
			if (item == awakeningItem)
			{
				awakeningItem = null;
			}
			checkingForStackableItemData = item;
		}

		private static void ResetCheckingForStackableItemData()
		{
			checkingForStackableItemData = null;
		}

		private static IEnumerable<CodeInstruction> CheckStackableInFindFreeStackMethods(IEnumerable<CodeInstruction> instructionsEnumerable)
		{
			CodeInstruction[] instructions = instructionsEnumerable.ToArray();
			Label target = (Label)instructions.First([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (CodeInstruction i) => i.opcode == OpCodes.Br || i.opcode == OpCodes.Br_S).operand;
			CodeInstruction targetedInstr = instructions.First([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (CodeInstruction i) => i.labels.Contains(target));
			Label? label = default(Label?);
			CodeInstruction lastBranch = instructions.Reverse().First([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label) && targetedInstr.labels.Contains(label.Value));
			CodeInstruction loadingInstruction = null;
			int j = 0;
			while (j < instructions.Length)
			{
				yield return instructions[j];
				if (loadingInstruction == null && instructions[j].opcode == OpCodes.Call && ((MethodInfo)instructions[j].operand).Name == "get_Current")
				{
					loadingInstruction = instructions[j + 1].Clone();
					loadingInstruction.opcode = new Dictionary<OpCode, OpCode>
					{
						{
							OpCodes.Stloc_0,
							OpCodes.Ldloc_0
						},
						{
							OpCodes.Stloc_1,
							OpCodes.Ldloc_1
						},
						{
							OpCodes.Stloc_2,
							OpCodes.Ldloc_2
						},
						{
							OpCodes.Stloc_3,
							OpCodes.Ldloc_3
						},
						{
							OpCodes.Stloc_S,
							OpCodes.Ldloc_S
						}
					}[loadingInstruction.opcode];
				}
				if (instructions[j] == lastBranch)
				{
					yield return loadingInstruction;
					yield return new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.DeclaredField(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "checkingForStackableItemData"));
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "CheckItemDataIsStackableFindFree", (Type[])null, (Type[])null));
					yield return new CodeInstruction(OpCodes.Brfalse, (object)target);
				}
				int num = j + 1;
				j = num;
			}
		}

		private static bool CheckItemDataIsStackableFindFree(ItemData item, [<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)] ItemData target)
		{
			if (target == null)
			{
				return true;
			}
			Dictionary<string, string> dictionary = IsStackable(item, target);
			if (dictionary != null)
			{
				newValuesOnStackable = dictionary;
				return true;
			}
			return false;
		}

		private static void ResetNewValuesOnStackable()
		{
			newValuesOnStackable = null;
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(2)]
		private static void ApplyNewValuesOnStackable(ItemData __result)
		{
			if (__result == null || newValuesOnStackable == null)
			{
				return;
			}
			foreach (KeyValuePair<string, string> item in newValuesOnStackable)
			{
				__result.m_customData[item.Key] = item.Value;
			}
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })]
		private static Dictionary<string, string> IsStackable(ItemData a, ItemData b)
		{
			<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2 = <6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(a);
			if (<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2 != null)
			{
				return <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2.IsStackableWithOtherInfo(<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(b));
			}
			<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo3 = <6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(b);
			if (<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo3 != null)
			{
				return <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo3.IsStackableWithOtherInfo(null);
			}
			return new Dictionary<string, string>();
		}

		private static bool CheckItemDataStackableAddItem(Inventory __instance, ItemData item, int x, int y, [<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<string, string> __state, ref bool __result)
		{
			ItemData itemAt = __instance.GetItemAt(x, y);
			if (itemAt != null)
			{
				Dictionary<string, string> dictionary = IsStackable(item, itemAt);
				if (dictionary == null)
				{
					__result = false;
					return false;
				}
				__state = dictionary;
			}
			return true;
		}

		private static void ApplyCustomItemDataStackableAddItem(Inventory __instance, int x, int y, [<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })] Dictionary<string, string> __state, bool __result)
		{
			if (!__result || __state == null)
			{
				return;
			}
			foreach (KeyValuePair<string, string> item in __state)
			{
				__instance.GetItemAt(x, y).m_customData[item.Key] = item.Value;
			}
		}

		private static void ApplyCustomItemDataStackableAutoStack(ItemDrop item, Dictionary<string, string> customData)
		{
			item.m_itemData.m_customData = customData;
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })]
		private static Dictionary<string, string> IsStackableItemDrop(ItemDrop drop, ItemData item)
		{
			return IsStackable(drop.m_itemData, item);
		}

		private static IEnumerable<CodeInstruction> HandleAutostackableItems(IEnumerable<CodeInstruction> instructionList, ILGenerator ilg)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			List<CodeInstruction> list = instructionList.ToList();
			FieldInfo fieldInfo = AccessTools.DeclaredField(typeof(ItemData), "m_stack");
			FieldInfo fieldInfo2 = AccessTools.DeclaredField(typeof(ItemDrop), "m_itemData");
			Label? label = default(Label?);
			for (int i = 0; i < list.Count; i++)
			{
				if (!CodeInstructionExtensions.StoresField(list[i], fieldInfo))
				{
					continue;
				}
				for (int num = i; num > 0; num--)
				{
					if (CodeInstructionExtensions.Branches(list[num], ref label))
					{
						for (int num2 = num; num2 > 0; num2--)
						{
							if (CodeInstructionExtensions.LoadsField(list[num2], fieldInfo2, false))
							{
								LocalBuilder localBuilder = ilg.DeclareLocal(typeof(Dictionary<string, string>));
								LocalBuilder localBuilder2 = ilg.DeclareLocal(typeof(ItemData));
								list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ApplyCustomItemDataStackableAutoStack", (Type[])null, (Type[])null)));
								list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc, (object)localBuilder.LocalIndex));
								list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
								list.Insert(num + 1, new CodeInstruction(OpCodes.Brfalse, (object)label));
								list.Insert(num + 1, new CodeInstruction(OpCodes.Stloc, (object)localBuilder.LocalIndex));
								list.Insert(num + 1, new CodeInstruction(OpCodes.Dup, (object)localBuilder.LocalIndex));
								list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "IsStackableItemDrop", (Type[])null, (Type[])null)));
								list.Insert(num + 1, new CodeInstruction(OpCodes.Ldloc, (object)localBuilder2.LocalIndex));
								list.Insert(num + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
								list.Insert(num2 + 1, new CodeInstruction(OpCodes.Stloc, (object)localBuilder2.LocalIndex));
								list.Insert(num2 + 1, new CodeInstruction(OpCodes.Dup, (object)null));
								return list;
							}
						}
					}
				}
			}
			throw new Exception("Found no stack store in a branch");
		}

		private static IEnumerable<CodeInstruction> TransferCustomItemDataOnUpgrade(IEnumerable<CodeInstruction> instructions, ILGenerator ilg)
		{
			MethodInfo itemDeleter = AccessTools.DeclaredMethod(typeof(Inventory), "RemoveItem", new Type[1] { typeof(ItemData) }, (Type[])null);
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(instruction, (MemberInfo)itemDeleter))
				{
					yield return new CodeInstruction(OpCodes.Dup, (object)null);
					yield return new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.DeclaredField(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "currentlyUpgradingItem"));
				}
				yield return instruction;
			}
		}

		private static void ResetCurrentlyUpgradingItem()
		{
			currentlyUpgradingItem = null;
		}

		private static void CopyCustomDataFromUpgradedItem(ItemDrop item)
		{
			if (currentlyUpgradingItem != null)
			{
				item.m_itemData.m_customData = currentlyUpgradingItem.m_customData;
				<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2 = <6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.Data(currentlyUpgradingItem);
				<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.itemInfo.Remove(currentlyUpgradingItem);
				<6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions.itemInfo.Add(item.m_itemData, <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2);
				item.m_itemData.m_quality = currentlyUpgradingItem.m_quality + 1;
				item.m_itemData.m_variant = currentlyUpgradingItem.m_variant;
				<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2.ItemData = item.m_itemData;
				<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2.LoadAll();
				foreach (ItemData value in <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo2.data.Values)
				{
					value.Upgraded();
				}
				currentlyUpgradingItem = null;
				awakeningItem = null;
				return;
			}
			GameObject dropPrefab = item.m_itemData.m_dropPrefab;
			if (dropPrefab == null || item.m_itemData.m_customData.Count != 0)
			{
				return;
			}
			ZNetView component = ((Component)item).GetComponent<ZNetView>();
			ZDO val = ((Object.op_Implicit((Object)(object)component) && component.IsValid()) ? component.GetZDO() : null);
			if (val != null && val.GetInt(ZDOVars.s_dataCount, -1) != -1)
			{
				return;
			}
			item.m_itemData.m_customData = new Dictionary<string, string>(dropPrefab.GetComponent<ItemDrop>().m_itemData.m_customData);
			if (val == null)
			{
				return;
			}
			int num = 0;
			val.Set(ZDOVars.s_dataCount, item.m_itemData.m_customData.Count, false);
			foreach (KeyValuePair<string, string> customDatum in item.m_itemData.m_customData)
			{
				val.Set($"data_{num}", customDatum.Key);
				val.Set($"data__{num++}", customDatum.Value);
			}
		}

		private static IEnumerable<CodeInstruction> ImportCustomDataOnUpgrade(IEnumerable<CodeInstruction> instructionList)
		{
			List<CodeInstruction> list = instructionList.ToList();
			foreach (CodeInstruction instruction in list)
			{
				yield return instruction;
				if (instruction.opcode == OpCodes.Stfld && CodeInstructionExtensions.OperandIs(instruction, (MemberInfo)AccessTools.DeclaredField(typeof(ItemData), "m_dropPrefab")))
				{
					yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "CopyCustomDataFromUpgradedItem", (Type[])null, (Type[])null));
				}
			}
		}

		private static void TrackAwakeningItem(ItemDrop __instance)
		{
			if (ZNetView.m_forceDisableInit)
			{
				awakeningItem = __instance.m_itemData;
			}
		}

		static <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01d0: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_023f: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_02a1: Expected O, but got Unknown
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			//IL_0310: Expected O, but got Unknown
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Expected O, but got Unknown
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Expected O, but got Unknown
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Expected O, but got Unknown
			//IL_03c0: Expected O, but got Unknown
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Expected O, but got Unknown
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Expected O, but got Unknown
			//IL_0452: Expected O, but got Unknown
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Expected O, but got Unknown
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Expected O, but got Unknown
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Expected O, but got Unknown
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Expected O, but got Unknown
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Expected O, but got Unknown
			//IL_065d: Expected O, but got Unknown
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Expected O, but got Unknown
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Expected O, but got Unknown
			//IL_070f: Expected O, but got Unknown
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Expected O, but got Unknown
			ForceLoadTypes = new HashSet<Type>();
			typeInheritorsCache = new Dictionary<Type, HashSet<Type>>();
			knownTypes = new HashSet<string>();
			awakeningItem = null;
			primaryAssembly = Assembly.GetExecutingAssembly();
			assemblyNameCache = new Dictionary<Assembly, string>();
			classKeyCache = new Dictionary<Type, string>();
			removeMethod = typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo).GetMethods().Single([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (MethodInfo m) => m.Name == "Remove" && m.IsGenericMethod && m.GetParameters()[0].ParameterType == typeof(string));
			Harmony val = new Harmony("org.bepinex.helpers.ItemDataManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "Save", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "SaveInventoryPrefix", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			foreach (MethodInfo item in from m in typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where m.Name == "SaveToZDO"
				select m)
			{
				val.Patch((MethodBase)item, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "SavePrefix", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[4]
			{
				typeof(ItemData),
				typeof(int),
				typeof(int),
				typeof(int)
			}, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "CheckItemDataStackableAddItem", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ApplyCustomItemDataStackableAddItem", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "CanAddItem", new Type[2]
			{
				typeof(ItemData),
				typeof(int)
			}, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "SaveCheckingForStackableItemData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ResetCheckingForStackableItemData", (Type[])null), (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[1] { typeof(ItemData) }, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "SaveCheckingForStackableItemData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ResetCheckingForStackableItemData", (Type[])null), (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[2]
			{
				typeof(ItemData),
				typeof(Vector2i)
			}, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "SaveCheckingForStackableItemData", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ResetCheckingForStackableItemData", (Type[])null), (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "FindFreeStackSpace", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "CheckStackableInFindFreeStackMethods", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Inventory), "FindFreeStackItem", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "CheckStackableInFindFreeStackMethods", (Type[])null, (Type[])null));
			val.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ResetNewValuesOnStackable", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ApplyNewValuesOnStackable", (Type[])null, (Type[])null)), val2, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemDrop), "AutoStackItems", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "HandleAutostackableItems", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(InventoryGui), "DoCrafting", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "TransferCustomItemDataOnUpgrade", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ResetCurrentlyUpgradingItem", (Type[])null, (Type[])null)), (HarmonyMethod)null);
			foreach (MethodInfo item2 in from m in typeof(ItemData).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where m.Name == "LoadFromZDO"
				select m)
			{
				val.Patch((MethodBase)item2, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "RegisterForceLoadedTypes", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "Load", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "RegisterForceLoadedTypesOnPlayerLoaded", (Type[])null, (Type[])null), 700, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Inventory), "AddItem", new Type[8]
			{
				typeof(string),
				typeof(int),
				typeof(int),
				typeof(int),
				typeof(long),
				typeof(string),
				typeof(Vector2i),
				typeof(bool)
			}, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "RegisterForceLoadedTypesAddItem", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(ItemDrop), "Awake", (Type[])null, (Type[])null);
			HarmonyMethod val3 = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "TrackAwakeningItem", (Type[])null, (Type[])null));
			val2 = new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ImportCustomDataOnUpgrade", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null);
			val.Patch((MethodBase)methodInfo2, val3, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ItemDropAwake", (Type[])null, (Type[])null), 800, (string[])null, (string[])null, (bool?)null), val2, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemDrop), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ItemDropAwakeDelayed", (Type[])null, (Type[])null), 799, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemData), "Clone", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ItemDataClonePrefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ItemDataClonePostfix", (Type[])null, (Type[])null), 500, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ItemData), "Clone", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(<1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo), "ItemDataClonePostfixDelayed", (Type[])null, (Type[])null), 499, (string[])null, (string[])null, (bool?)null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	[PublicAPI]
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	public class <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo : IEnumerable<object>, IEnumerable
	{
		private readonly object foreignItemInfo;

		public string Mod => ((string)foreignItemInfo.GetType().GetProperty("Mod")?.GetValue(foreignItemInfo)) ?? "";

		public ItemData ItemData { get; private set; }

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public string this[string key]
		{
			[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
			get
			{
				object obj = foreignItemInfo.GetType().InvokeMember("Item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty, null, foreignItemInfo, new object[1] { key });
				if (obj != null)
				{
					return (string)obj.GetType().GetProperty("Value")?.GetValue(obj);
				}
				return null;
			}
			[param: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
			set
			{
				foreignItemInfo.GetType().GetMethod("set_Item", BindingFlags.Instance | BindingFlags.Public)?.Invoke(foreignItemInfo, new object[2] { key, value });
			}
		}

		internal <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo(ItemData itemData, object foreignItemInfo)
		{
			ItemData = itemData;
			this.foreignItemInfo = foreignItemInfo;
		}

		public T GetOrCreate<T>(string key = "") where T : class, new()
		{
			return Add<T>(key) ?? Get<T>(key);
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(2)]
		private object call([<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(1)] string name, [<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 1, 2 })] object[] values, [<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 1, 2 })] Type[] args, Type generic = null)
		{
			MethodInfo[] methods = foreignItemInfo.GetType().GetMethods();
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name == name && (from p in methodInfo.GetParameters()
					select (!p.ParameterType.IsGenericParameter) ? p.ParameterType : null).SequenceEqual(args) && (object)generic != null == methodInfo.IsGenericMethod)
				{
					MethodInfo methodInfo2 = methodInfo;
					if ((object)generic != null)
					{
						methodInfo2 = methodInfo2.MakeGenericMethod(generic);
					}
					return methodInfo2.Invoke(foreignItemInfo, values);
				}
			}
			return null;
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public T Add<T>(string key = "") where T : class, new()
		{
			return call("Add", new object[1] { key }, new Type[1] { typeof(string) }, typeof(T)) as T;
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public T Get<T>(string key = "") where T : class
		{
			return call("Get", new object[1] { key }, new Type[1] { typeof(string) }, typeof(T)) as T;
		}

		public Dictionary<string, T> GetAll<T>() where T : class
		{
			return ((call("GetAll", Array.Empty<object>(), Array.Empty<Type>(), typeof(T)) as T) as Dictionary<string, T>) ?? new Dictionary<string, T>();
		}

		public bool Remove(string key = "")
		{
			return (call("Add", new object[1] { key }, new Type[1] { typeof(string) }) as bool?).GetValueOrDefault();
		}

		public bool Remove<T>(string key = "") where T : class
		{
			return (call("Remove", new object[1] { key }, new Type[1] { typeof(string) }, typeof(T)) as bool?).GetValueOrDefault();
		}

		public bool Remove<T>(T itemData) where T : class
		{
			return (call("Remove", new object[1] { itemData }, new Type[1], typeof(T)) as bool?).GetValueOrDefault();
		}

		public void Save()
		{
			call("Save", Array.Empty<object>(), Array.Empty<Type>());
		}

		public void LoadAll()
		{
			call("LoadAll", Array.Empty<object>(), Array.Empty<Type>());
		}

		public IEnumerator<object> GetEnumerator()
		{
			return (IEnumerator<object>)((call("GetEnumerator", Array.Empty<object>(), Array.Empty<Type>()) as IEnumerator<object>) ?? ((object)new List<object>().GetEnumerator()));
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	[PublicAPI]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	public static class <6f3ec1fa-e871-4d08-8e86-9948aea834c6>ItemExtensions
	{
		private const string className = "ItemDataManager.ItemExtensions";

		internal static readonly ConditionalWeakTable<ItemData, <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo> itemInfo = new ConditionalWeakTable<ItemData, <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo>();

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 1, 1, 1, 1, 2 })]
		private static readonly ConditionalWeakTable<ItemData, Dictionary<string, <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo>> foreignItemInfo = new ConditionalWeakTable<ItemData, Dictionary<string, <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo>>();

		public static <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo Data(this ItemData item)
		{
			if (itemInfo.TryGetValue(item, out var value))
			{
				return value;
			}
			itemInfo.Add(item, value = new <1d44808e-6f5a-43ca-8828-df2832fdc6ec>ItemInfo(item));
			return value;
		}

		[return: <b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)]
		public static <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo Data(this ItemData item, string mod)
		{
			Dictionary<string, <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo> orCreateValue = foreignItemInfo.GetOrCreateValue(item);
			if (orCreateValue.TryGetValue(mod, out var value))
			{
				return value;
			}
			if (!Chainloader.PluginInfos.TryGetValue(mod, out var value2))
			{
				return null;
			}
			object obj = ((object)value2.Instance).GetType().Assembly.GetType("ItemDataManager.ItemExtensions")?.GetMethod("Data", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ItemData) }, Array.Empty<ParameterModifier>())?.Invoke(null, new object[1] { item });
			if (obj != null)
			{
				return orCreateValue[mod] = new <991dd66d-feb8-4117-ab1e-5156d5f17046>ForeignItemInfo(item, obj);
			}
			Debug.LogWarning((object)("Mod " + mod + " has an ItemDataManager.ItemExtensions class, but no Data(ItemDrop.ItemData) method could be called on it."));
			return orCreateValue[mod] = null;
		}
	}
}
namespace AzuAutoStore
{
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	internal static class TerminalInitTerminalPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
			public static readonly <>c <>9 = new <>c();

			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
			public static Func<Piece, bool> <>9__2_7;

			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
			public static Func<Piece, VanillaContainers> <>9__2_9;

			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
			public static Func<ItemData, int> <>9__2_11;

			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
			public static ConsoleEvent <>9__2_0;

			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
			public static ConsoleOptionsFetcher <>9__2_1;

			[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
			internal void <Postfix>b__2_0(ConsoleEventArgs args)
			{
				<>c__DisplayClass2_0 <>c__DisplayClass2_ = new <>c__DisplayClass2_0();
				if (args.Length > 1 && Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					<>c__DisplayClass2_.itemCount = 0;
					bool flag = <>c__DisplayClass2_.<Postfix>g__SearchNearbyContainersFor|2(args[1]);
					((Character)Player.m_localPlayer).Message((MessageType)2, flag ? $"Found {<>c__DisplayClass2_.itemCount} items matching '{args[1]}' in nearby containers." : ("<color=red>No items matching '" + args[1] + "' found in nearby containers.</color>"), 0, (Sprite)null);
				}
			}

			[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
			internal bool <Postfix>b__2_7(Piece p)
			{
				return Object.op_Implicit((Object)(object)((Component)p).GetComponent<Container>());
			}

			[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
			internal VanillaContainers <Postfix>b__2_9(Piece p)
			{
				return VanillaContainers.Create(((Component)p).GetComponent<Container>());
			}

			[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
			internal int <Postfix>b__2_11(ItemData item)
			{
				return item.m_stack;
			}

			[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
			internal List<string> <Postfix>b__2_1()
			{
				if (Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					return ZNetScene.instance.GetPrefabNames();
				}
				return new List<string>();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass2_0
		{
			public int itemCount;
		}

		private const float SearchRadius = 50f;

		public static void GetAllPiecesInRadius(Vector3 p, float radius, List<Piece> pieces)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (Piece.s_ghostLayer == 0)
			{
				Piece.s_ghostLayer = LayerMask.NameToLayer("ghost");
			}
			foreach (Piece s_allPiece in Piece.s_allPieces)
			{
				if (((Component)s_allPiece).gameObject.layer != Piece.s_ghostLayer && (double)Vector3.Distance(p, ((Component)s_allPiece).transform.position) < (double)radius)
				{
					pieces.Add(s_allPiece);
				}
			}
		}

		private static void Postfix(Terminal __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				ConsoleEvent val = [<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ConsoleEventArgs args) =>
				{
					int itemCount;
					if (args.Length > 1 && Object.op_Implicit((Object)(object)ZNetScene.instance))
					{
						itemCount = 0;
						bool flag = SearchNearbyContainersFor(args[1]);
						((Character)Player.m_localPlayer).Message((MessageType)2, flag ? $"Found {itemCount} items matching '{args[1]}' in nearby containers." : ("<color=red>No items matching '" + args[1] + "' found in nearby containers.</color>"), 0, (Sprite)null);
					}
					IEnumerable<AzuAutoStore.Interfaces.IContainer> GetNearbyMatchingPieces(string query)
					{
						//IL_0024: Unknown result type (might be due to invalid IL or missing references)
						List<Piece> list = new List<Piece>();
						GetAllPiecesInRadius(((Component)Player.m_localPlayer).transform.position, 50f, list);
						IEnumerable<AzuAutoStore.Interfaces.IContainer> second = ItemDrawers_API.AllDrawers.Where([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemDrawers_API.Drawer x) => string.Equals(x.Prefab, query, StringComparison.CurrentCultureIgnoreCase)).Select(kgDrawer.Create);
						return (from p in list
							where Object.op_Implicit((Object)(object)((Component)p).GetComponent<Container>())
							where ContainerContainsMatchingItem((Component)(object)p, query.ToLower(), ref itemCount)
							select VanillaContainers.Create(((Component)p).GetComponent<Container>())).Concat(second);
					}
					bool SearchNearbyContainersFor(string query)
					{
						//IL_003b: Unknown result type (might be due to invalid IL or missing references)
						//IL_004a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0083: Unknown result type (might be due to invalid IL or missing references)
						//IL_0088: Unknown result type (might be due to invalid IL or missing references)
						//IL_008f: Unknown result type (might be due to invalid IL or missing references)
						//IL_009b: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
						bool result = false;
						AzuAutoStore.Interfaces.IContainer container2 = null;
						float num = float.MaxValue;
						foreach (AzuAutoStore.Interfaces.IContainer nearbyMatchingPiece in GetNearbyMatchingPieces(query))
						{
							Functions.PingContainer(nearbyMatchingPiece.gameObject);
							result = true;
							float num2 = Vector3.Distance(nearbyMatchingPiece.gameObject.transform.position, ((Component)Player.m_localPlayer).transform.position);
							if (num2 < num)
							{
								num = num2;
								container2 = nearbyMatchingPiece;
							}
						}
						if (container2 != null)
						{
							Vector3 position = container2.gameObject.transform.position;
							((Character)Player.m_localPlayer).SetLookDir(position - ((Component)Player.m_localPlayer).transform.position, 3.5f);
						}
						return result;
					}
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			object obj2 = <>c.<>9__2_1;
			if (obj2 == null)
			{
				ConsoleOptionsFetcher val2 = [<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] () => Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefabNames() : new List<string>();
				<>c.<>9__2_1 = val2;
				obj2 = (object)val2;
			}
			new ConsoleCommand("azuautostoresearch", "[prefab name/query text] - search for items in chests near the player. It uses the prefab name", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false);
			static bool ContainerContainsMatchingItem(Component container, string query, ref int count)
			{
				IEnumerable<ItemData> source = (from i in container.GetComponent<Container>().GetInventory().GetAllItems()
					where NormalizedItemName(i).Contains(query) || i.m_shared.m_name.ToLower().Contains(query)
					select i).ToList();
				count += source.Sum([<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (ItemData item) => item.m_stack);
				return source.Any();
			}
			static string NormalizedItemName(ItemData itemData)
			{
				return Utils.GetPrefabName(itemData.m_dropPrefab).ToLower();
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Azumatt.AzuAutoStore", "AzuAutoStore", "3.0.6")]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	public class AzuAutoStorePlugin : BaseUnityPlugin
	{
		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
		public enum Toggle
		{
			Off,
			On
		}

		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(1)]
			public string Category;

			[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>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 = "AzuAutoStore";

		internal const string ModVersion = "3.0.6";

		internal const string Author = "Azumatt";

		internal const string ModGUID = "Azumatt.AzuAutoStore";

		internal const string KgGuid = "kg.ItemDrawers";

		internal const string BackpacksGuid = "org.bepinex.plugins.backpacks";

		private const string ConfigFileName = "Azumatt.AzuAutoStore.cfg";

		private static readonly string ConfigFileFullPath;

		internal static string ConnectionError;

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

		public static readonly ManualLogSource AzuAutoStoreLogger;

		private static readonly ConfigSync ConfigSync;

		internal static bool BackpacksIsLoaded;

		internal static readonly string yamlFileName;

		internal static readonly string yamlPath;

		internal static readonly CustomSyncedValue<string> AzuAutoStoreContainerData;

		internal static readonly CustomSyncedValue<string> CraftyContainerGroupsData;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 2, 1, 1 })]
		internal static Dictionary<string, object> yamlData;

		[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(new byte[] { 1, 2, 1, 2 })]
		internal static Dictionary<string, HashSet<string>> groups;

		internal static AzuAutoStorePlugin self;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		internal static ConfigEntry<Toggle> DontStoreToBackpacks;

		internal static ConfigEntry<Toggle> ChestsPickupFromGround;

		internal static ConfigEntry<Toggle> MustHaveExistingItemToPull;

		internal static ConfigEntry<KeyboardShortcut> SingleItemShortcut;

		private static ConfigEntry<KeyboardShortcut> _storeShortcut;

		private static ConfigEntry<KeyboardShortcut> _pauseShortcut;

		internal static ConfigEntry<int> SecondsToWaitBeforeStoring;

		internal static ConfigEntry<float> IntervalSeconds;

		internal static ConfigEntry<float> PlayerRange;

		internal static ConfigEntry<float> FallbackRange;

		internal static ConfigEntry<Toggle> PlayerIgnoreHotbar;

		internal static ConfigEntry<Toggle> PlayerIgnoreQuickSlots;

		internal static ConfigEntry<string> PingVfxString;

		internal static ConfigEntry<Toggle> HighlightContainers;

		internal static ConfigEntry<Toggle> PingContainers;

		public static ConfigEntry<Color> BorderColorFavoritedItem;

		public static ConfigEntry<Color> BorderColorFavoritedItemOnFavoritedSlot;

		public static ConfigEntry<Color> BorderColorFavoritedSlot;

		public static ConfigEntry<bool> DisplayTooltipHint;

		public static ConfigEntry<KeyboardShortcut> FavoritingModifierKeybind1;

		public static ConfigEntry<KeyboardShortcut> FavoritingModifierKeybind2;

		public static ConfigEntry<KeyboardShortcut> SearchModifierKeybind;

		public static ConfigEntry<string> FavoritedItemTooltip;

		public static ConfigEntry<string> FavoritedSlotTooltip;

		public static ConfigEntry<string> ItemOnFavoritedSlotTooltip;

		public void Awake()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Expected O, but got Unknown
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			self = this;
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, new ConfigDescription("If on, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 10
				}
			}));
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			DontStoreToBackpacks = config("1 - General", "Dont Store to Backpacks", Toggle.Off, new ConfigDescription("If on, items will not be stored in backpacks.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 9
				}
			}));
			ChestsPickupFromGround = config("1 - General", "Chests Pickup From Ground", Toggle.On, new ConfigDescription("If on, chests will pick up items from the ground if they are in range. If off, chests will not begin their periodic checks for items nearby. Reloading zone or logging out might be required.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 8
				}
			}));
			MustHaveExistingItemToPull = config("1 - General", "Must Have Existing Item To Pull", Toggle.On, new ConfigDescription("If on, the chest must already have the item in its inventory to pull it from the world or player into the chest.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 7
				}
			}));
			PlayerRange = config("1 - General", "Player Range", 5f, new ConfigDescription("The maximum distance from the player to store items in chests when the Store Shortcut is pressed. Follows storage rules for allowed items.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 6
				}
			}));
			FallbackRange = config("1 - General", "Fallback Range", 10f, new ConfigDescription("The range to use if the container has no range set in the yml file. This will be the fallback range for all containers.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 5
				}
			}));
			PlayerIgnoreHotbar = config("1 - General", "Player Ignore Hotbar", Toggle.On, new ConfigDescription("If on, the player's hotbar will not be stored when the Store Shortcut is pressed.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4
				}
			}), synchronizedSetting: false);
			PlayerIgnoreQuickSlots = config("1 - General", "Player Ignore Quick Slots", Toggle.Off, new ConfigDescription("If on, the player's quick slots will not be stored when the Store Shortcut is pressed. (Requires Quick Slots mod, turn on only if you need it!)", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3
				}
			}), synchronizedSetting: false);
			PingVfxString = TextEntryConfig("1 - General", "Ping VFX", "vfx_Potion_health_medium", new ConfigDescription("The VFX to play when a chest is pinged. Leave blank to disable and only highlight the chest. (Full prefab list: https://valheim-modding.github.io/Jotunn/data/prefabs/prefab-list.html)", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2
				}
			}));
			HighlightContainers = config("1 - General", "Highlight Containers", Toggle.On, new ConfigDescription("If on, the containers will be highlighted when something is stored in them. If off, the containers will not be highlighted if something is stored in them.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1
				}
			}), synchronizedSetting: false);
			PingContainers = config("1 - General", "Ping Containers", Toggle.On, new ConfigDescription("If on, the containers will be pinged with the Ping VFX when something is stored in them. If off, the containers will not be pinged if something is stored in them.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 0
				}
			}), synchronizedSetting: false);
			SecondsToWaitBeforeStoring = config("1 - General", "Seconds To Wait Before Storing", 10, new ConfigDescription("The number of seconds to wait before storing items into chests nearby automatically after you have pressed your hotkey to pause.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 60), Array.Empty<object>()));
			IntervalSeconds = config("1 - General", "IntervalSeconds", 10f, new ConfigDescription("The number of seconds that must pass before the chest will do an automatic check for items nearby, WARNING: Reducing this will decrease performance!", (AcceptableValueBase)null, Array.Empty<object>()));
			SingleItemShortcut = config<KeyboardShortcut>("2 - Shortcuts", "Store Single Item Shortcut", new KeyboardShortcut((KeyCode)325, Array.Empty<KeyCode>()), new ConfigDescription("Keyboard shortcut/Hotkey to store a single item that you click from your inventory into nearby containers.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2
				}
			}), synchronizedSetting: false);
			_storeShortcut = config<KeyboardShortcut>("2 - Shortcuts", "Store Shortcut", new KeyboardShortcut((KeyCode)46, Array.Empty<KeyCode>()), new ConfigDescription("Keyboard shortcut/Hotkey to store your inventory into nearby containers.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1
				}
			}), synchronizedSetting: false);
			_pauseShortcut = config<KeyboardShortcut>("2 - Shortcuts", "Pause Shortcut", new KeyboardShortcut((KeyCode)46, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Keyboard shortcut/Hotkey to temporarily stop storing items into chests nearby automatically. Does not override the player hotkey store.", synchronizedSetting: false);
			SearchModifierKeybind = config<KeyboardShortcut>("2 - Shortcuts", "SearchModifierKeybind", new KeyboardShortcut((KeyCode)121, Array.Empty<KeyCode>()), "While holding this, you can search nearby chests for the prefab you clicked in your inventory.", synchronizedSetting: false);
			string group = "3 - Favoriting";
			string text = "While holding this, left clicking on items or right clicking on slots favorites them, disallowing storing";
			BorderColorFavoritedItem = config<Color>(group, "BorderColorFavoritedItem", new Color(1f, 0.8482759f, 0f), "Color of the border for slots containing favorited items.", synchronizedSetting: false);
			BorderColorFavoritedItem.SettingChanged += [<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(0)] (object a, EventArgs b) =>
			{
				FavoritingMode.RefreshDisplay();
			};
			BorderColorFavoritedItemOnFavoritedSlot = config<Color>(group, "BorderColorFavoritedItemOnFavoritedSlot", new Color(0.5f, 0.67413795f, 0.5f), "Color of the border of a favorited slot that also contains a favorited item.", synchronizedSetting: false);
			BorderColorFavoritedSlot = config<Color>(group, "BorderColorFavoritedSlot", new Color(0f, 0.5f, 1f), "Color of the border for favorited slots.", synchronizedSetting: false);
			DisplayTooltipHint = config(group, "DisplayTooltipHint", value: true, "Whether to add additional info the item tooltip of a favorited or trash flagged item.", synchronizedSetting: false);
			FavoritingModifierKeybind1 = config<KeyboardShortcut>(group, "FavoritingModifierKeybind1", new KeyboardShortcut((KeyCode)122, Array.Empty<KeyCode>()), text + " Identical to FavoritingModifierKeybind2.", synchronizedSetting: false);
			FavoritingModifierKeybind2 = config<KeyboardShortcut>(group, "FavoritingModifierKeybind2", new KeyboardShortcut((KeyCode)122, Array.Empty<KeyCode>()), text + " Identical to FavoritingModifierKeybind1.", synchronizedSetting: false);
			FavoritedItemTooltip = config(group, "FavoritedItemTooltip", "Item is favorited and won't be stored", string.Empty, synchronizedSetting: false);
			FavoritedSlotTooltip = config(group, "FavoritedSlotTooltip", "Slot is favorited and won't be stored", string.Empty, synchronizedSetting: false);
			ItemOnFavoritedSlotTooltip = config(group, "ItemOnFavoritedSlotTooltip", "Item & Slot are favorited and won't be stored", string.Empty, synchronizedSetting: false);
			if (!File.Exists(yamlPath))
			{
				WriteConfigFileFromResource(yamlPath);
			}
			AzuAutoStoreContainerData.ValueChanged += OnValChangedUpdate;
			AzuAutoStoreContainerData.AssignLocalValue(File.ReadAllText(yamlPath));
			AutoDoc();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

		public void Start()
		{
			BorderRenderer.Border = loadSprite("border.png");
			if (Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.backpacks"))
			{
				BackpacksIsLoaded = true;
			}
		}

		private void AutoDoc()
		{
		}

		private static void WriteConfigFileFromResource(string configFilePath)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = "AzuAutoStore.Example.yml";
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				throw new FileNotFoundException("Resource '" + text + "' not found in the assembly.");
			}
			using StreamReader streamReader = new StreamReader(stream);
			string contents = streamReader.ReadToEnd();
			File.WriteAllText(configFilePath, contents);
		}

		private void Update()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			KeyboardShortcut value = _storeShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && ((Character)Player.m_localPlayer).TakeInput())
			{
				Functions.TryStore();
			}
			value = _pauseShortcut.Value;
			if (!((KeyboardShortcut)(ref value)).IsDown() || !((Character)Player.m_localPlayer).TakeInput())
			{
				return;
			}
			Boxes.StoringPaused = !Boxes.StoringPaused;
			foreach (Container container in Boxes.Containers)
			{
				if (container.m_nview.IsValid())
				{
					container.m_nview.InvokeRPC("RequestPause", new object[1] { Boxes.StoringPaused });
				}
			}
		}

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

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "Azumatt.AzuAutoStore.cfg");
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
			FileSystemWatcher fileSystemWatcher2 = new FileSystemWatcher(Paths.ConfigPath, yamlFileName);
			fileSystemWatcher2.Changed += ReadYamlFiles;
			fileSystemWatcher2.Created += ReadYamlFiles;
			fileSystemWatcher2.Renamed += ReadYamlFiles;
			fileSystemWatcher2.IncludeSubdirectories = true;
			fileSystemWatcher2.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher2.EnableRaisingEvents = true;
		}

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

		private void ReadYamlFiles(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(yamlPath))
			{
				return;
			}
			try
			{
				AzuAutoStoreLogger.LogDebug((object)"ReadConfigValues called");
				AzuAutoStoreContainerData.AssignLocalValue(File.ReadAllText(yamlPath));
			}
			catch
			{
				AzuAutoStoreLogger.LogError((object)("There was an issue loading your " + yamlFileName));
				AzuAutoStoreLogger.LogError((object)"Please check your entries for spelling and format!");
			}
		}

		private static void OnValChangedUpdate()
		{
			AzuAutoStoreLogger.LogDebug((object)"OnValChanged called");
			try
			{
				YamlUtils.ReadYaml(AzuAutoStoreContainerData.Value);
				YamlUtils.ParseGroups();
			}
			catch (Exception arg)
			{
				AzuAutoStoreLogger.LogError((object)$"Failed to deserialize {yamlFileName}: {arg}");
			}
		}

		private static byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static Texture2D loadTexture(string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_001f: Expected O, but got Unknown
			Texture2D val = new Texture2D(0, 0);
			ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("assets." + name));
			return val;
		}

		internal static Sprite loadSprite(string name)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = loadTexture(name);
			if ((Object)(object)val != (Object)null)
			{
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
			}
			return null;
		}

		private ConfigEntry<T> config<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>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<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>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);
		}

		private ConfigEntry<T> TextEntryConfig<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>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> TextEntryConfig<[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(2)] T>(string group, string name, T value, string desc, bool synchronizedSetting = true)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
			{
				CustomDrawer = Functions.TextAreaDrawer
			};
			return TextEntryConfig(group, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), synchronizedSetting);
		}

		static AzuAutoStorePlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + "Azumatt.AzuAutoStore.cfg";
			ConnectionError = "";
			AzuAutoStoreLogger = Logger.CreateLogSource("AzuAutoStore");
			ConfigSync = new ConfigSync("Azumatt.AzuAutoStore")
			{
				DisplayName = "AzuAutoStore",
				CurrentVersion = "3.0.6",
				MinimumRequiredVersion = "3.0.6"
			};
			BackpacksIsLoaded = false;
			yamlFileName = "Azumatt.AzuAutoStore.yml";
			string configPath2 = Paths.ConfigPath;
			directorySeparatorChar = Path.DirectorySeparatorChar;
			yamlPath = configPath2 + directorySeparatorChar + yamlFileName;
			AzuAutoStoreContainerData = new CustomSyncedValue<string>(ConfigSync, "azuautostoreData", "");
			CraftyContainerGroupsData = new CustomSyncedValue<string>(ConfigSync, "azuautostoreGroupsData", "");
			groups = null;
			self = null;
			_serverConfigLocked = null;
			DontStoreToBackpacks = null;
			ChestsPickupFromGround = null;
			MustHaveExistingItemToPull = null;
			SingleItemShortcut = null;
			_storeShortcut = null;
			_pauseShortcut = null;
			SecondsToWaitBeforeStoring = null;
			IntervalSeconds = null;
			PlayerRange = null;
			FallbackRange = null;
			PlayerIgnoreHotbar = null;
			PlayerIgnoreQuickSlots = null;
			PingVfxString = null;
			HighlightContainers = null;
			PingContainers = null;
			BorderColorFavoritedItem = null;
			BorderColorFavoritedItemOnFavoritedSlot = null;
			BorderColorFavoritedSlot = null;
			DisplayTooltipHint = null;
			FavoritingModifierKeybind1 = null;
			FavoritingModifierKeybind2 = null;
			SearchModifierKeybind = null;
			FavoritedItemTooltip = null;
			FavoritedSlotTooltip = null;
			ItemOnFavoritedSlotTooltip = 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;
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			AzuAutoStorePlugin.AzuAutoStoreLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("AzuAutoStore_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_AzuAutoStore_Version);
			AzuAutoStorePlugin.AzuAutoStoreLogger.LogInfo((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("3.0.6");
			peer.m_rpc.Invoke("AzuAutoStore_VersionCheck", new object[1] { val });
		}
	}
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			AzuAutoStorePlugin.AzuAutoStoreLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "AzuAutoStoreRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + AzuAutoStorePlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				AzuAutoStorePlugin.AzuAutoStoreLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable(0)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_AzuAutoStore_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			AzuAutoStorePlugin.AzuAutoStoreLogger.LogInfo((object)("Version check, local: 3.0.6,  remote: " + text));
			if (text != "3.0.6")
			{
				AzuAutoStorePlugin.ConnectionError = "AzuAutoStore Installed: 3.0.6\n Needed: " + text;
				if (ZNet.instance.IsServer())
				{
					AzuAutoStorePlugin.AzuAutoStoreLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting..."));
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				AzuAutoStorePlugin.AzuAutoStoreLogger.LogInfo((object)"Received same version from server!");
			}
			else
			{
				AzuAutoStorePlugin.AzuAutoStoreLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
				ValidatedPeers.Add(rpc);
			}
		}
	}
}
namespace AzuAutoStore.Util
{
	[<9904bf2f-0b27-48b2-bb88-8001f16bc687>NullableContext(1)]
	[<b98913af-fa5d-4999-8d68-f6f19ee333f7>Nullable