Decompiled source of MountRidingSystem v1.0.0

MountRidingSystem.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CreatureManager;
using DragonWars.CompanionUI;
using DragonWars.Patches.MountController;
using DragonWars.Patches.MountController.Aim;
using DragonWars.Patches.Movement;
using DragonWars.Patches.Pets;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using Splatform;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("MountRidingSystem")]
[assembly: AssemblyCompany("Yggdrah")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("MountRidingSystem")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: <d2667a69-d0b3-4704-92c6-41fdc9c759bc>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<536cc781-dd96-4518-b532-648fb480f32b>Embedded]
	internal sealed class <536cc781-dd96-4518-b532-648fb480f32b>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<536cc781-dd96-4518-b532-648fb480f32b>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <2b8845ad-5ceb-427b-ad51-e27f55672f41>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <2b8845ad-5ceb-427b-ad51-e27f55672f41>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <2b8845ad-5ceb-427b-ad51-e27f55672f41>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<536cc781-dd96-4518-b532-648fb480f32b>Embedded]
	[CompilerGenerated]
	internal sealed class <65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[<536cc781-dd96-4518-b532-648fb480f32b>Embedded]
	internal sealed class <d2667a69-d0b3-4704-92c6-41fdc9c759bc>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <d2667a69-d0b3-4704-92c6-41fdc9c759bc>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
public class MonsterMapIcon : MonoBehaviour
{
	public string iconName = "";

	public Sprite iconSprite;

	private PinData mapMarker;

	private Character monster;

	private void Start()
	{
		monster = ((Component)this).GetComponent<Character>();
		if ((Object)(object)monster != (Object)null && monster.IsTamed())
		{
			AddMapMarker();
		}
	}

	private void Update()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if (mapMarker != null && (Object)(object)monster != (Object)null && monster.IsTamed())
		{
			mapMarker.m_pos = ((Component)this).transform.position;
		}
	}

	private void AddMapMarker()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Minimap.instance != (Object)null)
		{
			mapMarker = Minimap.instance.AddPin(((Component)this).transform.position, (PinType)3, iconName, false, false, 0L, default(PlatformUserID));
			mapMarker.m_icon = iconSprite;
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)Minimap.instance != (Object)null && mapMarker != null)
		{
			Minimap.instance.RemovePin(mapMarker);
		}
	}
}
namespace MountRidingSystem.Compendium
{
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	public static class MountRidingCompendium
	{
		[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)]
		[HarmonyPatch(typeof(Player), "Update")]
		private static class Player_Update_EnsureCompendiumEntries_Patch
		{
			[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
			[HarmonyPostfix]
			private static void Postfix(Player __instance)
			{
				if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
				{
					if ((Object)(object)s_lastLocalPlayer != (Object)(object)__instance)
					{
						s_lastLocalPlayer = __instance;
						s_defaultEntriesEnsured = false;
					}
					if (!s_defaultEntriesEnsured)
					{
						RefreshKnownText(__instance, "MountRidingSystem_Guide", "Mount Riding Guide", "MountRidingSystem adds rideable companions and mounts to Valheim.\n\n<color=#FFB81F>SUMMONING</color>\nShift + R  - Summon the equipped companion\nShift + Q  - Dismiss the equipped companion\n\n<color=#FFB81F>COMPANION MANAGEMENT</color>\n<color=#7CFC00>Shift + I</color>  - Open Companion Management near your owned companion\n\nUse Companion Management to view health, hunger, preferred food, command behaviour and companion name colour.\n\nYou can change the colour of your mount's name by clicking the mount's name inside the Companion Management UI, then selecting the colour you want.");
						RefreshKnownText(__instance, "MountRidingSystem_Commands", "Mount & Companion Commands", "<color=#FFB81F>COMPANION</color>\nShift + R  - Summon equipped companion\nShift + Q  - Dismiss equipped companion\n<color=#7CFC00>Shift + I</color>  - Open Companion Management\nShift + V  - Order your mount to stay; flying mounts will land and remain in place\nShift + F  - Call your mount to you; it will run or fly toward you and automatically mount or catch you when it reaches you, even while you are airborne\n\n<color=#FFB81F>RIDING</color>\nR          - Toggle mounted autorun\nSpace      - Ground jump / flying ascend\nCtrl       - Flying descend\nF          - Toggle flight on supported mounts\n\n<color=#FFB81F>COMBAT</color>\nMouse 0    - Primary mount attack\nMouse 1    - Secondary mount attack\nV          - Additional configured mount attack\n\n<color=#FFB81F>BEHAVIOUR</color>\nPassive    - Avoid initiating combat\nAggressive - Engage valid hostile targets");
						s_defaultEntriesEnsured = true;
					}
				}
			}
		}

		public const string MountRidingId = "MountRidingSystem_MountRiding";

		public const string SummoningId = "MountRidingSystem_Summoning";

		public const string CompanionManagementId = "MountRidingSystem_CompanionManagement";

		public const string CommandsId = "MountRidingSystem_Commands";

		public const string FeedingId = "MountRidingSystem_Feeding";

		public const string StaminaId = "MountRidingSystem_Stamina";

		public const string FlyingId = "MountRidingSystem_Flying";

		public const string CombatId = "MountRidingSystem_Combat";

		public const string InjuredId = "MountRidingSystem_Injured";

		private const string Prefix = "MountRidingSystem_";

		private const string GuideTitle = "Mount Riding Guide";

