Decompiled source of ShieldMeBruh v1.0.8

plugins/ShieldMeBruh.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using ShieldMeBruh.Configuration;
using ShieldMeBruh.Features;
using ShieldMeBruh.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Vapok.Common.Abstractions;
using Vapok.Common.Managers;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Managers.Creature;
using Vapok.Common.Managers.LocalizationManager;
using Vapok.Common.Managers.Location;
using Vapok.Common.Managers.PieceManager;
using Vapok.Common.Managers.Skill;
using Vapok.Common.Managers.StatusEffects;
using Vapok.Common.Shared;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: Guid("997CB563-FCC7-44B7-8F71-069747D27CC5")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("ShieldMeBruh")]
[assembly: AssemblyCompany("Vapok Gaming")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("A Valheim Quality of Life Mod that will auto equip a selected shield when a one-handed weapon is equipped. I need a shield! Shield me Bruh!")]
[assembly: AssemblyTitle("ShieldMeBruh")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.8.0")]
[module: <957af6bc-c4fc-472e-bf9d-5e686e88575b>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<f57889cd-d782-4c6f-9617-e7b704e89d72>Embedded]
	internal sealed class <f57889cd-d782-4c6f-9617-e7b704e89d72>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[<f57889cd-d782-4c6f-9617-e7b704e89d72>Embedded]
	[CompilerGenerated]
	internal sealed class <957af6bc-c4fc-472e-bf9d-5e686e88575b>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <957af6bc-c4fc-472e-bf9d-5e686e88575b>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShieldMeBruh
{
	[BepInPlugin("vapok.mods.shieldmebruh", "Shield Me Bruh!", "1.0.8")]
	public class ShieldMeBruh : BaseUnityPlugin, IPluginInfo
	{
		public class Waiting
		{
			public event EventHandler StatusChanged;

			public void ValheimIsAwake(bool awakeFlag)
			{
				if (awakeFlag)
				{
					this.StatusChanged?.Invoke(this, EventArgs.Empty);
				}
			}
		}

		private const string _pluginId = "vapok.mods.shieldmebruh";

		private const string _displayName = "Shield Me Bruh!";

		private const string _version = "1.0.8";

		public static bool ValheimAwake;

		public static Waiting Waiter;

		private static ShieldMeBruh _instance;

		private static ConfigSyncBase _config;

		private static ILogIt _log;

		private Harmony _harmony;

		public static ILogIt Log => _log;

		public static AutoShield AutoShield { get; private set; }

		public string PluginId => "vapok.mods.shieldmebruh";

		public string DisplayName => "Shield Me Bruh!";

		public string Version => "1.0.8";

		public BaseUnityPlugin Instance => (BaseUnityPlugin)(object)_instance;

		[UsedImplicitly]
		private void Awake()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			_instance = this;
			Waiter = new Waiting();
			Localizer.Init();
			_config = new ConfigRegistry(_instance);
			LogManager.Init(PluginId, out _log);
			Localizer.Waiter.StatusChanged += InitializeModule;
			AutoShield = new AutoShield();
			AutoShield.FeatureInitialized = true;
			AutoShield.ResetEvent.OnResetEvent += delegate
			{
				ResetAutoSheild();
			};
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
		}

		private void Start()
		{
			AutoShield.LoadAssets();
		}

		private void Update()
		{
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				Object.op_Implicit((Object)(object)ZNetScene.instance);
			}
		}

		private void ResetAutoSheild()
		{
			AutoShield.ResetAutoShieldOnPlayerAwake();
		}

		private void OnDestroy()
		{
			_instance = null;
			AutoShield = null;
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		public void InitializeModule(object send, EventArgs args)
		{
			if (!ValheimAwake)
			{
				ConfigRegistry.Waiter.ConfigurationComplete(configDone: true);
				ValheimAwake = true;
			}
		}
	}
}
namespace ShieldMeBruh.Patches
{
	public static class DeathEvent
	{
		[HarmonyPatch(typeof(Player), "OnDeath")]
		private static class OnDeathEventPatch
		{
			private static void Postfix(bool __runOriginal)
			{
				if (__runOriginal)
				{
					ShieldMeBruh.AutoShield.SetShieldStatus(statusSetTo: false);
					DeathInProgress = true;
				}
			}
		}

