Decompiled source of FunGuy Fury v1.0.7

FunGuy_Fury.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using FunGuy_Fury.Patches;
using FunGuy_Fury.Util;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using StatusEffectManager;
using TMPro;
using UnityEngine;

[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyProduct("FunGuy_Fury")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyFileVersion("1.0.7")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("FunGuy_Fury")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyConfiguration("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.7.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<4ed31cff-da4b-44d5-afcc-8f889904376c>Embedded]
	internal sealed class <4ed31cff-da4b-44d5-afcc-8f889904376c>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<4ed31cff-da4b-44d5-afcc-8f889904376c>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<4ed31cff-da4b-44d5-afcc-8f889904376c>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace FunGuy_Fury
{
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[BepInPlugin("Azumatt.FunGuy_Fury", "FunGuy_Fury", "1.0.7")]
	public class FunGuy_FuryPlugin : BaseUnityPlugin
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
			public string Category;

			[UsedImplicitly]
			[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		internal const string ModName = "FunGuy_Fury";

		internal const string ModVersion = "1.0.7";

		internal const string Author = "Azumatt";

		private const string ModGUID = "Azumatt.FunGuy_Fury";

		private static string ConfigFileName = "Azumatt.FunGuy_Fury.cfg";

		private static string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("Azumatt.FunGuy_Fury");

		internal static FunGuy_FuryPlugin context;

		public static readonly ManualLogSource FunGuyFuryLogger;

		private static readonly ConfigSync ConfigSync;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		internal static ConfigEntry<float> DamageBoost;

		internal static ConfigEntry<float> Cooldown;

		internal static ConfigEntry<float> Duration;

		internal static ConfigEntry<string> StartMessage;

		internal static ConfigEntry<string> StopMessage;

		internal static ConfigEntry<string> CooldownMessage;

		internal static ConfigEntry<string> EffectTooltip;

		internal static ConfigEntry<float> DamagePerHit;

		internal static ConfigEntry<float> DamageInterval;

		internal static DateTime LastShroomTime;

		public void Awake()
		{
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			context = this;
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			DamageBoost = config("1 - General", "Damage Boost", 2f, "Damage multiplier gained from eating the mushroom. Applies to creatures, players, and trees.");
			Cooldown = config("2 - Berserk Effect", "Cooldown", 15f, "Cooldown in seconds between each use of the effect. Prevents eating the food if the cooldown is not over. Displays the cooldown when failed to eat the food. Tweak the Cooldown Message to change the message displayed.");
			Duration = config("2 - Berserk Effect", "Duration", 15f, "Duration in seconds of the berserker effect.");
			StartMessage = textEntryConfig("2 - Berserk Effect", "Start Message", "Damage increased at the cost of health!", "Message displayed when the berserk effect starts.", synchronizedSetting: false);
			StopMessage = textEntryConfig("2 - Berserk Effect", "Stop Message", "", "Message displayed when the berserk effect ends.", synchronizedSetting: false);
			CooldownMessage = textEntryConfig("2 - Berserk Effect", "Cooldown Message", "You are still recovering from your last berserk rage! {0} remaining.", "Message displayed when the cooldown is not over. {0} is replaced by the remaining time in seconds.", synchronizedSetting: false);
			EffectTooltip = textEntryConfig("2 - Berserk Effect", "Effect Tooltip", "<color=red>Increase damage x2, but at the cost of health loss over time</color>", "Tooltip shown when hovering over the Fly Agaric mushroom to describe the effect.", synchronizedSetting: false);
			DamagePerHit = config("2 - Berserk Effect", "Damage Per Hit", 5f, "Damage taken per hit while berserk.");
			DamageInterval = config("2 - Berserk Effect", "Damage Interval", 1f, "Interval in seconds between each damage tick.");
			Cooldown.SettingChanged += Functions.UpdateConfig;
			Duration.SettingChanged += Functions.UpdateConfig;
			StartMessage.SettingChanged += Functions.UpdateConfig;
			StopMessage.SettingChanged += Functions.UpdateConfig;
			EffectTooltip.SettingChanged += Functions.UpdateConfig;
			DamagePerHit.SettingChanged += Functions.UpdateConfig;
			DamageInterval.SettingChanged += Functions.UpdateConfig;
			Item item = new Item("funguyfury", "FlyAgaricHat");
			item.Name.English("Fly Agaric Hat");
			item.Description.English("A amanita muscaria mushroom hat!");
			item.Crafting.Add(CraftingTable.Inventory, 3);
			item.RequiredItems.Add("FlyAgaricMushroom", 20);
			item.RequiredUpgradeItems.Add("FlyAgaricMushroom", 10);
			item.Snapshot();
			Item item2 = new Item("funguyfury", "FlyAgaricMushroom");
			item2.Name.English("Fly Agaric Mushroom");
			item2.Description.English("Amanita muscaria, commonly known as the fly agaric or fly amanita");
			item2.Snapshot();
			item2.DropsFrom.Add("Draugr", 0.1f, 1, 2);
			item2.DropsFrom.Add("Draugr_Elite", 0.2f, 1, 2);
			item2.DropsFrom.Add("Draugr_Ranged", 0.1f, 1, 2);
			item2.DropsFrom.Add("Dverger", 0.4f, 1, 2);
			item2.DropsFrom.Add("DvergerMage", 0.4f, 1, 2);
			item2.DropsFrom.Add("DvergerMageFire", 0.4f, 1, 2);
			item2.DropsFrom.Add("DvergerMageIce", 0.4f, 1, 2);
			item2.DropsFrom.Add("DvergerMageSupport", 0.4f, 1, 2);
			CustomSE customSE = new CustomSE("Berserk");
			customSE.Name.English("Berserk");
			customSE.Type = EffectType.Consume;
			customSE.Icon = "berserkerse.png";
			((StatusEffect)customSE.Effect).m_cooldown = 0f;
			((StatusEffect)customSE.Effect).m_activationAnimation = "gpower";
			((StatusEffect)customSE.Effect).m_ttl = Duration.Value;
			((StatusEffect)customSE.Effect).m_startMessageType = (MessageType)2;
			((StatusEffect)customSE.Effect).m_startMessage = "Damage increased at the cost of health";
			((StatusEffect)customSE.Effect).m_stopMessageType = (MessageType)2;
			((StatusEffect)customSE.Effect).m_stopMessage = "";
			((StatusEffect)customSE.Effect).m_tooltip = "<color=red>Increase damage x2, but at the cost of health loss over time</color>";
			customSE.Effect.m_damagePerHit = 2f;
			customSE.Effect.m_damageInterval = 1f;
			customSE.Effect.m_baseTTL = 1f;
			customSE.Effect.m_TTLPerDamage = 1f;
			customSE.Effect.m_TTLPerDamagePlayer = 5f;
			customSE.Effect.m_TTLPower = 0.5f;
			customSE.AddSEToPrefab(customSE, "FlyAgaricMushroom");
			PrefabManager.RegisterPrefab("funguyfury", "Pickable_FlyAgaricMushroom");
			PrefabManager.RegisterPrefab("funguyfury", "sfx_berserk_female");
			PrefabManager.RegisterPrefab("funguyfury", "sfx_berserk_male");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

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

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

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

		private ConfigEntry<T> config<[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			ConfigSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		private ConfigEntry<T> textEntryConfig<[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)] T>(string group, string name, T value, string desc, bool synchronizedSetting = true)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
			{
				CustomDrawer = Functions.TextAreaDrawer
			};
			return config(group, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), synchronizedSetting);
		}

		static FunGuy_FuryPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			context = null;
			FunGuyFuryLogger = Logger.CreateLogSource("FunGuy_Fury");
			ConfigSync = new ConfigSync("Azumatt.FunGuy_Fury")
			{
				DisplayName = "FunGuy_Fury",
				CurrentVersion = "1.0.7",
				MinimumRequiredVersion = "1.0.7"
			};
			_serverConfigLocked = null;
			DamageBoost = null;
			Cooldown = null;
			Duration = null;
			StartMessage = null;
			StopMessage = null;
			CooldownMessage = null;
			EffectTooltip = null;
			DamagePerHit = null;
			DamageInterval = null;
			LastShroomTime = DateTime.MinValue;
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			FunGuy_FuryPlugin.FunGuyFuryLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("FunGuy_Fury_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_FunGuy_Fury_Version);
			FunGuy_FuryPlugin.FunGuyFuryLogger.LogDebug((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("1.0.7");
			val.Write(RpcHandlers.ComputeHashForMod().Replace("-", ""));
			peer.m_rpc.Invoke("FunGuy_Fury_VersionCheck", new object[1] { val });
		}
	}
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			FunGuy_FuryPlugin.FunGuyFuryLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "FunGuy_FuryRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + FunGuy_FuryPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				FunGuy_FuryPlugin.FunGuyFuryLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

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

		public static string ComputeHashForMod()
		{
			using SHA256 sHA = SHA256.Create();
			byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location));
			StringBuilder stringBuilder = new StringBuilder();
			byte[] array2 = array;
			foreach (byte b in array2)
			{
				stringBuilder.Append(b.ToString("X2"));
			}
			return stringBuilder.ToString();
		}
	}
}
namespace FunGuy_Fury.Util
{
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public class Functions
	{
		public static void SetBerserkerZdo(long sender, ZDOID zdoid, bool isBerserker)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ZNetScene.instance.FindInstance(zdoid);
			if ((Object)(object)val == (Object)null)
			{
				FunGuy_FuryPlugin.FunGuyFuryLogger.LogError((object)"Player not found");
				return;
			}
			FunGuy_FuryPlugin.FunGuyFuryLogger.LogDebug((object)$"Setting Berserker {isBerserker} for ZDOID: {zdoid}");
			if (isBerserker)
			{
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
				foreach (Renderer obj in componentsInChildren)
				{
					MaterialPropertyBlock val2 = new MaterialPropertyBlock();
					obj.GetPropertyBlock(val2);
					val2.SetColor("_Color", Color.red);
					val2.SetColor("_EmissionColor", Color.red * 1f);
					obj.SetPropertyBlock(val2);
				}
			}
			else
			{
				ResetArmor(val.GetComponent<Player>());
				val.GetComponent<VisEquipment>().UpdateEquipmentVisuals();
			}
		}