		private const string GuideBody = "MountRidingSystem adds rideable companions and mounts to Valheim.\n\n<color=#FFB81F>SUMMONING</color>\nShift + R  - Summon the equipped companion\nShift + Q  - Dismiss the equipped companion\n\n<color=#FFB81F>COMPANION MANAGEMENT</color>\n<color=#7CFC00>Shift + I</color>  - Open Companion Management near your owned companion\n\nUse Companion Management to view health, hunger, preferred food, command behaviour and companion name colour.\n\nYou can change the colour of your mount's name by clicking the mount's name inside the Companion Management UI, then selecting the colour you want.";

		private const string CommandsTitle = "Mount & Companion Commands";

		private const string CommandsBody = "<color=#FFB81F>COMPANION</color>\nShift + R  - Summon equipped companion\nShift + Q  - Dismiss equipped companion\n<color=#7CFC00>Shift + I</color>  - Open Companion Management\nShift + V  - Order your mount to stay; flying mounts will land and remain in place\nShift + F  - Call your mount to you; it will run or fly toward you and automatically mount or catch you when it reaches you, even while you are airborne\n\n<color=#FFB81F>RIDING</color>\nR          - Toggle mounted autorun\nSpace      - Ground jump / flying ascend\nCtrl       - Flying descend\nF          - Toggle flight on supported mounts\n\n<color=#FFB81F>COMBAT</color>\nMouse 0    - Primary mount attack\nMouse 1    - Secondary mount attack\nV          - Additional configured mount attack\n\n<color=#FFB81F>BEHAVIOUR</color>\nPassive    - Avoid initiating combat\nAggressive - Engage valid hostile targets";

		private static MethodInfo s_addKnownTextMethod;

		private static MethodInfo s_getKnownTextsMethod;

		private static bool s_methodsResolved;

		private static readonly HashSet<string> s_sessionUnlocked = new HashSet<string>(StringComparer.Ordinal);

		private static Player s_lastLocalPlayer;

		private static bool s_defaultEntriesEnsured;

		public static bool UnlockGuide(Player player = null)
		{
			return Unlock("MountRidingSystem_Guide", "Mount Riding Guide", "MountRidingSystem adds rideable companions and mounts to Valheim.\n\n<color=#FFB81F>SUMMONING</color>\nShift + R  - Summon the equipped companion\nShift + Q  - Dismiss the equipped companion\n\n<color=#FFB81F>COMPANION MANAGEMENT</color>\n<color=#7CFC00>Shift + I</color>  - Open Companion Management near your owned companion\n\nUse Companion Management to view health, hunger, preferred food, command behaviour and companion name colour.\n\nYou can change the colour of your mount's name by clicking the mount's name inside the Companion Management UI, then selecting the colour you want.", player);
		}

		public static bool UnlockMountRiding(Player player = null)
		{
			return Unlock("MountRidingSystem_MountRiding", "Mount Riding", "Tamed companions can be used as mounts when they support a saddle.\n\nApproach your companion and interact with its saddle to ride. Mounted movement uses the creature's own movement and stamina systems.");
		}

		public static bool UnlockSummoning(Player player = null)
		{
			return Unlock("MountRidingSystem_Summoning", "Summoning & Dismissing", "Equip the companion item linked to the mount you want to use.\n\nHold Shift and press R to summon your companion.\nHold Shift and press Q to dismiss it.\n\nA dismissed companion keeps its stored companion data and can be summoned again later.");
		}

		public static bool UnlockCompanionManagement(Player player = null)
		{
			return Unlock("MountRidingSystem_CompanionManagement", "Companion Management", "Stand near one of your owned companions and press Shift + I to open Companion Management.\n\nFrom this window you can inspect health, growth, hunger and status, view preferred food, change command behaviour, and choose the companion's name colour.");
		}

		public static bool UnlockCommands(Player player = null)
		{
			return Unlock("MountRidingSystem_Commands", "Mount & Companion Commands", "<color=#FFB81F>COMPANION</color>\nShift + R  - Summon equipped companion\nShift + Q  - Dismiss equipped companion\n<color=#7CFC00>Shift + I</color>  - Open Companion Management\nShift + V  - Order your mount to stay; flying mounts will land and remain in place\nShift + F  - Call your mount to you; it will run or fly toward you and automatically mount or catch you when it reaches you, even while you are airborne\n\n<color=#FFB81F>RIDING</color>\nR          - Toggle mounted autorun\nSpace      - Ground jump / flying ascend\nCtrl       - Flying descend\nF          - Toggle flight on supported mounts\n\n<color=#FFB81F>COMBAT</color>\nMouse 0    - Primary mount attack\nMouse 1    - Secondary mount attack\nV          - Additional configured mount attack\n\n<color=#FFB81F>BEHAVIOUR</color>\nPassive    - Avoid initiating combat\nAggressive - Engage valid hostile targets", player);
		}

		public static bool UnlockFeeding(Player player = null)
		{
			return Unlock("MountRidingSystem_Feeding", "Feeding & Preferred Food", "Companions have preferred foods.\n\nOpen Companion Management to see the foods accepted by the current creature. Drag a valid food onto the companion's feeding area to feed it.\n\nFeeding time is preserved when supported companions are dismissed and summoned again.");
		}

		public static bool UnlockStamina(Player player = null)
		{
			return Unlock("MountRidingSystem_Stamina", "Mount Stamina", "Some mounts use stamina for movement and combat actions.\n\nRunning, flying, boosting or attacking may consume stamina depending on the mount and server configuration. Allow stamina to recover before attempting another demanding action.");
		}