		[HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")]
		private static class TombstoneTakeAllEventPatch
		{
			private static void Postfix(TombStone __instance, bool __runOriginal)
			{
				//IL_0091: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: Invalid comparison between Unknown and I4
				DeathInProgress = false;
				if ((Object)(object)Game.instance == (Object)null || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				Player localPlayer = default(Player);
				int num;
				if (__instance.IsOwner())
				{
					localPlayer = Player.m_localPlayer;
					num = ((localPlayer != null) ? 1 : 0);
				}
				else
				{
					num = 0;
				}
				if (((uint)num & (__runOriginal ? 1u : 0u)) == 0)
				{
					return;
				}
				PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
				string text = ((playerProfile != null) ? playerProfile.GetName() : null);
				if (text == null || (Object)(object)__instance.m_container == (Object)null || !__instance.m_container.m_name.Equals(text))
				{
					return;
				}
				Vector2i? val = ShieldMeBruh.AutoShield.GetShieldSaveData()?.SavedElement;
				if (!val.HasValue || val.Value.x < 0 || val.Value.y < 0)
				{
					return;
				}
				ItemData itemAt = ((Humanoid)localPlayer).GetInventory().GetItemAt(val.Value.x, val.Value.y);
				if (((Humanoid)localPlayer).GetInventory() == null)
				{
					return;
				}
				Element val2 = null;
				if ((Object)(object)ShieldMeBruh.AutoShield.GetActiveInstance() == (Object)null)
				{
					if (ShieldMeBruh.AutoShield.CurrentElement != null)
					{
						val2 = ShieldMeBruh.AutoShield.CurrentElement;
					}
				}
				else
				{
					val2 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(val.Value.x, val.Value.y, ((Humanoid)localPlayer).GetInventory().m_width);
				}
				if (val2 != null && itemAt != null && (int)itemAt.m_shared.m_itemType == 5)
				{
					ShieldMeBruh.AutoShield.ApplyShieldToElement(val2, itemAt);
				}
			}
		}

		public static bool DeathInProgress;
	}
	public class FejdStartupPatches
	{
		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		[HarmonyAfter(new string[] { "org.bepinex.helpers.LocalizationManager" })]
		[HarmonyBefore(new string[] { "org.bepinex.helpers.ItemManager" })]
		public static class FejdStartupAwakePatch
		{
			private static void Prefix()
			{
				ShieldMeBruh.Waiter.ValheimIsAwake(awakeFlag: true);
			}
		}
	}
	public static class Humanoid_Patches
	{
		[HarmonyPatch(typeof(Humanoid), "EquipItem")]
		private static class HumanoidEquipItemPatch
		{
			private static void Postfix(Humanoid __instance, ItemData item, ref bool __result, ItemData ___m_leftItem, bool __runOriginal)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Invalid comparison between Unknown and I4
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Invalid comparison between Unknown and I4
				//IL_00c2: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Invalid comparison between Unknown and I4
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val == null || !ShieldMeBruh.AutoShield.FeatureInitialized || !__runOriginal || !__result || (int)item.m_shared.m_itemType != 3 || ___m_leftItem != null)
				{
					return;
				}
				if (ShieldMeBruh.AutoShield.SelectedShield != null)
				{
					ItemData itemAt = ((Humanoid)val).m_inventory.GetItemAt(ShieldMeBruh.AutoShield.CurrentElement.m_pos.x, ShieldMeBruh.AutoShield.CurrentElement.m_pos.y);
					if (itemAt != null && (int)itemAt.m_shared.m_itemType == 5)
					{
						((Humanoid)val).EquipItem(itemAt, true);
					}
					return;
				}
				AutoShieldSaveData shieldSaveData = ShieldMeBruh.AutoShield.GetShieldSaveData();
				if (shieldSaveData.SavedElement.x >= 0 && shieldSaveData.SavedElement.y >= 0)
				{
					ItemData itemAt2 = ((Humanoid)val).m_inventory.GetItemAt(shieldSaveData.SavedElement.x, shieldSaveData.SavedElement.y);
					if (itemAt2 != null && (int)itemAt2.m_shared.m_itemType == 5)
					{
						((Humanoid)val).EquipItem(itemAt2, true);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
		private static class HumanoidUnequipItemPatch
		{
			private static void Postfix(Humanoid __instance, ItemData item, ItemData ___m_leftItem, bool __runOriginal)
			{
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Invalid comparison between Unknown and I4
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Invalid comparison between Unknown and I4
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val == null || item == null || ___m_leftItem == null || !ShieldMeBruh.AutoShield.FeatureInitialized || !__runOriginal || !ShieldMeBruh.AutoShield.EnableAutoUnequip.Value)
				{
					return;
				}
				ItemData val2 = null;
				if (ShieldMeBruh.AutoShield.CurrentElement == null && ShieldMeBruh.AutoShield.SelectedShield == null)
				{
					AutoShieldSaveData shieldSaveData = ShieldMeBruh.AutoShield.GetShieldSaveData();
					if (shieldSaveData.SavedElement.x >= 0 && shieldSaveData.SavedElement.y >= 0)
					{
						val2 = ((Humanoid)val).m_inventory.GetItemAt(shieldSaveData.SavedElement.x, shieldSaveData.SavedElement.y);
						if ((int)item.m_shared.m_itemType == 3 && val2 != null && ___m_leftItem.m_shared.m_name == val2.m_shared.m_name && ___m_leftItem == val2)
						{
							((Humanoid)val).UnequipItem(val2, true);
						}
					}
				}
				else
				{
					val2 = ((Humanoid)val).m_inventory.GetItemAt(ShieldMeBruh.AutoShield.CurrentElement.m_pos.x, ShieldMeBruh.AutoShield.CurrentElement.m_pos.y);
					if ((int)item.m_shared.m_itemType == 3 && ShieldMeBruh.AutoShield.SelectedShield != null && val2 != null && ___m_leftItem.m_shared.m_name == ShieldMeBruh.AutoShield.SelectedShield.m_shared.m_name && ___m_leftItem == val2)
					{
						((Humanoid)val).UnequipItem(val2, true);
					}
				}
			}
		}
	}
	public static class InventoryGrid_Patches
	{
		[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
		public static class InventoryGridUpdateGuiPatch
		{
			private static bool _initializedElement;

			public static void ResetInitializedElement()
			{
				_initializedElement = false;
			}

			[HarmonyPriority(800)]
			private static void Prefix(InventoryGrid __instance, ref bool __state)
			{
				if (ShieldMeBruh.AutoShield.FeatureInitialized && ((Object)__instance).name.Equals("PlayerGrid"))
				{
					__state = false;
					int width = __instance.m_inventory.GetWidth();
					int height = __instance.m_inventory.GetHeight();
					if (__instance.m_width != width || __instance.m_height != height)
					{
						ShieldMeBruh.Log.Debug($"Width {width} doesn't match {__instance.m_width}");
						ShieldMeBruh.Log.Debug($"Height {height} doesn't match {__instance.m_height}");
						__state = true;
						_initializedElement = false;
					}
				}
			}

			private static void Postfix(InventoryGrid __instance, ref bool __state, bool __runOriginal)
			{
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)__instance).name.Equals("PlayerGrid") || !__state || !__runOriginal)
				{
					return;
				}
				ShieldMeBruh.Log.Debug("Inventory Grid needs to init.");
				foreach (Element element2 in __instance.m_elements)
				{
					UIInputHandler componentInChildren = element2.m_go.GetComponentInChildren<UIInputHandler>();
					componentInChildren.m_onMiddleDown = (Action<UIInputHandler>)Delegate.Combine(componentInChildren.m_onMiddleDown, new Action<UIInputHandler>(ShieldMeBruh.AutoShield.OnMiddleClick));
					ShieldMeBruh.Log.Debug($"Adding to element: X: {element2.m_pos.x}  Y: {element2.m_pos.y}");
				}
				if (_initializedElement || !Player.m_localPlayer.m_customData.ContainsKey("vapok.mods.shieldmebruh"))
				{
					return;
				}
				Vector2i savedElement = ShieldMeBruh.AutoShield.GetShieldSaveData().SavedElement;
				if (savedElement.x >= 0 && savedElement.y >= 0)
				{
					Element element = __instance.GetElement(savedElement.x, savedElement.y, __instance.m_width);
					ItemData itemAt = __instance.m_inventory.GetItemAt(savedElement.x, savedElement.y);
					if (element != null && itemAt != null)
					{
						ShieldMeBruh.AutoShield.ApplyShieldToElement(element, itemAt);
					}
				}
				_initializedElement = true;
			}
		}
	}
	public static class InventoryGui_Patches
	{
		[HarmonyPatch(typeof(InventoryGui), "Show")]
		private static class ShowInventoryPatch
		{
			private static void Postfix(InventoryGui __instance, bool __runOriginal)
			{
				if (__runOriginal)
				{
					ShieldMeBruh.AutoShield.SetActiveInstance(__instance.m_playerGrid);
				}
			}
		}
	}
	public static class MoveProtection
	{
		[HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[]
		{
			typeof(Inventory),
			typeof(ItemData)
		})]
		private static class MoveItemPatch
		{
			private static void Prefix(Inventory __instance, Inventory fromInventory, ItemData item)
			{
				if (!_movingWithDropItem && (ShieldMeBruh.AutoShield.CurrentElement != null || ShieldMeBruh.AutoShield.SelectedShield != null) && __instance != null && fromInventory != null && item != null && !__instance.m_name.Equals("Inventory"))
				{
					ShieldMeBruh.AutoShield.ResetCurrentSheildElement();
				}
			}
		}

