Decompiled source of Takers Underworld v1.0.7

BepInEx/plugins/The_Bees_Decree-VALKEA_Food_PROPS/ValkeaProps.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using ValkeaProps;

[assembly: AssemblyFileVersion("1.2.5")]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyProduct("ValkeaProps")]
[assembly: AssemblyCompany("TheBeesDecree")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("ValkeaProps")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.5.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<4e290285-20b8-488c-963a-412ab2847843>Embedded]
	internal sealed class <4e290285-20b8-488c-963a-412ab2847843>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<4e290285-20b8-488c-963a-412ab2847843>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <1b085ef8-c05f-4287-bfc0-c06ec6693295>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <1b085ef8-c05f-4287-bfc0-c06ec6693295>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <1b085ef8-c05f-4287-bfc0-c06ec6693295>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<4e290285-20b8-488c-963a-412ab2847843>Embedded]
	[CompilerGenerated]
	internal sealed class <e97c5803-69aa-460e-abe9-409844477c78>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <e97c5803-69aa-460e-abe9-409844477c78>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ValkeaProps
{
	[BepInPlugin("TheBeesDecree.ValkeaProps", "ValkeaProps", "1.2.5")]
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	public class ValkeaPropsplugin : BaseUnityPlugin
	{
		[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			public bool? Browsable = false;
		}

		internal const string ModName = "ValkeaProps";

		internal const string ModVersion = "1.2.5";

		internal const string Author = "TheBeesDecree";

		private const string ModGUID = "TheBeesDecree.ValkeaProps";

		private static string ConfigFileName = "TheBeesDecree.ValkeaProps.cfg";

		private static string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("TheBeesDecree.ValkeaProps");

		public static readonly ManualLogSource ValkeaPropsLogger;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 2, 1 })]
		private static GameObject[] myobjects;

		private static readonly ConfigSync ConfigSync;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private static ConfigEntry<bool> _serverConfigLocked;

		public void Awake()
		{
			_serverConfigLocked = config("General", "Force Server Config", value: true, "Force Server Config");
			ConfigSync.AddLockingConfigEntry<bool>(_serverConfigLocked);
			Item item = new Item("valkeaprops", "Chucharier");
			item.Name.English("Chucharier");
			item.Description.English("Legend has it that Chucharier is the holy sausage needed to assemble all goods from ValkeaProps");
			item.Name.German("Chucharier");
			item.Description.German("Das Chucharier.");
			item.Crafting.Add(CraftingTable.Workbench, 1);
			item.RequiredItems.Add("Sausages", 5);
			item.RequiredItems.Add("Honey", 1);
			item.RequiredItems.Add("Coins", 999);
			item.RequiredUpgradeItems.Add("Coins", 99);
			item.CraftAmount = 1;
			AssetBundle val = PrefabManager.RegisterAssetBundle("valkeaprops");
			myobjects = val.LoadAllAssets<GameObject>();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

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

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

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

		public static void TryRegisterFabs(ZNetScene zNetScene)
		{
			List<GameObject> list = null;
			if ((Object)(object)zNetScene == (Object)null)
			{
				return;
			}
			List<GameObject> prefabs = zNetScene.m_prefabs;
			if (prefabs == null || prefabs.Count <= 0 || myobjects == null)
			{
				return;
			}
			GameObject[] array = myobjects;
			foreach (GameObject val in array)
			{
				if (((Object)val).name.Contains("Chucharier") && Object.op_Implicit((Object)(object)val.GetComponent<ItemDrop>()))
				{
					list = val.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces;
				}
				if (list == null)
				{
					continue;
				}
				foreach (GameObject item in list)
				{
					if (zNetScene.m_prefabs.Contains(item))
					{
						return;
					}
					zNetScene.m_prefabs.Add(item);
				}
			}
		}

		private ConfigEntry<T> config<[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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);
			SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		static ValkeaPropsplugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			ValkeaPropsLogger = Logger.CreateLogSource("ValkeaProps");
			ConfigSync = new ConfigSync("TheBeesDecree.ValkeaProps")
			{
				DisplayName = "ValkeaProps",
				CurrentVersion = "1.2.5",
				MinimumRequiredVersion = "1.2.5"
			};
		}
	}
}
namespace ItemManager
{
	[PublicAPI]
	public enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("piece_MeadCauldron")]
		MeadCauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("piece_preptable")]
		PrepTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[PublicAPI]
	public enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	public class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free = false;

		public void Add(string itemName, int amount)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amount = amount
			});
		}

		public void Add(string itemName, ConfigEntry<int> amountConfig)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig
			});
		}
	}
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[PublicAPI]
	public class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

		public void Add(CraftingTable table, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = table,
				level = level
			});
		}

		public void Add(string customTable, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				level = level,
				custom = customTable
			});
		}
	}
	[PublicAPI]
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	public class ItemRecipe
	{
		public readonly RequiredResourceList RequiredItems = new RequiredResourceList();

		public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList();

		public readonly CraftingStationList Crafting = new CraftingStationList();

		public int CraftAmount = 1;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		public ConfigEntryBase RecipeIsActive = null;
	}
	public struct Requirement
	{
		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(1)]
		public string itemName;

		public int amount;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		public ConfigEntry<int> amountConfig;
	}
	public struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		public string custom;
	}
	[Flags]
	public enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Full = 7
	}
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	public class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min)
			});
		}
	}
	public struct DropTarget
	{
		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(1)]
		public string creature;

		public int min;

		public int max;

		public float chance;
	}
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[PublicAPI]
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	public class Item
	{
		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
		private class ItemConfig
		{
			[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> craft;

			[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> upgrade;

			public ConfigEntry<CraftingTable> table = null;

			public ConfigEntry<int> tableLevel = null;

			public ConfigEntry<string> customTable = null;

			[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
			public ConfigEntry<int> maximumTableLevel;
		}

		[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(2)]
		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string Category;

			[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer;

			public Func<bool> browsability;
		}

		[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)]
		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)]
		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

			public SerializedRequirements(List<Requirement> reqs)
			{
				Reqs = reqs;
			}

			public SerializedRequirements(string reqs)
			{
				Reqs = reqs.Split(new char[1] { ',' }).Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					Requirement result = default(Requirement);
					result.itemName = array[0];
					result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2);
					return result;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}"));
			}

			[return: <1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
			public static ItemDrop fetchByName(ObjectDB objectDB, string name)
			{
				GameObject itemPrefab = objectDB.GetItemPrefab(name);
				ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("The required item '" + name + "' does not exist."));
				}
				return val;
			}

			public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade)
			{
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Expected O, but got Unknown
				//IL_00f7: Expected O, but got Unknown
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Requirement r) =>
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_0037: Unknown result type (might be due to invalid IL or missing references)
					ItemDrop val4 = ResItem(r);
					return (val4 == null) ? ((Requirement)null) : new Requirement
					{
						m_amount = (r.amountConfig?.Value ?? r.amount),
						m_resItem = val4,
						m_amountPerLevel = 0
					};
				}));
				foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != ""))
				{
					if (!dictionary.TryGetValue(item.itemName, out var value) || value == null)
					{
						ItemDrop val = ResItem(item);
						if (val != null)
						{
							string itemName = item.itemName;
							Requirement val2 = new Requirement
							{
								m_resItem = val,
								m_amount = 0
							};
							Requirement val3 = val2;
							dictionary[itemName] = val2;
							value = val3;
						}
					}
					if (value != null)
					{
						value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount;
					}
				}
				return dictionary.Values.Where([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Requirement v) => v != null).ToArray();
				[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(2)]
				ItemDrop ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
		private class SerializedDrop
		{
			public readonly List<DropTarget> Drops;

			public SerializedDrop(List<DropTarget> drops)
			{
				Drops = drops;
			}

			public SerializedDrop(string drops)
			{
				Drops = ((drops == "") ? ((IEnumerable<string>)Array.Empty<string>()) : ((IEnumerable<string>)drops.Split(new char[1] { ',' }))).Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					if (array.Length <= 2 || !int.TryParse(array[2], out var result))
					{
						result = 1;
					}
					if (array.Length <= 3 || !int.TryParse(array[3], out var result2))
					{
						result2 = result;
					}
					DropTarget result3 = default(DropTarget);
					result3.creature = array[0];
					result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f);
					result3.min = result;
					result3.max = result2;
					return result3;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}" + ((r.min == r.max) ? "" : $":{r.max}")));
			}

			[return: <1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
			private static Character fetchByName(ZNetScene netScene, string name)
			{
				GameObject prefab = netScene.GetPrefab(name);
				Character val = ((prefab != null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("The drop target character '" + name + "' does not exist."));
				}
				return val;
			}

			public Dictionary<Character, Drop> toCharacterDrops(ZNetScene netScene, GameObject item)
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Expected O, but got Unknown
				Dictionary<Character, Drop> dictionary = new Dictionary<Character, Drop>();
				foreach (DropTarget drop in Drops)
				{
					Character val = fetchByName(netScene, drop.creature);
					if (val != null)
					{
						dictionary[val] = new Drop
						{
							m_prefab = item,
							m_amountMin = drop.min,
							m_amountMax = drop.max,
							m_chance = drop.chance
						};
					}
				}
				return dictionary;
			}
		}

		private static readonly List<Item> registeredItems = new List<Item>();

		private static readonly Dictionary<ItemDrop, Item> itemDropMap = new Dictionary<ItemDrop, Item>();

		private static Dictionary<Item, Dictionary<string, List<Recipe>>> activeRecipes = new Dictionary<Item, Dictionary<string, List<Recipe>>>();

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		private static Dictionary<Item, Dictionary<string, ItemConfig>> itemCraftConfigs = new Dictionary<Item, Dictionary<string, ItemConfig>>();

		private static Dictionary<Item, ConfigEntry<string>> itemDropConfigs = new Dictionary<Item, ConfigEntry<string>>();

		private Dictionary<CharacterDrop, Drop> characterDrops = new Dictionary<CharacterDrop, Drop>();

		private readonly Dictionary<ConfigEntryBase, Action> statsConfigs = new Dictionary<ConfigEntryBase, Action>();

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable = null;

		private Configurability configurationVisible = Configurability.Full;

		public readonly GameObject Prefab;

		[Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")]
		public int MaximumRequiredStationLevel = int.MaxValue;

		[Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")]
		public readonly DropTargets DropsFrom = new DropTargets();

		internal List<Conversion> Conversions = new List<Conversion>();

		internal List<ItemConversion> conversions = new List<ItemConversion>();

		public Dictionary<string, ItemRecipe> Recipes = new Dictionary<string, ItemRecipe>();

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private LocalizeKey _name;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private LocalizeKey _description;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private static object configManager;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private static Localization _english;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private static object _configSync;

		private Configurability configurability => Configurable ?? DefaultConfigurability;

		[Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")]
		public RequiredResourceList RequiredItems => this[""].RequiredItems;

		[Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")]
		public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems;

		[Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")]
		public CraftingStationList Crafting => this[""].Crafting;

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase RecipeIsActive
		{
			[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(2)]
			get
			{
				return this[""].RecipeIsActive;
			}
			[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(2)]
			set
			{
				this[""].RecipeIsActive = value;
			}
		}

		[Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")]
		public int CraftAmount
		{
			get
			{
				return this[""].CraftAmount;
			}
			set
			{
				this[""].CraftAmount = value;
			}
		}

		public ItemRecipe this[string name]
		{
			get
			{
				if (Recipes.TryGetValue(name, out var value))
				{
					return value;
				}
				return Recipes[name] = new ItemRecipe();
			}
		}

		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
				if (shared.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(shared.m_name);
				}
				else
				{
					string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(shared.m_name);
					shared.m_name = text;
				}
				return _name;
			}
		}

		public LocalizeKey Description
		{
			get
			{
				LocalizeKey description = _description;
				if (description != null)
				{
					return description;
				}
				SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
				if (shared.m_description.StartsWith("$"))
				{
					_description = new LocalizeKey(shared.m_description);
				}
				else
				{
					string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_");
					_description = new LocalizeKey(text).English(shared.m_description);
					shared.m_description = text;
				}
				return _description;
			}
		}

		private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English"));

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)]
		private static object configSync
		{
			[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(2)]
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		public Item(string assetBundleFileName, string prefabName, string folderName = "assets")
			: this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName)
		{
		}

		public Item(AssetBundle bundle, string prefabName)
			: this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true)
		{
		}

		public Item(GameObject prefab, bool skipRegistering = false)
		{
			if (!skipRegistering)
			{
				PrefabManager.RegisterPrefab(prefab, addToObjectDb: true);
			}
			Prefab = prefab;
			registeredItems.Add(this);
			itemDropMap[Prefab.GetComponent<ItemDrop>()] = this;
		}

		public void ToggleConfigurationVisibility(Configurability visible)
		{
			configurationVisible = visible;
			if (itemDropConfigs.TryGetValue(this, out var value))
			{
				Toggle((ConfigEntryBase)(object)value, Configurability.Drop);
			}
			if (itemCraftConfigs.TryGetValue(this, out var value2))
			{
				foreach (ItemConfig value4 in value2.Values)
				{
					ToggleObj(value4, Configurability.Recipe);
				}
			}
			foreach (Conversion conversion in Conversions)
			{
				if (conversion.config != null)
				{
					ToggleObj(conversion.config, Configurability.Recipe);
				}
			}
			foreach (KeyValuePair<ConfigEntryBase, Action> statsConfig in statsConfigs)
			{
				Toggle(statsConfig.Key, Configurability.Stats);
				if ((visible & Configurability.Stats) != 0)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				foreach (object obj2 in tags)
				{
					if (obj2 is ConfigurationManagerAttributes configurationManagerAttributes)
					{
						configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability());
					}
				}
			}
			void ToggleObj(object obj, Configurability check)
			{
				FieldInfo[] fields = obj.GetType().GetFields();
				foreach (FieldInfo fieldInfo in fields)
				{
					object? value3 = fieldInfo.GetValue(obj);
					ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null);
					if (val != null)
					{
						Toggle(val, check);
					}
				}
			}
		}

		internal static void reloadConfigDisplay()
		{
			configManager?.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
		}

		internal static void Patch_FejdStartup()
		{
			//IL_0f7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f83: Unknown result type (might be due to invalid IL or missing references)
			//IL_104b: Unknown result type (might be due to invalid IL or missing references)
			//IL_104e: Invalid comparison between Unknown and I4
			//IL_0c49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c53: Expected O, but got Unknown
			//IL_1050: Unknown result type (might be due to invalid IL or missing references)
			//IL_1053: Invalid comparison between Unknown and I4
			//IL_1055: Unknown result type (might be due to invalid IL or missing references)
			//IL_1059: Invalid comparison between Unknown and I4
			//IL_11bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_11c2: Invalid comparison between Unknown and I4
			//IL_105b: Unknown result type (might be due to invalid IL or missing references)
			//IL_105e: Invalid comparison between Unknown and I4
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Expected O, but got Unknown
			//IL_11c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_11c7: Invalid comparison between Unknown and I4
			//IL_1060: Unknown result type (might be due to invalid IL or missing references)
			//IL_1064: Invalid comparison between Unknown and I4
			//IL_0d77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d81: Expected O, but got Unknown
			//IL_0e23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2d: Expected O, but got Unknown
			//IL_11c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_11cc: Invalid comparison between Unknown and I4
			//IL_1066: Unknown result type (might be due to invalid IL or missing references)
			//IL_1069: Invalid comparison between Unknown and I4
			//IL_0ed8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee2: Expected O, but got Unknown
			//IL_13dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_13df: Invalid comparison between Unknown and I4
			//IL_11ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d2: Invalid comparison between Unknown and I4
			//IL_106b: Unknown result type (might be due to invalid IL or missing references)
			//IL_106f: Invalid comparison between Unknown and I4
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Expected O, but got Unknown
			//IL_13e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e5: Invalid comparison between Unknown and I4
			//IL_11d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d8: Invalid comparison between Unknown and I4
			//IL_1071: Unknown result type (might be due to invalid IL or missing references)
			//IL_1075: Invalid comparison between Unknown and I4
			//IL_13e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ea: Invalid comparison between Unknown and I4
			//IL_1077: Unknown result type (might be due to invalid IL or missing references)
			//IL_107a: Invalid comparison between Unknown and I4
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Expected O, but got Unknown
			//IL_14ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_14d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_14d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_14d8: Invalid comparison between Unknown and I4
			//IL_13ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_13f0: Invalid comparison between Unknown and I4
			//IL_107c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1080: Invalid comparison between Unknown and I4
			//IL_14da: Unknown result type (might be due to invalid IL or missing references)
			//IL_14de: Invalid comparison between Unknown and I4
			//IL_13f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_13f6: Invalid comparison between Unknown and I4
			//IL_1082: Unknown result type (might be due to invalid IL or missing references)
			//IL_1086: Invalid comparison between Unknown and I4
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Expected O, but got Unknown
			//IL_1554: Unknown result type (might be due to invalid IL or missing references)
			//IL_1557: Invalid comparison between Unknown and I4
			//IL_1559: Unknown result type (might be due to invalid IL or missing references)
			//IL_155c: Invalid comparison between Unknown and I4
			//IL_155e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1562: Invalid comparison between Unknown and I4
			//IL_16b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_16b8: Invalid comparison between Unknown and I4
			//IL_1564: Unknown result type (might be due to invalid IL or missing references)
			//IL_1567: Invalid comparison between Unknown and I4
			//IL_1569: Unknown result type (might be due to invalid IL or missing references)
			//IL_156d: Invalid comparison between Unknown and I4
			//IL_156f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1573: Invalid comparison between Unknown and I4
			//IL_18c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_18ce: Invalid comparison between Unknown and I4
			//IL_19a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_19a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_19aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_19ae: Invalid comparison between Unknown and I4
			//IL_19b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_19b4: Invalid comparison between Unknown and I4
			//IL_1625: Unknown result type (might be due to invalid IL or missing references)
			//IL_162a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a2d: Invalid comparison between Unknown and I4
			//IL_1a2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a33: Invalid comparison between Unknown and I4
			//IL_1a35: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a39: Invalid comparison between Unknown and I4
			//IL_1a3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a3e: Invalid comparison between Unknown and I4
			//IL_1ec6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ec9: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			if (DefaultConfigurability != 0)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item3 in registeredItems.Where([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item2 = item3;
					string name2 = item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("['[\"\\]]").Replace(english.Localize(name2), "").Trim();
					string localizedName = Localization.instance.Localize(name2).Trim();
					if ((item2.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item2] = new Dictionary<string, ItemConfig>();
						foreach (string item4 in item2.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item4;
							int order = 0;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							ItemConfig itemConfig2 = (itemCraftConfigs[item2][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							if (!item2.Recipes.ContainsKey(configKey) || item2.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							ItemConfig itemConfig3 = cfg;
							string group = englishName;
							string name3 = "Crafting Station" + text;
							CraftingTable table = item2.Recipes[configKey].Crafting.Stations.First().Table;
							string text2 = "Crafting station where " + englishName + " is available.";
							object[] array = new object[1];
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes();
							int num = order - 1;
							order = num;
							configurationManagerAttributes.Order = num;
							configurationManagerAttributes.Browsable = (item2.configurationVisible & Configurability.Recipe) != 0;
							configurationManagerAttributes.Category = localizedName;
							array[0] = configurationManagerAttributes;
							itemConfig3.table = config(group, name3, table, new ConfigDescription(text2, (AcceptableValueBase)null, array));
							ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes();
							num = order - 1;
							order = num;
							configurationManagerAttributes2.Order = num;
							configurationManagerAttributes2.browsability = CustomTableBrowsability;
							configurationManagerAttributes2.Browsable = CustomTableBrowsability() && (item2.configurationVisible & Configurability.Recipe) != 0;
							configurationManagerAttributes2.Category = localizedName;
							ConfigurationManagerAttributes customTableAttributes = configurationManagerAttributes2;
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, item2.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes();
							num = order - 1;
							order = num;
							configurationManagerAttributes3.Order = num;
							configurationManagerAttributes3.browsability = TableLevelBrowsability;
							configurationManagerAttributes3.Browsable = TableLevelBrowsability() && (item2.configurationVisible & Configurability.Recipe) != 0;
							configurationManagerAttributes3.Category = localizedName;
							ConfigurationManagerAttributes configurationManagerAttributes4 = configurationManagerAttributes3;
							hideWhenNoneAttributes.Add(configurationManagerAttributes4);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item2.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes4 }));
							cfg.tableLevel.SettingChanged += [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value8))
								{
									value8.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item2.MaximumRequiredStationLevel == int.MaxValue) ? (item2.Recipes[configKey].Crafting.Stations.First().level + item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item2.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes4 }));
							}
							if ((!item2.Recipes[configKey].RequiredItems.Free || item2.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item2.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item2.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName);
							}
							if (item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item2.Recipes[configKey].RequiredUpgradeItems.Free || item2.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item2.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item2.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName);
							}
							if (cfg.craft != null)
							{
								cfg.craft.SettingChanged += ConfigChanged;
							}
							if (cfg.upgrade != null)
							{
								cfg.upgrade.SettingChanged += ConfigChanged;
							}
							void ConfigChanged(object o, EventArgs e)
							{
								if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value4))
								{
									foreach (Recipe item5 in value4)
									{
										item5.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? ""));
									}
								}
							}
							bool CustomTableBrowsability()
							{
								return cfg.table.Value == CraftingTable.Custom;
							}
							bool ItemBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							void TableConfigChanged(object o, EventArgs e)
							{
								if (activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value5))
								{
									value5.First().m_enabled = cfg.table.Value != CraftingTable.Disabled;
									CraftingTable value6 = cfg.table.Value;
									if (value6 == CraftingTable.Inventory || value6 == CraftingTable.Disabled)
									{
										value5.First().m_craftingStation = null;
									}
									else if (cfg.table.Value == CraftingTable.Custom)
									{
										Recipe obj = value5.First();
										GameObject prefab2 = ZNetScene.instance.GetPrefab(cfg.customTable.Value);
										obj.m_craftingStation = ((prefab2 != null) ? prefab2.GetComponent<CraftingStation>() : null);
									}
									else
									{
										value5.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(cfg.table.Value)).GetComponent<CraftingStation>();
									}
								}
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item6 in hideWhenNoneAttributes)
								{
									item6.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig(string name, string value, string desc)
							{
								//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
								//IL_00cc: Expected O, but got Unknown
								ConfigurationManagerAttributes configurationManagerAttributes5 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable
								};
								int num3 = order - 1;
								order = num3;
								configurationManagerAttributes5.Order = num3;
								configurationManagerAttributes5.browsability = ItemBrowsability;
								configurationManagerAttributes5.Browsable = ItemBrowsability() && (item2.configurationVisible & Configurability.Recipe) != 0;
								configurationManagerAttributes5.Category = localizedName;
								ConfigurationManagerAttributes configurationManagerAttributes6 = configurationManagerAttributes5;
								hideWhenNoneAttributes.Add(configurationManagerAttributes6);
								return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes6 }));
							}
						}
						if ((item2.configurability & Configurability.Drop) != 0)
						{
							ConfigEntry<string> val3 = (itemDropConfigs[item2] = config(englishName, "Drops from", new SerializedDrop(item2.DropsFrom.Drops).ToString(), new ConfigDescription("Creatures " + englishName + " drops from", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									CustomDrawer = drawDropsConfigTable,
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Drop) != 0)
								}
							})));
							ConfigEntry<string> val4 = val3;
							val4.SettingChanged += [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object _, EventArgs _) =>
							{
								item2.UpdateCharacterDrop();
							};
						}
						for (int j = 0; j < item2.Conversions.Count; j++)
						{
							string text3 = ((item2.Conversions.Count > 1) ? $"{j + 1}. " : "");
							Conversion conversion = item2.Conversions[j];
							conversion.config = new Conversion.ConversionConfig();
							int index = j;
							conversion.config.input = config(englishName, text3 + "Conversion Input Item", conversion.Input, new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.input.SettingChanged += [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (index < item2.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item2.conversions[index].m_from = from;
										UpdatePiece();
									}
								}
							};
							conversion.config.piece = config(englishName, text3 + "Conversion Piece", conversion.Piece, new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.piece.SettingChanged += [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							conversion.config.customPiece = config(englishName, text3 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.customPiece.SettingChanged += [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item2.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance))
								{
									string text4 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value)));
									string activePiece = conversion.config.activePiece;
									if (conversion.config.activePiece != null)
									{
										Smelter component = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent<Smelter>();
										int num2 = component.m_conversion.IndexOf(item2.conversions[index]);
										if (num2 >= 0)
										{
											Smelter[] array4 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val5 in array4)
											{
												if (Utils.GetPrefabName(((Component)val5).gameObject) == activePiece)
												{
													val5.m_conversion.RemoveAt(num2);
												}
											}
										}
										conversion.config.activePiece = null;
									}
									if (item2.conversions[index].m_from != null && conversion.config.piece.Value != 0)
									{
										GameObject prefab = ZNetScene.instance.GetPrefab(text4);
										if (((prefab != null) ? prefab.GetComponent<Smelter>() : null) != null)
										{
											conversion.config.activePiece = text4;
											Smelter[] array5 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val6 in array5)
											{
												if (Utils.GetPrefabName(((Component)val6).gameObject) == text4)
												{
													val6.m_conversion.Add(item2.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item2.configurability & Configurability.Stats) == 0)
					{
						continue;
					}
					item2.statsConfigs.Clear();
					SharedData shared2 = item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
					ItemType itemType = shared2.m_itemType;
					statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value)
					{
						shared.m_weight = value;
					});
					statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value)
					{
						shared.m_value = value;
					});
					if ((int)itemType == 4 || (int)itemType == 7 || (int)itemType == 12 || (int)itemType == 6 || (int)itemType == 11 || (int)itemType == 5 || (int)itemType == 17 || (int)itemType == 19 || (int)itemType == 3 || (int)itemType == 14 || (int)itemType == 22)
					{
						statcfg<float>("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value)
						{
							shared.m_maxDurability = value;
						});
						statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value)
						{
							shared.m_durabilityPerLevel = value;
						});
						statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value)
						{
							shared.m_movementModifier = value;
						});
					}
					if ((int)itemType == 4 || (int)itemType == 5 || (int)itemType == 3 || (int)itemType == 14 || (int)itemType == 22)
					{
						statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value)
						{
							shared.m_blockPower = value;
						});
						statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value)
						{
							shared.m_blockPowerPerLevel = value;
						});
						statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value)
						{
							shared.m_deflectionForce = value;
						});
						statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value)
						{
							shared.m_deflectionForcePerLevel = value;
						});
						statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value)
						{
							shared.m_timedBlockBonus = value;
						});
					}
					else if ((int)itemType == 7 || (int)itemType == 12 || (int)itemType == 6 || (int)itemType == 11 || (int)itemType == 17)
					{
						statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value)
						{
							shared.m_armor = value;
						});
						statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value)
						{
							shared.m_armorPerLevel = value;
						});
					}
					SkillType skillType = shared2.m_skillType;
					if ((int)skillType == 7 || (int)skillType == 12)
					{
						statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value)
						{
							shared.m_toolTier = value;
						});
					}
					if ((int)itemType == 5 || (int)itemType == 7 || (int)itemType == 12 || (int)itemType == 6 || (int)itemType == 11 || (int)itemType == 17)
					{
						Dictionary<DamageType, DamageModifier> modifiers = shared2.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier);
						DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType));
						DamageType[] array2 = new DamageType[5];
						RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
						foreach (DamageType item7 in first.Except((IEnumerable<DamageType>)(object)array2))
						{
							DamageType damageType = item7;
							statcfg<DamageModifier>(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => modifiers.TryGetValue(damageType, out var value7) ? value7 : DamageModifier.None, delegate(SharedData shared, DamageModifier value)
							{
								//IL_0003: Unknown result type (might be due to invalid IL or missing references)
								//IL_000c: Unknown result type (might be due to invalid IL or missing references)
								//IL_0011: Unknown result type (might be due to invalid IL or missing references)
								//IL_0019: Unknown result type (might be due to invalid IL or missing references)
								//IL_001e: Unknown result type (might be due to invalid IL or missing references)
								//IL_001f: Unknown result type (might be due to invalid IL or missing references)
								//IL_002c: Unknown result type (might be due to invalid IL or missing references)
								//IL_0031: Unknown result type (might be due to invalid IL or missing references)
								//IL_0037: Unknown result type (might be due to invalid IL or missing references)
								//IL_009d: Unknown result type (might be due to invalid IL or missing references)
								//IL_0066: Unknown result type (might be due to invalid IL or missing references)
								DamageModPair val7 = default(DamageModPair);
								val7.m_type = damageType;
								val7.m_modifier = (DamageModifier)value;
								DamageModPair val8 = val7;
								for (int num4 = 0; num4 < shared.m_damageModifiers.Count; num4++)
								{
									if (shared.m_damageModifiers[num4].m_type == damageType)
									{
										if (value == DamageModifier.None)
										{
											shared.m_damageModifiers.RemoveAt(num4);
										}
										else
										{
											shared.m_damageModifiers[num4] = val8;
										}
										return;
									}
								}
								if (value != DamageModifier.None)
								{
									shared.m_damageModifiers.Add(val8);
								}
							});
						}
					}
					if ((int)itemType == 2 && shared2.m_food > 0f)
					{
						statcfg<float>("Health", "Health value of " + englishName + ".", (SharedData shared) => shared.m_food, delegate(SharedData shared, float value)
						{
							shared.m_food = value;
						});
						statcfg<float>("Stamina", "Stamina value of " + englishName + ".", (SharedData shared) => shared.m_foodStamina, delegate(SharedData shared, float value)
						{
							shared.m_foodStamina = value;
						});
						statcfg<float>("Eitr", "Eitr value of " + englishName + ".", (SharedData shared) => shared.m_foodEitr, delegate(SharedData shared, float value)
						{
							shared.m_foodEitr = value;
						});
						statcfg<float>("Duration", "Duration of " + englishName + ".", (SharedData shared) => shared.m_foodBurnTime, delegate(SharedData shared, float value)
						{
							shared.m_foodBurnTime = value;
						});
						statcfg<float>("Health Regen", "Health regen value of " + englishName + ".", (SharedData shared) => shared.m_foodRegen, delegate(SharedData shared, float value)
						{
							shared.m_foodRegen = value;
						});
					}
					if ((int)shared2.m_skillType == 10)
					{
						statcfg<float>("Health Cost", "Health cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealth, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_attackHealth = value;
						});
						statcfg<float>("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealthPercentage, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_attackHealthPercentage = value;
						});
					}
					skillType = shared2.m_skillType;
					if ((int)skillType == 10 || (int)skillType == 9)
					{
						statcfg<float>("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackEitr, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_attackEitr = value;
						});
					}
					if ((int)itemType != 3 && (int)itemType != 14 && (int)itemType != 22 && (int)itemType != 4)
					{
						continue;
					}
					statcfg<float>("Knockback", "Knockback of " + englishName + ".", (SharedData shared) => shared.m_attackForce, delegate(SharedData shared, float value)
					{
						shared.m_attackForce = value;
					});
					statcfg<float>("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData shared) => shared.m_backstabBonus, delegate(SharedData shared, float value)
					{
						shared.m_backstabBonus = value;
					});
					statcfg<float>("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackStamina, delegate(SharedData shared, float value)
					{
						shared.m_attack.m_attackStamina = value;
					});
					SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_damage = val;
					});
					SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_slash = val;
					});
					SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_pierce = val;
					});
					SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_blunt = val;
					});
					SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_chop = val;
					});
					SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_pickaxe = val;
					});
					SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_fire = val;
					});
					SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_poison = val;
					});
					SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_frost = val;
					});
					SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_lightning = val;
					});
					SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_spirit = val;
					});
					if ((int)itemType == 4)
					{
						statcfg<int>("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_projectileBursts, delegate(SharedData shared, int value)
						{
							shared.m_attack.m_projectileBursts = value;
						});
						statcfg<float>("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_burstInterval, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_burstInterval = value;
						});
						statcfg<float>("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracyMin, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileAccuracyMin = value;
						});
						statcfg<float>("Accuracy", "Accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracy, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileAccuracy = value;
						});
						statcfg<float>("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVelMin, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileVelMin = value;
						});
						statcfg<float>("Velocity", "Velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVel, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileVel = value;
						});
						statcfg<float>("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData shared) => shared.m_attack.m_drawDurationMin, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_drawDurationMin = value;
						});
						statcfg<float>("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData shared) => shared.m_attack.m_drawStaminaDrain, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_drawStaminaDrain = value;
						});
					}
					void SetDmg(string dmgType, Func<DamageTypes, float> readDmg, setDmgFunc setDmg)
					{
						statcfg<float>(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData shared) => readDmg(shared.m_damages), delegate(SharedData shared, float val)
						{
							setDmg(ref shared.m_damages, val);
						});
						statcfg<float>(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData shared) => readDmg(shared.m_damagesPerLevel), delegate(SharedData shared, float val)
						{
							setDmg(ref shared.m_damagesPerLevel, val);
						});
					}
					void statcfg<T>(string configName, string description, [<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 1, 1, 0 })] Func<SharedData, T> readDefault, [<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 1, 1, 0 })] Action<SharedData, T> setValue)
					{
						//IL_0083: Unknown result type (might be due to invalid IL or missing references)
						//IL_008d: Expected O, but got Unknown
						SharedData shared3 = item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ConfigEntry<T> cfg2 = config(englishName, configName, readDefault(shared3), new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
						{
							new ConfigurationManagerAttributes
							{
								Category = localizedName,
								Browsable = ((item2.configurationVisible & Configurability.Stats) != 0)
							}
						}));
						if ((item2.configurationVisible & Configurability.Stats) != 0)
						{
							setValue(shared3, cfg2.Value);
						}
						string itemName = shared3.m_name;
						item2.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig);
						cfg2.SettingChanged += [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object _, EventArgs _) =>
						{
							if ((item2.configurationVisible & Configurability.Stats) != 0)
							{
								ApplyConfig();
							}
						};
						void ApplyConfig()
						{
							setValue(shared3, cfg2.Value);
							Inventory[] source = (from c in Player.s_players.Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType<Container>()
									select c.GetInventory())
								where c != null
								select c).ToArray();
							foreach (ItemData item8 in (from i in (from p in ObjectDB.instance.m_items
									select p.GetComponent<ItemDrop>() into c
									where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent<ZNetView>())
									select c).Concat(ItemDrop.s_instances)
								select i.m_itemData).Concat(source.SelectMany([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Inventory i) => i.GetAllItems())))
							{
								if (item8.m_shared.m_name == itemName)
								{
									setValue(item8.m_shared, cfg2.Value);
								}
							}
						}
					}
				}
				if (saveOnConfigSet)
				{
					plugin.Config.SaveOnConfigSet = true;
					plugin.Config.Save();
				}
			}
			foreach (Item registeredItem in registeredItems)
			{
				Item item = registeredItem;
				foreach (KeyValuePair<string, ItemRecipe> recipe in item.Recipes)
				{
					KeyValuePair<string, ItemRecipe> kv = recipe;
					RequiredResourceList[] array3 = new RequiredResourceList[2]
					{
						kv.Value.RequiredItems,
						kv.Value.RequiredUpgradeItems
					};
					foreach (RequiredResourceList requiredResourceList in array3)
					{
						for (int l = 0; l < requiredResourceList.Requirements.Count; l++)
						{
							ConfigEntry<int> amountCfg;
							int resourceIndex;
							if ((item.configurability & Configurability.Recipe) != 0)
							{
								amountCfg = requiredResourceList.Requirements[l].amountConfig;
								if (amountCfg != null)
								{
									resourceIndex = l;
									amountCfg.SettingChanged += ConfigChanged;
								}
							}
							void ConfigChanged(object o, EventArgs e)
							{
								if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(kv.Key, out var value3))
								{
									foreach (Recipe item9 in value3)
									{
										item9.m_resources[resourceIndex].m_amount = amountCfg.Value;
									}
								}
							}
						}
					}
					ConfigEntryBase enabledCfg = kv.Value.RecipeIsActive;
					if (enabledCfg != null)
					{
						((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged));
					}
					void ConfigChanged(object o, EventArgs e)
					{
						if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(kv.Key, out var value2))
						{
							foreach (Recipe item10 in value2)
							{
								item10.m_enabled = (int)enabledCfg.BoxedValue != 0;
							}
						}
					}
				}
			}
		}

		[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)]
		[return: <1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(1)]
		private static string getInternalName<T>(T value) where T : struct
		{
			return ((InternalName)typeof(T).GetMember(value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName;
		}

		[HarmonyPriority(0)]
		internal static void Patch_ObjectDBInit(ObjectDB __instance)
		{
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Expected O, but got Unknown
			if ((Object)(object)__instance.GetItemPrefab("Wood") == (Object)null)
			{
				return;
			}
			hiddenCraftRecipes.Clear();
			hiddenUpgradeRecipes.Clear();
			foreach (Item registeredItem in registeredItems)
			{
				activeRecipes[registeredItem] = new Dictionary<string, List<Recipe>>();
				itemCraftConfigs.TryGetValue(registeredItem, out var value);
				foreach (KeyValuePair<string, ItemRecipe> recipe in registeredItem.Recipes)
				{
					List<Recipe> list = new List<Recipe>();
					foreach (CraftingStationConfig station in recipe.Value.Crafting.Stations)
					{
						ItemConfig itemConfig = value?[recipe.Key];
						Recipe val = ScriptableObject.CreateInstance<Recipe>();
						((Object)val).name = ((Object)registeredItem.Prefab).name + "_Recipe_" + station.Table;
						val.m_amount = registeredItem[recipe.Key].CraftAmount;
						val.m_enabled = itemConfig == null || itemConfig.table.Value != CraftingTable.Disabled;
						val.m_item = registeredItem.Prefab.GetComponent<ItemDrop>();
						val.m_resources = SerializedRequirements.toPieceReqs(__instance, (itemConfig?.craft == null) ? new SerializedRequirements(registeredItem[recipe.Key].RequiredItems.Requirements) : new SerializedRequirements(itemConfig.craft.Value), (itemConfig?.upgrade == null) ? new SerializedRequirements(registeredItem[recipe.Key].RequiredUpgradeItems.Requirements) : new SerializedRequirements(itemConfig.upgrade.Value));
						CraftingTable craftingTable = ((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value);
						if (craftingTable == CraftingTable.Inventory || craftingTable == CraftingTable.Disabled)
						{
							val.m_craftingStation = null;
						}
						else if (((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value) == CraftingTable.Custom)
						{
							GameObject prefab = ZNetScene.instance.GetPrefab((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value);
							if (prefab != null)
							{
								val.m_craftingStation = prefab.GetComponent<CraftingStation>();
							}
							else
							{
								Debug.LogWarning((object)("Custom crafting station '" + ((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value) + "' does not exist"));
							}
						}
						else
						{
							val.m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value)).GetComponent<CraftingStation>();
						}
						val.m_minStationLevel = ((itemConfig == null || list.Count > 0) ? station.level : itemConfig.tableLevel.Value);
						ConfigEntryBase recipeIsActive = recipe.Value.RecipeIsActive;
						val.m_enabled = (int)(((recipeIsActive != null) ? recipeIsActive.BoxedValue : null) ?? ((object)1)) != 0;
						list.Add(val);
						if (!registeredItem[recipe.Key].RequiredItems.Free && registeredItem[recipe.Key].RequiredItems.Requirements.Count == 0)
						{
							hiddenCraftRecipes.Add(val, recipe.Value.RecipeIsActive);
						}
						if (!registeredItem[recipe.Key].RequiredUpgradeItems.Free && registeredItem[recipe.Key].RequiredUpgradeItems.Requirements.Count == 0)
						{
							hiddenUpgradeRecipes.Add(val, recipe.Value.RecipeIsActive);
						}
					}
					activeRecipes[registeredItem].Add(recipe.Key, list);
					__instance.m_recipes.AddRange(list);
				}
				registeredItem.conversions = new List<ItemConversion>();
				for (int i = 0; i < registeredItem.Conversions.Count; i++)
				{
					Conversion conversion = registeredItem.Conversions[i];
					registeredItem.conversions.Add(new ItemConversion
					{
						m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input),
						m_to = registeredItem.Prefab.GetComponent<ItemDrop>()
					});
					ConversionPiece conversionPiece = conversion.config?.piece.Value ?? conversion.Piece;
					string text = null;
					if (conversionPiece != 0 && registeredItem.conversions[i].m_from != null)
					{
						text = ((conversionPiece != ConversionPiece.Custom) ? getInternalName(conversionPiece) : (conversion.config?.customPiece.Value ?? conversion.customPiece));
						GameObject prefab2 = ZNetScene.instance.GetPrefab(text);
						Smelter val2 = ((prefab2 != null) ? prefab2.GetComponent<Smelter>() : null);
						if (val2 != null)
						{
							val2.m_conversion.Add(registeredItem.conversions[i]);
						}
						else
						{
							text = null;
						}
					}
					if (conversion.config != null)
					{
						conversion.config.activePiece = text;
					}
				}
			}
		}

		internal static void Patch_OnAddSmelterInput(ItemData item, bool __result)
		{
			if (__result)
			{
				((Humanoid)Player.m_localPlayer).UnequipItem(item, true);
			}
		}

		internal static void Patch_MaximumRequiredStationLevel(Recipe __instance, ref int __result, int quality)
		{
			if (!itemDropMap.TryGetValue(__instance.m_item, out var value))
			{
				return;
			}
			IEnumerable<ItemConfig> source;
			if (!itemCraftConfigs.TryGetValue(value, out var value2))
			{
				source = Enumerable.Empty<ItemConfig>();
			}
			else
			{
				CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
				if (currentCraftingStation != null)
				{
					string stationName = Utils.GetPrefabName(((Component)currentCraftingStation).gameObject);
					source = from c in value2.Where([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (KeyValuePair<string, ItemConfig> c) =>
						{
							CraftingTable value3 = c.Value.table.Value;
							if (1 == 0)
							{
							}
							bool result;
							switch (value3)
							{
							case CraftingTable.Disabled:
							case CraftingTable.Inventory:
								result = false;
								break;
							case CraftingTable.Custom:
								result = c.Value.customTable.Value == stationName;
								break;
							default:
								result = getInternalName(c.Value.table.Value) == stationName;
								break;
							}
							if (1 == 0)
							{
							}
							return result;
						})
						select c.Value;
				}
				else
				{
					source = value2.Values;
				}
			}
			__result = Mathf.Min(Mathf.Max(1, __instance.m_minStationLevel) + (quality - 1), (from cfg in source
				where cfg.maximumTableLevel != null
				select cfg.maximumTableLevel.Value).DefaultIfEmpty(value.MaximumRequiredStationLevel).Max());
		}

		internal static void Patch_GetAvailableRecipesPrefix([<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 2, 1, 1, 1, 2 })] ref Dictionary<Assembly, Dictionary<Recipe, ConfigEntryBase>> __state)
		{
			if (__state == null)
			{
				__state = new Dictionary<Assembly, Dictionary<Recipe, ConfigEntryBase>>();
			}
			Dictionary<Recipe, ConfigEntryBase> dictionary;
			if (InventoryGui.instance.InCraftTab())
			{
				dictionary = hiddenCraftRecipes;
			}
			else
			{
				if (!InventoryGui.instance.InUpradeTab())
				{
					return;
				}
				dictionary = hiddenUpgradeRecipes;
			}
			foreach (Recipe key in dictionary.Keys)
			{
				key.m_enabled = false;
			}
			__state[Assembly.GetExecutingAssembly()] = dictionary;
		}

		internal static void Patch_GetAvailableRecipesFinalizer([<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(new byte[] { 1, 1, 1, 1, 2 })] Dictionary<Assembly, Dictionary<Recipe, ConfigEntryBase>> __state)
		{
			if (!__state.TryGetValue(Assembly.GetExecutingAssembly(), out var value))
			{
				return;
			}
			foreach (KeyValuePair<Recipe, ConfigEntryBase> item in value)
			{
				Recipe key = item.Key;
				ConfigEntryBase value2 = item.Value;
				key.m_enabled = (int)(((value2 != null) ? value2.BoxedValue : null) ?? ((object)1)) != 0;
			}
		}

		internal static void Patch_ZNetSceneAwake(ZNetScene __instance)
		{
			foreach (Item registeredItem in registeredItems)
			{
				registeredItem.AssignDropToCreature();
			}
		}

		public void AssignDropToCreature()
		{
			characterDrops.Clear();
			SerializedDrop serializedDrop = new SerializedDrop(DropsFrom.Drops);
			if (itemDropConfigs.TryGetValue(this, out var value))
			{
				serializedDrop = new SerializedDrop(value.Value);
			}
			foreach (KeyValuePair<Character, Drop> item in serializedDrop.toCharacterDrops(ZNetScene.s_instance, Prefab))
			{
				CharacterDrop val = ((Component)item.Key).GetComponent<CharacterDrop>();
				if (val == null)
				{
					val = ((Component)item.Key).gameObject.AddComponent<CharacterDrop>();
				}
				val.m_drops.Add(item.Value);
				characterDrops.Add(val, item.Value);
			}
		}

		public void UpdateCharacterDrop()
		{
			if (!Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				return;
			}
			foreach (KeyValuePair<CharacterDrop, Drop> characterDrop in characterDrops)
			{
				if (Object.op_Implicit((Object)(object)characterDrop.Key))
				{
					characterDrop.Key.m_drops.Remove(characterDrop.Value);
				}
			}
			AssignDropToCreature();
		}

		public void Snapshot(float lightIntensity = 1.3f, Quaternion? cameraRotation = null)
		{
			SnapshotItem(Prefab.GetComponent<ItemDrop>(), lightIntensity, cameraRotation);
		}

		public static void SnapshotItem(ItemDrop item, float lightIntensity = 1.3f, Quaternion? cameraRotation = null)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Expected O, but got Unknown
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			Camera component = new GameObject("Camera", new Type[1] { typeof(Camera) }).GetComponent<Camera>();
			component.backgroundColor = Color.clear;
			component.clearFlags = (CameraClearFlags)2;
			component.fieldOfView = 0.5f;
			component.farClipPlane = 10000000f;
			component.cullingMask = 1073741824;
			((Component)component).transform.rotation = (Quaternion)(((??)cameraRotation) ?? Quaternion.Euler(90f, 0f, 45f));
			Light component2 = new GameObject("Light", new Type[1] { typeof(Light) }).GetComponent<Light>();
			((Component)component2).transform.rotation = Quaternion.Euler(150f, 0f, -5f);
			component2.type = (LightType)1;
			component2.cullingMask = 1073741824;
			component2.intensity = lightIntensity;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, 0f, 64f, 64f);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)((Component)item).transform.Find("attach")).gameObject);
			Transform[] componentsInChildren = val2.GetComponentsInChildren<Transform>();
			foreach (Transform val3 in componentsInChildren)
			{
				((Component)val3).gameObject.layer = 30;
			}
			Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>();
			Vector3 val4 = componentsInChildren2.Aggregate(Vector3.positiveInfinity, [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Vector3 cur, Renderer renderer) =>
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				Vector3 result2;
				if (!(renderer is ParticleSystemRenderer))
				{
					Bounds bounds2 = renderer.bounds;
					result2 = Vector3.Min(cur, ((Bounds)(ref bounds2)).min);
				}
				else
				{
					result2 = cur;
				}
				return result2;
			});
			Vector3 val5 = componentsInChildren2.Aggregate(Vector3.negativeInfinity, [<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (Vector3 cur, Renderer renderer) =>
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				Vector3 result;
				if (!(renderer is ParticleSystemRenderer))
				{
					Bounds bounds = renderer.bounds;
					result = Vector3.Max(cur, ((Bounds)(ref bounds)).max);
				}
				else
				{
					result = cur;
				}
				return result;
			});
			Vector3 val6 = val5 - val4;
			component.targetTexture = RenderTexture.GetTemporary((int)((Rect)(ref val)).width, (int)((Rect)(ref val)).height);
			float num = Mathf.Max(val6.x, val6.z);
			float num2 = Mathf.Min(val6.x, val6.z);
			float num3 = (num + num2) / Mathf.Sqrt(2f) / Mathf.Tan(component.fieldOfView * ((float)Math.PI / 180f));
			Transform transform = ((Component)component).transform;
			Vector3 val7 = (val4 + val5) / 2f;
			val7.y = val5.y;
			transform.position = val7 + new Vector3(0f, num3, 0f);
			((Component)component2).transform.position = transform.position + new Vector3(-2f, 0f, 0.2f) / 3f * (0f - num3);
			component.Render();
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = component.targetTexture;
			Texture2D val8 = new Texture2D((int)((Rect)(ref val)).width, (int)((Rect)(ref val)).height, (TextureFormat)4, false);
			val8.ReadPixels(val, 0, 0);
			val8.Apply();
			RenderTexture.active = active;
			item.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val8, val, new Vector2(0.5f, 0.5f)) };
			Object.DestroyImmediate((Object)(object)val2);
			component.targetTexture.Release();
			Object.Destroy((Object)(object)component);
			Object.Destroy((Object)(object)component2);
		}

		private static bool CheckItemIsUpgrade(InventoryGui gui)
		{
			ItemData itemData = ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData;
			return itemData != null && itemData.m_quality > 0;
		}

		internal static IEnumerable<CodeInstruction> Transpile_InventoryGui(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> instrs = instructions.ToList();
			FieldInfo amountField = AccessTools.DeclaredField(typeof(Recipe), "m_amount");
			int i = 0;
			while (i < instrs.Count)
			{
				yield return instrs[i];
				if (i > 1 && instrs[i - 2].opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(instrs[i - 2], (MemberInfo)amountField) && instrs[i - 1].opcode == OpCodes.Ldc_I4_1 && instrs[i].operand is Label)
				{
					yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Item), "CheckItemIsUpgrade", (Type[])null, (Type[])null));
					yield return new CodeInstruction(OpCodes.Brtrue, instrs[i].operand);
				}
				int num = i + 1;
				i = num;
			}
		}

		private static void drawRequirementsConfigTable(ConfigEntryBase cfg)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			bool valueOrDefault = cfg.Description.Tags.Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault();
			List<Requirement> list = new List<Requirement>();
			bool flag = false;
			int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true)
				.Invoke(configManager, Array.Empty<object>()) ?? ((object)130));
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			foreach (Requirement req in new SerializedRequirements((string)cfg.BoxedValue).Reqs)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				int num2 = req.amount;
				if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 40f
				}, Array.Empty<GUILayoutOption>()), out var result) && result != num2 && !valueOrDefault)
				{
					num2 = result;
					flag = true;
				}
				string text = GUILayout.TextField(req.itemName, new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = num - 40 - 21 - 21 - 9
				}, Array.Empty<GUILayoutOption>());
				string text2 = (valueOrDefault ? req.itemName : text);
				flag = flag || text2 != req.itemName;
				if (GUILayout.Button("x", new GUIStyle(GUI.skin.button)
				{
					fixedWidth = 21f
				}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
				{
					flag = true;
				}
				else
				{
					list.Add(new Requirement
					{
						amount = num2,
						itemName = text2
					});
				}
				if (GUILayout.Button("+", new GUIStyle(GUI.skin.button)
				{
					fixedWidth = 21f
				}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
				{
					flag = true;
					list.Add(new Requirement
					{
						amount = 1,
						itemName = ""
					});
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
			if (flag)
			{
				cfg.BoxedValue = new SerializedRequirements(list).ToString();
			}
		}

		private static void drawDropsConfigTable(ConfigEntryBase cfg)
		{
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Expected O, but got Unknown
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Expected O, but got Unknown
			bool valueOrDefault = cfg.Description.Tags.Select([<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault();
			List<DropTarget> list = new List<DropTarget>();
			bool flag = false;
			int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true)
				.Invoke(configManager, Array.Empty<object>()) ?? ((object)130));
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			foreach (DropTarget item in new SerializedDrop((string)cfg.BoxedValue).Drops.DefaultIfEmpty(new DropTarget
			{
				min = 1,
				max = 1,
				creature = "",
				chance = 1f
			}))
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				string text = GUILayout.TextField(item.creature, new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = num - 21 - 21 - 6
				}, Array.Empty<GUILayoutOption>());
				string text2 = (valueOrDefault ? item.creature : text);
				flag = flag || text2 != item.creature;
				bool flag2 = GUILayout.Button("x", new GUIStyle(GUI.skin.button)
				{
					fixedWidth = 21f
				}, Array.Empty<GUILayoutOption>());
				bool flag3 = GUILayout.Button("+", new GUIStyle(GUI.skin.button)
				{
					fixedWidth = 21f
				}, Array.Empty<GUILayoutOption>());
				GUILayout.EndHorizontal();
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Label("Chance: ", Array.Empty<GUILayoutOption>());
				float num2 = item.chance;
				if (float.TryParse(GUILayout.TextField((num2 * 100f).ToString(CultureInfo.InvariantCulture), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 45f
				}, Array.Empty<GUILayoutOption>()), out var result) && !Mathf.Approximately(result / 100f, num2) && !valueOrDefault)
				{
					num2 = result;
					flag = true;
				}
				GUILayout.Label("% Amount: ", Array.Empty<GUILayoutOption>());
				int num3 = item.min;
				if (int.TryParse(GUILayout.TextField(num3.ToString(), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 35f
				}, Array.Empty<GUILayoutOption>()), out var result2) && result2 != num3 && !valueOrDefault)
				{
					num3 = result2;
					flag = true;
				}
				GUILayout.Label(" - ", Array.Empty<GUILayoutOption>());
				int num4 = item.max;
				if (int.TryParse(GUILayout.TextField(num4.ToString(), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 35f
				}, Array.Empty<GUILayoutOption>()), out var result3) && result3 != num4 && !valueOrDefault)
				{
					num4 = result3;
					flag = true;
				}
				if (flag2 && !valueOrDefault)
				{
					flag = true;
				}
				else
				{
					list.Add(new DropTarget
					{
						creature = text2,
						min = num3,
						max = num4,
						chance = num2
					});
				}
				if (flag3 && !valueOrDefault)
				{
					flag = true;
					list.Add(new DropTarget
					{
						min = 1,
						max = 1,
						creature = "",
						chance = 1f
					});
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
			if (flag)
			{
				cfg.BoxedValue = new SerializedDrop(list).ToString();
			}
		}

		private static ConfigEntry<T> config<[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)] T>(string group, string name, T value, ConfigDescription description)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T))
				.Invoke(configSync, new object[1] { val });
			return val;
		}

		private static ConfigEntry<T> config<[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(2)] T>(string group, string name, T value, string description)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	[PublicAPI]
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	public class LocalizeKey
	{
		private static readonly List<LocalizeKey> keys = new List<LocalizeKey>();

		public readonly string Key;

		public readonly Dictionary<string, string> Localizations = new Dictionary<string, string>();

		public LocalizeKey(string key)
		{
			Key = key.Replace("$", "");
		}

		public void Alias(string alias)
		{
			Localizations.Clear();
			if (!alias.Contains("$"))
			{
				alias = "$" + alias;
			}
			Localizations["alias"] = alias;
			Localization.instance.AddWord(Key, Localization.instance.Localize(alias));
		}

		public LocalizeKey English(string key)
		{
			return addForLang("English", key);
		}

		public LocalizeKey Swedish(string key)
		{
			return addForLang("Swedish", key);
		}

		public LocalizeKey French(string key)
		{
			return addForLang("French", key);
		}

		public LocalizeKey Italian(string key)
		{
			return addForLang("Italian", key);
		}

		public LocalizeKey German(string key)
		{
			return addForLang("German", key);
		}

		public LocalizeKey Spanish(string key)
		{
			return addForLang("Spanish", key);
		}

		public LocalizeKey Russian(string key)
		{
			return addForLang("Russian", key);
		}

		public LocalizeKey Romanian(string key)
		{
			return addForLang("Romanian", key);
		}

		public LocalizeKey Bulgarian(string key)
		{
			return addForLang("Bulgarian", key);
		}

		public LocalizeKey Macedonian(string key)
		{
			return addForLang("Macedonian", key);
		}

		public LocalizeKey Finnish(string key)
		{
			return addForLang("Finnish", key);
		}

		public LocalizeKey Danish(string key)
		{
			return addForLang("Danish", key);
		}

		public LocalizeKey Norwegian(string key)
		{
			return addForLang("Norwegian", key);
		}

		public LocalizeKey Icelandic(string key)
		{
			return addForLang("Icelandic", key);
		}

		public LocalizeKey Turkish(string key)
		{
			return addForLang("Turkish", key);
		}

		public LocalizeKey Lithuanian(string key)
		{
			return addForLang("Lithuanian", key);
		}

		public LocalizeKey Czech(string key)
		{
			return addForLang("Czech", key);
		}

		public LocalizeKey Hungarian(string key)
		{
			return addForLang("Hungarian", key);
		}

		public LocalizeKey Slovak(string key)
		{
			return addForLang("Slovak", key);
		}

		public LocalizeKey Polish(string key)
		{
			return addForLang("Polish", key);
		}

		public LocalizeKey Dutch(string key)
		{
			return addForLang("Dutch", key);
		}

		public LocalizeKey Portuguese_European(string key)
		{
			return addForLang("Portuguese_European", key);
		}

		public LocalizeKey Portuguese_Brazilian(string key)
		{
			return addForLang("Portuguese_Brazilian", key);
		}

		public LocalizeKey Chinese(string key)
		{
			return addForLang("Chinese", key);
		}

		public LocalizeKey Japanese(string key)
		{
			return addForLang("Japanese", key);
		}

		public LocalizeKey Korean(string key)
		{
			return addForLang("Korean", key);
		}

		public LocalizeKey Hindi(string key)
		{
			return addForLang("Hindi", key);
		}

		public LocalizeKey Thai(string key)
		{
			return addForLang("Thai", key);
		}

		public LocalizeKey Abenaki(string key)
		{
			return addForLang("Abenaki", key);
		}

		public LocalizeKey Croatian(string key)
		{
			return addForLang("Croatian", key);
		}

		public LocalizeKey Georgian(string key)
		{
			return addForLang("Georgian", key);
		}

		public LocalizeKey Greek(string key)
		{
			return addForLang("Greek", key);
		}

		public LocalizeKey Serbian(string key)
		{
			return addForLang("Serbian", key);
		}

		public LocalizeKey Ukrainian(string key)
		{
			return addForLang("Ukrainian", key);
		}

		private LocalizeKey addForLang(string lang, string value)
		{
			Localizations[lang] = value;
			if (Localization.instance.GetSelectedLanguage() == lang)
			{
				Localization.instance.AddWord(Key, value);
			}
			else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key))
			{
				Localization.instance.AddWord(Key, value);
			}
			return this;
		}

		[HarmonyPriority(300)]
		internal static void AddLocalizedKeys(Localization __instance, string language)
		{
			foreach (LocalizeKey key in keys)
			{
				string value2;
				if (key.Localizations.TryGetValue(language, out var value) || key.Localizations.TryGetValue("English", out value))
				{
					__instance.AddWord(key.Key, value);
				}
				else if (key.Localizations.TryGetValue("alias", out value2))
				{
					Localization.instance.AddWord(key.Key, Localization.instance.Localize(value2));
				}
			}
		}
	}
	[<e97c5803-69aa-460e-abe9-409844477c78>NullableContext(1)]
	[<1b085ef8-c05f-4287-bfc0-c06ec6693295>Nullable(0)]
	public static class LocalizationCache
	{
		private static readonly Dictionary<string, Localization> localizations = new Dictionary<string,