		public static bool UnlockFlying(Player player = null)
		{
			return Unlock("MountRidingSystem_Flying", "Flying Mounts", "Flying companions have additional riding controls.\n\nF toggles flight when supported.\nSpace ascends while flying.\nCtrl descends.\nR can enable mounted autorun.");
		}

		public static bool UnlockCombat(Player player = null)
		{
			return Unlock("MountRidingSystem_Combat", "Mount Combat", "Many mounts can attack while being ridden.\n\nPrimary, secondary and additional mount attacks depend on the creature's configured attack set. Some attacks consume mount stamina or use their own cooldown.");
		}

		public static bool UnlockInjured(Player player = null)
		{
			return Unlock("MountRidingSystem_Injured", "Injured Companions", "When a supported companion is defeated, it may become injured instead of permanently consuming its summoning item.\n\nAn injured companion cannot be summoned again until its injury cooldown has expired.");
		}

		public static bool Unlock(string id, string title, string body, Player player = null)
		{
			if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(body))
			{
				return false;
			}
			if (player == null)
			{
				player = Player.m_localPlayer;
			}
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			if (!id.StartsWith("MountRidingSystem_", StringComparison.Ordinal))
			{
				id = "MountRidingSystem_" + id;
			}
			ResolveMethods();
			if (s_addKnownTextMethod == null)
			{
				Debug.LogWarning((object)"[MountRidingSystem] Could not find Player.AddKnownText; Compendium entry was not added.");
				return false;
			}
			if (IsKnown(player, id, title))
			{
				s_sessionUnlocked.Add(id);
				return false;
			}
			if (s_sessionUnlocked.Contains(id))
			{
				return false;
			}
			try
			{
				object[] array = BuildAddKnownTextArguments(s_addKnownTextMethod, id, title, body);
				if (array == null)
				{
					Debug.LogWarning((object)"[MountRidingSystem] Unsupported Player.AddKnownText signature.");
					return false;
				}
				s_addKnownTextMethod.Invoke(player, array);
				s_sessionUnlocked.Add(id);
				Debug.Log((object)("[MountRidingSystem] Unlocked Compendium entry: " + title));
				return true;
			}
			catch (TargetInvocationException ex)
			{
				Debug.LogWarning((object)("[MountRidingSystem] AddKnownText failed: " + (ex.InnerException?.Message ?? ex.Message)));
			}
			catch (Exception ex2)
			{
				Debug.LogWarning((object)("[MountRidingSystem] AddKnownText failed: " + ex2.Message));
			}
			return false;
		}

