Decompiled source of CargoQuestItems v1.0.3

CargoQuestItems.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.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CargoQuestItems.Managers;
using CargoQuestItems.QuestItems;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using PieceManager;
using ServerSync;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CargoQuestItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("CargoQuestItems")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: AssemblyCompany("RustyMods")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<ea7a1965-28c3-4f45-8c49-e8da96151a5b>Embedded]
	internal sealed class <ea7a1965-28c3-4f45-8c49-e8da96151a5b>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<ea7a1965-28c3-4f45-8c49-e8da96151a5b>Embedded]
	internal sealed class <ee63775d-e183-433e-85b5-51f0a1ab9269>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <ee63775d-e183-433e-85b5-51f0a1ab9269>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <ee63775d-e183-433e-85b5-51f0a1ab9269>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[<ea7a1965-28c3-4f45-8c49-e8da96151a5b>Embedded]
	internal sealed class <7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace PieceManager
{
	[PublicAPI]
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	public static class MaterialReplacer
	{
		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)]
		public enum ShaderType
		{
			PieceShader,
			VegetationShader,
			RockShader,
			RugShader,
			GrassShader,
			CustomCreature,
			UseUnityShader
		}

		private static readonly Dictionary<GameObject, bool> ObjectToSwap;

		private static readonly Dictionary<string, Material> OriginalMaterials;

		private static readonly Dictionary<GameObject, ShaderType> ObjectsForShaderReplace;

		private static readonly HashSet<Shader> CachedShaders;

		private static bool hasRun;

		static MaterialReplacer()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			CachedShaders = new HashSet<Shader>();
			hasRun = false;
			OriginalMaterials = new Dictionary<string, Material>();
			ObjectToSwap = new Dictionary<GameObject, bool>();
			ObjectsForShaderReplace = new Dictionary<GameObject, ShaderType>();
			Harmony val = new Harmony("org.bepinex.helpers.PieceManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZoneSystem), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void RegisterGameObjectForShaderSwap(GameObject go, ShaderType type)
		{
			if (!ObjectsForShaderReplace.ContainsKey(go))
			{
				ObjectsForShaderReplace.Add(go, type);
			}
		}

		public static void RegisterGameObjectForMatSwap(GameObject go, bool isJotunnMock = false)
		{
			if (!ObjectToSwap.ContainsKey(go))
			{
				ObjectToSwap.Add(go, isJotunnMock);
			}
		}

		private static void GetAllMaterials()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val in array)
			{
				OriginalMaterials[((Object)val).name] = val;
			}
		}

		[HarmonyPriority(700)]
		private static void ReplaceAllMaterialsWithOriginal()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType == 4 || hasRun)
			{
				return;
			}
			if (OriginalMaterials.Count == 0)
			{
				GetAllMaterials();
			}
			foreach (KeyValuePair<GameObject, bool> item in ObjectToSwap)
			{
				GameObject key = item.Key;
				bool value = item.Value;
				ProcessGameObjectMaterials(key, value);
			}
			AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>();
			AssetBundle[] array2 = array;
			foreach (AssetBundle val in array2)
			{
				IEnumerable<Shader> enumerable3;
				try
				{
					IEnumerable<Shader> enumerable2;
					if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val))
					{
						IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>();
						enumerable2 = enumerable;
					}
					else
					{
						enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>)
							where (Object)(object)shader != (Object)null
							select shader;
					}
					enumerable3 = enumerable2;
				}
				catch (Exception)
				{
					continue;
				}
				if (enumerable3 == null)
				{
					continue;
				}
				foreach (Shader item2 in enumerable3)
				{
					CachedShaders.Add(item2);
				}
			}
			foreach (KeyValuePair<GameObject, ShaderType> item3 in ObjectsForShaderReplace)
			{
				GameObject key2 = item3.Key;
				ShaderType value2 = item3.Value;
				ProcessGameObjectShaders(key2, value2);
			}
			hasRun = true;
		}

		private static void ProcessGameObjectMaterials(GameObject go, bool isJotunnMock)
		{
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials.Select([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (Material material) => ReplaceMaterial(material, isJotunnMock)).ToArray();
				val.sharedMaterials = sharedMaterials;
			}
		}

		private static Material ReplaceMaterial(Material originalMaterial, bool isJotunnMock)
		{
			string text = (isJotunnMock ? "JVLmock_" : "_REPLACE_");
			if (!((Object)originalMaterial).name.StartsWith(text, StringComparison.Ordinal))
			{
				return originalMaterial;
			}
			string text2 = ((Object)originalMaterial).name.Replace(" (Instance)", "").Replace(text, "");
			if (OriginalMaterials.TryGetValue(text2, out var value))
			{
				return value;
			}
			Debug.LogWarning((object)("No suitable material found to replace: " + text2));
			return originalMaterial;
		}

		private static void ProcessGameObjectShaders(GameObject go, ShaderType shaderType)
		{
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				foreach (Material val2 in sharedMaterials)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						val2.shader = GetShaderForType(val2.shader, shaderType, ((Object)val2.shader).name);
					}
				}
			}
		}

		private static Shader GetShaderForType(Shader orig, ShaderType shaderType, string originalShaderName)
		{
			return (Shader)(shaderType switch
			{
				ShaderType.PieceShader => FindShaderWithName(orig, "Custom/Piece"), 
				ShaderType.VegetationShader => FindShaderWithName(orig, "Custom/Vegetation"), 
				ShaderType.RockShader => FindShaderWithName(orig, "Custom/StaticRock"), 
				ShaderType.RugShader => FindShaderWithName(orig, "Custom/Rug"), 
				ShaderType.GrassShader => FindShaderWithName(orig, "Custom/Grass"), 
				ShaderType.CustomCreature => FindShaderWithName(orig, "Custom/Creature"), 
				ShaderType.UseUnityShader => FindShaderWithName(orig, ((Object)(object)FindShaderWithName(orig, originalShaderName) != (Object)null) ? originalShaderName : "ToonDeferredShading2017"), 
				_ => FindShaderWithName(orig, "Standard"), 
			});
		}

		public static Shader FindShaderWithName(Shader origShader, string name)
		{
			foreach (Shader cachedShader in CachedShaders)
			{
				if (((Object)cachedShader).name == name)
				{
					return cachedShader;
				}
			}
			return origShader;
		}
	}
}
namespace CargoQuestItems
{
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[BepInPlugin("RustyMods.CargoQuestItems", "CargoQuestItems", "1.0.3")]
	public class CargoQuestItemsPlugin : BaseUnityPlugin
	{
		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
			public string Category;