		[HarmonyPatch(typeof(Inventory), "MoveItemToThis", new Type[]
		{
			typeof(Inventory),
			typeof(ItemData),
			typeof(int),
			typeof(int),
			typeof(int)
		})]
		private static class MoveItemToThisPatch
		{
			private static void Prefix(Inventory __instance, Inventory fromInventory, ItemData item, int x, int y)
			{
				if (_movingWithDropItem || (ShieldMeBruh.AutoShield.CurrentElement == null && ShieldMeBruh.AutoShield.SelectedShield == null) || __instance == null || fromInventory == null || item == null || !__instance.m_name.Equals("Inventory"))
				{
					return;
				}
				if (item != ShieldMeBruh.AutoShield.SelectedShield)
				{
					Element element = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(x, y, __instance.m_width);
					Element element2 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(item.m_gridPos.x, item.m_gridPos.y, __instance.m_width);
					ItemData itemAt = __instance.GetItemAt(x, y);
					if (element == null || element2 == null || itemAt == null || itemAt != ShieldMeBruh.AutoShield.SelectedShield)
					{
						return;
					}
					_futureElement = element2;
					_oldElement = element;
				}
				else
				{
					Element element3 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(x, y, __instance.m_width);
					Element element4 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(item.m_gridPos.x, item.m_gridPos.y, __instance.m_width);
					if (element3 == null || element4 == null)
					{
						return;
					}
					_futureElement = element3;
					_oldElement = element4;
				}
				_reEnableShield = true;
				_movingWithMoveItemToThis = true;
			}

			private static void Postfix(Inventory __instance, Inventory fromInventory, ItemData item, int x, int y, bool __runOriginal)
			{
				if (_movingWithDropItem || !__runOriginal || item == null)
				{
					return;
				}
				if (_reEnableShield)
				{
					ItemData itemAt = __instance.GetItemAt(_futureElement.m_pos.x, _futureElement.m_pos.y);
					if (itemAt != null && _oldElement != null && _futureElement != null)
					{
						ShieldMeBruh.AutoShield.ResetCurrentSheildElement(_oldElement);
						ShieldMeBruh.AutoShield.ApplyShieldToElement(_futureElement, itemAt);
					}
					_reEnableShield = false;
				}
				_oldElement = null;
				_futureElement = null;
				_movingWithMoveItemToThis = false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[] { typeof(ItemData) })]
		private static class RemoveItemPatch
		{
			private static void Postfix(Inventory __instance, ItemData item, bool __runOriginal)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Invalid comparison between Unknown and I4
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				if (item != null && __runOriginal && __instance != null && ShieldMeBruh.AutoShield.CurrentElement != null && ShieldMeBruh.AutoShield.SelectedShield != null && !_movingWithDropItem && !_movingWithMoveItemToThis && (int)item.m_shared.m_itemType == 5 && item.m_gridPos == ShieldMeBruh.AutoShield.CurrentElement.m_pos)
				{
					ShieldMeBruh.AutoShield.ResetCurrentSheildElement();
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGrid), "DropItem", new Type[]
		{
			typeof(Inventory),
			typeof(ItemData),
			typeof(int),
			typeof(Vector2i)
		})]
		private static class DropItemPatch
		{
			private static void Prefix(InventoryGrid __instance, Inventory fromInventory, ItemData item, int amount, Vector2i pos)
			{
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				if (item == null || (Object)(object)__instance == (Object)null || ShieldMeBruh.AutoShield.SelectedShield == null || (Object)(object)ShieldMeBruh.AutoShield.GetActiveInstance() == (Object)null || !((Object)__instance).name.Equals("PlayerGrid"))
				{
					return;
				}
				if (item != ShieldMeBruh.AutoShield.SelectedShield)
				{
					Element element = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(pos.x, pos.y, __instance.m_width);
					Element element2 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(item.m_gridPos.x, item.m_gridPos.y, __instance.m_width);
					ItemData itemAt = __instance.m_inventory.GetItemAt(pos.x, pos.y);
					if (element == null || element2 == null || itemAt == null || itemAt != ShieldMeBruh.AutoShield.SelectedShield)
					{
						return;
					}
					_futureElement = element2;
					_oldElement = element;
				}
				else
				{
					Element element3 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(pos.x, pos.y, __instance.m_width);
					Element element4 = ShieldMeBruh.AutoShield.GetActiveInstance().GetElement(item.m_gridPos.x, item.m_gridPos.y, __instance.m_width);
					if (element3 == null || element4 == null)
					{
						return;
					}
					_futureElement = element3;
					_oldElement = element4;
				}
				_reEnableShieldOnDropItem = true;
				_movingWithDropItem = true;
			}

			private static void Postfix(InventoryGrid __instance, Inventory fromInventory, ItemData item, int amount, Vector2i pos, ref bool __result, bool __runOriginal)
			{
				if (!__result || !__runOriginal)
				{
					_reEnableShieldOnDropItem = false;
					_oldElement = null;
					_futureElement = null;
					_movingWithDropItem = false;
					return;
				}
				if (_reEnableShieldOnDropItem)
				{
					ItemData itemAt = __instance.m_inventory.GetItemAt(_futureElement.m_pos.x, _futureElement.m_pos.y);
					if (itemAt != null && _oldElement != null && _futureElement != null)
					{
						ShieldMeBruh.AutoShield.ResetCurrentSheildElement(_oldElement);
						ShieldMeBruh.AutoShield.ApplyShieldToElement(_futureElement, itemAt);
					}
					_reEnableShieldOnDropItem = false;
				}
				_oldElement = null;
				_futureElement = null;
				_movingWithDropItem = false;
			}
		}

		private static bool _reEnableShield;

		private static bool _movingWithMoveItemToThis;

		private static bool _movingWithDropItem;

		private static bool _reEnableShieldOnDropItem;

		private static Element _futureElement;

		private static Element _oldElement;
	}
	public static class Player_Patches
	{
		[HarmonyPatch(typeof(Player), "SetLocalPlayer")]
		private static class HumanoidEquipItemPatch
		{
			private static void Postfix(Player __instance)
			{
				AutoShield.ResetEvent.PerformReset(__instance);
			}
		}
	}
}
namespace ShieldMeBruh.Features
{
	public class AutoShieldSaveData
	{
		public Vector2i SavedElement { get; set; }

		public string ItemName { get; set; }
	}
	public class AutoShield
	{
		public static class ResetEvent
		{
			public static event EventHandler OnResetEvent;

			public static void PerformReset(Player player)
			{
				if (!((Object)(object)Player.m_localPlayer == (Object)null))
				{
					((Humanoid)player).UnequipItem(((Humanoid)player).m_rightItem, false);
					((Humanoid)player).UnequipItem(((Humanoid)player).m_leftItem, false);
					ResetEvent.OnResetEvent(ShieldMeBruh.AutoShield, EventArgs.Empty);
				}
			}
		}

		private InventoryGrid _activeInstance;

		private Sprite _shield;

		public Element CurrentElement;

		public bool FeatureInitialized;

		public ItemData SelectedShield;

		public ConfigEntry<bool> EnableAutoShield { get; private set; }

		public ConfigEntry<bool> EnableAutoUnequip { get; private set; }

		public AutoShield()
		{
			ConfigRegistry.Waiter.StatusChanged += delegate
			{
				RegisterConfigurationFile();
			};
		}

		public void LoadAssets()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			string text = "ShieldMeBruh.Resources";
			_shield = LoadSprite(text + ".shield.png", new Rect(0f, 0f, 1024f, 1024f));
		}