		private static bool RefreshKnownText(Player player, string id, string title, string body)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			ResolveMethods();
			if (s_getKnownTextsMethod != null)
			{
				try
				{
					object obj = s_getKnownTextsMethod.Invoke(player, null);
					if (obj is IDictionary dictionary)
					{
						if (dictionary.Contains(title))
						{
							dictionary[title] = body;
							s_sessionUnlocked.Add(id);
							return true;
						}
						if (dictionary.Contains(id))
						{
							dictionary[id] = body;
							s_sessionUnlocked.Add(id);
							return true;
						}
					}
				}
				catch
				{
				}
			}
			if (!IsKnown(player, id, title))
			{
				return Unlock(id, title, body, player);
			}
			if (s_addKnownTextMethod != null)
			{
				try
				{
					object[] array = BuildAddKnownTextArguments(s_addKnownTextMethod, id, title, body);
					if (array != null)
					{
						s_addKnownTextMethod.Invoke(player, array);
						s_sessionUnlocked.Add(id);
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		public static bool IsKnown(Player player, string id, string title = null)
		{
			if ((Object)(object)player == (Object)null || string.IsNullOrWhiteSpace(id))
			{
				return false;
			}
			ResolveMethods();
			if (s_getKnownTextsMethod == null)
			{
				return s_sessionUnlocked.Contains(id);
			}
			try
			{
				object obj = s_getKnownTextsMethod.Invoke(player, null);
				if (obj == null)
				{
					return s_sessionUnlocked.Contains(id);
				}
				if (obj is IDictionary dictionary)
				{
					if (dictionary.Contains(id))
					{
						return true;
					}
					if (!string.IsNullOrWhiteSpace(title) && dictionary.Contains(title))
					{
						return true;
					}
					foreach (DictionaryEntry item in dictionary)
					{
						string a = item.Key?.ToString() ?? string.Empty;
						string text = item.Value?.ToString() ?? string.Empty;
						if (string.Equals(a, id, StringComparison.Ordinal) || (!string.IsNullOrWhiteSpace(title) && string.Equals(a, title, StringComparison.Ordinal)) || text.Contains(id))
						{
							return true;
						}
					}
					return false;
				}
				if (obj is IEnumerable enumerable)
				{
					foreach (object item2 in enumerable)
					{
						if (item2 != null)
						{
							string text2 = item2.ToString();
							if (!string.IsNullOrEmpty(text2) && (text2.Contains(id) || (!string.IsNullOrWhiteSpace(title) && text2.Contains(title))))
							{
								return true;
							}
						}
					}
				}
			}
			catch
			{
			}
			return s_sessionUnlocked.Contains(id);
		}

		private static void ResolveMethods()
		{
			if (s_methodsResolved)
			{
				return;
			}
			s_methodsResolved = true;
			MethodInfo[] methods = typeof(Player).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			MethodInfo[] array = methods;
			foreach (MethodInfo methodInfo in array)
			{
				if (methodInfo == null)
				{
					continue;
				}
				if (string.Equals(methodInfo.Name, "AddKnownText", StringComparison.Ordinal))
				{
					ParameterInfo[] parameters = methodInfo.GetParameters();
					if (s_addKnownTextMethod == null || parameters.Length > s_addKnownTextMethod.GetParameters().Length)
					{
						s_addKnownTextMethod = methodInfo;
					}
				}
				else if (string.Equals(methodInfo.Name, "GetKnownTexts", StringComparison.Ordinal) && methodInfo.GetParameters().Length == 0)
				{
					s_getKnownTextsMethod = methodInfo;
				}
			}
		}

		private static object[] BuildAddKnownTextArguments(MethodInfo method, string id, string title, string body)
		{
			if (method == null)
			{
				return null;
			}
			ParameterInfo[] parameters = method.GetParameters();
			if (parameters.Length == 0)
			{
				return null;
			}
			object[] array = new object[parameters.Length];
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < parameters.Length; i++)
			{
				if (parameters[i].ParameterType == typeof(string))
				{
					num2++;
				}
			}
			for (int j = 0; j < parameters.Length; j++)
			{
				ParameterInfo parameterInfo = parameters[j];
				Type parameterType = parameterInfo.ParameterType;
				if (parameterType == typeof(string))
				{
					if (num2 >= 3)
					{
						array[j] = num switch
						{
							1 => title, 
							0 => id, 
							_ => body, 
						};
					}
					else if (num2 == 2)
					{
						array[j] = ((num == 0) ? title : body);
					}
					else
					{
						array[j] = title;
					}
					num++;
				}
				else if (parameterInfo.HasDefaultValue)
				{
					array[j] = parameterInfo.DefaultValue;
				}
				else if (parameterType == typeof(bool))
				{
					array[j] = false;
				}
				else if (parameterType.IsValueType)
				{
					array[j] = Activator.CreateInstance(parameterType);
				}
				else
				{
					array[j] = null;
				}
			}
			return array;
		}

		public static void UnlockAllForTesting(Player player = null)
		{
			if (player == null)
			{
				player = Player.m_localPlayer;
			}
			if (!((Object)(object)player == (Object)null))
			{
				UnlockGuide(player);
				UnlockMountRiding(player);
				UnlockSummoning(player);
				UnlockCompanionManagement(player);
				UnlockCommands(player);
				UnlockFeeding(player);
				UnlockStamina(player);
				UnlockFlying(player);
				UnlockCombat(player);
				UnlockInjured(player);
			}
		}

		public static void ClearSessionCache()
		{
			s_sessionUnlocked.Clear();
		}
	}
}
namespace PieceManager
{
	[PublicAPI]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	public static class MaterialReplacer
	{
		[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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 (!((Object)(object)go == (Object)null) && !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([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (Material material) => ((Object)(object)material == (Object)null) ? null : ReplaceMaterial(material, isJotunnMock)).ToArray();
				val.sharedMaterials = sharedMaterials;
			}
		}

		private static Material ReplaceMaterial(Material originalMaterial, bool isJotunnMock)
		{
			if ((Object)(object)originalMaterial == (Object)null)
			{
				return null;
			}
			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;
		}
	}
	[PublicAPI]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	public class SnapPointMaker
	{
		private static List<GameObject> _objectsToApplySnaps;

		static SnapPointMaker()
		{
			_objectsToApplySnaps = new List<GameObject>();
		}

		public static void AddObjectForSnapPoints(GameObject obj)
		{
			_objectsToApplySnaps.Add(obj);
		}

		public static void ApplySnapPoints()
		{
			foreach (GameObject objectsToApplySnap in _objectsToApplySnaps)
			{
				GrabVerticesAssignSnaps(objectsToApplySnap);
			}
		}

		private static void GrabVerticesAssignSnaps(GameObject obj)
		{
			Vector3[] colliderVertexPosRotated = GetColliderVertexPosRotated(obj);
			AttachSnapPoints(obj, colliderVertexPosRotated);
		}

		private static Vector3[] GetColliderVertexPosRotated(GameObject obj)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			BoxCollider componentInChildren = obj.GetComponentInChildren<BoxCollider>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return array;
			}
			Transform transform = obj.transform;
			Vector3 val = componentInChildren.center - componentInChildren.size * 0.5f;
			Vector3 val2 = componentInChildren.center + componentInChildren.size * 0.5f;
			array[0] = transform.TransformPoint(new Vector3(val.x, val.y, val.z));
			array[1] = transform.TransformPoint(new Vector3(val.x, val.y, val2.z));
			array[2] = transform.TransformPoint(new Vector3(val.x, val2.y, val.z));
			array[3] = transform.TransformPoint(new Vector3(val.x, val2.y, val2.z));
			array[4] = transform.TransformPoint(new Vector3(val2.x, val.y, val.z));
			array[5] = transform.TransformPoint(new Vector3(val2.x, val.y, val2.z));
			array[6] = transform.TransformPoint(new Vector3(val2.x, val2.y, val.z));
			array[7] = transform.TransformPoint(new Vector3(val2.x, val2.y, val2.z));
			return array;
		}