		private static void ResetArmor(Player p)
		{
			VisEquipment component = ((Component)p).GetComponent<VisEquipment>();
			component.m_currentLeftItemHash = -1000;
			component.m_currentRightItemHash = -1000;
			component.m_currentChestItemHash = -1000;
			component.m_currentLegItemHash = -1000;
			component.m_currentHelmetItemHash = -1000;
			component.m_currentShoulderItemHash = -1000;
			component.m_currentBeardItemHash = -1000;
			component.m_currentHairItemHash = -1000;
			component.m_currentUtilityItemHash = -1000;
			component.m_currentLeftBackItemHash = -1000;
			component.m_currentRightBackItemHash = -1000;
		}

		internal static void RPC_BattleCryBerserkSE(long sender, ZDOID zdoid)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ZNetScene.instance.FindInstance(zdoid);
			if ((Object)(object)val == (Object)null)
			{
				FunGuy_FuryPlugin.FunGuyFuryLogger.LogError((object)"Player not found, cannot do effect");
				return;
			}
			GameObject obj = ((val.GetComponent<Player>().GetPlayerModel() == 1) ? ZNetScene.instance.GetPrefab("sfx_berserk_female") : ZNetScene.instance.GetPrefab("sfx_berserk_male"));
			Transform transform = val.transform;
			Object.Instantiate<GameObject>(obj, transform.position, transform.rotation);
			Object.Instantiate<GameObject>(obj, val.transform, false);
		}

		internal static void TextAreaDrawer(ConfigEntryBase entry)
		{
			GUILayout.ExpandHeight(true);
			GUILayout.ExpandWidth(true);
			entry.BoxedValue = GUILayout.TextArea((string)entry.BoxedValue, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
		}

		internal static void UpdateConfig(object o, EventArgs e)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			bool saveOnConfigSet = ((BaseUnityPlugin)FunGuy_FuryPlugin.context).Config.SaveOnConfigSet;
			((BaseUnityPlugin)FunGuy_FuryPlugin.context).Config.SaveOnConfigSet = false;
			SE_Berserk[] array = Resources.FindObjectsOfTypeAll<SE_Berserk>();
			foreach (SE_Berserk obj in array)
			{
				((StatusEffect)obj).m_cooldown = 0f;
				((StatusEffect)obj).m_activationAnimation = "gpower";
				((StatusEffect)obj).m_ttl = FunGuy_FuryPlugin.Duration.Value;
				((StatusEffect)obj).m_startMessageType = (MessageType)2;
				((StatusEffect)obj).m_startMessage = FunGuy_FuryPlugin.StartMessage.Value;
				((StatusEffect)obj).m_stopMessageType = (MessageType)2;
				((StatusEffect)obj).m_stopMessage = FunGuy_FuryPlugin.StopMessage.Value;
				((StatusEffect)obj).m_tooltip = FunGuy_FuryPlugin.EffectTooltip.Value;
				obj.m_damagePerHit = FunGuy_FuryPlugin.DamagePerHit.Value;
				obj.m_damageInterval = FunGuy_FuryPlugin.DamageInterval.Value;
			}
			if (saveOnConfigSet)
			{
				((BaseUnityPlugin)FunGuy_FuryPlugin.context).Config.SaveOnConfigSet = true;
				((BaseUnityPlugin)FunGuy_FuryPlugin.context).Config.Save();
			}
		}

		internal static void CheckHitApplyModifier(HitData hit)
		{
			Character attacker = hit.GetAttacker();
			if (!((Object)(object)attacker == (Object)null) && attacker.IsPlayer() && attacker.m_seman.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Berserk")))
			{
				hit.ApplyModifier(FunGuy_FuryPlugin.DamageBoost.Value);
			}
		}
	}
}
namespace FunGuy_Fury.Patches
{
	[HarmonyPatch(typeof(Player), "ConsumeItem")]
	internal static class Player_ConsumeItem_Patch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static bool Prefix(Player __instance, Inventory inventory, ItemData item)
		{
			if (((Object)item.m_dropPrefab).name != "FlyAgaricMushroom")
			{
				return true;
			}
			if ((int)((double)(FunGuy_FuryPlugin.Cooldown.Value + FunGuy_FuryPlugin.Duration.Value) - (DateTime.Now - FunGuy_FuryPlugin.LastShroomTime).TotalSeconds) >= 0)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(FunGuy_FuryPlugin.CooldownMessage.Value, (int)((double)(FunGuy_FuryPlugin.Cooldown.Value + FunGuy_FuryPlugin.Duration.Value) - (DateTime.Now - FunGuy_FuryPlugin.LastShroomTime).TotalSeconds)), 0, (Sprite)null);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	internal static class PlayerDamagePatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(Character __instance, ref HitData hit)
		{
			if (!__instance.IsDebugFlying() && __instance.m_nview.IsOwner() && !((double)__instance.GetHealth() <= 0.0) && !__instance.IsDead() && !__instance.IsTeleporting() && !__instance.InCutscene() && (!hit.m_dodgeable || !__instance.IsDodgeInvincible()))
			{
				Functions.CheckHitApplyModifier(hit);
			}
		}
	}
	[HarmonyPatch(typeof(TreeLog), "RPC_Damage")]
	internal static class TreeLogRPCDamagePatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(TreeLog __instance, ref HitData hit)
		{
			Functions.CheckHitApplyModifier(hit);
		}
	}
	[HarmonyPatch(typeof(TreeBase), "RPC_Damage")]
	internal static class TreeBasePatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(TreeBase __instance, ref HitData hit)
		{
			Functions.CheckHitApplyModifier(hit);
		}
	}
	[HarmonyPatch(typeof(Game), "Start")]
	internal static class GameStartPatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Postfix(Game __instance)
		{
			ZRoutedRpc.s_instance.Register<ZDOID, bool>("SetBerserkerZdo", (Action<long, ZDOID, bool>)Functions.SetBerserkerZdo);
			ZRoutedRpc.s_instance.Register<ZDOID>("BattleCryBerserkSE", (Action<long, ZDOID>)Functions.RPC_BattleCryBerserkSE);
		}
	}
	[HarmonyPatch(typeof(StatusEffect), "IsDone")]
	internal static class StatusEffectIsDonePatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Postfix(StatusEffect __instance, ref bool __result)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if ((((Object)__instance).name == "Berserk") & __result)
			{
				ZRoutedRpc.s_instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SetBerserkerZdo", new object[2]
				{
					__instance.m_character.GetZDOID(),
					false
				});
			}
		}
	}
	[HarmonyPatch(typeof(StatusEffect), "Setup")]
	internal static class StatusEffectSetUpPatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Postfix(StatusEffect __instance, Character character)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)__instance).name == "Berserk")
			{
				FunGuy_FuryPlugin.LastShroomTime = DateTime.Now;
				__instance.m_character.m_zanim.SetTrigger("gpower");
				ZRoutedRpc.s_instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SetBerserkerZdo", new object[2]
				{
					__instance.m_character.GetZDOID(),
					true
				});
				ZRoutedRpc.s_instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "BattleCryBerserkSE", new object[1] { __instance.m_character.GetZDOID() });
			}
		}
	}
	public class SE_Berserk : StatusEffect
	{
		public float m_damageInterval = 1f;

		public float m_baseTTL = 2f;

		public float m_TTLPerDamagePlayer = 2f;

		public float m_TTLPerDamage = 2f;

		public float m_TTLPower = 0.5f;

		public float m_timer;

		public float m_damageLeft;

		public float m_damagePerHit;

		public override void UpdateStatusEffect(float dt)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			((StatusEffect)this).UpdateStatusEffect(dt);
			m_timer -= dt;
			if (!((double)m_timer > 0.0))
			{
				m_timer = m_damageInterval;
				HitData val = new HitData();
				val.m_point = base.m_character.GetCenterPoint();
				val.m_damage.m_damage = m_damagePerHit;
				m_damageLeft -= m_damagePerHit;
				base.m_character.ApplyDamage(val, true, false, (DamageModifier)0);
			}
		}

		public void AddDamage(float damage)
		{
			if (!((double)damage < (double)m_damageLeft))
			{
				m_damageLeft = damage;
				base.m_ttl = m_baseTTL + Mathf.Pow(m_damageLeft * (base.m_character.IsPlayer() ? m_TTLPerDamagePlayer : m_TTLPerDamage), m_TTLPower);
				int num = (int)((double)base.m_ttl / (double)m_damageInterval);
				m_damagePerHit = m_damageLeft / (float)num;
				FunGuy_FuryPlugin.FunGuyFuryLogger.LogDebug((object)("Berserker damage: " + m_damageLeft + " ttl:" + base.m_ttl + " hits:" + num + " dmg perhit:" + m_damagePerHit));
				((StatusEffect)this).ResetTime();
			}
		}
	}
	[HarmonyPatch(typeof(Player), "UseStamina")]
	internal static class PlayerUseStamPatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(Player __instance, ref float v)
		{
			if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Berserk")))
			{
				v = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(ZoneSystem), "Start")]
	internal static class ZoneSystemStartPatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(ZoneSystem __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			GameObject prefab = ZNetScene.instance.GetPrefab("Pickable_FlyAgaricMushroom");
			ZoneVegetation item = new ZoneVegetation
			{
				m_name = ((Object)prefab).name,
				m_prefab = prefab,
				m_enable = true,
				m_max = 0.65f,
				m_forcePlacement = true,
				m_scaleMin = 1f,
				m_scaleMax = 1.75f,
				m_chanceToUseGroundTilt = 0f,
				m_biome = (Biome)514,
				m_biomeArea = (BiomeArea)3,
				m_blockCheck = true,
				m_minAltitude = 0.01f,
				m_maxAltitude = 1000f,
				m_groupSizeMin = 1,
				m_groupSizeMax = 3,
				m_groupRadius = 32f,
				m_inForest = false,
				m_forestTresholdMin = 0f,
				m_forestTresholdMax = 1f,
				m_foldout = false
			};
			__instance.m_vegetation.Add(item);
		}
	}
	[HarmonyPatch(typeof(ZoneSystem), "ValidateVegetation")]
	internal static class ZoneSystemValidatePatch
	{
		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
		private static void Prefix(ZoneSystem __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			GameObject prefab = ZNetScene.instance.GetPrefab("Pickable_FlyAgaricMushroom");
			ZoneVegetation item = new ZoneVegetation
			{
				m_name = ((Object)prefab).name,
				m_prefab = prefab,
				m_enable = true,
				m_max = 0.65f,
				m_forcePlacement = true,
				m_scaleMin = 1f,
				m_scaleMax = 1.75f,
				m_chanceToUseGroundTilt = 0f,
				m_biome = (Biome)514,
				m_biomeArea = (BiomeArea)3,
				m_blockCheck = true,
				m_minAltitude = 0.01f,
				m_maxAltitude = 1000f,
				m_groupSizeMin = 1,
				m_groupSizeMax = 3,
				m_groupRadius = 32f,
				m_inForest = false,
				m_forestTresholdMin = 0f,
				m_forestTresholdMax = 1f,
				m_foldout = false
			};
			__instance.m_vegetation.Add(item);
		}
	}
}
namespace StatusEffectManager
{
	[Description("The ItemDrop effect to apply the status effect")]
	[PublicAPI]
	public enum EffectType
	{
		Equip,
		Attack,
		Consume,
		Set
	}
	public struct SE_Item
	{
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(1)]
		public StatusEffect Effect;