		public void SetActiveInstance(InventoryGrid instance)
		{
			_activeInstance = instance;
		}

		public InventoryGrid GetActiveInstance()
		{
			return _activeInstance;
		}

		private void RegisterConfigurationFile()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			EnableAutoShield = ConfigSyncBase.UnsyncedConfig("Local Config", "Enable Auto Shield", value: true, new ConfigDescription("When enabled, selected shield will automatically equip when a one handed weapon is equipped.", (AcceptableValueBase)null, new object[1]
			{
				new Vapok.Common.Shared.ConfigurationManagerAttributes
				{
					Order = 1
				}
			}));
			EnableAutoShield.SettingChanged += delegate
			{
				SetEnabledStatus();
			};
			EnableAutoUnequip = ConfigSyncBase.UnsyncedConfig("Local Config", "Enable Auto Unequip", value: true, new ConfigDescription("When enabled, when one handed weapon is unequipped, the marked equipped shield, will also unequip.", (AcceptableValueBase)null, new object[1]
			{
				new Vapok.Common.Shared.ConfigurationManagerAttributes
				{
					Order = 1
				}
			}));
		}

		public Sprite LoadSprite(string path, Rect size, Vector2? pivot = null, int units = 100)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			if (!pivot.HasValue)
			{
				pivot = new Vector2(0.5f, 0.5f);
			}
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
			Texture2D val = new Texture2D((int)((Rect)(ref size)).width, (int)((Rect)(ref size)).height, (TextureFormat)20, false);
			ImageConversion.LoadImage(val, ReadToEnd(manifestResourceStream));
			if ((Object)val == (Object)null)
			{
				ShieldMeBruh.Log.Error("Missing Embedded Resource: " + path);
			}
			return Sprite.Create(val, size, pivot.Value, (float)units, 0u, (SpriteMeshType)1);
		}

		private byte[] ReadToEnd(Stream stream)
		{
			long position = stream.Position;
			stream.Position = 0L;
			try
			{
				byte[] array = new byte[4096];
				int num = 0;
				int num2;
				while ((num2 = stream.Read(array, num, array.Length - num)) > 0)
				{
					num += num2;
					if (num == array.Length)
					{
						int num3 = stream.ReadByte();
						if (num3 != -1)
						{
							byte[] array2 = new byte[array.Length * 2];
							Buffer.BlockCopy(array, 0, array2, 0, array.Length);
							Buffer.SetByte(array2, num, (byte)num3);
							array = array2;
							num++;
						}
					}
				}
				byte[] array3 = array;
				if (array.Length != num)
				{
					array3 = new byte[num];
					Buffer.BlockCopy(array, 0, array3, 0, num);
				}
				return array3;
			}
			finally
			{
				stream.Position = position;
			}
		}

		private Image CreateShieldedImage(Image baseImg, Image noTeleport)
		{
			//IL_003a: 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)
			Image obj = Object.Instantiate<Image>(baseImg, ((Component)baseImg).transform.parent);
			((Object)((Component)obj).transform).name = "shield";
			obj.sprite = _shield;
			((Object)obj).name = "shield";
			((Graphic)obj).color = ((Graphic)noTeleport).color;
			obj.type = noTeleport.type;
			return obj;
		}

		public void OnMiddleClick(UIInputHandler middleClick)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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)
			if (!FeatureInitialized || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)_activeInstance == (Object)null || (Object)(object)middleClick == (Object)null || (Object)(object)((Component)middleClick).gameObject == (Object)null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			Vector2i buttonPos = _activeInstance.GetButtonPos(((Component)middleClick).gameObject);
			ShieldMeBruh.Log.Debug($"Button Pressed on {buttonPos.x},{buttonPos.y}");
			ItemData itemAt = _activeInstance.m_inventory.GetItemAt(buttonPos.x, buttonPos.y);
			if (itemAt == null)
			{
				return;
			}
			ShieldMeBruh.Log.Debug($"Item Name {itemAt.m_shared.m_name} of type {itemAt.m_shared.m_itemType}");
			if ((int)itemAt.m_shared.m_itemType != 5)
			{
				return;
			}
			Vector2i val = default(Vector2i);
			((Vector2i)(ref val))..ctor(buttonPos.x, buttonPos.y);
			Element element = _activeInstance.GetElement(buttonPos.x, buttonPos.y, _activeInstance.m_width);
			if (CurrentElement == null)
			{
				ApplyShieldToElement(element, itemAt, allowReset: true);
			}
			else if (CurrentElement.m_pos == val)
			{
				ResetCurrentSheildElement();
			}
			else if (CurrentElement.m_pos != val)
			{
				ItemData itemAt2 = _activeInstance.GetInventory().GetItemAt(CurrentElement.m_pos.x, CurrentElement.m_pos.y);
				ItemData val2 = itemAt;
				ResetCurrentSheildElement();
				ApplyShieldToElement(element, itemAt, allowReset: true);
				if (itemAt2 != null && itemAt2.m_equipped)
				{
					((Humanoid)localPlayer).EquipItem(val2, true);
				}
			}
		}

		public void SetShieldStatus(bool statusSetTo)
		{
			FeatureInitialized = EnableAutoShield.Value;
			if (!EnableAutoShield.Value)
			{
				return;
			}
			if (statusSetTo)
			{
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null && CurrentElement != null && SelectedShield != null && ((Humanoid)localPlayer).GetInventory().GetItemAt(CurrentElement.m_pos.x, CurrentElement.m_pos.y) != SelectedShield)
				{
					statusSetTo = false;
				}
			}
			if (CurrentElement != null)
			{
				((Behaviour)GetShield(CurrentElement)).enabled = statusSetTo;
			}
		}

		public void SetEnabledStatus()
		{
			FeatureInitialized = EnableAutoShield.Value;
			if (EnableAutoShield.Value)
			{
				if (CurrentElement != null)
				{
					((Behaviour)GetShield(CurrentElement)).enabled = true;
				}
			}
			else if (CurrentElement != null)
			{
				((Behaviour)GetShield(CurrentElement)).enabled = false;
			}
		}

		public void ResetCurrentSheildElement(Element selectedElement = null)
		{
			if (CurrentElement != null && selectedElement == null)
			{
				((Behaviour)GetShield(CurrentElement)).enabled = false;
			}
			if (selectedElement != null)
			{
				((Behaviour)GetShield(selectedElement)).enabled = false;
			}
			CurrentElement = null;
			SelectedShield = null;
		}

		public void ApplyShieldToElement(Element selectedElement, ItemData itemAt, bool allowReset = false)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if ((int)itemAt.m_shared.m_itemType == 5)
			{
				((Behaviour)GetShield(selectedElement)).enabled = true;
				if (CurrentElement == null)
				{
					CurrentElement = selectedElement;
					SelectedShield = itemAt;
				}
				else if ((CurrentElement.m_pos == selectedElement.m_pos && allowReset) || selectedElement.m_pos.x < 0 || selectedElement.m_pos.y < 0)
				{
					((Behaviour)GetShield(CurrentElement)).enabled = false;
					CurrentElement = null;
					SelectedShield = null;
				}
				else
				{
					CurrentElement = selectedElement;
					SelectedShield = itemAt;
				}
				Vector2i savedElement = default(Vector2i);
				((Vector2i)(ref savedElement))..ctor(-1, -1);
				if (CurrentElement != null)
				{
					((Vector2i)(ref savedElement))..ctor(CurrentElement.m_pos.x, CurrentElement.m_pos.y);
				}
				AutoShieldSaveData autoShieldSaveData = new AutoShieldSaveData();
				autoShieldSaveData.SavedElement = savedElement;
				SaveShieldSaveData(autoShieldSaveData);
				SetEnabledStatus();
			}
		}

		private Image GetShield(Element element)
		{
			Image val = null;
			if ((Object)(object)element.m_go == (Object)null)
			{
				ShieldMeBruh.Log.Error("Element.m_go is null");
				return null;
			}
			if (element.m_go.transform.childCount > 0)
			{
				for (int i = 0; i < element.m_go.transform.childCount; i++)
				{
					Image component = ((Component)element.m_go.transform.GetChild(i)).GetComponent<Image>();
					if ((Object)(object)component != (Object)null && ((Object)((Component)component).transform).name == "shield")
					{
						val = component;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				ShieldMeBruh.Log.Debug("Image Null: " + ((Object)element.m_go.transform).name);
				val = CreateShieldedImage(element.m_icon, element.m_noteleport);
			}
			((Behaviour)val).enabled = false;
			return val;
		}

		public void ResetAutoShieldOnPlayerAwake()
		{
			if (!DeathEvent.DeathInProgress)
			{
				ShieldMeBruh.Log.Debug("Resetting Player Context");
				_activeInstance = null;
				CurrentElement = null;
				SelectedShield = null;
			}
		}

		public AutoShieldSaveData GetShieldSaveData()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			AutoShieldSaveData result = new AutoShieldSaveData
			{
				SavedElement = new Vector2i(-1, -1)
			};
			if (Player.m_localPlayer.m_customData.ContainsKey("vapok.mods.shieldmebruh"))
			{
				result = new DeserializerBuilder().Build().Deserialize<AutoShieldSaveData>(Player.m_localPlayer.m_customData["vapok.mods.shieldmebruh"]);
			}
			return result;
		}

		public void SaveShieldSaveData(AutoShieldSaveData savedData)
		{
			string value = new SerializerBuilder().Build().Serialize(savedData);
			if (Player.m_localPlayer.m_customData.ContainsKey("vapok.mods.shieldmebruh"))
			{
				Player.m_localPlayer.m_customData["vapok.mods.shieldmebruh"] = value;
			}
			else
			{
				Player.m_localPlayer.m_customData.Add("vapok.mods.shieldmebruh", value);
			}
		}
	}
}
namespace ShieldMeBruh.Configuration
{
	public class ConfigRegistry : ConfigSyncBase
	{
		public static Waiting Waiter;