			[UsedImplicitly]
			[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		internal const string ModName = "CargoQuestItems";

		internal const string ModVersion = "1.0.3";

		internal const string Author = "RustyMods";

		private const string ModGUID = "RustyMods.CargoQuestItems";

		private static string ConfigFileName = "RustyMods.CargoQuestItems.cfg";

		private static string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("RustyMods.CargoQuestItems");

		public static readonly ManualLogSource CargoQuestItemsLogger;

		private static readonly ConfigSync ConfigSync;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<string> _BarrelSmallName;

		public static ConfigEntry<string> _BarrelSmallDesc;

		public static ConfigEntry<bool> _BarrelSmallTeleport;

		public static ConfigEntry<float> _BarrelSmallWeight;

		public static ConfigEntry<string> _BarrelMediumName;

		public static ConfigEntry<string> _BarrelMediumDesc;

		public static ConfigEntry<bool> _BarrelMediumTeleport;

		public static ConfigEntry<float> _BarrelMediumWeight;

		public static ConfigEntry<string> _BarrelLargeName;

		public static ConfigEntry<string> _BarrelLargeDesc;

		public static ConfigEntry<bool> _BarrelLargeTeleport;

		public static ConfigEntry<float> _BarrelLargeWeight;

		public static ConfigEntry<string> _CrateSmallName;

		public static ConfigEntry<string> _CrateSmallDesc;

		public static ConfigEntry<bool> _CrateSmallTeleport;

		public static ConfigEntry<float> _CrateSmallWeight;

		public static ConfigEntry<string> _CrateMediumName;

		public static ConfigEntry<string> _CrateMediumDesc;

		public static ConfigEntry<bool> _CrateMediumTeleport;

		public static ConfigEntry<float> _CrateMediumWeight;

		public static ConfigEntry<string> _CrateLargeName;

		public static ConfigEntry<string> _CrateLargeDesc;

		public static ConfigEntry<bool> _CrateLargeTeleport;

		public static ConfigEntry<float> _CrateLargeWeight;

		public static ConfigEntry<string> _CargoMediumName;

		public static ConfigEntry<string> _CargoMediumDesc;

		public static ConfigEntry<bool> _CargoMediumTeleport;

		public static ConfigEntry<float> _CargoMediumWeight;

		public static ConfigEntry<string> _CargoLargeName;

		public static ConfigEntry<string> _CargoLargeDesc;

		public static ConfigEntry<bool> _CargoLargeTeleport;

		public static ConfigEntry<float> _CargoLargeWeight;

		public static ConfigEntry<string> _CargoHugeName;

		public static ConfigEntry<string> _CargoHugeDesc;

		public static ConfigEntry<bool> _CargoHugeTeleport;

		public static ConfigEntry<float> _CargoHugeWeight;

		public void Awake()
		{
			InitConfigs();
			LoadItems.InitItems();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

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

		private void InitConfigs()
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Expected O, but got Unknown
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Expected O, but got Unknown
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Expected O, but got Unknown
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Expected O, but got Unknown
			//IL_078e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0799: Expected O, but got Unknown
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_088a: Expected O, but got Unknown
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_BarrelSmallName = config("2 - Small Barrel", "Name", "Small Barrel", "Set the name of the barrel");
			_BarrelSmallName.SettingChanged += OnBarrelSmallChange;
			_BarrelSmallDesc = config("2 - Small Barrel", "Description", "A small barrel", "Set the description of the barrel");
			_BarrelSmallDesc.SettingChanged += OnBarrelSmallChange;
			_BarrelSmallTeleport = config("2 - Small Barrel", "Teleportable", value: false, "Set the teleportablity of the barrel");
			_BarrelSmallTeleport.SettingChanged += OnBarrelSmallChange;
			_BarrelSmallWeight = config("2 - Small Barrel", "Weight", 1f, new ConfigDescription("Set the weight of a small barrel", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_BarrelSmallWeight.SettingChanged += OnBarrelSmallChange;
			_BarrelMediumName = config("3 - Medium Barrel", "Name", "Medium Barrel", "Set the name of the barrel");
			_BarrelMediumName.SettingChanged += OnBarrelMediumChange;
			_BarrelMediumDesc = config("3 - Medium Barrel", "Description", "A medium barrel", "Set the description of the barrel");
			_BarrelMediumDesc.SettingChanged += OnBarrelMediumChange;
			_BarrelMediumTeleport = config("3 - Medium Barrel", "Teleportable", value: false, "Set the teleportablity of the barrel");
			_BarrelMediumTeleport.SettingChanged += OnBarrelMediumChange;
			_BarrelMediumWeight = config("3 - Medium Barrel", "Weight", 1f, new ConfigDescription("Set the weight of a medium barrel", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_BarrelMediumWeight.SettingChanged += OnBarrelMediumChange;
			_BarrelLargeName = config("4 - Large Barrel", "Name", "Large Barrel", "Set the name of the barrel");
			_BarrelLargeName.SettingChanged += OnBarrelLargeChange;
			_BarrelLargeDesc = config("4 - Large Barrel", "Description", "A large barrel", "Set the description of the barrel");
			_BarrelLargeDesc.SettingChanged += OnBarrelLargeChange;
			_BarrelLargeTeleport = config("4 - Large Barrel", "Teleportable", value: false, "Set the teleportablity of the barrel");
			_BarrelLargeTeleport.SettingChanged += OnBarrelLargeChange;
			_BarrelLargeWeight = config("4 - Large Barrel", "Weight", 1f, new ConfigDescription("Set the weight of a large barrel", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_BarrelLargeWeight.SettingChanged += OnBarrelLargeChange;
			_CrateSmallName = config("5 - Small Crate", "Name", "Small Crate", "Set the name of the Crate");
			_CrateSmallName.SettingChanged += OnCrateSmallChange;
			_CrateSmallDesc = config("5 - Small Crate", "Description", "A small crate", "Set the description of the Crate");
			_CrateSmallDesc.SettingChanged += OnCrateSmallChange;
			_CrateSmallTeleport = config("5 - Small Crate", "Teleportable", value: false, "Set the teleportablity of the Crate");
			_CrateSmallTeleport.SettingChanged += OnCrateSmallChange;
			_CrateSmallWeight = config("5 - Small Crate", "Weight", 1f, new ConfigDescription("Set the weight of a small crate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_CrateSmallWeight.SettingChanged += OnCrateSmallChange;
			_CrateMediumName = config("6 - Medium Crate", "Name", "Medium Crate", "Set the name of the Crate");
			_CrateMediumName.SettingChanged += OnCrateMediumChange;
			_CrateMediumDesc = config("6 - Medium Crate", "Description", "A medium crate", "Set the description of the Crate");
			_CrateMediumDesc.SettingChanged += OnCrateMediumChange;
			_CrateMediumTeleport = config("6 - Medium Crate", "Teleportable", value: false, "Set the teleportablity of the Crate");
			_CrateMediumTeleport.SettingChanged += OnCrateMediumChange;
			_CrateMediumWeight = config("6 - Medium Crate", "Weight", 1f, new ConfigDescription("Set the weight of a medium crate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_CrateMediumWeight.SettingChanged += OnCrateMediumChange;
			_CrateLargeName = config("7 - Large Crate", "Name", "Large Crate", "Set the name of the Crate");
			_CrateLargeName.SettingChanged += OnCrateLargeChange;
			_CrateLargeDesc = config("7 - Large Crate", "Description", "A large crate", "Set the description of the Crate");
			_CrateLargeDesc.SettingChanged += OnCrateLargeChange;
			_CrateLargeTeleport = config("7 - Large Crate", "Teleportable", value: false, "Set the teleportablity of the Crate");
			_CrateLargeTeleport.SettingChanged += OnCrateLargeChange;
			_CrateLargeWeight = config("7 - Large Crate", "Weight", 1f, new ConfigDescription("Set the weight of a large crate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_CrateLargeWeight.SettingChanged += OnCrateLargeChange;
			_CargoMediumName = config("8 - Medium Cargo", "Name", "Medium Cargo", "Set the name of the Cargo");
			_CargoMediumName.SettingChanged += OnCargoMediumChange;
			_CargoMediumDesc = config("8 - Medium Cargo", "Description", "A medium cargo", "Set the description of the Cargo");
			_CargoMediumDesc.SettingChanged += OnCargoMediumChange;
			_CargoMediumTeleport = config("8 - Medium Cargo", "Teleportable", value: false, "Set the teleportablity of the Cargo");
			_CargoMediumTeleport.SettingChanged += OnCargoMediumChange;
			_CargoMediumWeight = config("8 - Medium Cargo", "Weight", 1f, new ConfigDescription("Set the weight of a medium cargo", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_CargoMediumWeight.SettingChanged += OnCargoMediumChange;
			_CargoLargeName = config("9 - Large Cargo", "Name", "Large Cargo", "Set the name of the Cargo");
			_CargoLargeName.SettingChanged += OnCargoLargeChange;
			_CargoLargeDesc = config("9 - Large Cargo", "Description", "A large cargo", "Set the description of the Cargo");
			_CargoLargeDesc.SettingChanged += OnCargoLargeChange;
			_CargoLargeTeleport = config("9 - Large Cargo", "Teleportable", value: false, "Set the teleportablity of the Cargo");
			_CargoLargeTeleport.SettingChanged += OnCargoLargeChange;
			_CargoLargeWeight = config("9 - Large Cargo", "Weight", 1f, new ConfigDescription("Set the weight of a large cargo", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_CargoLargeWeight.SettingChanged += OnCargoLargeChange;
			_CargoHugeName = config("91 - Huge Cargo", "Name", "Huge Cargo", "Set the name of the Cargo");
			_CargoHugeName.SettingChanged += OnCargoHugeChange;
			_CargoHugeDesc = config("91 - Huge Cargo", "Description", "A huge cargo", "Set the description of the Cargo");
			_CargoHugeDesc.SettingChanged += OnCargoHugeChange;
			_CargoHugeTeleport = config("91 - Huge Cargo", "Teleportable", value: false, "Set the teleportablity of the Cargo");
			_CargoHugeTeleport.SettingChanged += OnCargoHugeChange;
			_CargoHugeWeight = config("91 - Huge Cargo", "Weight", 1f, new ConfigDescription("Set the weight of a huge cargo", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
			_CargoHugeWeight.SettingChanged += OnCargoHugeChange;
		}

		private static void OnBarrelSmallChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("BarrelSmall");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _BarrelSmallName.Value;
					val.m_itemData.m_shared.m_description = _BarrelSmallDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _BarrelSmallTeleport.Value;
					val.m_itemData.m_shared.m_weight = _BarrelSmallWeight.Value;
				}
			}
		}

		private static void OnBarrelMediumChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("BarrelMedium");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _BarrelMediumName.Value;
					val.m_itemData.m_shared.m_description = _BarrelMediumDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _BarrelMediumTeleport.Value;
					val.m_itemData.m_shared.m_weight = _BarrelMediumWeight.Value;
				}
			}
		}

		private static void OnBarrelLargeChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("BarrelLarge");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _BarrelLargeName.Value;
					val.m_itemData.m_shared.m_description = _BarrelLargeDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _BarrelLargeTeleport.Value;
					val.m_itemData.m_shared.m_weight = _BarrelLargeWeight.Value;
				}
			}
		}

		private static void OnCrateSmallChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CrateSmall");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _CrateSmallName.Value;
					val.m_itemData.m_shared.m_description = _CrateSmallDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _CrateSmallTeleport.Value;
					val.m_itemData.m_shared.m_weight = _CrateSmallWeight.Value;
				}
			}
		}

		private static void OnCrateMediumChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CrateMedium");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _CrateMediumName.Value;
					val.m_itemData.m_shared.m_description = _CrateMediumDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _CrateMediumTeleport.Value;
					val.m_itemData.m_shared.m_weight = _CrateMediumWeight.Value;
				}
			}
		}

		private static void OnCrateLargeChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CrateLarge");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _CrateLargeName.Value;
					val.m_itemData.m_shared.m_description = _CrateLargeDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _CrateLargeTeleport.Value;
					val.m_itemData.m_shared.m_weight = _CrateLargeWeight.Value;
				}
			}
		}

		private static void OnCargoMediumChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CargoMedium");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _CargoMediumName.Value;
					val.m_itemData.m_shared.m_description = _CargoMediumDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _CargoMediumTeleport.Value;
					val.m_itemData.m_shared.m_weight = _CargoMediumWeight.Value;
				}
			}
		}

		private static void OnCargoLargeChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CargoLarge");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _CargoLargeName.Value;
					val.m_itemData.m_shared.m_description = _CargoLargeDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _CargoLargeTeleport.Value;
					val.m_itemData.m_shared.m_weight = _CargoLargeWeight.Value;
				}
			}
		}

		private static void OnCargoHugeChange(object sender, EventArgs e)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("CargoHuge");
				ItemDrop val = default(ItemDrop);
				if (prefab.TryGetComponent<ItemDrop>(ref val))
				{
					val.m_itemData.m_shared.m_name = _CargoHugeName.Value;
					val.m_itemData.m_shared.m_description = _CargoHugeDesc.Value;
					val.m_itemData.m_shared.m_teleportable = _CargoHugeTeleport.Value;
					val.m_itemData.m_shared.m_weight = _CargoHugeWeight.Value;
				}
			}
		}

		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
			{
				CargoQuestItemsLogger.LogDebug((object)"ReadConfigValues called");
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				CargoQuestItemsLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				CargoQuestItemsLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		private ConfigEntry<T> config<[<ee63775d-e183-433e-85b5-51f0a1ab9269>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<[<ee63775d-e183-433e-85b5-51f0a1ab9269>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 CargoQuestItemsPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			CargoQuestItemsLogger = Logger.CreateLogSource("CargoQuestItems");
			ConfigSync = new ConfigSync("RustyMods.CargoQuestItems")
			{
				DisplayName = "CargoQuestItems",
				CurrentVersion = "1.0.3",
				MinimumRequiredVersion = "1.0.3"
			};
			_serverConfigLocked = null;
			_BarrelSmallName = null;
			_BarrelSmallDesc = null;
			_BarrelSmallTeleport = null;
			_BarrelSmallWeight = null;
			_BarrelMediumName = null;
			_BarrelMediumDesc = null;
			_BarrelMediumTeleport = null;
			_BarrelMediumWeight = null;
			_BarrelLargeName = null;
			_BarrelLargeDesc = null;
			_BarrelLargeTeleport = null;
			_BarrelLargeWeight = null;
			_CrateSmallName = null;
			_CrateSmallDesc = null;
			_CrateSmallTeleport = null;
			_CrateSmallWeight = null;
			_CrateMediumName = null;
			_CrateMediumDesc = null;
			_CrateMediumTeleport = null;
			_CrateMediumWeight = null;
			_CrateLargeName = null;
			_CrateLargeDesc = null;
			_CrateLargeTeleport = null;
			_CrateLargeWeight = null;
			_CargoMediumName = null;
			_CargoMediumDesc = null;
			_CargoMediumTeleport = null;
			_CargoMediumWeight = null;
			_CargoLargeName = null;
			_CargoLargeDesc = null;
			_CargoLargeTeleport = null;
			_CargoLargeWeight = null;
			_CargoHugeName = null;
			_CargoHugeDesc = null;
			_CargoHugeTeleport = null;
			_CargoHugeWeight = null;
		}
	}
	public static class KeyboardExtensions
	{
		public static bool IsKeyDown(this KeyboardShortcut shortcut)
		{
			//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)
			return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
		}

		public static bool IsKeyHeld(this KeyboardShortcut shortcut)
		{
			//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)
			return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			CargoQuestItemsPlugin.CargoQuestItemsLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("CargoQuestItems_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_CargoQuestItems_Version);
			CargoQuestItemsPlugin.CargoQuestItemsLogger.LogInfo((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("1.0.3");
			peer.m_rpc.Invoke("CargoQuestItems_VersionCheck", new object[1] { val });
		}
	}
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			CargoQuestItemsPlugin.CargoQuestItemsLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "CargoQuestItemsRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + CargoQuestItemsPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				CargoQuestItemsPlugin.CargoQuestItemsLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_CargoQuestItems_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			CargoQuestItemsPlugin.CargoQuestItemsLogger.LogInfo((object)("Version check, local: 1.0.3,  remote: " + text));
			if (text != "1.0.3")
			{
				CargoQuestItemsPlugin.ConnectionError = "CargoQuestItems Installed: 1.0.3\n Needed: " + text;
				if (ZNet.instance.IsServer())
				{
					CargoQuestItemsPlugin.CargoQuestItemsLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting..."));
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				CargoQuestItemsPlugin.CargoQuestItemsLogger.LogInfo((object)"Received same version from server!");
			}
			else
			{
				CargoQuestItemsPlugin.CargoQuestItemsLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
				ValidatedPeers.Add(rpc);
			}
		}

		public static string ComputeHashForMod()
		{
			using SHA256 sHA = SHA256.Create();
			byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location));
			StringBuilder stringBuilder = new StringBuilder();
			byte[] array2 = array;
			foreach (byte b in array2)
			{
				stringBuilder.Append(b.ToString("X2"));
			}
			return stringBuilder.ToString();
		}
	}
}
namespace CargoQuestItems.QuestItems
{
	public static class LoadItems
	{
		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(1)]
		public static readonly List<string> ItemSharedNames = new List<string>();