		private static void AttachSnapPoints(GameObject objecttosnap, Vector3[] vector3S)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			foreach (Vector3 val in vector3S)
			{
				GameObject val2 = new GameObject();
				((Object)val2).name = "_snappoint";
				val2.tag = "snappoint";
				val2.layer = 10;
				GameObject val3 = Object.Instantiate<GameObject>(val2, val, Quaternion.identity, objecttosnap.transform);
				val3.SetActive(false);
			}
		}
	}
}
namespace ItemManager
{
	[PublicAPI]
	public enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("piece_MeadCauldron")]
		MeadCauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("piece_preptable")]
		PrepTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[PublicAPI]
	public enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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
			});
		}
	}
	[PublicAPI]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	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
			});
		}
	}
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		public ConfigEntryBase RecipeIsActive = null;
	}
	[PublicAPI]
	public class Trade
	{
		public Trader Trader = Trader.None;

		public uint Price = 0u;

		public uint Stack = 1u;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		public string RequiredGlobalKey = null;
	}
	[Flags]
	[PublicAPI]
	public enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	public struct Requirement
	{
		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(1)]
		public string itemName;

		public int amount;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		public string custom;
	}
	[Flags]
	public enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[PublicAPI]
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	public class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min),
				levelMultiplier = levelMultiplier
			});
		}
	}
	public struct DropTarget
	{
		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(1)]
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
	[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
	[PublicAPI]
	[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(1)]
	public class Item
	{
		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
		private class ItemConfig
		{
			[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> craft;

			[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> upgrade;

			public ConfigEntry<CraftingTable> table = null;

			public ConfigEntry<int> tableLevel = null;

			public ConfigEntry<string> customTable = null;

			[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
			public ConfigEntry<int> maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient = null;

			public ConfigEntry<float> qualityResultAmountMultiplier = null;
		}

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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;
		}

		[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)]
		private class RequirementQuality
		{
			public int quality;
		}

		[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(2)]
		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string Category;

			[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer;

			public Func<bool> browsability;
		}

		[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)]
		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)]
		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					int result;
					int result2;
					return new Requirement
					{
						itemName = array[0],
						amount = ((array.Length <= 1 || !int.TryParse(array[1], out result)) ? 1 : result),
						quality = ((array.Length > 2 && int.TryParse(array[2], out result2)) ? result2 : 0)
					};
				}).ToList())
			{
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : "")));
			}

			[return: <2b8845ad-5ceb-427b-ad51-e27f55672f41>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>)([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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();
				[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(2)]
				ItemDrop ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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";
					float result3;
					return new DropTarget
					{
						creature = array[0],
						chance = ((array.Length > 1 && float.TryParse(array[1], out result3)) ? result3 : 1f),
						min = result,
						max = result2,
						levelMultiplier = levelMultiplier
					};
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0")));
			}

			[return: <2b8845ad-5ceb-427b-ad51-e27f55672f41>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>>>();

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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>();

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		private LocalizeKey _name;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		private LocalizeKey _description;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		private static object configManager;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		private static Localization _english;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>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;

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase RecipeIsActive
		{
			[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(2)]
			get
			{
				return this[""].RecipeIsActive;
			}
			[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(2)]
		private static object configSync
		{
			[<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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) != Configurability.Disabled)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				foreach (object obj in tags)
				{
					if (obj is ConfigurationManagerAttributes configurationManagerAttributes)
					{
						configurationManagerAttributes.Browsable = (visible & check) != Configurability.Disabled && (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()
		{
			if (configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager) is int num && num != 0)
			{
				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_1001: Unknown result type (might be due to invalid IL or missing references)
			//IL_1006: Unknown result type (might be due to invalid IL or missing references)
			//IL_2395: Unknown result type (might be due to invalid IL or missing references)
			//IL_239f: Expected O, but got Unknown
			//IL_10ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1127: Expected I4, but got Unknown
			//IL_0ccc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd6: Expected O, but got Unknown
			//IL_1267: Unknown result type (might be due to invalid IL or missing references)
			//IL_126a: Unknown result type (might be due to invalid IL or missing references)
			//IL_126c: 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_0dfa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e04: Expected O, but got Unknown
			//IL_0ea6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb0: Expected O, but got Unknown
			//IL_1270: Unknown result type (might be due to invalid IL or missing references)
			//IL_1274: Invalid comparison between Unknown and I4
			//IL_0f5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f65: Expected O, but got Unknown
			//IL_1489: Unknown result type (might be due to invalid IL or missing references)
			//IL_148c: Unknown result type (might be due to invalid IL or missing references)
			//IL_148e: 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_1278: Unknown result type (might be due to invalid IL or missing references)
			//IL_127c: Invalid comparison between Unknown and I4
			//IL_1492: Unknown result type (might be due to invalid IL or missing references)
			//IL_1496: Unknown result type (might be due to invalid IL or missing references)
			//IL_1498: 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_1581: Unknown result type (might be due to invalid IL or missing references)
			//IL_1586: Unknown result type (might be due to invalid IL or missing references)
			//IL_1588: Unknown result type (might be due to invalid IL or missing references)
			//IL_158b: Invalid comparison between Unknown and I4
			//IL_149c: Unknown result type (might be due to invalid IL or missing references)
			//IL_14a0: Invalid comparison between Unknown and I4
			//IL_158f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1593: 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_160c: Unknown result type (might be due to invalid IL or missing references)
			//IL_160f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1611: 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_1615: Unknown result type (might be due to invalid IL or missing references)
			//IL_1619: Unknown result type (might be due to invalid IL or missing references)
			//IL_161b: Invalid comparison between Unknown and I4
			//IL_176e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1771: Invalid comparison between Unknown and I4
			//IL_161f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1623: Invalid comparison between Unknown and I4
			//IL_1980: Unknown result type (might be due to invalid IL or missing references)
			//IL_1987: Invalid comparison between Unknown and I4
			//IL_1a5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a61: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a63: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a67: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a69: Invalid comparison between Unknown and I4
			//IL_16de: Unknown result type (might be due to invalid IL or missing references)
			//IL_16e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae7: Invalid comparison between Unknown and I4
			//IL_1aeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1aef: Invalid comparison between Unknown and I4
			//IL_1af3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1af7: Invalid comparison between Unknown and I4
			//IL_1f88: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f8b: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			if (DefaultConfigurability != Configurability.Disabled)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item3 in registeredItems.Where([<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item = item3;
					string name = item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name), "").Trim();
					string localizedName = Localization.instance.Localize(name).Trim();
					int order = 0;
					if ((item.configurability & Configurability.Recipe) != Configurability.Disabled)
					{
						itemCraftConfigs[item] = new Dictionary<string, ItemConfig>();
						foreach (string item4 in item.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item4;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (!item.Recipes.ContainsKey(configKey) || item.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig = (itemCraftConfigs[item][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text, item.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 = ((item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, item.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() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out var value))
								{
									value.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item.MaximumRequiredStationLevel == int.MaxValue) ? (item.Recipes[configKey].Crafting.Stations.First().level + item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item.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, item.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() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out var value))
								{
									foreach (Recipe item5 in value)
									{
										item5.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item.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 += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out var value))
								{
									foreach (Recipe item6 in value)
									{
										item6.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item.Recipes[configKey].RequiredItems.Free || item.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig3("Crafting Costs" + text, new SerializedRequirements(item.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false);
							}
							if (item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item.Recipes[configKey].RequiredUpgradeItems.Free || item.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig3("Upgrading Costs" + text, new SerializedRequirements(item.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)
							{
								item.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)
							{
								item.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value);
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item7 in hideWhenNoneAttributes)
								{
									item7.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig3(string name2, 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 configurationManagerAttributes2 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable(item, isUpgrade),
									Order = (order -= 1),
									browsability = ItemBrowsability,
									Browsable = (ItemBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								};
								hideWhenNoneAttributes.Add(configurationManagerAttributes2);
								return config(englishName, name2, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 }));
							}
						}
						if ((item.configurability & Configurability.Drop) != Configurability.Disabled)
						{
							ConfigEntry<string> val = (itemDropConfigs[item] = config(englishName, "Drops from", new SerializedDrop(item.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									CustomDrawer = drawDropsConfigTable,
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							})));
							ConfigEntry<string> val3 = val;
							val3.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
							{
								item.UpdateCharacterDrop();
							};
						}
						for (int num = 0; num < item.Conversions.Count; num++)
						{
							string text2 = ((item.Conversions.Count > 1) ? $"{num + 1}. " : "");
							Conversion conversion = item.Conversions[num];
							conversion.config = new Conversion.ConversionConfig();
							int index = num;
							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 = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.input.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (index < item.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop val4 = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item.conversions[index].m_from = val4;
										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 = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.piece.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>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 = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.customPiece.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item.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 num4 = component.m_conversion.IndexOf(item.conversions[index]);
										if (num4 >= 0)
										{
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val4 in array3)
											{
												if (Utils.GetPrefabName(((Component)val4).gameObject) == activePiece)
												{
													val4.m_conversion.RemoveAt(num4);
												}
											}
										}
										conversion.config.activePiece = null;
									}
									if (item.conversions[index].m_from != null && conversion.config.piece.Value != ConversionPiece.Disabled)
									{
										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 val5 in array4)
											{
												if (Utils.GetPrefabName(((Component)val5).gameObject) == text3)
												{
													val5.m_conversion.Add(item.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item.configurability & Configurability.Stats) != Configurability.Disabled)
					{
						item.statsConfigs.Clear();
						SharedData shared = item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ItemType itemType = shared.m_itemType;
						statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData val4) => val4.m_weight, delegate(SharedData val4, float value)
						{
							val4.m_weight = value;
						});
						statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData val4) => val4.m_value, delegate(SharedData val4, int value)
						{
							val4.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 val4) => val4.m_maxDurability, delegate(SharedData val4, float value)
							{
								val4.m_maxDurability = value;
							});
							statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData val4) => val4.m_durabilityPerLevel, delegate(SharedData val4, float value)
							{
								val4.m_durabilityPerLevel = value;
							});
							statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData val4) => val4.m_movementModifier, delegate(SharedData val4, float value)
							{
								val4.m_movementModifier = value;
							});
						}
						if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData val4) => val4.m_blockPower, delegate(SharedData val4, float value)
							{
								val4.m_blockPower = value;
							});
							statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData val4) => val4.m_blockPowerPerLevel, delegate(SharedData val4, float value)
							{
								val4.m_blockPowerPerLevel = value;
							});
							statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData val4) => val4.m_deflectionForce, delegate(SharedData val4, float value)
							{
								val4.m_deflectionForce = value;
							});
							statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData val4) => val4.m_deflectionForcePerLevel, delegate(SharedData val4, float value)
							{
								val4.m_deflectionForcePerLevel = value;
							});
							statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData val4) => val4.m_timedBlockBonus, delegate(SharedData val4, float value)
							{
								val4.m_timedBlockBonus = value;
							});
						}
						else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData val4) => val4.m_armor, delegate(SharedData val4, float value)
							{
								val4.m_armor = value;
							});
							statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData val4) => val4.m_armorPerLevel, delegate(SharedData val4, float value)
							{
								val4.m_armorPerLevel = value;
							});
						}
						SkillType skillType = shared.m_skillType;
						if (((int)skillType == 7 || (int)skillType == 12) ? true : false)
						{
							statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData val4) => val4.m_toolTier, delegate(SharedData val4, int value)
							{
								val4.m_toolTier = value;
							});
						}
						if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							Dictionary<DamageType, DamageModifier> modifiers = shared.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 damageType in first.Except((IEnumerable<DamageType>)(object)array))
							{
								statcfg<DamageModifier>(((object)Unsafe.As<DamageType, DamageType>(ref damageType)/*cast due to .constrained prefix*/).ToString() + " Resistance", ((object)Unsafe.As<DamageType, DamageType>(ref damageType)/*cast due to .constrained prefix*/).ToString() + " resistance of " + englishName + ".", (SharedData _) => modifiers.TryGetValue(damageType, out var value) ? value : DamageModifier.None, delegate(SharedData val5, 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 val4 = new DamageModPair
									{
										m_type = damageType,
										m_modifier = (DamageModifier)value
									};
									for (int i = 0; i < val5.m_damageModifiers.Count; i++)
									{
										if (val5.m_damageModifiers[i].m_type == damageType)
										{
											if (value == DamageModifier.None)
											{
												val5.m_damageModifiers.RemoveAt(i);
											}
											else
											{
												val5.m_damageModifiers[i] = val4;
											}
											return;
										}
									}
									if (value != DamageModifier.None)
									{
										val5.m_damageModifiers.Add(val4);
									}
								});
							}
						}
						if ((int)itemType == 2 && shared.m_food > 0f)
						{
							statcfg<float>("Health", "Health value of " + englishName + ".", (SharedData val4) => val4.m_food, delegate(SharedData val4, float value)
							{
								val4.m_food = value;
							});
							statcfg<float>("Stamina", "Stamina value of " + englishName + ".", (SharedData val4) => val4.m_foodStamina, delegate(SharedData val4, float value)
							{
								val4.m_foodStamina = value;
							});
							statcfg<float>("Eitr", "Eitr value of " + englishName + ".", (SharedData val4) => val4.m_foodEitr, delegate(SharedData val4, float value)
							{
								val4.m_foodEitr = value;
							});
							statcfg<float>("Duration", "Duration of " + englishName + ".", (SharedData val4) => val4.m_foodBurnTime, delegate(SharedData val4, float value)
							{
								val4.m_foodBurnTime = value;
							});
							statcfg<float>("Health Regen", "Health regen value of " + englishName + ".", (SharedData val4) => val4.m_foodRegen, delegate(SharedData val4, float value)
							{
								val4.m_foodRegen = value;
							});
						}
						if ((int)shared.m_skillType == 10)
						{
							statcfg<float>("Health Cost", "Health cost of " + englishName + ".", (SharedData val4) => val4.m_attack.m_attackHealth, delegate(SharedData val4, float value)
							{
								val4.m_attack.m_attackHealth = value;
							});
							statcfg<float>("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData val4) => val4.m_attack.m_attackHealthPercentage, delegate(SharedData val4, float value)
							{
								val4.m_attack.m_attackHealthPercentage = value;
							});
						}
						skillType = shared.m_skillType;
						if (skillType - 9 <= 1)
						{
							statcfg<float>("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData val4) => val4.m_attack.m_attackEitr, delegate(SharedData val4, float value)
							{
								val4.m_attack.m_attackEitr = value;
							});
						}
						if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Knockback", "Knockback of " + englishName + ".", (SharedData val4) => val4.m_attackForce, delegate(SharedData val4, float value)
							{
								val4.m_attackForce = value;
							});
							statcfg<float>("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData val4) => val4.m_backstabBonus, delegate(SharedData val4, float value)
							{
								val4.m_backstabBonus = value;
							});
							statcfg<float>("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData val4) => val4.m_attack.m_attackStamina, delegate(SharedData val4, float value)
							{
								val4.m_attack.m_attackStamina = value;
							});
							SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float damage)
							{
								dmg.m_damage = damage;
							});
							SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float slash)
							{
								dmg.m_slash = slash;
							});
							SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float pierce)
							{
								dmg.m_pierce = pierce;
							});
							SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float blunt)
							{
								dmg.m_blunt = blunt;
							});
							SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float chop)
							{
								dmg.m_chop = chop;
							});
							SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float pickaxe)
							{
								dmg.m_pickaxe = pickaxe;
							});
							SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float fire)
							{
								dmg.m_fire = fire;
							});
							SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float poison)
							{
								dmg.m_poison = poison;
							});
							SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float frost)
							{
								dmg.m_frost = frost;
							});
							SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float lightning)
							{
								dmg.m_lightning = lightning;
							});
							SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float spirit)
							{
								dmg.m_spirit = spirit;
							});
							if ((int)itemType == 4)
							{
								statcfg<int>("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData val4) => val4.m_attack.m_projectileBursts, delegate(SharedData val4, int value)
								{
									val4.m_attack.m_projectileBursts = value;
								});
								statcfg<float>("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData val4) => val4.m_attack.m_burstInterval, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_burstInterval = value;
								});
								statcfg<float>("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData val4) => val4.m_attack.m_projectileAccuracyMin, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_projectileAccuracyMin = value;
								});
								statcfg<float>("Accuracy", "Accuracy for " + englishName + ".", (SharedData val4) => val4.m_attack.m_projectileAccuracy, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_projectileAccuracy = value;
								});
								statcfg<float>("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData val4) => val4.m_attack.m_projectileVelMin, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_projectileVelMin = value;
								});
								statcfg<float>("Velocity", "Velocity for " + englishName + ".", (SharedData val4) => val4.m_attack.m_projectileVel, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_projectileVel = value;
								});
								statcfg<float>("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData val4) => val4.m_attack.m_drawDurationMin, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_drawDurationMin = value;
								});
								statcfg<float>("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData val4) => val4.m_attack.m_drawStaminaDrain, delegate(SharedData val4, float value)
								{
									val4.m_attack.m_drawStaminaDrain = value;
								});
							}
						}
					}
					List<ConfigurationManagerAttributes> traderAttributes;
					if ((item.configurability & Configurability.Trader) != Configurability.Disabled)
					{
						traderAttributes = new List<ConfigurationManagerAttributes>();
						item.traderConfig = new TraderConfig
						{
							trader = config(englishName, "Trader Selling", item.Trade.Trader, new ConfigDescription("Which traders sell " + englishName + ".", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item.configurationVisible & Configurability.Trader) != 0),
									Category = localizedName
								}
							}))
						};
						item.traderConfig.trader.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
						{
							item.ReloadTraderConfiguration();
							foreach (ConfigurationManagerAttributes item8 in traderAttributes)
							{
								item8.Browsable = TraderBrowsability();
							}
							reloadConfigDisplay();
						};
						item.traderConfig.price = traderConfig<uint>("Trader Price", item.Trade.Price, "Price of " + englishName + " at the trader.");
						item.traderConfig.stack = traderConfig<uint>("Trader Stack", item.Trade.Stack, "Stack size of " + englishName + " in the trader. Also known as the number of items sold by a trader in one transaction.");
						item.traderConfig.requiredGlobalKey = traderConfig<string>("Trader Required Global Key", item.Trade.RequiredGlobalKey ?? "", "Required global key to unlock " + englishName + " at the trader.");
						if (item.traderConfig.trader.Value != Trader.None)
						{
							PrefabManager.AddItemToTrader(item.Prefab, item.traderConfig.trader.Value, item.traderConfig.price.Value, item.traderConfig.stack.Value, item.traderConfig.requiredGlobalKey.Value);
						}
					}
					else if (item.Trade.Trader != Trader.None)
					{
						PrefabManager.AddItemToTrader(item.Prefab, item.Trade.Trader, item.Trade.Price, item.Trade.Stack, item.Trade.RequiredGlobalKey);
					}
					void SetDmg(string dmgType, Func<DamageTypes, float> readDmg, setDmgFunc setDmg)
					{
						statcfg<float>(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData val4) => readDmg(val4.m_damages), delegate(SharedData val4, float value)
						{
							setDmg(ref val4.m_damages, value);
						});
						statcfg<float>(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData val4) => readDmg(val4.m_damagesPerLevel), delegate(SharedData val4, float value)
						{
							setDmg(ref val4.m_damagesPerLevel, value);
						});
					}
					bool TraderBrowsability()
					{
						return item.traderConfig.trader.Value != Trader.None;
					}
					void statcfg<T>(string configName, string description, [<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 1, 1, 0 })] Func<SharedData, T> readDefault, [<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 1, 1, 0 })] Action<SharedData, T> setValue)
					{
						//IL_0079: Unknown result type (might be due to invalid IL or missing references)
						//IL_0083: Expected O, but got Unknown
						SharedData shared2 = item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ConfigEntry<T> cfg2 = config(englishName, configName, readDefault(shared2), new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
						{
							new ConfigurationManagerAttributes
							{
								Category = localizedName,
								Browsable = ((item.configurationVisible & Configurability.Stats) != 0)
							}
						}));
						if ((item.configurationVisible & Configurability.Stats) != Configurability.Disabled)
						{
							setValue(shared2, cfg2.Value);
						}
						item.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig);
						cfg2.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
						{
							if ((item.configurationVisible & Configurability.Stats) != Configurability.Disabled)
							{
								ApplyConfig();
							}
						};
						void ApplyConfig()
						{
							item.ApplyToAllInstances(delegate(ItemData val4)
							{
								setValue(val4.m_shared, cfg2.Value);
							});
						}
					}
					[return: <2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(new byte[] { 1, 0 })]
					ConfigEntry<T> traderConfig<T>(string name2, [<2b8845ad-5ceb-427b-ad51-e27f55672f41>Nullable(0)] T value, string desc)
					{
						//IL_009b: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a5: Expected O, but got Unknown
						ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes
						{
							Order = (order -= 1),
							browsability = TraderBrowsability,
							Browsable = (TraderBrowsability() && (item.configurationVisible & Configurability.Trader) != 0),
							Category = localizedName
						};
						traderAttributes.Add(configurationManagerAttributes2);
						ConfigEntry<T> val4 = config(englishName, name2, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 }));
						val4.SettingChanged += [<65bc6c0a-c289-423f-b7d5-d6dba9ddcad7>NullableContext(0)] (object _, EventArgs _) =>
						{
							item.ReloadTraderConfiguration();
						};
						return val4;
					}
				}
				if (saveOnConfigSet)
				{