Decompiled source of ChaosArmor v13.0.3

BepInEx/plugins/ChaosArmor.dll

Decompiled 2 days 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BlacksmithTools;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
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: AssemblyProduct("ChaosArmor")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCompany("ChaosArmor")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyTitle("ChaosArmor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ChaosArmor
{
	public class ButchersNails : MonoBehaviour
	{
		private Humanoid wearer;

		public void Start()
		{
			Transform root = ((Component)this).transform.root;
			object obj;
			if (root == null)
			{
				obj = null;
			}
			else
			{
				GameObject gameObject = ((Component)root).gameObject;
				obj = ((gameObject != null) ? gameObject.GetComponent<Player>() : null);
			}
			wearer = (Humanoid)obj;
			if ((Object)(object)wearer != (Object)null)
			{
				Humanoid obj2 = wearer;
				((Character)obj2).m_onDamaged = (Action<float, Character>)Delegate.Combine(((Character)obj2).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
		}

		public void OnDisable()
		{
			if ((Object)(object)wearer != (Object)null)
			{
				Humanoid obj = wearer;
				((Character)obj).m_onDamaged = (Action<float, Character>)Delegate.Remove(((Character)obj).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
			wearer = null;
		}

		public void OnDamaged(float dmg, Character idfkLol)
		{
			float maxHealth = ((Character)wearer).GetMaxHealth();
			if (dmg > Math.Min(60f, maxHealth / 2f))
			{
				((Character)wearer).AddStamina(45f);
			}
			else if (dmg >= 10f)
			{
				((Character)wearer).AddStamina(15f);
			}
		}
	}
	[BepInPlugin("ReepusDeepusDelmeepus4902761.ChaosArmor", "ChaosArmor", "13.0.0")]
	public class ReepusDeepusDelmeepusChaosArmor : BaseUnityPlugin
	{
		[HarmonyPatch]
		public static class ObjectDBPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(ObjectDB), "Awake")]
			[HarmonyPriority(0)]
			public static void Patch_ObjectDBAwake(ObjectDB __instance)
			{
				StatusEffect statusEffect = __instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(shieldVanilla));
				staffShield = (SE_Shield)(object)((statusEffect is SE_Shield) ? statusEffect : null);
			}
		}

		[HarmonyPatch]
		public static class ZNetScenePatch
		{
			[HarmonyPatch(typeof(ZNetScene), "Awake")]
			[HarmonyPostfix]
			public static void Patch_ZNetSceneAwake(ZNetScene __instance)
			{
				__instance.m_prefabs.Add(Clanka.prefabStep);
				__instance.m_prefabs.Add(Clanka.prefabRun);
				__instance.m_prefabs.Add(Clanka.prefabJump);
				__instance.m_prefabs.Add(Clanka.prefabDodge);
				__instance.m_prefabs.Add(Clanka.prefabLand);
				__instance.m_prefabs.Add(Clanka.prefabBootStep);
			}
		}

		[HarmonyPatch]
		public static class AudioManPatch
		{
			private static void SetAudioMixerGroup(GameObject prefab, AudioMixerGroup group)
			{
				AudioSource component = prefab.GetComponent<AudioSource>();
				component.outputAudioMixerGroup = group;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(AudioMan), "Awake")]
			public static void Patch_AudioManAwake(AudioMan __instance)
			{
				if (!((Object)(object)Clanka.prefabStep == (Object)null))
				{
					AudioMixerGroup group = __instance.m_ambientMixer.audioMixer.FindMatchingGroups("Effects/SFX").FirstOrDefault();
					SetAudioMixerGroup(Clanka.prefabStep, group);
					SetAudioMixerGroup(Clanka.prefabRun, group);
					SetAudioMixerGroup(Clanka.prefabDodge, group);
					SetAudioMixerGroup(Clanka.prefabLand, group);
					SetAudioMixerGroup(Clanka.prefabJump, group);
					SetAudioMixerGroup(Clanka.prefabBootRun, group);
					SetAudioMixerGroup(Clanka.prefabBootStep, group);
				}
			}
		}

		private const string ModName = "ChaosArmor";

		private const string ModVersion = "13.0.0";

		private const string ModGUID = "ReepusDeepusDelmeepus4902761.ChaosArmor";

		private const string T0Chest = "T0ChaosPlateArmor";

		private const string T1Chest = "T1ChaosPlateArmor";

		private const string T2Chest = "T2ChaosPlateArmor";

		private const string T3Chest = "ChaosPlateArmorBody";

		private const string T4Chest = "EliteChaosPlateArmor";

		private const string T5UChest = "EliteChaosPlateArmorT2";

		private const string T5Chest = "EliteChaosPlateArmorTzeentch";

		private const string T0ASSLegs = "T0ChaosPlateLegs";

		private const string T1ASSLegs = "T1ChaosPlateLegs";

		private const string T2ASSLegs = "T2ChaosPlateLegs";

		private const string T3ASSLegs = "ChaosPlateLegs";

		private const string T4ASSLegs = "EliteChaosPlateLegs";

		private const string T5UASSLegs = "EliteChaosPlateLegsT2";

		private const string T5ASSLegs = "EliteChaosPlateLegsTzeentch";

		private static string shieldVanilla = "Staff_shield";

		public static int T1Hash;

		public static int T2Hash;

		public static int T3Hash;

		public static int T4Hash;

		public static int T5Hash;

		public static int T5UHash;

		public static HashSet<int> clankyPrefabNames = new HashSet<int>();

		public static SE_Shield staffShield;

		private static ConfigEntry<bool> doTheRoar;

		private static SE_Stats T3SetStatus;

		private static SE_Stats T4SetStatus;

		private Assembly assembly;

		private Localization LocalizationClusterfuck;

		public static bool DoTheRoar => doTheRoar.Value;

		public void Awake()
		{
			//IL_1772: Unknown result type (might be due to invalid IL or missing references)
			//IL_1777: Unknown result type (might be due to invalid IL or missing references)
			//IL_177e: Unknown result type (might be due to invalid IL or missing references)
			//IL_178e: Expected O, but got Unknown
			//IL_178e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1793: Unknown result type (might be due to invalid IL or missing references)
			//IL_179a: Unknown result type (might be due to invalid IL or missing references)
			//IL_17aa: Expected O, but got Unknown
			//IL_17c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_17cf: Expected O, but got Unknown
			assembly = Assembly.GetExecutingAssembly();
			T1Hash = StringExtensionMethods.GetStableHashCode("T1ChaosPlateArmor");
			T2Hash = StringExtensionMethods.GetStableHashCode("T2ChaosPlateArmor");
			T3Hash = StringExtensionMethods.GetStableHashCode("ChaosPlateArmorBody");
			T4Hash = StringExtensionMethods.GetStableHashCode("EliteChaosPlateArmor");
			T5Hash = StringExtensionMethods.GetStableHashCode("EliteChaosPlateArmorTzeentch");
			T5UHash = StringExtensionMethods.GetStableHashCode("EliteChaosPlateArmorT2");
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("T0ChaosPlateArmor"));
			clankyPrefabNames.Add(T1Hash);
			clankyPrefabNames.Add(T2Hash);
			clankyPrefabNames.Add(T3Hash);
			clankyPrefabNames.Add(T4Hash);
			clankyPrefabNames.Add(T5Hash);
			clankyPrefabNames.Add(T5UHash);
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("T0ChaosPlateLegs"));
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("T1ChaosPlateLegs"));
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("T2ChaosPlateLegs"));
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("ChaosPlateLegs"));
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("EliteChaosPlateLegs"));
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("EliteChaosPlateLegsT2"));
			clankyPrefabNames.Add(StringExtensionMethods.GetStableHashCode("EliteChaosPlateLegsTzeentch"));
			LoadTranslations();
			SetStatusEffects();
			Item item = new Item("chaosarmor", "T0ChaosPlateArmor");
			item.Name.English("Scrap Breastplate");
			item.Description.English("A plain breastplate cast from metal, warped and dented from what feels like a lifetime of use. It's barely holding together, yet something feels strangely familiar about the make, barren as it is now. A strange icon is clasped over it.");
			item.Crafting.Add(CraftingTable.Forge, 1);
			item.RequiredItems.Add("Bronze", 5);
			item.RequiredItems.Add("TrophyFrostTroll", 1);
			item.RequiredItems.Add("LeatherScraps", 9);
			item.RequiredUpgradeItems.Add("Bronze", 3);
			RegisterTranslations(item);
			Item item2 = new Item("chaosarmor", "T0ChaosPlateHelm");
			item2.Name.English("Scrap Helmet");
			item2.Description.English("A full helm cast from metal with a narrow visor. The wear of elements and war have taken a toll upon its integrity, but perhaps the familiarity of all-encasing metal is comfort enough for some.");
			item2.Crafting.Add(CraftingTable.Forge, 1);
			item2.RequiredItems.Add("Bronze", 6);
			item2.RequiredItems.Add("TrollHide", 3);
			item2.RequiredUpgradeItems.Add("Bronze", 4);
			RegisterTranslations(item2);
			Item item3 = new Item("chaosarmor", "T0ChaosPlateLegs");
			item3.Name.English("Scrap greaves");
			item3.Description.English("Unremarkable breeches and boots reinforced with well-worn metal. What little plating remains is battered almost beyond use, but its weight offers an anchor in unfamiliar lands.");
			item3.Crafting.Add(CraftingTable.Forge, 1);
			item3.RequiredItems.Add("Bronze", 4);
			item3.RequiredItems.Add("TrollHide", 2);
			item3.RequiredUpgradeItems.Add("Bronze", 2);
			RegisterTranslations(item3);
			Item item4 = new Item("chaosarmor", "T1ChaosPlateArmor");
			item4.Name.English("Half plate harness");
			item4.Description.English("A battered suit of heavy plate. The eight-spoked star clasped over the breastplate is dull and rusted. Reduces knockback from incoming attacks.");
			item4.Crafting.Add(CraftingTable.Forge, 1);
			item4.RequiredItems.Add("Iron", 25);
			item4.RequiredItems.Add("T0ChaosPlateArmor", 1);
			item4.RequiredItems.Add("LeatherScraps", 9);
			item4.RequiredUpgradeItems.Add("Iron", 5);
			item4.CraftAmount = 1;
			RegisterTranslations(item4);
			Item item5 = new Item("chaosarmor", "T1ChaosPlateHelm");
			item5.Name.English("Grave-iron plate helm");
			item5.Description.English("An iron plate helm, shrouded in funeral rags. Time will tell if the looming shadow of death comes for you or your foes.");
			item5.Crafting.Add(CraftingTable.Forge, 1);
			item5.RequiredItems.Add("Iron", 25);
			item5.RequiredItems.Add("T0ChaosPlateHelm", 1);
			item5.RequiredItems.Add("TrophyWraith", 1);
			item5.RequiredUpgradeItems.Add("Iron", 3);
			item5.CraftAmount = 1;
			RegisterTranslations(item5);
			Item item6 = new Item("chaosarmor", "T1ChaosPlateLegs");
			item6.Name.English("Battered plate leggings");
			item6.Description.English("Thick leather leggings reinforced with metal. The armor plates are heavy, anchoring the boots to the earth with stains and scars that cannot be erased.");
			item6.Crafting.Add(CraftingTable.Forge, 1);
			item6.RequiredItems.Add("Iron", 20);
			item6.RequiredItems.Add("LeatherScraps", 4);
			item6.RequiredItems.Add("T0ChaosPlateLegs", 1);
			item6.RequiredUpgradeItems.Add("Iron", 3);
			item6.RequiredUpgradeItems.Add("TrollHide", 5);
			item6.CraftAmount = 1;
			RegisterTranslations(item6);
			Item item7 = new Item("chaosarmor", "T2ChaosPlateArmor");
			item7.Name.English("Three quarters plate harness");
			item7.Description.English("A battered suit of heavy plate, cast from blackened silver. The eight-spoked star clasped over the breastplate catches the sun's rays with an uncanny, icy glint. Reduces knockback from incoming attacks.");
			item7.Crafting.Add(CraftingTable.Forge, 1);
			item7.RequiredItems.Add("Silver", 30);
			item7.RequiredItems.Add("Obsidian", 15);
			item7.RequiredItems.Add("FreezeGland", 5);
			item7.RequiredItems.Add("T1ChaosPlateArmor", 1);
			item7.RequiredUpgradeItems.Add("Silver", 10);
			item7.RequiredUpgradeItems.Add("FreezeGland", 5);
			item7.CraftAmount = 1;
			RegisterTranslations(item7);
			Item item8 = new Item("chaosarmor", "T2ChaosPlateHelm");
			item8.Name.English("Profaned plate helm");
			item8.Description.English("An icy plate helm, brazenly wreathed in tooth and cloth. Whether it is worn in ghastly tribute to the wolfmen or in bloody defiance is up to you.");
			item8.Crafting.Add(CraftingTable.Forge, 1);
			item8.RequiredItems.Add("Silver", 20);
			item8.RequiredItems.Add("TrophyCultist", 1);
			item8.RequiredItems.Add("FreezeGland", 5);
			item8.RequiredItems.Add("T1ChaosPlateHelm", 1);
			item8.RequiredUpgradeItems.Add("Silver", 5);
			item8.RequiredUpgradeItems.Add("FreezeGland", 5);
			item8.CraftAmount = 1;
			RegisterTranslations(item8);
			Item item9 = new Item("chaosarmor", "T2ChaosPlateLegs");
			item9.Name.English("Refurbished plate leggings");
			item9.Description.English("Thick leather leggings reinforced with blackened silver. The armor plates are heavy, anchoring the boots to the earth with stains and scars that cannot be erased.");
			item9.Crafting.Add(CraftingTable.Forge, 1);
			item9.RequiredItems.Add("Silver", 20);
			item9.RequiredItems.Add("FreezeGland", 5);
			item9.RequiredItems.Add("Obsidian", 15);
			item9.RequiredItems.Add("T1ChaosPlateLegs", 1);
			item9.RequiredUpgradeItems.Add("Silver", 5);
			item9.RequiredUpgradeItems.Add("FreezeGland", 5);
			item9.CraftAmount = 1;
			RegisterTranslations(item9);
			Item item10 = new Item("chaosarmor", "ChaosPlateArmorBody");
			item10.Name.English("Dormant plate harness");
			item10.Description.English("A full harness of heavy plate, too cumbersome to be carried by an ordinary body of mere flesh and bone. A sheath of rigid fibre is carefully woven beneath the plate- long-dead as it may be, twitches of vigor seem to pulse through at the tune of your own movements. Significantly reduces knockback from incoming attacks. Slightly reduces stagger taken.");
			item10.Crafting.Add(CraftingTable.Forge, 1);
			item10.RequiredItems.Add("BlackMetal", 30);
			item10.RequiredItems.Add("YmirRemains", 5);
			item10.RequiredItems.Add("TrophySGolem", 1);
			item10.RequiredItems.Add("T2ChaosPlateArmor", 1);
			item10.RequiredUpgradeItems.Add("BlackMetal", 10);
			item10.CraftAmount = 1;
			try
			{
				ItemDrop component = item10.Prefab.GetComponent<ItemDrop>();
				component.m_itemData.m_shared.m_setName = "ChaosT3Set";
				component.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T3SetStatus;
				component.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)ex);
			}
			RegisterTranslations(item10);
			Item item11 = new Item("chaosarmor", "ChaosPlateHelm");
			item11.Name.English("Dormant plate helm");
			item11.Description.English("A vicious-looking casque. The alloy plate that encloses it seems corroded and stained, even though the structure yet holds steady. An uncanny air of familiarity echoes within its confines.");
			item11.Crafting.Add(CraftingTable.Forge, 1);
			item11.RequiredItems.Add("BlackMetal", 15);
			item11.RequiredItems.Add("YmirRemains", 2);
			item11.RequiredItems.Add("TrophySerpent", 1);
			item11.RequiredItems.Add("T2ChaosPlateHelm", 1);
			item11.RequiredUpgradeItems.Add("BlackMetal", 5);
			item11.CraftAmount = 1;
			RegisterTranslations(item11);
			Item item12 = new Item("chaosarmor", "ChaosPlateLegs");
			item12.Name.English("Dormant plate greaves");
			item12.Description.English("Heavy greaves seemingly unfit for ordinary humans. Breeches of woven linen hide a grotesque array of rigid fibre underneath, perhaps the only reason you are able to move around in the metal boots that anchor you.");
			item12.Crafting.Add(CraftingTable.Forge, 1);
			item12.RequiredItems.Add("BlackMetal", 20);
			item12.RequiredItems.Add("LinenThread", 15);
			item12.RequiredItems.Add("YmirRemains", 5);
			item12.RequiredItems.Add("T2ChaosPlateLegs", 1);
			item12.RequiredUpgradeItems.Add("BlackMetal", 5);
			item12.CraftAmount = 1;
			RegisterTranslations(item12);
			try
			{
				ItemDrop component2 = item12.Prefab.GetComponent<ItemDrop>();
				component2.m_itemData.m_shared.m_setName = "ChaosT3Set";
				component2.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T3SetStatus;
				component2.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex2)
			{
				Debug.LogError((object)ex2);
			}
			Item item13 = new Item("chaosarmor", "EliteChaosPlateArmor");
			item13.Name.English("Animated plate harness");
			item13.Description.English("A full harness of deep-forged plate, far too cumbersome to be borne on human flesh and bone. A chained underlay of long-dead muscle courses with uncanny vigor, reanimated and bound to your own movements. All but negates knockback from incoming attacks. Slightly reduces stagger taken.");
			item13.Crafting.Add(CraftingTable.BlackForge, 1);
			item13.RequiredItems.Add("BlackMetal", 20);
			item13.RequiredItems.Add("BlackCore", 1);
			item13.RequiredItems.Add("Eitr", 9);
			item13.RequiredItems.Add("ChaosPlateArmorBody", 1);
			item13.RequiredUpgradeItems.Add("BlackMetal", 10);
			item13.CraftAmount = 1;
			RegisterTranslations(item13);
			try
			{
				ItemDrop component3 = item13.Prefab.GetComponent<ItemDrop>();
				component3.m_itemData.m_shared.m_setName = "ChaosT4Set";
				component3.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T4SetStatus;
				component3.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex3)
			{
				Debug.LogError((object)ex3);
			}
			Item item14 = new Item("chaosarmor", "EliteChaosPlateHelm");
			item14.Name.English("Abyssal plate helm");
			item14.Description.English("Shrouded in darkness as your plated skin may be, the horned proof of your bloody victories will ensure your place in the eyes of the gods.");
			item14.Crafting.Add(CraftingTable.BlackForge, 1);
			item14.RequiredItems.Add("BlackMetal", 15);
			item14.RequiredItems.Add("TrophySeekerBrute", 1);
			item14.RequiredItems.Add("Eitr", 3);
			item14.RequiredItems.Add("ChaosPlateHelm", 1);
			item14.RequiredUpgradeItems.Add("BlackMetal", 5);
			item14.RequiredUpgradeItems.Add("TrophySeekerBrute", 1);
			item14.CraftAmount = 1;
			RegisterTranslations(item14);
			Item item15 = new Item("chaosarmor", "ChaosPlateHelmAlt");
			item15.Name.English("Tenebrous plate helm");
			item15.Description.English("Dragged out from the murky shadows, visions of a distant and dark millennium glimmer like embers in the helm's eyeslits. What has been seen cannot be unseen.");
			item15.Crafting.Add(CraftingTable.BlackForge, 1);
			item15.RequiredItems.Add("Eitr", 9);
			item15.RequiredItems.Add("YagluthDrop", 1);
			item15.RequiredItems.Add("ChaosPlateHelm", 1);
			item15.RequiredUpgradeItems.Add("BlackMetal", 5);
			item15.CraftAmount = 1;
			RegisterTranslations(item15);
			Item item16 = new Item("chaosarmor", "EliteChaosPlateLegs");
			item16.Name.English("Animated plate greaves");
			item16.Description.English("Fully plated leggings. Chain hosen covers the gaps left by impassive metal, shrouding the twitching muscle beneath from prying eyes.");
			item16.Crafting.Add(CraftingTable.BlackForge, 1);
			item16.RequiredItems.Add("BlackMetal", 20);
			item16.RequiredItems.Add("Eitr", 9);
			item16.RequiredItems.Add("ChaosPlateLegs", 1);
			item16.RequiredUpgradeItems.Add("BlackMetal", 10);
			item16.CraftAmount = 1;
			RegisterTranslations(item16);
			try
			{
				ItemDrop component4 = item16.Prefab.GetComponent<ItemDrop>();
				component4.m_itemData.m_shared.m_setName = "ChaosT4Set";
				component4.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T4SetStatus;
				component4.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex4)
			{
				Debug.LogError((object)ex4);
			}
			Item item17 = new Item("chaosarmor", "EliteChaosPlateArmorTzeentch");
			item17.Name.English("Flickerscale plate harness");
			item17.Description.English("Reanimated plate harness, further enhanced by dynamos and armatures nearly beyond comprehension. All but negates knockback from incoming attacks. Slightly reduces stagger taken. Reactive shielding additionally scaling with current Eitr levels triggers upon receiving sufficient damage in a single strike or when health is critical.");
			item17.Crafting.Add(CraftingTable.BlackForge, 5);
			item17.RequiredItems.Add("FlametalNew", 30);
			item17.RequiredItems.Add("ShieldCore", 1);
			item17.RequiredItems.Add("GemstoneBlue", 1);
			item17.RequiredItems.Add("EliteChaosPlateArmor", 1);
			item17.RequiredUpgradeItems.Add("FlametalNew", 9);
			item17.RequiredUpgradeItems.Add("SerpentScale", 9);
			item17.CraftAmount = 1;
			RegisterTranslations(item17);
			try
			{
				ItemDrop component5 = item17.Prefab.GetComponent<ItemDrop>();
				component5.m_itemData.m_shared.m_setName = "ChaosT5Set";
				component5.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T4SetStatus;
				component5.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex5)
			{
				Debug.LogError((object)ex5);
			}
			Item item18 = new Item("chaosarmor", "ChaosPlateHelmAltTzeentch");
			item18.Name.English("Arcane breather helm");
			item18.Description.English("Dragged out from the murky shadows, visions of a distant and dark millennium glimmer like embers in the helm's eyeslits. What has been seen cannot be unseen.");
			item18.Crafting.Add(CraftingTable.BlackForge, 5);
			item18.RequiredItems.Add("MoltenCore", 1);
			item18.RequiredItems.Add("FlametalNew", 15);
			item18.RequiredItems.Add("ChaosPlateHelmAlt", 1);
			item18.RequiredUpgradeItems.Add("FlametalNew", 3);
			item18.CraftAmount = 1;
			RegisterTranslations(item18);
			Item item19 = new Item("chaosarmor", "EliteChaosPlateHelmTzeentch");
			item19.Name.English("Arcane plate helm");
			item19.Description.English("Shrouded in darkness as your plated skin may be, the horned proof of your bloody victories will ensure your place in the eyes of the gods.");
			item19.Crafting.Add(CraftingTable.BlackForge, 5);
			item19.RequiredItems.Add("MoltenCore", 1);
			item19.RequiredItems.Add("FlametalNew", 20);
			item19.RequiredItems.Add("EliteChaosPlateHelm", 1);
			item19.RequiredUpgradeItems.Add("FlametalNew", 3);
			item19.CraftAmount = 1;
			RegisterTranslations(item19);
			Item item20 = new Item("chaosarmor", "EliteChaosPlateHelmTzeentchBoss");
			item20.Name.English("Arcane channeler helm");
			item20.Description.English("Tingly.");
			item20.Crafting.Add(CraftingTable.BlackForge, 5);
			item20.RequiredItems.Add("TrophyCultist", 1);
			item20.RequiredItems.Add("EliteChaosPlateHelmTzeentch", 1);
			item20.RequiredUpgradeItems.Add("QueenDrop", 1);
			item20.CraftAmount = 1;
			RegisterTranslations(item20);
			Item item21 = new Item("chaosarmor", "EliteChaosPlateLegsTzeentch");
			item21.Name.English("Flickerscale plate greaves");
			item21.Description.English("Reanimated plate leggings, housing a complex array of arcane circuits. Recovers a flat amount of Eitr upon blocking or receiving sufficient damage.");
			item21.Crafting.Add(CraftingTable.BlackForge, 5);
			item21.RequiredItems.Add("Copper", 20);
			item21.RequiredItems.Add("GemstoneBlue", 1);
			item21.RequiredItems.Add("FlametalNew", 20);
			item21.RequiredItems.Add("EliteChaosPlateLegs", 1);
			item21.RequiredUpgradeItems.Add("FlametalNew", 4);
			item21.CraftAmount = 1;
			RegisterTranslations(item21);
			try
			{
				ItemDrop component6 = item21.Prefab.GetComponent<ItemDrop>();
				component6.m_itemData.m_shared.m_setName = "ChaosT5Set";
				component6.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T4SetStatus;
				component6.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex6)
			{
				Debug.LogError((object)ex6);
			}
			Item item22 = new Item("chaosarmor", "EliteChaosPlateArmorT2");
			item22.Name.English("Magmascale plate harness");
			item22.Description.English("A full harness of deep-forged plate, far too cumbersome to be borne on human flesh and bone. An inscrutable array of circuits snakes through the reanimated muscle beneath like veins, faintly pulsing with the latent power of a dead heartbeat. All but negates knockback from incoming attacks. Slightly reduces stagger taken. Weak emergency reactive shield triggers upon taking extreme damage or when health is critical.");
			item22.Crafting.Add(CraftingTable.BlackForge, 5);
			item22.RequiredItems.Add("FlametalNew", 30);
			item22.RequiredItems.Add("GemstoneRed", 1);
			item22.RequiredItems.Add("ShieldCore", 1);
			item22.RequiredItems.Add("EliteChaosPlateArmor", 1);
			item22.RequiredUpgradeItems.Add("FlametalNew", 10);
			item22.CraftAmount = 1;
			RegisterTranslations(item22);
			try
			{
				ItemDrop component7 = item22.Prefab.GetComponent<ItemDrop>();
				component7.m_itemData.m_shared.m_setName = "ChaosT4Set";
				component7.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T4SetStatus;
				component7.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex7)
			{
				Debug.LogError((object)ex7);
			}
			Item item23 = new Item("chaosarmor", "EliteChaosPlateHelmT2");
			item23.Name.English("Magmaskin plate helm");
			item23.Description.English("Shrouded in darkness as your plated skin may be, the horned proof of your bloody victories will ensure your place in the eyes of the gods.");
			item23.Crafting.Add(CraftingTable.BlackForge, 5);
			item23.RequiredItems.Add("FlametalNew", 15);
			item23.RequiredItems.Add("MoltenCore", 1);
			item23.RequiredItems.Add("EliteChaosPlateHelm", 1);
			item23.RequiredUpgradeItems.Add("FlametalNew", 5);
			item23.RequiredUpgradeItems.Add("TrophySeekerBrute", 1);
			item23.CraftAmount = 1;
			RegisterTranslations(item23);
			Item item24 = new Item("chaosarmor", "ChaosPlateHelmAltT2");
			item24.Name.English("Magmaskin breather helm");
			item24.Description.English("Dragged out from the murky shadows, visions of a distant and dark millennium glimmer like embers in the helm's eyeslits. What has been seen cannot be unseen.");
			item24.Crafting.Add(CraftingTable.BlackForge, 5);
			item24.RequiredItems.Add("FlametalNew", 9);
			item24.RequiredItems.Add("MoltenCore", 1);
			item24.RequiredItems.Add("ChaosPlateHelmAlt", 1);
			item24.RequiredUpgradeItems.Add("FlametalNew", 5);
			item24.CraftAmount = 1;
			RegisterTranslations(item24);
			Item item25 = new Item("chaosarmor", "EliteChaosPlateLegsT2");
			item25.Name.English("Magmaskin plate greaves");
			item25.Description.English("Fully plated leggings. Chain hosen covers the gaps left by impassive metal, shrouding the twitching muscle beneath from prying eyes. Recovers a small flat amount of stamina when moderate to heavy damage is taken.");
			item25.Crafting.Add(CraftingTable.BlackForge, 5);
			item25.RequiredItems.Add("FlametalNew", 20);
			item25.RequiredItems.Add("GemstoneRed", 1);
			item25.RequiredItems.Add("EliteChaosPlateLegs", 1);
			item25.RequiredUpgradeItems.Add("FlametalNew", 10);
			item25.CraftAmount = 1;
			RegisterTranslations(item25);
			try
			{
				ItemDrop component8 = item25.Prefab.GetComponent<ItemDrop>();
				component8.m_itemData.m_shared.m_setName = "ChaosT4Set";
				component8.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)T4SetStatus;
				component8.m_itemData.m_shared.m_setSize = 2;
			}
			catch (Exception ex8)
			{
				Debug.LogError((object)ex8);
			}
			AssetBundle value = null;
			PrefabManager.BundleId bundleId = default(PrefabManager.BundleId);
			bundleId.folderName = "assets";
			bundleId.assetBundleFileName = "chaosarmor";
			PrefabManager.BundleId key = bundleId;
			if (!PrefabManager.bundleCache.TryGetValue(key, out value))
			{
				AssetBundle[] source = Resources.FindObjectsOfTypeAll<AssetBundle>();
				Debug.LogWarning((object)$"unable to find assetbundle in ItemManager cache, attempting manual retrieval: {source.Count()} assetbundles found in resources");
				value = ((IEnumerable<AssetBundle>)source).FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle a) => ((Object)a).name == "chaosarmor")) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ".assets.chaosarmor"));
			}
			if ((Object)(object)value != (Object)null)
			{
				Clanka.prefabStep = value.LoadAsset<GameObject>("sfx_reepus_footstepClankChaos");
				Clanka.prefabRun = value.LoadAsset<GameObject>("sfx_reepus_footstepClank2Chaos");
				Clanka.prefabDodge = value.LoadAsset<GameObject>("sfx_reepus_dodgeChaos");
				Clanka.prefabLand = value.LoadAsset<GameObject>("sfx_reepus_landChaos");
				Clanka.prefabJump = value.LoadAsset<GameObject>("sfx_reepus_jumpClankChaos");
				Clanka.prefabBootStep = value.LoadAsset<GameObject>("sfx_reepus_footstepBootWalkChaos");
				Clanka.prefabBootRun = value.LoadAsset<GameObject>("sfx_reepus_footstepBootRunChaos");
				Clanka.jumpData = new EffectData
				{
					m_enabled = true,
					m_prefab = Clanka.prefabJump
				};
				Clanka.dodgeData = new EffectData
				{
					m_enabled = true,
					m_prefab = Clanka.prefabDodge
				};
			}
			else
			{
				Debug.LogWarning((object)"Failed to load clanking");
			}
			ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "ReepusDelmeepus.ChaosArmorClank.cfg"), true);
			doTheRoar = val.Bind<bool>("General", "do the clank", true, "Make player go clank-clank if chaos armor is equipped. Not synced with server.");
			RegisterBlacksmithTools();
			Harmony.CreateAndPatchAll(assembly, (string)null);
		}

		public static void AttachShieldFx(SE_Shield shield)
		{
			if ((Object)(object)staffShield != (Object)null)
			{
				((StatusEffect)shield).m_startEffects.m_effectPrefabs = ((StatusEffect)staffShield).m_startEffects.m_effectPrefabs.Concat(staffShield.m_hitEffects.m_effectPrefabs).ToArray();
				shield.m_breakEffects = staffShield.m_breakEffects;
				shield.m_hitEffects = staffShield.m_hitEffects;
				((StatusEffect)shield).m_stopEffects = staffShield.m_breakEffects;
			}
		}

		private void SetStatusEffects()
		{
			try
			{
				T3SetStatus = ScriptableObject.CreateInstance<SE_Stats>();
				((Object)T3SetStatus).name = "ChaosT3SetEffect";
				T3SetStatus.m_staminaRegenMultiplier = 1.05f;
				T3SetStatus.m_addMaxCarryWeight = 16f;
				T4SetStatus = ScriptableObject.CreateInstance<SE_Stats>();
				((Object)T4SetStatus).name = "ChaosT4SetEffect";
				T4SetStatus.m_staminaRegenMultiplier = 1.15f;
				T4SetStatus.m_addMaxCarryWeight = 32f;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)ex);
			}
		}

		private void LoadTranslations()
		{
			try
			{
				string directoryName = Path.GetDirectoryName(assembly.Location);
				string path = Path.Combine(directoryName, "Localization.yml");
				string text = "am I ever going to fix this, probably not";
				text = File.ReadAllText(path);
				StringReader input = new StringReader(text);
				Deserializer deserializer = new Deserializer();
				LocalizationClusterfuck = deserializer.Deserialize<Localization>(input);
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("Localization file was not loaded cuz mod author is a lazy ass who still won't change the hardcoded directory: " + ex.Message));
			}
		}

		private void RegisterTranslations(Item item)
		{
			if (LocalizationClusterfuck == null)
			{
				return;
			}
			foreach (string key in LocalizationClusterfuck.Localizations.Keys)
			{
				try
				{
					item.Name.addForLang(key, LocalizationClusterfuck.Localizations[key][((Object)item.Prefab).name]["Name"]);
					item.Description.addForLang(key, LocalizationClusterfuck.Localizations[key][((Object)item.Prefab).name]["Description"]);
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("fucked something up registering translations for " + key + " on " + ((Object)item.Prefab).name + ": " + ex.Message));
				}
			}
		}

		private void RegisterBlacksmithTools()
		{
			try
			{
				BodypartSystem.bodypartSettings.Add("T0ChaosPlateArmor", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("T1ChaosPlateArmor", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("T2ChaosPlateArmor", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("ChaosPlateArmorBody", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("EliteChaosPlateArmor", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("EliteChaosPlateArmorTzeentch", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("EliteChaosPlateArmorT2", new List<bodyPart>
				{
					(bodyPart)1,
					(bodyPart)2,
					(bodyPart)3,
					(bodyPart)4,
					(bodyPart)5,
					(bodyPart)6,
					(bodyPart)7
				});
				BodypartSystem.bodypartSettings.Add("T0ChaosPlateLegs", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
				BodypartSystem.bodypartSettings.Add("T1ChaosPlateLegs", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
				BodypartSystem.bodypartSettings.Add("T2ChaosPlateLegs", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
				BodypartSystem.bodypartSettings.Add("ChaosPlateLegs", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
				BodypartSystem.bodypartSettings.Add("EliteChaosPlateLegs", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
				BodypartSystem.bodypartSettings.Add("EliteChaosPlateLegsTzeentch", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
				BodypartSystem.bodypartSettings.Add("EliteChaosPlateLegsT2", new List<bodyPart>
				{
					(bodyPart)11,
					(bodyPart)8,
					(bodyPart)12,
					(bodyPart)13,
					(bodyPart)9,
					(bodyPart)10
				});
			}
			catch (Exception)
			{
				Debug.LogWarning((object)"Blacksmith's Tools failed to register but Chaos Armor should still be functional; keep an eye out for updates to Blacksmith's Tools");
			}
		}
	}
	internal class Localization
	{
		public Dictionary<string, Dictionary<string, Dictionary<string, string>>> Localizations;
	}
	public class Clanka : MonoBehaviour
	{
		public static GameObject prefabStep;

		public static GameObject prefabRun;

		public static GameObject prefabJump;

		public static GameObject prefabDodge;

		public static GameObject prefabLand;

		public static GameObject prefabBootStep;

		public static GameObject prefabBootRun;

		public static EffectData jumpData;

		public static EffectData dodgeData;

		private Player wearer;

		public void Start()
		{
			if (ReepusDeepusDelmeepusChaosArmor.DoTheRoar && !((Object)(object)prefabStep == (Object)null))
			{
				Transform root = ((Component)this).transform.root;
				object obj;
				if (root == null)
				{
					obj = null;
				}
				else
				{
					GameObject gameObject = ((Component)root).gameObject;
					obj = ((gameObject != null) ? gameObject.GetComponent<Player>() : null);
				}
				wearer = (Player)obj;
				if ((Object)(object)wearer != (Object)null)
				{
					MakePlayerClanky(wearer);
				}
			}
		}

		public void OnDisable()
		{
			if (ReepusDeepusDelmeepusChaosArmor.DoTheRoar && !((Object)(object)prefabStep == (Object)null))
			{
				if ((Object)(object)wearer != (Object)null && !ReepusDeepusDelmeepusChaosArmor.clankyPrefabNames.Contains(((Humanoid)wearer).m_visEquipment?.m_currentChestItemHash ?? (-1)) && !ReepusDeepusDelmeepusChaosArmor.clankyPrefabNames.Contains(((Humanoid)wearer).m_visEquipment?.m_currentLegItemHash ?? (-1)))
				{
					UnclankPlayer(wearer);
				}
				wearer = null;
			}
		}

		private static void MakePlayerClanky(Player player)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			FootStep component = ((Component)player).GetComponent<FootStep>();
			if ((Object)(object)component == (Object)null || ((Character)player).m_jumpEffects == null || player.m_dodgeEffects == null)
			{
				return;
			}
			foreach (StepEffect effect in component.m_effects)
			{
				HashSet<GameObject> hashSet = new HashSet<GameObject>(effect.m_effectPrefabs);
				bool flag = false;
				MotionType motionType = effect.m_motionType;
				MotionType val = motionType;
				if (((int)val == 2 || (int)val == 8) ? (hashSet.Add(prefabRun) | hashSet.Add(prefabBootRun)) : (((int)val != 32) ? (hashSet.Add(prefabStep) | hashSet.Add(prefabBootStep)) : (hashSet.Add(prefabLand) | hashSet.Add(prefabBootRun))))
				{
					effect.m_effectPrefabs = hashSet.ToArray();
				}
			}
			HashSet<EffectData> hashSet2 = new HashSet<EffectData>(((Character)player).m_jumpEffects.m_effectPrefabs);
			bool flag2 = hashSet2.Add(jumpData);
			HashSet<EffectData> hashSet3 = new HashSet<EffectData>(player.m_dodgeEffects.m_effectPrefabs);
			bool flag3 = hashSet3.Add(dodgeData);
			if (flag2)
			{
				((Character)player).m_jumpEffects.m_effectPrefabs = hashSet2.ToArray();
			}
			if (flag3)
			{
				player.m_dodgeEffects.m_effectPrefabs = hashSet3.ToArray();
			}
		}

		private static void UnclankPlayer(Player player)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			FootStep component = ((Component)player).GetComponent<FootStep>();
			if ((Object)(object)component == (Object)null || ((Character)player).m_jumpEffects == null || player.m_dodgeEffects == null)
			{
				return;
			}
			foreach (StepEffect effect in component.m_effects)
			{
				HashSet<GameObject> hashSet = new HashSet<GameObject>(effect.m_effectPrefabs);
				bool flag = false;
				MotionType motionType = effect.m_motionType;
				MotionType val = motionType;
				if (((int)val == 2 || (int)val == 8) ? (hashSet.Remove(prefabRun) | hashSet.Remove(prefabBootRun)) : (((int)val != 32) ? (hashSet.Remove(prefabStep) | hashSet.Remove(prefabBootStep)) : (hashSet.Remove(prefabLand) | hashSet.Remove(prefabBootRun))))
				{
					effect.m_effectPrefabs = hashSet.ToArray();
				}
			}
			HashSet<EffectData> hashSet2 = new HashSet<EffectData>(((Character)player).m_jumpEffects.m_effectPrefabs);
			bool flag2 = hashSet2.Remove(jumpData);
			HashSet<EffectData> hashSet3 = new HashSet<EffectData>(player.m_dodgeEffects.m_effectPrefabs);
			bool flag3 = hashSet3.Remove(dodgeData);
			if (flag2)
			{
				((Character)player).m_jumpEffects.m_effectPrefabs = hashSet2.ToArray();
			}
			if (flag3)
			{
				player.m_dodgeEffects.m_effectPrefabs = hashSet3.ToArray();
			}
		}
	}
	public class EitrDynamo : MonoBehaviour
	{
		private Humanoid wearer;

		public void Start()
		{
			Transform root = ((Component)this).transform.root;
			object obj;
			if (root == null)
			{
				obj = null;
			}
			else
			{
				GameObject gameObject = ((Component)root).gameObject;
				obj = ((gameObject != null) ? gameObject.GetComponent<Player>() : null);
			}
			wearer = (Humanoid)obj;
			if ((Object)(object)wearer != (Object)null)
			{
				Humanoid obj2 = wearer;
				((Character)obj2).m_onDamaged = (Action<float, Character>)Delegate.Combine(((Character)obj2).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
		}

		public void OnDisable()
		{
			if ((Object)(object)wearer != (Object)null)
			{
				Humanoid obj = wearer;
				((Character)obj).m_onDamaged = (Action<float, Character>)Delegate.Remove(((Character)obj).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
			wearer = null;
		}

		public void OnDamaged(float dmg, Character idfkLol)
		{
			bool flag = ((Character)wearer).HaveEitr(0f);
			float maxEitr = ((Character)wearer).GetMaxEitr();
			float maxHealth = ((Character)wearer).GetMaxHealth();
			if (maxEitr > 0f)
			{
				if (dmg > Math.Min(50f, maxHealth / 3f))
				{
					((Character)wearer).AddEitr(70f);
				}
				else if (dmg > 30f)
				{
					((Character)wearer).AddEitr(40f);
				}
				else if (dmg < 20f && !((Character)wearer).m_blocking)
				{
					((Character)wearer).AddEitr(3f);
				}
				else
				{
					((Character)wearer).AddEitr(25f);
				}
			}
		}
	}
	public class EitrShield : MonoBehaviour
	{
		private Humanoid wearer;

		private const string shieldName = "TzeentchReactiveShield";

		private int shieldHash;

		public void Start()
		{
			Transform root = ((Component)this).transform.root;
			object obj;
			if (root == null)
			{
				obj = null;
			}
			else
			{
				GameObject gameObject = ((Component)root).gameObject;
				obj = ((gameObject != null) ? gameObject.GetComponent<Player>() : null);
			}
			wearer = (Humanoid)obj;
			if ((Object)(object)wearer != (Object)null)
			{
				shieldHash = StringExtensionMethods.GetStableHashCode("TzeentchReactiveShield");
				Humanoid obj2 = wearer;
				((Character)obj2).m_onDamaged = (Action<float, Character>)Delegate.Combine(((Character)obj2).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
		}

		public void OnDisable()
		{
			if ((Object)(object)wearer != (Object)null)
			{
				Humanoid obj = wearer;
				((Character)obj).m_onDamaged = (Action<float, Character>)Delegate.Remove(((Character)obj).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
			wearer = null;
		}

		public void OnDamaged(float dmg, Character idfkLol)
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ((Character)wearer).HaveEitr(0f);
			float maxHealth = ((Character)wearer).GetMaxHealth();
			float num = Math.Max(25f, maxHealth / 4f);
			float num2 = (flag ? (((Character)wearer).GetEitrPercentage() * ((Character)wearer).GetMaxEitr()) : 0f);
			bool flag2 = ((Character)wearer).GetHealth() <= num;
			bool flag3 = dmg < 10f;
			SEMan sEMan = ((Character)wearer).GetSEMan();
			if (flag3 && (!flag2 || sEMan.HaveStatusEffect(shieldHash)))
			{
				return;
			}
			SE_Shield val = ScriptableObject.CreateInstance<SE_Shield>();
			((Object)val).name = "TzeentchReactiveShield";
			((StatusEffect)val).m_nameHash = shieldHash;
			((StatusEffect)val).m_ttl = ((flag3 && flag2) ? 5f : (20f + 0.35f * num2));
			val.m_levelUpSkillOnBreak = (SkillType)10;
			val.m_levelUpSkillFactor = 0.5f;
			val.m_absorbDamagePerSkillLevel = 1f;
			val.m_absorbDamage = ((flag3 && flag2) ? 5f : (5f + num2));
			ReepusDeepusDelmeepusChaosArmor.AttachShieldFx(val);
			float num3 = Math.Min(75f, maxHealth / 2f);
			float num4 = Math.Min(25f, maxHealth / 3f);
			if (dmg >= num3)
			{
				val.m_absorbDamage += 120f;
			}
			else
			{
				float num5 = dmg;
				if (num5 < num3 && num5 >= num4)
				{
					val.m_absorbDamage += 70f;
				}
				else
				{
					float num6 = dmg;
					if (num6 < num4 && num6 >= 10f)
					{
						val.m_absorbDamage += 30f;
					}
				}
			}
			val.m_absorbDamage = Math.Min(val.m_absorbDamage, 900f);
			((StatusEffect)val).m_ttl = Math.Min(((StatusEffect)val).m_ttl, 100f);
			sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f);
		}
	}
	public class EmergencyShield : MonoBehaviour
	{
		private Humanoid wearer;

		private const string shieldName = "UndividedReactiveEmergencyShield";

		private int shieldHash;

		public void Start()
		{
			Transform root = ((Component)this).transform.root;
			object obj;
			if (root == null)
			{
				obj = null;
			}
			else
			{
				GameObject gameObject = ((Component)root).gameObject;
				obj = ((gameObject != null) ? gameObject.GetComponent<Player>() : null);
			}
			wearer = (Humanoid)obj;
			if ((Object)(object)wearer != (Object)null)
			{
				shieldHash = StringExtensionMethods.GetStableHashCode("UndividedReactiveEmergencyShield");
				Humanoid obj2 = wearer;
				((Character)obj2).m_onDamaged = (Action<float, Character>)Delegate.Combine(((Character)obj2).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
		}

		public void OnDisable()
		{
			if ((Object)(object)wearer != (Object)null)
			{
				Humanoid obj = wearer;
				((Character)obj).m_onDamaged = (Action<float, Character>)Delegate.Remove(((Character)obj).m_onDamaged, new Action<float, Character>(OnDamaged));
			}
			wearer = null;
		}

		public void OnDamaged(float dmg, Character idfkLol)
		{
			float maxHealth = ((Character)wearer).GetMaxHealth();
			float num = Math.Max(25f, maxHealth / 4f);
			bool flag = ((Character)wearer).GetHealth() <= num;
			float num2 = Math.Min(60f, maxHealth / 2f);
			bool flag2 = dmg < num2;
			SEMan sEMan = ((Character)wearer).GetSEMan();
			if (!flag2 || (flag && !sEMan.HaveStatusEffect(shieldHash)))
			{
				SE_Shield val = ScriptableObject.CreateInstance<SE_Shield>();
				((Object)val).name = "UndividedReactiveEmergencyShield";
				((StatusEffect)val).m_nameHash = shieldHash;
				((StatusEffect)val).m_ttl = ((flag2 && flag) ? 10f : 25f);
				val.m_absorbDamage = 25f;
				ReepusDeepusDelmeepusChaosArmor.AttachShieldFx(val);
				sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f);
			}
		}
	}
	public static class PoiseBois
	{
		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		public static class ReduceDamageTaken
		{
			[UsedImplicitly]
			private static void Prefix(Character __instance, HitData hit)
			{
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					if (((Humanoid)val).m_visEquipment.m_currentChestItemHash == ReepusDeepusDelmeepusChaosArmor.T4Hash || ((Humanoid)val).m_visEquipment.m_currentChestItemHash == ReepusDeepusDelmeepusChaosArmor.T5Hash || ((Humanoid)val).m_visEquipment.m_currentChestItemHash == ReepusDeepusDelmeepusChaosArmor.T5UHash)
					{
						hit.m_pushForce *= 0.15f;
						hit.m_staggerMultiplier *= 0.75f;
					}
					else if (((Humanoid)val).m_visEquipment.m_currentChestItemHash == ReepusDeepusDelmeepusChaosArmor.T3Hash)
					{
						hit.m_pushForce *= 0.4f;
						hit.m_staggerMultiplier *= 0.85f;
					}
					else if (((Humanoid)val).m_visEquipment.m_currentChestItemHash == ReepusDeepusDelmeepusChaosArmor.T2Hash || ((Humanoid)val).m_visEquipment.m_currentChestItemHash == ReepusDeepusDelmeepusChaosArmor.T1Hash)
					{
						hit.m_pushForce *= 0.65f;
					}
				}
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[<07e1adc6-f1f6-43a8-9d7b-f3f6d7a5d914>Embedded]
	[CompilerGenerated]
	internal sealed class <07e1adc6-f1f6-43a8-9d7b-f3f6d7a5d914>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<07e1adc6-f1f6-43a8-9d7b-f3f6d7a5d914>Embedded]
	[CompilerGenerated]
	internal sealed class <9fea78a9-51e8-4771-810c-70d42b044566>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <9fea78a9-51e8-4771-810c-70d42b044566>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <9fea78a9-51e8-4771-810c-70d42b044566>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<07e1adc6-f1f6-43a8-9d7b-f3f6d7a5d914>Embedded]
	[CompilerGenerated]
	internal sealed class <9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<07e1adc6-f1f6-43a8-9d7b-f3f6d7a5d914>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <d1c90f99-b1a7-461b-8719-6b61f3a87722>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <d1c90f99-b1a7-461b-8719-6b61f3a87722>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
	}
	[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(1)]
	[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
	internal class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
	[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(1)]
	[PublicAPI]
	internal class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free;

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

		public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig,
				quality = quality
			});
		}
	}
	[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(1)]
	[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
	[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
			});
		}
	}
	[PublicAPI]
	[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(1)]
	[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
	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;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public ConfigEntryBase RecipeIsActive;
	}
	[PublicAPI]
	internal class Trade
	{
		public Trader Trader;

		public uint Price;

		public uint Stack = 1u;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public string RequiredGlobalKey;
	}
	[Flags]
	[PublicAPI]
	internal enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	internal struct Requirement
	{
		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(1)]
		public string itemName;

		public int amount;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public ConfigEntry<int> amountConfig;

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

		public int level;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public string custom;
	}
	[Flags]
	internal enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[PublicAPI]
	[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
	[<9a65228b-ac81-4f3f-a441-594a8f6a209f>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, bool levelMultiplier = true)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min),
				levelMultiplier = levelMultiplier
			});
		}
	}
	internal struct DropTarget
	{
		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(1)]
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;
	}
	internal enum Toggle
	{
		On = 1,
		Off = 0
	}
	[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(1)]
	[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
	[PublicAPI]
	internal class Item
	{
		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
		public class ItemConfig
		{
			[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> craft;

			[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> upgrade;

			public ConfigEntry<CraftingTable> table;

			public ConfigEntry<int> tableLevel;

			public ConfigEntry<string> customTable;

			[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
			public ConfigEntry<int> maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient;

			public ConfigEntry<float> qualityResultAmountMultiplier;
		}

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
		public class TraderConfig
		{
			public ConfigEntry<Trader> trader;

			public ConfigEntry<uint> price;

			public ConfigEntry<uint> stack;

			public ConfigEntry<string> requiredGlobalKey;
		}

		[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)]
		public class RequirementQuality
		{
			public int quality;
		}

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
		[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(2)]
		public class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string Category;

			[UsedImplicitly]
			[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;

			public Func<bool> browsability;
		}

		[PublicAPI]
		[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)]
		public delegate void setDmgFunc(ref DamageTypes dmg, float value);

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
		public class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

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

			public SerializedRequirements(string reqs)
				: this(reqs.Split(new char[1] { ',' }).Select([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					Requirement result = default(Requirement);
					result.itemName = array[0];
					result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2);
					result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0);
					return result;
				}).ToList())
			{
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : "")));
			}

			[return: <9fea78a9-51e8-4771-810c-70d42b044566>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)
				{
					Debug.LogWarning((object)("The required item '" + name + "' does not exist."));
				}
				return obj;
			}

			public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade)
			{
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Expected O, but got Unknown
				//IL_0194: Expected O, but got Unknown
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Expected O, but got Unknown
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<9a65228b-ac81-4f3f-a441-594a8f6a209f>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 val6 = ResItem(r);
					return (val6 != null) ? new Requirement
					{
						m_amount = (r.amountConfig?.Value ?? r.amount),
						m_resItem = val6,
						m_amountPerLevel = 0
					} : ((Requirement)null);
				}));
				List<Requirement> list = dictionary.Values.Where([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (Requirement v) => v != null).ToList();
				foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != ""))
				{
					if (item.quality > 0)
					{
						ItemDrop val = ResItem(item);
						if (val != null)
						{
							Requirement val2 = new Requirement
							{
								m_resItem = val,
								m_amountPerLevel = (item.amountConfig?.Value ?? item.amount),
								m_amount = 0
							};
							list.Add(val2);
							requirementQuality.Add(val2, new RequirementQuality
							{
								quality = item.quality
							});
						}
						continue;
					}
					if (!dictionary.TryGetValue(item.itemName, out var value) || value == null)
					{
						ItemDrop val3 = ResItem(item);
						if (val3 != null)
						{
							string itemName = item.itemName;
							Requirement val4 = new Requirement
							{
								m_resItem = val3,
								m_amount = 0
							};
							Requirement val5 = val4;
							dictionary[itemName] = val4;
							value = val5;
							list.Add(value);
						}
					}
					if (value != null)
					{
						value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount;
					}
				}
				return list.ToArray();
				[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(2)]
				ItemDrop ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(0)]
		public 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([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					if (array.Length <= 2 || !int.TryParse(array[2], out var result))
					{
						result = 1;
					}
					if (array.Length <= 3 || !int.TryParse(array[3], out var result2))
					{
						result2 = result;
					}
					bool levelMultiplier = array.Length <= 4 || array[4] != "0";
					DropTarget result3 = default(DropTarget);
					result3.creature = array[0];
					result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f);
					result3.min = result;
					result3.max = result2;
					result3.levelMultiplier = levelMultiplier;
					return result3;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0")));
			}

			[return: <9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
			public 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)
				{
					Debug.LogWarning((object)("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_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Expected O, but got Unknown
				Dictionary<Character, Drop> dictionary = new Dictionary<Character, Drop>();
				foreach (DropTarget drop in Drops)
				{
					Character val = fetchByName(netScene, drop.creature);
					if (val != null)
					{
						dictionary[val] = new Drop
						{
							m_prefab = item,
							m_amountMin = drop.min,
							m_amountMax = drop.max,
							m_chance = drop.chance,
							m_levelMultiplier = drop.levelMultiplier
						};
					}
				}
				return dictionary;
			}
		}

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

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

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

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(new byte[] { 1, 1, 2 })]
		public static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(new byte[] { 1, 1, 2 })]
		public static Dictionary<Recipe, ConfigEntryBase> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();

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

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

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

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

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

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable;

		public Configurability configurationVisible = Configurability.Full;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public TraderConfig traderConfig;

		public readonly GameObject Prefab;

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

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

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

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

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

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

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public LocalizeKey _name;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public LocalizeKey _description;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public static object configManager;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public static Localization _english;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public static BaseUnityPlugin _plugin;

		public static bool hasConfigSync = true;

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public static object _configSync;

		public 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;

		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public ConfigEntryBase RecipeIsActive
		{
			[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(2)]
			get
			{
				return this[""].RecipeIsActive;
			}
			[<9a65228b-ac81-4f3f-a441-594a8f6a209f>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;
			}
		}

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

		public 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([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<9fea78a9-51e8-4771-810c-70d42b044566>Nullable(2)]
		public static object configSync
		{
			[<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(2)]
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

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

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

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

		public void ToggleConfigurationVisibility(Configurability visible)
		{
			configurationVisible = visible;
			if (itemDropConfigs.TryGetValue(this, out var value))
			{
				Toggle((ConfigEntryBase)(object)value, Configurability.Drop);
			}
			if (itemCraftConfigs.TryGetValue(this, out var value2))
			{
				foreach (ItemConfig value4 in value2.Values)
				{
					ToggleObj(value4, Configurability.Recipe);
				}
			}
			foreach (Conversion conversion in Conversions)
			{
				if (conversion.config != null)
				{
					ToggleObj(conversion.config, Configurability.Recipe);
				}
			}
			foreach (KeyValuePair<ConfigEntryBase, Action> statsConfig in statsConfigs)
			{
				Toggle(statsConfig.Key, Configurability.Stats);
				if ((visible & Configurability.Stats) != 0)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				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);
					}
				}
			}
		}

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

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

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

		public static void Patch_FejdStartup()
		{
			//IL_0e99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_2164: Unknown result type (might be due to invalid IL or missing references)
			//IL_216e: Expected O, but got Unknown
			//IL_0f62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fbb: Expected I4, but got Unknown
			//IL_0b88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b92: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			//IL_10ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f4: Invalid comparison between Unknown and I4
			//IL_10f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fa: Invalid comparison between Unknown and I4
			//IL_0cab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb5: Expected O, but got Unknown
			//IL_0d56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d60: Expected O, but got Unknown
			//IL_10fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1100: Invalid comparison between Unknown and I4
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			//IL_0e0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e14: Expected O, but got Unknown
			//IL_12fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1300: Invalid comparison between Unknown and I4
			//IL_1302: Unknown result type (might be due to invalid IL or missing references)
			//IL_1306: Unknown result type (might be due to invalid IL or missing references)
			//IL_1308: Invalid comparison between Unknown and I4
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Expected O, but got Unknown
			//IL_130a: Unknown result type (might be due to invalid IL or missing references)
			//IL_130e: Invalid comparison between Unknown and I4
			//IL_13e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ed: Invalid comparison between Unknown and I4
			//IL_13ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_13f3: Invalid comparison between Unknown and I4
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Expected O, but got Unknown
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Expected O, but got Unknown
			//IL_1462: Unknown result type (might be due to invalid IL or missing references)
			//IL_1465: Unknown result type (might be due to invalid IL or missing references)
			//IL_1467: Invalid comparison between Unknown and I4
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Expected O, but got Unknown
			//IL_1469: Unknown result type (might be due to invalid IL or missing references)
			//IL_146d: Unknown result type (might be due to invalid IL or missing references)
			//IL_146f: Invalid comparison between Unknown and I4
			//IL_1471: Unknown result type (might be due to invalid IL or missing references)
			//IL_1475: Invalid comparison between Unknown and I4
			//IL_15b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_15b5: Invalid comparison between Unknown and I4
			//IL_17b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b9: Invalid comparison between Unknown and I4
			//IL_1882: Unknown result type (might be due to invalid IL or missing references)
			//IL_1887: Unknown result type (might be due to invalid IL or missing references)
			//IL_1889: Unknown result type (might be due to invalid IL or missing references)
			//IL_188d: Unknown result type (might be due to invalid IL or missing references)
			//IL_188f: Invalid comparison between Unknown and I4
			//IL_18fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1901: Unknown result type (might be due to invalid IL or missing references)
			//IL_1903: Invalid comparison between Unknown and I4
			//IL_1528: Unknown result type (might be due to invalid IL or missing references)
			//IL_152d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1905: Unknown result type (might be due to invalid IL or missing references)
			//IL_1909: Invalid comparison between Unknown and I4
			//IL_190b: Unknown result type (might be due to invalid IL or missing references)
			//IL_190f: Invalid comparison between Unknown and I4
			//IL_1d7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d7f: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			if (DefaultConfigurability != 0)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item4 in registeredItems.Where([<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item3 = item4;
					string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("['\\[\"\\]]").Replace(english.Localize(name2), "").Trim();
					string localizedName = Localization.instance.Localize(name2).Trim();
					int order = 0;
					if ((item3.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>();
						foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item5;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6))
								{
									value6.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							}
							cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = QualityResultBrowsability,
								Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5))
								{
									foreach (Recipe item6 in value5)
									{
										item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes }));
							cfg.qualityResultAmountMultiplier.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value4))
								{
									foreach (Recipe item7 in value4)
									{
										item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false);
							}
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true);
							}
							if (cfg.craft != null)
							{
								cfg.craft.SettingChanged += ConfigChanged;
							}
							if (cfg.upgrade != null)
							{
								cfg.upgrade.SettingChanged += ConfigChanged;
							}
							void ConfigChanged(object o, EventArgs e)
							{
								item3.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? ""));
							}
							bool CustomTableBrowsability()
							{
								return cfg.table.Value == CraftingTable.Custom;
							}
							bool ItemBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							bool QualityResultBrowsability()
							{
								return cfg.requireOneIngredient.Value == Toggle.On;
							}
							void TableConfigChanged(object o, EventArgs e)
							{
								item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value);
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes)
								{
									item8.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig(string name, string value, string desc, bool isUpgrade)
							{
								//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
								//IL_00b1: Expected O, but got Unknown
								ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade),
									Order = (order -= 1),
									browsability = ItemBrowsability,
									Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								};
								hideWhenNoneAttributes.Add(configurationManagerAttributes3);
								return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 }));
							}
						}
						if ((item3.configurability & Configurability.Drop) != 0)
						{
							ConfigEntry<string> val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									CustomDrawer = drawDropsConfigTable,
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Drop) != 0)
								}
							})));
							val3.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								item3.UpdateCharacterDrop();
							};
						}
						for (int j = 0; j < item3.Conversions.Count; j++)
						{
							string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : "");
							Conversion conversion = item3.Conversions[j];
							conversion.config = new Conversion.ConversionConfig();
							int index = j;
							conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.input.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								if (index < item3.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item3.conversions[index].m_from = from;
										UpdatePiece();
									}
								}
							};
							conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.piece.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Duration of conversion to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0)
								}
							}));
							conversion.config.customPiece.SettingChanged += [<9a65228b-ac81-4f3f-a441-594a8f6a209f>NullableContext(0)] (object _, EventArgs _) =>
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance))
								{
									string text3 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value)));
									string activePiece = conversion.config.activePiece;
									if (conversion.config.activePiece != null)
									{
										int num = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent<Smelter>().m_conversion.IndexOf(item3.conversions[index]);
										if (num >= 0)
										{
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val4 in array3)
											{
												if (Utils.GetPrefabName(((Component)val4).gameObject) == activePiece)
												{
													val4.m_conversion.RemoveAt(num);
												}
											}
										}
										conversion.config.activePiece = null;
									}
									if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0)
									{
										GameObject prefab = ZNetScene.instance.GetPrefab(text3);
										if (((prefab != null) ? prefab.GetComponent<Smelter>() : null) != null)
										{
											conversion.config.activePiece = text3;
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val5 in array3)
											{
												if (Utils.GetPrefabName(((Component)val5).gameObject) == text3)
												{
													val5.m_conversion.Add(item3.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item3.configurability & Configurability.Stats) != 0)
					{
						item3.statsConfigs.Clear();
						SharedData shared2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ItemType itemType = shared2.m_itemType;
						statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value)
						{
							shared.m_weight = value;
						});
						statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value)
						{
							shared.m_value = value;
						});
						bool flag;
						switch (itemType - 3)
						{
						case 0:
						case 1:
						case 2:
						case 3:
						case 4:
						case 8:
						case 9:
						case 11:
						case 14:
						case 16:
						case 19:
							flag = true;
							break;
						default:
							flag = false;
							break;
						}
						if (flag)
						{
							statcfg<float>("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value)
							{
								shared.m_maxDurability = value;
							});
							statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value)
							{
								shared.m_durabilityPerLevel = value;
							});
							statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value)
							{
								shared.m_movementModifier = value;
							});
						}
						if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value)
							{
								shared.m_blockPower = value;
							});
							statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value)
							{
								shared.m_blockPowerPerLevel = value;
							});
							statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value)
							{
								shared.m_deflectionForce = value;
							});
							statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value)
							{
								shared.m_deflectionForcePerLevel = value;
							});
							statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value)
							{
								shared.m_timedBlockBonus = value;
							});
						}
						else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value)
							{
								shared.m_armor = value;
							});
							statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value)
							{
								shared.m_armorPerLevel = value;
							});
						}
						SkillType skillType = shared2.m_skillType;
						if (((int)skillType == 7 || (int)skillType == 12) ? true : false)
						{
							statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value)
							{
								shared.m_toolTier = value;
							});
						}
						if ((itemType - 5 <= 2 || itemType - 11 <= 1