		public EffectType Type;
	}
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[PublicAPI]
	public class CustomSE
	{
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		public static class LocalizationCache
		{
			private static readonly Dictionary<string, Localization> localizations = new Dictionary<string, Localization>();

			internal static void LocalizationPostfix(Localization __instance, string language)
			{
				string key = localizations.FirstOrDefault([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (KeyValuePair<string, Localization> l) => l.Value == __instance).Key;
				if (key != null)
				{
					localizations.Remove(key);
				}
				if (!localizations.ContainsKey(language))
				{
					localizations.Add(language, __instance);
				}
			}

			public static Localization ForLanguage([<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)] string language = null)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out var value))
				{
					return value;
				}
				value = new Localization();
				if (language != null)
				{
					value.SetupLanguage(language);
				}
				return value;
			}
		}

		private static readonly List<CustomSE> RegisteredEffects = new List<CustomSE>();

		private static readonly Dictionary<StatusEffect, CustomSE> CustomEffectMap = new Dictionary<StatusEffect, CustomSE>();

		internal static readonly List<StatusEffect> CustomSEs = new List<StatusEffect>();

		internal static readonly Dictionary<SE_Item, string> AddToPrefabs = new Dictionary<SE_Item, string>();

		[Description("Instance of the StatusEffect.")]
		public readonly SE_Berserk Effect;

		[Description("Set the type of effect you are adding. If the item can attack, consume, or be equipped, change this to correspond.")]
		public EffectType Type;

		private string _folderName = "icons";

		private AssetBundle _assetBundle;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		public Sprite IconSprite;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private string IconName;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private LocalizeKey _name;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static Localization _english;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static object _configSync;

		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		public string Icon
		{
			[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(2)]
			get
			{
				return IconName;
			}
			[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(2)]
			set
			{
				IconName = value;
				IconSprite = ((IconName == null) ? null : loadSprite(IconName));
				((StatusEffect)Effect).m_icon = IconSprite;
			}
		}

		[Description("Sets the in-game name for the StatusEffect")]
		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				StatusEffect effect = (StatusEffect)(object)Effect;
				if (effect.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(effect.m_name);
				}
				else
				{
					string text = "$statuseffect_" + ((Object)Effect).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(effect.m_name);
					effect.m_name = text;
				}
				return _name;
			}
		}

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

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static object configSync
		{
			[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 + " StatusEffectManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		public CustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
			: this(EffectManager.RegisterAssetBundle(assetBundleFileName, folderName), customEffectName)
		{
		}

		public CustomSE(AssetBundle bundle, string customEffectName)
		{
			Effect = EffectManager.RegisterCustomSE(bundle, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[(StatusEffect)(object)Effect] = this;
		}

		public CustomSE(string customEffectName)
		{
			Effect = ScriptableObject.CreateInstance<SE_Berserk>();
			EffectManager.RegisterCustomSE((StatusEffect)(object)Effect, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[(StatusEffect)(object)Effect] = this;
		}

		[return: <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((_folderName == "") ? "" : ".") + _folderName + "." + name);
			if (manifestResourceStream == null)
			{
				return null;
			}
			manifestResourceStream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		[return: <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private Texture2D loadTexture(string name)
		{
			//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_0019: Expected O, but got Unknown
			//IL_001b: Expected O, but got Unknown
			byte[] array = ReadEmbeddedFileBytes(name);
			if (array != null)
			{
				Texture2D val = new Texture2D(0, 0);
				ImageConversion.LoadImage(val, array);
				return val;
			}
			return null;
		}

		private Sprite loadSprite(string name)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = loadTexture(name);
			if (val != null)
			{
				return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), Vector2.zero);
			}
			AssetBundle assetBundle = _assetBundle;
			Sprite val2 = ((assetBundle != null) ? assetBundle.LoadAsset<Sprite>(name) : null);
			if (val2 != null)
			{
				return val2;
			}
			throw new FileNotFoundException("Could not find a file named " + name + " for the effect icon");
		}

		[Description("Adds the CustomSE to a prefab by adding it on ZNetScene awake. The effect type will be used to determine when the effect applies.")]
		public void AddSEToPrefab(CustomSE customSE, string prefabName)
		{
			SE_Item sE_Item = default(SE_Item);
			sE_Item.Effect = (StatusEffect)(object)customSE.Effect;
			sE_Item.Type = customSE.Type;
			SE_Item key = sE_Item;
			AddToPrefabs.Add(key, prefabName);
		}

		private static ConfigEntry<T> config<[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)] T>(string group, string name, T value, ConfigDescription description)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T))
				.Invoke(configSync, new object[1] { val });
			return val;
		}

		private static ConfigEntry<T> config<[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)] T>(string group, string name, T value, string description)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[PublicAPI]
	public class LocalizeKey
	{
		public readonly string Key;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		private LocalizeKey addForLang(string lang, string value)
		{
			if (Localization.instance.GetSelectedLanguage() == lang)
			{
				Localization.instance.AddWord(Key, value);
			}
			else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key))
			{
				Localization.instance.AddWord(Key, value);
			}
			return this;
		}
	}
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	public static class EffectManager
	{
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		private struct BundleId
		{
			[UsedImplicitly]
			public string assetBundleFileName;

			[UsedImplicitly]
			public string folderName;
		}

		private static readonly Dictionary<BundleId, AssetBundle> bundleCache;

		static EffectManager()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			bundleCache = new Dictionary<BundleId, AssetBundle>();
			Harmony val = new Harmony("org.bepinex.helpers.StatusEffectManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(CustomSE.LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets")
		{
			BundleId bundleId = default(BundleId);
			bundleId.assetBundleFileName = assetBundleFileName;
			bundleId.folderName = folderName;
			BundleId key = bundleId;
			if (!bundleCache.TryGetValue(key, out var value))
			{
				Dictionary<BundleId, AssetBundle> dictionary = bundleCache;
				AssetBundle? obj = ((IEnumerable<AssetBundle>)Resources.FindObjectsOfTypeAll<AssetBundle>()).FirstOrDefault((Func<AssetBundle, bool>)([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((folderName == "") ? "" : ".") + folderName + "." + assetBundleFileName));
				AssetBundle result = obj;
				dictionary[key] = obj;
				return result;
			}
			return value;
		}

		public static StatusEffect RegisterCustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
		{
			return (StatusEffect)(object)RegisterCustomSE(RegisterAssetBundle(assetBundleFileName, folderName), customEffectName);
		}

		public static SE_Berserk RegisterCustomSE(AssetBundle assets, string customEffectName)
		{
			SE_Berserk sE_Berserk = (SE_Berserk)(object)assets.LoadAsset<ScriptableObject>(customEffectName);
			CustomSE.CustomSEs.Add((StatusEffect)(object)sE_Berserk);
			return sE_Berserk;
		}

		public static StatusEffect RegisterCustomSE(StatusEffect customSE, string customEffectName)
		{
			((Object)customSE).name = customEffectName;
			CustomSE.CustomSEs.Add(customSE);
			return customSE;
		}

		[HarmonyPriority(700)]
		private static void Patch_ObjectDBInit(ObjectDB __instance)
		{
			foreach (StatusEffect customSE in CustomSE.CustomSEs)
			{
				if (!__instance.m_StatusEffects.Contains(customSE))
				{
					__instance.m_StatusEffects.Add(customSE);
				}
			}
			__instance.UpdateItemHashes();
		}

		[HarmonyPriority(700)]
		private static void Patch_ZNetSceneAwake(ZNetScene __instance)
		{
			foreach (KeyValuePair<SE_Item, string> addToPrefab in CustomSE.AddToPrefabs)
			{
				try
				{
					GameObject prefab = __instance.GetPrefab(addToPrefab.Value);
					ItemDrop val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<ItemDrop>() : prefab.GetComponentInChildren<ItemDrop>());
					Aoe val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Aoe>() : prefab.GetComponentInChildren<Aoe>());
					EffectArea val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<EffectArea>() : prefab.GetComponentInChildren<EffectArea>());
					if (Object.op_Implicit((Object)(object)val))
					{
						switch (addToPrefab.Key.Type)
						{
						case EffectType.Equip:
							val.m_itemData.m_shared.m_equipStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Attack:
							val.m_itemData.m_shared.m_attackStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Consume:
							val.m_itemData.m_shared.m_consumeStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Set:
							val.m_itemData.m_shared.m_setSize = 1;
							val.m_itemData.m_shared.m_setName = ((Object)addToPrefab.Key.Effect).name;
							val.m_itemData.m_shared.m_setStatusEffect = addToPrefab.Key.Effect;
							break;
						default:
							throw new ArgumentOutOfRangeException();
						}
					}
					else if (Object.op_Implicit((Object)(object)val2))
					{
						val2.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else if (Object.op_Implicit((Object)(object)val3))
					{
						val3.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else
					{
						Debug.LogWarning((object)("The prefab '" + ((Object)prefab).name + "' does not have an ItemDrop, AOE, or EffectArea component. Cannot add the StatusEffect to the prefab."));
					}
				}
				catch (Exception arg)
				{
					Debug.LogWarning((object)$"BROKE : {arg}");
				}
			}
		}
	}
}
namespace ItemManager
{
	[PublicAPI]
	public enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[PublicAPI]
	public enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public 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
			});
		}
	}
	[PublicAPI]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

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

		public void Add(string customTable, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				level = level,
				custom = customTable
			});
		}
	}
	[PublicAPI]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	public class ItemRecipe
	{
		public readonly RequiredResourceList RequiredItems = new RequiredResourceList();

		public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList();

		public readonly CraftingStationList Crafting = new CraftingStationList();

		public int CraftAmount = 1;

		public bool RequireOnlyOneIngredient;

		public float QualityResultAmountMultiplier = 1f;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		public ConfigEntryBase RecipeIsActive;
	}
	[PublicAPI]
	public class Trade
	{
		public Trader Trader;

		public uint Price;

		public uint Stack = 1u;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		public string RequiredGlobalKey;
	}
	[PublicAPI]
	[Flags]
	public enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	public struct Requirement
	{
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(1)]
		public string itemName;

		public int amount;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		public ConfigEntry<int> amountConfig;

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

		public int level;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		public string custom;
	}
	[Flags]
	public enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[PublicAPI]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = max.GetValueOrDefault(min),
				levelMultiplier = levelMultiplier
			});
		}
	}
	public struct DropTarget
	{
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(1)]
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
	[PublicAPI]
	[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
	[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(1)]
	public class Item
	{
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		private class ItemConfig
		{
			[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> craft;

			[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(new byte[] { 2, 1 })]
			public ConfigEntry<string> upgrade;

			public ConfigEntry<CraftingTable> table;

			public ConfigEntry<int> tableLevel;

			public ConfigEntry<string> customTable;

			[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
			public ConfigEntry<int> maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient;

			public ConfigEntry<float> qualityResultAmountMultiplier;
		}

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		private class TraderConfig
		{
			public ConfigEntry<Trader> trader;

			public ConfigEntry<uint> price;

			public ConfigEntry<uint> stack;

			public ConfigEntry<string> requiredGlobalKey;
		}

		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)]
		private class RequirementQuality
		{
			public int quality;
		}

		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(2)]
		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string Category;

			[UsedImplicitly]
			[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;

			public Func<bool> browsability;
		}

		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)]
		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)]
		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

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

			public SerializedRequirements(string reqs)
				: this(reqs.Split(new char[1] { ',' }).Select([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : "")));
			}

			[return: <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>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>)([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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();
				[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(2)]
				ItemDrop ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(0)]
		private class SerializedDrop
		{
			public readonly List<DropTarget> Drops;

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

			public SerializedDrop(string drops)
			{
				Drops = ((drops == "") ? ((IEnumerable<string>)Array.Empty<string>()) : ((IEnumerable<string>)drops.Split(new char[1] { ',' }))).Select([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0")));
			}

			[return: <954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
			private static Character fetchByName(ZNetScene netScene, string name)
			{
				GameObject prefab = netScene.GetPrefab(name);
				Character obj = ((prefab != null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					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;
			}
		}

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

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

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

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(new byte[] { 1, 1, 2 })]
		private static Dictionary<Recipe, ConfigEntryBase> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();

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

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

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

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

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

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable;

		private Configurability configurationVisible = Configurability.Full;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private TraderConfig traderConfig;

		public readonly GameObject Prefab;

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

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

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

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

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

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

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private LocalizeKey _name;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private LocalizeKey _description;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static object configManager;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static Localization _english;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static object _configSync;

		private Configurability configurability => Configurable ?? DefaultConfigurability;

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

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

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

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase RecipeIsActive
		{
			[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(2)]
			get
			{
				return this[""].RecipeIsActive;
			}
			[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(2)]
			set
			{
				this[""].RecipeIsActive = value;
			}
		}

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

		public bool RequireOnlyOneIngredient
		{
			get
			{
				return this[""].RequireOnlyOneIngredient;
			}
			set
			{
				this[""].RequireOnlyOneIngredient = value;
			}
		}

		public float QualityResultAmountMultiplier
		{
			get
			{
				return this[""].QualityResultAmountMultiplier;
			}
			set
			{
				this[""].QualityResultAmountMultiplier = value;
			}
		}

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

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

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

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

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<954c2ec0-5e0b-4b67-b82b-ffc13be76f76>Nullable(2)]
		private static object configSync
		{
			[<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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);
					}
				}
			}
		}

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

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

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

		internal static void Patch_FejdStartup()
		{
			//IL_0e8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_2155: Unknown result type (might be due to invalid IL or missing references)
			//IL_215f: Expected O, but got Unknown
			//IL_0f53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fac: Expected I4, but got Unknown
			//IL_0b79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b83: 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_10e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e5: Invalid comparison between Unknown and I4
			//IL_10e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_10eb: Invalid comparison between Unknown and I4
			//IL_0c9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca6: Expected O, but got Unknown
			//IL_0d47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d51: Expected O, but got Unknown
			//IL_10ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f1: 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_0dfb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e05: Expected O, but got Unknown
			//IL_12ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f1: Invalid comparison between Unknown and I4
			//IL_12f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f9: 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_12fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ff: Invalid comparison between Unknown and I4
			//IL_13d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_13d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_13db: Unknown result type (might be due to invalid IL or missing references)
			//IL_13de: Invalid comparison between Unknown and I4
			//IL_13e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e4: 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_1453: Unknown result type (might be due to invalid IL or missing references)
			//IL_1456: Unknown result type (might be due to invalid IL or missing references)
			//IL_1458: 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_145a: Unknown result type (might be due to invalid IL or missing references)
			//IL_145e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1460: Invalid comparison between Unknown and I4
			//IL_1462: Unknown result type (might be due to invalid IL or missing references)
			//IL_1466: Invalid comparison between Unknown and I4
			//IL_15a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_15a6: Invalid comparison between Unknown and I4
			//IL_17a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_17aa: Invalid comparison between Unknown and I4
			//IL_1873: Unknown result type (might be due to invalid IL or missing references)
			//IL_1878: Unknown result type (might be due to invalid IL or missing references)
			//IL_187a: Unknown result type (might be due to invalid IL or missing references)
			//IL_187e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1880: Invalid comparison between Unknown and I4
			//IL_18ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_18f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_18f4: Invalid comparison between Unknown and I4
			//IL_1519: Unknown result type (might be due to invalid IL or missing references)
			//IL_151e: Unknown result type (might be due to invalid IL or missing references)
			//IL_18f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_18fa: Invalid comparison between Unknown and I4
			//IL_18fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1900: Invalid comparison between Unknown and I4
			//IL_1d6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d70: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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([<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>NullableContext(0)] (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item3 = item4;
					string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim();
					string localizedName = Localization.instance.Localize(name2).Trim();
					int order = 0;
					if ((item3.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>();
						foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item5;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 += [<5ef0fbef-3fa6-44a9-bba9-1d9a67d09f2e>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 Spee