		public static void InitItems()
		{
			Item item = new Item("questitemsbundle", "BarrelSmall");
			item.Name.English(CargoQuestItemsPlugin._BarrelSmallName.Value);
			item.Description.English(CargoQuestItemsPlugin._BarrelSmallDesc.Value);
			item.Configurable = Configurability.Disabled;
			item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._BarrelSmallWeight.Value;
			item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._BarrelSmallTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item.Prefab);
			ItemSharedNames.Add(item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item2 = new Item("questitemsbundle", "BarrelMedium");
			item2.Name.English(CargoQuestItemsPlugin._BarrelMediumName.Value);
			item2.Description.English(CargoQuestItemsPlugin._BarrelMediumDesc.Value);
			item2.Configurable = Configurability.Disabled;
			item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._BarrelMediumWeight.Value;
			item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._BarrelMediumTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item2.Prefab);
			ItemSharedNames.Add(item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item3 = new Item("questitemsbundle", "BarrelLarge");
			item3.Name.English(CargoQuestItemsPlugin._BarrelLargeName.Value);
			item3.Description.English(CargoQuestItemsPlugin._BarrelLargeDesc.Value);
			item3.Configurable = Configurability.Disabled;
			item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._BarrelLargeWeight.Value;
			item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._BarrelLargeTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item3.Prefab);
			ItemSharedNames.Add(item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item4 = new Item("questitemsbundle", "CrateSmall");
			item4.Name.English(CargoQuestItemsPlugin._CrateSmallName.Value);
			item4.Description.English(CargoQuestItemsPlugin._CrateSmallDesc.Value);
			item4.Configurable = Configurability.Disabled;
			item4.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._CrateSmallWeight.Value;
			item4.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._CrateSmallTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item4.Prefab);
			ItemSharedNames.Add(item4.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item5 = new Item("questitemsbundle", "CrateMedium");
			item5.Name.English(CargoQuestItemsPlugin._CrateMediumName.Value);
			item5.Description.English(CargoQuestItemsPlugin._CrateMediumDesc.Value);
			item5.Configurable = Configurability.Disabled;
			item5.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._CrateMediumWeight.Value;
			item5.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._CrateMediumTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item5.Prefab);
			ItemSharedNames.Add(item5.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item6 = new Item("questitemsbundle", "CrateLarge");
			item6.Name.English(CargoQuestItemsPlugin._CrateLargeName.Value);
			item6.Description.English(CargoQuestItemsPlugin._CrateLargeDesc.Value);
			item6.Configurable = Configurability.Disabled;
			item6.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._CrateLargeWeight.Value;
			item6.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._CrateLargeTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item6.Prefab);
			ItemSharedNames.Add(item6.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item7 = new Item("questitemsbundle", "CargoMedium");
			item7.Name.English(CargoQuestItemsPlugin._CargoMediumName.Value);
			item7.Description.English(CargoQuestItemsPlugin._CargoMediumDesc.Value);
			item7.Configurable = Configurability.Disabled;
			item7.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._CargoMediumWeight.Value;
			item7.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._CargoMediumTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item7.Prefab);
			ItemSharedNames.Add(item7.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item8 = new Item("questitemsbundle", "CargoLarge");
			item8.Name.English(CargoQuestItemsPlugin._CargoLargeName.Value);
			item8.Description.English(CargoQuestItemsPlugin._CargoLargeDesc.Value);
			item8.Configurable = Configurability.Disabled;
			item8.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._CargoLargeWeight.Value;
			item8.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._CargoLargeTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item8.Prefab);
			ItemSharedNames.Add(item8.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
			Item item9 = new Item("questitemsbundle", "CargoHuge");
			item9.Name.English(CargoQuestItemsPlugin._CargoHugeName.Value);
			item9.Description.English(CargoQuestItemsPlugin._CargoHugeDesc.Value);
			item9.Configurable = Configurability.Disabled;
			item9.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_weight = CargoQuestItemsPlugin._CargoHugeWeight.Value;
			item9.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_teleportable = CargoQuestItemsPlugin._CargoHugeTeleport.Value;
			MaterialReplacer.RegisterGameObjectForMatSwap(item9.Prefab);
			ItemSharedNames.Add(item9.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name);
		}
	}
}
namespace CargoQuestItems.Patches
{
	public static class ItemStandPatches
	{
		[HarmonyPatch(typeof(ItemStand), "CanAttach")]
		private static class CanAttachPatch
		{
			[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
			private static void Postfix(ItemStand __instance, ItemData item, ref bool __result)
			{
				if (!LoadItems.ItemSharedNames.Contains(item.m_shared.m_name))
				{
					if (!((Object)(object)__instance.GetAttachPrefab(item.m_dropPrefab) == (Object)null))
					{
						__result = true;
					}
				}
				else
				{
					__result = true;
				}
			}
		}
	}
}
namespace CargoQuestItems.Managers
{
	[PublicAPI]
	public enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[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
	}
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	public class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free = false;

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