		public ConfigRegistry(IPluginInfo mod, bool enableLockedConfigs = false)
			: base(mod, enableLockedConfigs)
		{
			Waiter = new Waiting();
			InitializeConfigurationSettings();
		}

		public sealed override void InitializeConfigurationSettings()
		{
			_ = ConfigSyncBase._config;
		}
	}
	public class Waiting
	{
		public event EventHandler StatusChanged;

		public void ConfigurationComplete(bool configDone)
		{
			if (configDone)
			{
				this.StatusChanged?.Invoke(this, EventArgs.Empty);
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[<135ad4d6-fbed-433a-9e98-8c9ffd783bc7>Embedded]
	[CompilerGenerated]
	internal sealed class <135ad4d6-fbed-433a-9e98-8c9ffd783bc7>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<135ad4d6-fbed-433a-9e98-8c9ffd783bc7>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <f9884790-bf0d-4de2-bb1a-227460ae56d8>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <f9884790-bf0d-4de2-bb1a-227460ae56d8>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <f9884790-bf0d-4de2-bb1a-227460ae56d8>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<135ad4d6-fbed-433a-9e98-8c9ffd783bc7>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<135ad4d6-fbed-433a-9e98-8c9ffd783bc7>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <b16a1032-c5ca-4437-853e-8439e08fea08>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <b16a1032-c5ca-4437-853e-8439e08fea08>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ItemManager
{
	[PublicAPI]
	internal enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[PublicAPI]
	internal enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(1)]
	[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
	internal class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
	[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(1)]
	internal class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free;

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

		public void Add(string itemName, ConfigEntry<int> amountConfig)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig
			});
		}
	}
	[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
	[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(1)]
	[PublicAPI]
	internal 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
			});
		}
	}
	[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
	[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(1)]
	[PublicAPI]
	internal 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;

		public float QualityResultAmountMultiplier = 1f;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		public ConfigEntryBase RecipeIsActive;
	}
	internal struct Requirement
	{
		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(1)]
		public string itemName;

		public int amount;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		public ConfigEntry<int> amountConfig;
	}
	internal struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		public string custom;
	}
	[Flags]
	internal enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Full = 7
	}
	[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
	[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(1)]
	internal class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min)
			});
		}
	}
	internal struct DropTarget
	{
		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(1)]
		public string creature;

		public int min;

		public int max;

		public float chance;
	}
	internal enum Toggle
	{
		On = 1,
		Off = 0
	}
	[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
	[PublicAPI]
	[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(1)]
	internal class Item
	{
		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
		private class ItemConfig
		{
			[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> craft;

			[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> upgrade;

			public ConfigEntry<CraftingTable> table;

			public ConfigEntry<int> tableLevel;

			public ConfigEntry<string> customTable;

			[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
			public ConfigEntry<int> maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient;

			public ConfigEntry<float> qualityResultAmountMultiplier;
		}

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
		[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(2)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string Category;

			[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer;

			public Func<bool> browsability;
		}

		[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)]
		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)]
		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(0)]
		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

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

			public SerializedRequirements(string reqs)
			{
				Reqs = reqs.Split(new char[1] { ',' }).Select([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					Requirement result = default(Requirement);
					result.itemName = array[0];
					result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2);
					return result;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}"));
			}

			[return: <f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
			public static ItemDrop fetchByName(ObjectDB objectDB, string name)
			{
				GameObject itemPrefab = objectDB.GetItemPrefab(name);
				ItemDrop obj = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					LogManager.Log.Warning("The required item '" + name + "' does not exist.");
				}
				return obj;
			}

			public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade)
			{
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Expected O, but got Unknown
				//IL_00e5: Expected O, but got Unknown
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Requirement r) =>
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0036: Unknown result type (might be due to invalid IL or missing references)
					//IL_003e: Expected O, but got Unknown
					ItemDrop val4 = ResItem(r);
					return (val4 != null) ? new Requirement
					{
						m_amount = (r.amountConfig?.Value ?? r.amount),
						m_resItem = val4,
						m_amountPerLevel = 0
					} : ((Requirement)null);
				}));
				foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != ""))
				{
					if (!dictionary.TryGetValue(item.itemName, out var value) || value == null)
					{
						ItemDrop val = ResItem(item);
						if (val != null)
						{
							string itemName = item.itemName;
							Requirement val2 = new Requirement
							{
								m_resItem = val,
								m_amount = 0
							};
							Requirement val3 = val2;
							dictionary[itemName] = val2;
							value = val3;
						}
					}
					if (value != null)
					{
						value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount;
					}
				}
				return dictionary.Values.Where([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Requirement v) => v != null).ToArray();
				[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(2)]
				ItemDrop ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>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([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					if (array.Length <= 2 || !int.TryParse(array[2], out var result))
					{
						result = 1;
					}
					if (array.Length <= 3 || !int.TryParse(array[3], out var result2))
					{
						result2 = result;
					}
					DropTarget result3 = default(DropTarget);
					result3.creature = array[0];
					result3.chance = ((array.Length > 1 && float.TryParse(array[1], NumberStyles.Any, CultureInfo.InvariantCulture, out var result4)) ? result4 : 1f);
					result3.min = result;
					result3.max = result2;
					return result3;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}" + ((r.min == r.max) ? "" : $":{r.max}")));
			}

			[return: <f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
			private static Character fetchByName(ZNetScene netScene, string name)
			{
				GameObject prefab = netScene.GetPrefab(name);
				Character obj = ((prefab != null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					LogManager.Log.Debug("The drop target character '" + name + "' does not exist.");
				}
				return obj;
			}

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

		private static bool _initialized = false;

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

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>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 static Dictionary<Item, ConfigEntry<bool>> itemDropEnabledConfig = new Dictionary<Item, ConfigEntry<bool>>();

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

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

		public string SectionName = string.Empty;

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable;

		private Configurability configurationVisible = Configurability.Full;

		public readonly GameObject Prefab;

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

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

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

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

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

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		private LocalizeKey _name;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		private LocalizeKey _description;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		private static object configManager;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		private static Localization _english;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>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;

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase RecipeIsActive
		{
			[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(2)]
			get
			{
				return this[""].RecipeIsActive;
			}
			[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>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_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(2)]
		private static object configSync
		{
			[<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>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 static void Init()
		{
			if (!_initialized)
			{
				_initialized = true;
			}
		}

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

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

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

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

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

		internal static void Patch_FejdStartup()
		{
			//IL_1075: Unknown result type (might be due to invalid IL or missing references)
			//IL_107a: Unknown result type (might be due to invalid IL or missing references)
			//IL_113e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1141: Unknown result type (might be due to invalid IL or missing references)
			//IL_1197: Expected I4, but got Unknown
			//IL_0c80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8a: Expected O, but got Unknown
			//IL_0d4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d54: Expected O, but got Unknown
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Expected O, but got Unknown
			//IL_12cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_12d0: Invalid comparison between Unknown and I4
			//IL_12d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_12d6: Invalid comparison between Unknown and I4
			//IL_0e87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e91: Expected O, but got Unknown
			//IL_0f32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3c: Expected O, but got Unknown
			//IL_12d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_12dc: Invalid comparison between Unknown and I4
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Expected O, but got Unknown
			//IL_0fe6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ff0: Expected O, but got Unknown
			//IL_14d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_14da: Unknown result type (might be due to invalid IL or missing references)
			//IL_14dc: Invalid comparison between Unknown and I4
			//IL_14de: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e4: Invalid comparison between Unknown and I4
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Expected O, but got Unknown
			//IL_14e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_14ea: Invalid comparison between Unknown and I4
			//IL_15bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c9: Invalid comparison between Unknown and I4
			//IL_15cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_15cf: Invalid comparison between Unknown and I4
			//IL_079a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a4: Expected O, but got Unknown
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Expected O, but got Unknown
			//IL_163e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1641: Unknown result type (might be due to invalid IL or missing references)
			//IL_1643: Invalid comparison between Unknown and I4
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Expected O, but got Unknown
			//IL_1645: Unknown result type (might be due to invalid IL or missing references)
			//IL_1649: Unknown result type (might be due to invalid IL or missing references)
			//IL_164b: Invalid comparison between Unknown and I4
			//IL_164d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1651: Invalid comparison between Unknown and I4
			//IL_178e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1791: Invalid comparison between Unknown and I4
			//IL_198e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1995: Invalid comparison between Unknown and I4
			//IL_1a5e: 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_1a65: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a69: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a6b: Invalid comparison between Unknown and I4
			//IL_1ada: Unknown result type (might be due to invalid IL or missing references)
			//IL_1add: Unknown result type (might be due to invalid IL or missing references)
			//IL_1adf: Invalid comparison between Unknown and I4
			//IL_1704: Unknown result type (might be due to invalid IL or missing references)
			//IL_1709: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ae5: Invalid comparison between Unknown and I4
			//IL_1ae7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1aeb: Invalid comparison between Unknown and I4
			//IL_1f58: Unknown result type (might be due to invalid IL or missing references)
			//IL_1f5b: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			if (DefaultConfigurability != 0)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item3 in registeredItems.Where([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item2 = item3;
					string text = (string.IsNullOrEmpty(item2.SectionName) ? item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name : item2.SectionName);
					string englishName = new Regex("['[\"\\]]").Replace(english.Localize(text), "").Trim();
					string localizedName = Localization.instance.Localize(text).Trim();
					if ((item2.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item2] = new Dictionary<string, ItemConfig>();
						foreach (string item4 in item2.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item4;
							int order = 0;
							string text2 = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (!item2.Recipes.ContainsKey(configKey) || item2.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig2 = (itemCraftConfigs[item2][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text2, item2.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 = ((item2.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item2.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text2, item2.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() && (item2.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text2, item2.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value10))
								{
									value10.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text2, (item2.MaximumRequiredStationLevel == int.MaxValue) ? (item2.Recipes[configKey].Crafting.Stations.First().level + item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item2.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							}
							cfg.requireOneIngredient = config(englishName, "Require only one resource" + text2, item2.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() && (item2.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value9))
								{
									foreach (Recipe item5 in value9)
									{
										item5.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text2, item2.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 += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value8))
								{
									foreach (Recipe item6 in value8)
									{
										item6.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item2.Recipes[configKey].RequiredItems.Free || item2.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item2.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig("Crafting Costs" + text2, new SerializedRequirements(item2.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName);
							}
							if (item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item2.Recipes[configKey].RequiredUpgradeItems.Free || item2.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item2.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig("Upgrading Costs" + text2, new SerializedRequirements(item2.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName);
							}
							if (cfg.craft != null)
							{
								cfg.craft.SettingChanged += ConfigChanged;
							}
							if (cfg.upgrade != null)
							{
								cfg.upgrade.SettingChanged += ConfigChanged;
							}
							void ConfigChanged(object o, EventArgs e)
							{
								if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value4))
								{
									foreach (Recipe item7 in value4)
									{
										item7.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? ""));
									}
								}
							}
							bool CustomTableBrowsability()
							{
								return cfg.table.Value == CraftingTable.Custom;
							}
							bool ItemBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							bool QualityResultBrowsability()
							{
								return cfg.requireOneIngredient.Value == Toggle.On;
							}
							void TableConfigChanged(object o, EventArgs e)
							{
								if (activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(configKey, out var value5))
								{
									value5.First().m_enabled = cfg.table.Value != CraftingTable.Disabled;
									CraftingTable value6 = cfg.table.Value;
									if ((uint)value6 <= 1u)
									{
										value5.First().m_craftingStation = null;
									}
									else if (cfg.table.Value == CraftingTable.Custom)
									{
										Recipe obj = value5.First();
										GameObject prefab2 = ZNetScene.instance.GetPrefab(cfg.customTable.Value);
										obj.m_craftingStation = ((prefab2 != null) ? prefab2.GetComponent<CraftingStation>() : null);
									}
									else
									{
										value5.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(cfg.table.Value)).GetComponent<CraftingStation>();
									}
								}
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes)
								{
									item8.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig(string name, string value, string desc)
							{
								//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
								//IL_00bf: Expected O, but got Unknown
								ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable,
									Order = (order -= 1),
									browsability = ItemBrowsability,
									Browsable = (ItemBrowsability() && (item2.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								};
								hideWhenNoneAttributes.Add(configurationManagerAttributes2);
								return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 }));
							}
						}
						if ((item2.configurability & Configurability.Drop) != 0)
						{
							ConfigEntry<bool> val3 = (itemDropEnabledConfig[item2] = config(englishName, "Drops Enabled", value: false, new ConfigDescription("Enables " + englishName + " drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Drop) != 0)
								}
							})));
							ConfigEntry<bool> dropsEnabledConfig = val3;
							ConfigEntry<string> val5 = (itemDropConfigs[item2] = config(englishName, "Drops from", new SerializedDrop(item2.DropsFrom.Drops).ToString(), new ConfigDescription("Creatures " + englishName + " drops from", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									CustomDrawer = drawDropsConfigTable,
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Drop) != 0)
								}
							})));
							dropsEnabledConfig.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								item2.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							val5.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								item2.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
						}
						for (int j = 0; j < item2.Conversions.Count; j++)
						{
							string text3 = ((item2.Conversions.Count > 1) ? $"{j + 1}. " : "");
							Conversion conversion = item2.Conversions[j];
							conversion.config = new Conversion.ConversionConfig();
							int index = j;
							conversion.config.input = config(englishName, text3 + "Conversion Input Item", conversion.Input, new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.input.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (index < item2.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item2.conversions[index].m_from = from;
										UpdatePiece();
									}
								}
							};
							conversion.config.piece = config(englishName, text3 + "Conversion Piece", conversion.Piece, new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.piece.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							conversion.config.customPiece = config(englishName, text3 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item2.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.customPiece.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item2.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance))
								{
									string text4 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value)));
									string activePiece = conversion.config.activePiece;
									if (conversion.config.activePiece != null)
									{
										int num = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent<Smelter>().m_conversion.IndexOf(item2.conversions[index]);
										if (num >= 0)
										{
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val6 in array3)
											{
												if (Utils.GetPrefabName(((Component)val6).gameObject) == activePiece)
												{
													val6.m_conversion.RemoveAt(num);
												}
											}
										}
										conversion.config.activePiece = null;
									}
									if (item2.conversions[index].m_from != null && conversion.config.piece.Value != 0)
									{
										GameObject prefab = ZNetScene.instance.GetPrefab(text4);
										if (((prefab != null) ? prefab.GetComponent<Smelter>() : null) != null)
										{
											conversion.config.activePiece = text4;
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val7 in array3)
											{
												if (Utils.GetPrefabName(((Component)val7).gameObject) == text4)
												{
													val7.m_conversion.Add(item2.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item2.configurability & Configurability.Stats) == 0)
					{
						continue;
					}
					item2.statsConfigs.Clear();
					SharedData shared2 = item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
					ItemType itemType = shared2.m_itemType;
					statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value)
					{
						shared.m_weight = value;
					});
					statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value)
					{
						shared.m_value = value;
					});
					bool flag;
					switch (itemType - 3)
					{
					case 0:
					case 1:
					case 2:
					case 3:
					case 4:
					case 8:
					case 9:
					case 11:
					case 14:
					case 16:
					case 19:
						flag = true;
						break;
					default:
						flag = false;
						break;
					}
					if (flag)
					{
						statcfg<float>("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value)
						{
							shared.m_maxDurability = value;
						});
						statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value)
						{
							shared.m_durabilityPerLevel = value;
						});
						statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value)
						{
							shared.m_movementModifier = value;
						});
					}
					if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
					{
						statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value)
						{
							shared.m_blockPower = value;
						});
						statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value)
						{
							shared.m_blockPowerPerLevel = value;
						});
						statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value)
						{
							shared.m_deflectionForce = value;
						});
						statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value)
						{
							shared.m_deflectionForcePerLevel = value;
						});
						statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value)
						{
							shared.m_timedBlockBonus = value;
						});
					}
					else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
					{
						statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value)
						{
							shared.m_armor = value;
						});
						statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value)
						{
							shared.m_armorPerLevel = value;
						});
					}
					SkillType skillType = shared2.m_skillType;
					if (((int)skillType == 7 || (int)skillType == 12) ? true : false)
					{
						statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value)
						{
							shared.m_toolTier = value;
						});
					}
					if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
					{
						Dictionary<DamageType, DamageModifier> modifiers = shared2.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier);
						DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType));
						DamageType[] array = new DamageType[5];
						RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
						foreach (DamageType item9 in first.Except((IEnumerable<DamageType>)(object)array))
						{
							DamageType damageType = item9;
							statcfg<DamageModifier>(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => (!modifiers.TryGetValue(damageType, out var value7)) ? DamageModifier.None : value7, delegate(SharedData shared, DamageModifier value)
							{
								//IL_0002: Unknown result type (might be due to invalid IL or missing references)
								//IL_000b: Unknown result type (might be due to invalid IL or missing references)
								//IL_0010: Unknown result type (might be due to invalid IL or missing references)
								//IL_0018: Unknown result type (might be due to invalid IL or missing references)
								//IL_001d: 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_002a: 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)
								//IL_0077: Unknown result type (might be due to invalid IL or missing references)
								//IL_0054: Unknown result type (might be due to invalid IL or missing references)
								DamageModPair val8 = default(DamageModPair);
								val8.m_type = damageType;
								val8.m_modifier = (DamageModifier)value;
								DamageModPair val9 = val8;
								for (int n = 0; n < shared.m_damageModifiers.Count; n++)
								{
									if (shared.m_damageModifiers[n].m_type == damageType)
									{
										if (value == DamageModifier.None)
										{
											shared.m_damageModifiers.RemoveAt(n);
										}
										else
										{
											shared.m_damageModifiers[n] = val9;
										}
										return;
									}
								}
								if (value != DamageModifier.None)
								{
									shared.m_damageModifiers.Add(val9);
								}
							});
						}
					}
					if ((int)itemType == 2 && shared2.m_food > 0f)
					{
						statcfg<float>("Health", "Health value of " + englishName + ".", (SharedData shared) => shared.m_food, delegate(SharedData shared, float value)
						{
							shared.m_food = value;
						});
						statcfg<float>("Stamina", "Stamina value of " + englishName + ".", (SharedData shared) => shared.m_foodStamina, delegate(SharedData shared, float value)
						{
							shared.m_foodStamina = value;
						});
						statcfg<float>("Eitr", "Eitr value of " + englishName + ".", (SharedData shared) => shared.m_foodEitr, delegate(SharedData shared, float value)
						{
							shared.m_foodEitr = value;
						});
						statcfg<float>("Duration", "Duration of " + englishName + ".", (SharedData shared) => shared.m_foodBurnTime, delegate(SharedData shared, float value)
						{
							shared.m_foodBurnTime = value;
						});
						statcfg<float>("Health Regen", "Health regen value of " + englishName + ".", (SharedData shared) => shared.m_foodRegen, delegate(SharedData shared, float value)
						{
							shared.m_foodRegen = value;
						});
					}
					if ((int)shared2.m_skillType == 10)
					{
						statcfg<float>("Health Cost", "Health cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealth, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_attackHealth = value;
						});
						statcfg<float>("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealthPercentage, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_attackHealthPercentage = value;
						});
					}
					skillType = shared2.m_skillType;
					if (skillType - 9 <= 1)
					{
						statcfg<float>("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackEitr, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_attackEitr = value;
						});
					}
					if ((itemType - 3 > 1 && (int)itemType != 14 && (int)itemType != 22) || 1 == 0)
					{
						continue;
					}
					statcfg<float>("Knockback", "Knockback of " + englishName + ".", (SharedData shared) => shared.m_attackForce, delegate(SharedData shared, float value)
					{
						shared.m_attackForce = value;
					});
					statcfg<float>("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData shared) => shared.m_backstabBonus, delegate(SharedData shared, float value)
					{
						shared.m_backstabBonus = value;
					});
					statcfg<float>("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackStamina, delegate(SharedData shared, float value)
					{
						shared.m_attack.m_attackStamina = value;
					});
					SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_damage = val;
					});
					SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_slash = val;
					});
					SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_pierce = val;
					});
					SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_blunt = val;
					});
					SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_chop = val;
					});
					SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_pickaxe = val;
					});
					SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_fire = val;
					});
					SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_poison = val;
					});
					SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_frost = val;
					});
					SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_lightning = val;
					});
					SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val)
					{
						dmg.m_spirit = val;
					});
					if ((int)itemType == 4)
					{
						statcfg<int>("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_projectileBursts, delegate(SharedData shared, int value)
						{
							shared.m_attack.m_projectileBursts = value;
						});
						statcfg<float>("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_burstInterval, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_burstInterval = value;
						});
						statcfg<float>("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracyMin, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileAccuracyMin = value;
						});
						statcfg<float>("Accuracy", "Accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracy, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileAccuracy = value;
						});
						statcfg<float>("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVelMin, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileVelMin = value;
						});
						statcfg<float>("Velocity", "Velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVel, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_projectileVel = value;
						});
						statcfg<float>("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData shared) => shared.m_attack.m_drawDurationMin, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_drawDurationMin = value;
						});
						statcfg<float>("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData shared) => shared.m_attack.m_drawStaminaDrain, delegate(SharedData shared, float value)
						{
							shared.m_attack.m_drawStaminaDrain = value;
						});
					}
					void SetDmg(string dmgType, Func<DamageTypes, float> readDmg, setDmgFunc setDmg)
					{
						statcfg<float>(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData shared) => readDmg(shared.m_damages), delegate(SharedData shared, float val)
						{
							setDmg(ref shared.m_damages, val);
						});
						statcfg<float>(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData shared) => readDmg(shared.m_damagesPerLevel), delegate(SharedData shared, float val)
						{
							setDmg(ref shared.m_damagesPerLevel, val);
						});
					}
					void statcfg<T>(string configName, string description, [<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(new byte[] { 1, 1, 0 })] Func<SharedData, T> readDefault, [<f9884790-bf0d-4de2-bb1a-227460ae56d8>Nullable(new byte[] { 1, 1, 0 })] Action<SharedData, T> setValue)
					{
						//IL_0082: Unknown result type (might be due to invalid IL or missing references)
						//IL_008c: Expected O, but got Unknown
						SharedData shared3 = item2.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ConfigEntry<T> cfg2 = config(englishName, configName, readDefault(shared3), new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
						{
							new ConfigurationManagerAttributes
							{
								Category = localizedName,
								Browsable = ((item2.configurationVisible & Configurability.Stats) != 0)
							}
						}));
						if ((item2.configurationVisible & Configurability.Stats) != 0)
						{
							setValue(shared3, cfg2.Value);
						}
						string itemName = shared3.m_name;
						item2.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig);
						cfg2.SettingChanged += [<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (object _, EventArgs _) =>
						{
							if ((item2.configurationVisible & Configurability.Stats) != 0)
							{
								ApplyConfig();
							}
						};
						void ApplyConfig()
						{
							setValue(shared3, cfg2.Value);
							Inventory[] source = (from c in Player.s_players.Select([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType<Container>()
									select c.GetInventory())
								where c != null
								select c).ToArray();
							foreach (ItemData item10 in (from i in (from p in ObjectDB.instance.m_items
									select p.GetComponent<ItemDrop>() into c
									where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent<ZNetView>())
									select c).Concat(ItemDrop.s_instances)
								select i.m_itemData).Concat(source.SelectMany([<d8b8fdd4-bde2-482f-b297-c4b1b2d37b74>NullableContext(0)] (Inventory i) => i.GetAllItems())))
							{
								if (item10.m_shared.m_name == itemName)
								{
									setValue(item10.m_shared, cfg2.Value);
								}
							}
						}
					}
				}
				if (saveOnConfigSet)
				{
					plugin.Config.SaveOnConfigSet = true;
					plugin.Config.Save();
				}
			}
			foreach (Item registeredItem in registeredItems)
			{
				Item item = registeredItem;
				foreach (KeyValuePair<string, ItemRecipe> recipe in item.Recipes)
				{
					KeyValuePair<string, ItemRecipe> kv = recipe;
					RequiredResourceList[] array2 = new RequiredResourceList[2]
					{
						kv.Value.RequiredItems,
						kv.Value.RequiredUpgradeItems
					};
					foreach (RequiredResourceList requiredResourceList in array2)
					{
						for (int l = 0; l < requiredResourceList.Requirements.Count; l++)
						{
							ConfigEntry<int> amountCfg;
							int resourceIndex;
							if ((item.configurability & Configurability.Recipe) != 0)
							{
								amountCfg = requiredResourceList.Requirements[l].amountConfig;
								if (amountCfg != null)
								{
									resourceIndex = l;
									amountCfg.SettingChanged += ConfigChanged;
								}
							}
							void ConfigChanged(object o, EventArgs e)
							{
								if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(kv.Key, out var value3))
								{
									foreach (Recipe item11 in value3)
									{
										item11.m_resources[resourceIndex].m_amount = amountCfg.Value;
									}
								}
							}
						}
					}