		public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig,
				quality = quality
			});
		}
	}
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>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
			});
		}
	}
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	[PublicAPI]
	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;

		public bool RequireOnlyOneIngredient = false;

		public float QualityResultAmountMultiplier = 1f;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		public ConfigEntryBase RecipeIsActive = null;
	}
	[PublicAPI]
	public class Trade
	{
		public Trader Trader = Trader.None;

		public uint Price = 0u;

		public uint Stack = 1u;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		public string RequiredGlobalKey = null;
	}
	[Flags]
	[PublicAPI]
	public enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	public struct Requirement
	{
		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(1)]
		public string itemName;

		public int amount;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		public ConfigEntry<int> amountConfig;

		[Description("Set to a non-zero value to apply the requirement only for a specific quality")]
		public int quality;
	}
	public struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		public string custom;
	}
	[Flags]
	public enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	[PublicAPI]
	public class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min),
				levelMultiplier = levelMultiplier
			});
		}
	}
	public struct DropTarget
	{
		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(1)]
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
	[PublicAPI]
	[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
	[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(1)]
	public class Item
	{
		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
		private class ItemConfig
		{
			[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> craft;

			[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> upgrade;

			public ConfigEntry<CraftingTable> table = null;

			public ConfigEntry<int> tableLevel = null;

			public ConfigEntry<string> customTable = null;

			[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
			public ConfigEntry<int> maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient = null;

			public ConfigEntry<float> qualityResultAmountMultiplier = null;
		}

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
		private class TraderConfig
		{
			public ConfigEntry<Trader> trader = null;

			public ConfigEntry<uint> price = null;

			public ConfigEntry<uint> stack = null;

			public ConfigEntry<string> requiredGlobalKey = null;
		}

		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)]
		private class RequirementQuality
		{
			public int quality;
		}

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(2)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string Category;

			[UsedImplicitly]
			[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;

			public Func<bool> browsability;
		}

		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)]
		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)]
		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(0)]
		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

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

			public SerializedRequirements(string reqs)
				: this(reqs.Split(new char[1] { ',' }).Select([<7610929e-3ecc-467b-bbeb-c7b46349bb72>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);
					result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0);
					return result;
				}).ToList())
			{
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : "")));
			}

			[return: <ee63775d-e183-433e-85b5-51f0a1ab9269>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_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Expected O, but got Unknown
				//IL_01b7: Expected O, but got Unknown
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Expected O, but got Unknown
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<7610929e-3ecc-467b-bbeb-c7b46349bb72>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 val6 = ResItem(r);
					return (val6 == null) ? ((Requirement)null) : new Requirement
					{
						m_amount = (r.amountConfig?.Value ?? r.amount),
						m_resItem = val6,
						m_amountPerLevel = 0
					};
				}));
				List<Requirement> list = dictionary.Values.Where([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (Requirement v) => v != null).ToList();
				foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != ""))
				{
					if (item.quality > 0)
					{
						ItemDrop val = ResItem(item);
						if (val != null)
						{
							Requirement val2 = new Requirement
							{
								m_resItem = val,
								m_amountPerLevel = (item.amountConfig?.Value ?? item.amount),
								m_amount = 0
							};
							list.Add(val2);
							requirementQuality.Add(val2, new RequirementQuality
							{
								quality = item.quality
							});
						}
						continue;
					}
					if (!dictionary.TryGetValue(item.itemName, out var value) || value == null)
					{
						ItemDrop val3 = ResItem(item);
						if (val3 != null)
						{
							string itemName = item.itemName;
							Requirement val4 = new Requirement
							{
								m_resItem = val3,
								m_amount = 0
							};
							Requirement val5 = val4;
							dictionary[itemName] = val4;
							value = val5;
							list.Add(value);
						}
					}
					if (value != null)
					{
						value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount;
					}
				}
				return list.ToArray();
				[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(2)]
				ItemDrop ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>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([<7610929e-3ecc-467b-bbeb-c7b46349bb72>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;
					}
					bool levelMultiplier = array.Length <= 4 || array[4] != "0";
					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;
					result3.levelMultiplier = levelMultiplier;
					return result3;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0")));
			}

			[return: <ee63775d-e183-433e-85b5-51f0a1ab9269>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_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: 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,
							m_levelMultiplier = drop.levelMultiplier
						};
					}
				}
				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>>>();

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>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>();

		private static readonly ConditionalWeakTable<Requirement, RequirementQuality> requirementQuality = new ConditionalWeakTable<Requirement, RequirementQuality>();

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable = null;

		private Configurability configurationVisible = Configurability.Full;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private TraderConfig traderConfig;

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

		[Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")]
		public readonly Trade Trade = new Trade();

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

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

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

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private LocalizeKey _name;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private LocalizeKey _description;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private static object configManager;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private static Localization _english;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>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;

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase RecipeIsActive
		{
			[<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(2)]
			get
			{
				return this[""].RecipeIsActive;
			}
			[<7610929e-3ecc-467b-bbeb-c7b46349bb72>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 bool RequireOnlyOneIngredient
		{
			get
			{
				return this[""].RequireOnlyOneIngredient;
			}
			set
			{
				this[""].RequireOnlyOneIngredient = value;
			}
		}

		public float QualityResultAmountMultiplier
		{
			get
			{
				return this[""].QualityResultAmountMultiplier;
			}
			set
			{
				this[""].QualityResultAmountMultiplier = 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([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<ee63775d-e183-433e-85b5-51f0a1ab9269>Nullable(2)]
		private static object configSync
		{
			[<7610929e-3ecc-467b-bbeb-c7b46349bb72>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;
			Prefab.GetComponent<ItemDrop>().m_itemData.m_dropPrefab = Prefab;
		}

		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()
		{
			object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager);
			if (obj is bool && (bool)obj)
			{
				configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
			}
		}

		private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue)
		{
			if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out var value))
			{
				value.First().m_enabled = table != CraftingTable.Disabled;
				if ((uint)table <= 1u)
				{
					value.First().m_craftingStation = null;
				}
				else if (table == CraftingTable.Custom)
				{
					Recipe obj = value.First();
					GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue);
					obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null);
				}
				else
				{
					value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent<CraftingStation>();
				}
			}
		}

		private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements)
		{
			if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out var value))
			{
				return;
			}
			foreach (Recipe item in value)
			{
				item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements);
			}
		}

		internal static void Patch_FejdStartup()
		{
			//IL_0ff2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ff7: Unknown result type (might be due to invalid IL or missing references)
			//IL_2386: Unknown result type (might be due to invalid IL or missing references)
			//IL_2390: Expected O, but got Unknown
			//IL_10bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1118: Expected I4, but got Unknown
			//IL_0cbd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc7: Expected O, but got Unknown
			//IL_1258: Unknown result type (might be due to invalid IL or missing references)
			//IL_125b: Unknown result type (might be due to invalid IL or missing references)
			//IL_125d: Invalid comparison between Unknown and I4
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_0deb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df5: Expected O, but got Unknown
			//IL_0e97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea1: Expected O, but got Unknown
			//IL_1261: Unknown result type (might be due to invalid IL or missing references)
			//IL_1265: Invalid comparison between Unknown and I4
			//IL_0f4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f56: Expected O, but got Unknown
			//IL_147a: Unknown result type (might be due to invalid IL or missing references)
			//IL_147d: Unknown result type (might be due to invalid IL or missing references)
			//IL_147f: Invalid comparison between Unknown and I4
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Expected O, but got Unknown
			//IL_1269: Unknown result type (might be due to invalid IL or missing references)
			//IL_126d: Invalid comparison between Unknown and I4
			//IL_1483: Unknown result type (might be due to invalid IL or missing references)
			//IL_1487: Unknown result type (might be due to invalid IL or missing references)
			//IL_1489: Invalid comparison between Unknown and I4
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Expected O, but got Unknown
			//IL_1572: Unknown result type (might be due to invalid IL or missing references)
			//IL_1577: Unknown result type (might be due to invalid IL or missing references)
			//IL_1579: Unknown result type (might be due to invalid IL or missing references)
			//IL_157c: Invalid comparison between Unknown and I4
			//IL_148d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1491: Invalid comparison between Unknown and I4
			//IL_1580: Unknown result type (might be due to invalid IL or missing references)
			//IL_1584: Invalid comparison between Unknown and I4
			//IL_0796: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a0: Expected O, but got Unknown
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f5: Expected O, but got Unknown
			//IL_15fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1600: Unknown result type (might be due to invalid IL or missing references)
			//IL_1602: Invalid comparison between Unknown and I4
			//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: Expected O, but got Unknown
			//IL_1606: Unknown result type (might be due to invalid IL or missing references)
			//IL_160a: Unknown result type (might be due to invalid IL or missing references)
			//IL_160c: Invalid comparison between Unknown and I4
			//IL_175f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1762: Invalid comparison between Unknown and I4
			//IL_1610: Unknown result type (might be due to invalid IL or missing references)
			//IL_1614: Invalid comparison between Unknown and I4
			//IL_1971: Unknown result type (might be due to invalid IL or missing references)
			//IL_1978: Invalid comparison between Unknown and I4
			//IL_1a4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a52: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a54: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a58: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a5a: Invalid comparison between Unknown and I4
			//IL_16cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_16d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad8: Invalid comparison between Unknown and I4
			//IL_1adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae0: Invalid comparison between Unknown and I4
			//IL_1ae4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae8: Invalid comparison between Unknown and I4
			//IL_1f79: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f7c: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			if (DefaultConfigurability != 0)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item4 in registeredItems.Where([<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item3 = item4;
					string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim();
					string localizedName = Localization.instance.Localize(name2).Trim();
					int order = 0;
					if ((item3.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>();
						foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item5;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6))
								{
									value6.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							}
							cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = QualityResultBrowsability,
								Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5))
								{
									foreach (Recipe item6 in value5)
									{
										item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes }));
							cfg.qualityResultAmountMultiplier.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value4))
								{
									foreach (Recipe item7 in value4)
									{
										item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false);
							}
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true);
							}
							if (cfg.craft != null)
							{
								cfg.craft.SettingChanged += ConfigChanged;
							}
							if (cfg.upgrade != null)
							{
								cfg.upgrade.SettingChanged += ConfigChanged;
							}
							void ConfigChanged(object o, EventArgs e)
							{
								item3.UpdateCraftConfig(configKey, 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;
							}
							bool QualityResultBrowsability()
							{
								return cfg.requireOneIngredient.Value == Toggle.On;
							}
							void TableConfigChanged(object o, EventArgs e)
							{
								item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value);
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes)
								{
									item8.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig(string name, string value, string desc, bool isUpgrade)
							{
								//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
								//IL_00be: Expected O, but got Unknown
								ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade),
									Order = (order -= 1),
									browsability = ItemBrowsability,
									Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								};
								hideWhenNoneAttributes.Add(configurationManagerAttributes3);
								return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 }));
							}
						}
						if ((item3.configurability & Configurability.Drop) != 0)
						{
							ConfigEntry<string> val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									CustomDrawer = drawDropsConfigTable,
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Drop) != 0)
								}
							})));
							ConfigEntry<string> val4 = val3;
							val4.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								item3.UpdateCharacterDrop();
							};
						}
						for (int j = 0; j < item3.Conversions.Count; j++)
						{
							string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : "");
							Conversion conversion = item3.Conversions[j];
							conversion.config = new Conversion.ConversionConfig();
							int index = j;
							conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.input.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (index < item3.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item3.conversions[index].m_from = from;
										UpdatePiece();
									}
								}
							};
							conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.piece.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.customPiece.SettingChanged += [<7610929e-3ecc-467b-bbeb-c7b46349bb72>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance))
								{
									string text3 = ((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 num = component.m_conversion.IndexOf(item3.conversions[index]);
										if (num >= 0)
										{
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val6 in array3)
											{
												if (Utils.GetPrefabName(((Component)val6).gameObject) == activePiece)
												{
													val6.m_conversion.RemoveAt(num);
												}
											}
										}
										conversion.config.activePiece = null;
									}
									if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0)
									{
										GameObject prefab = ZNetScene.instance.GetPrefab(text3);
										if (((prefab != null) ? prefab.GetComponent<Smelter>() : null) != null)
										{
											conversion.config.activePiece = text3;
											Smelter[] array4 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val7 in array4)
											{
												if (Utils.GetPrefabName(((Component)val7).gameObject) == text3)
												{
													val7.m_conversion.Add(item3.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item3.configurability & Configurability.Stats) != 0)
					{
						item3.statsConfigs.Clear();
						SharedData shared2 = item3.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;
						});
						bool flag;
						switch (itemType - 3)
						{
						case 0:
						case 1:
						case 2:
						case 3:
						case 4:
						case 8:
						case 9:
						case 11:
						case 14:
						case 16:
						case 19:
							flag = true;
							break;
						default:
							flag = false;
							break;
						}
						if (flag)
						{
							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 ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							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 ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							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) ? true : false)
						{
							statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value)
							{
								shared.m_toolTier = value;
							});
						}
						if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							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[] array = new DamageType[5];
							RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
							foreach (DamageType item9 in first.Except((IEnumerable<DamageType>)(object)array))
							{
								DamageType damageType = item9;
								statcfg<DamageModifier>(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => modifiers.TryGetValue(damageType, out var value3) ? value3 : 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 val8 = default(DamageModPair);
									val8.m_type = damageType;
									val8.m_modifier = (DamageModifier)value;
									DamageModPair val9 = val8;
									for (int num2 = 0; num2 < shared.m_damageModifiers.Count; num2++)
									{
										if (shared.m_damageModifiers[num2].m_type == damageType)
										{
											if (value == DamageModifier.None)
											{
												shared.m_damageModifiers.RemoveAt(num2);
											}
											else
											{
												shared.m_damageModifiers[num2] = val9;
											}
											return;
										}
									}
									if (value != DamageModifier.None)
									{
										shared.m_damageModifiers.Add(val9);
									}
								});
							}
						}
						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 (skillType - 9 <= 1)
						{
							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 ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							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_pr