Decompiled source of NoFogBruh v2.0.9

plugins/NoFogBruh.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
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.Net.Http;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using NoFogBruh.Configuration;
using NoFogBruh.Features;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.PostProcessing;
using UnityEngine.UI;
using Vapok.Common.Abstractions;
using Vapok.Common.Managers;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Managers.Creature;
using Vapok.Common.Managers.LocalizationManager;
using Vapok.Common.Managers.Location;
using Vapok.Common.Managers.PieceManager;
using Vapok.Common.Managers.Skill;
using Vapok.Common.Managers.Splash;
using Vapok.Common.Managers.StatusEffects;
using Vapok.Common.Managers.Telemetry;
using Vapok.Common.Shared;
using Vapok.Common.Tools;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoFogBruh")]
[assembly: AssemblyDescription("A Valheim Mod that Removes Fog from the Game.  No Fog Bruh!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Vapok Gaming")]
[assembly: AssemblyProduct("NoFogBruh")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("997CB563-FCC7-44B7-8F71-069747D27CC5")]
[assembly: AssemblyFileVersion("2.0.9.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NoFogBruh
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("vapok.mods.nofogbruh", "No Fog Bruh", "2.0.9")]
	[SynchronizationMode(/*Could not decode attribute arguments.*/)]
	public class NoFogBruh : BaseUnityPlugin, IPluginInfo
	{
		public class Waiting
		{
			public event EventHandler StatusChanged;

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

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

		private const string _displayName = "No Fog Bruh";

		private const string _version = "2.0.9";

		public static bool ValheimAwake;

		public static Waiting Waiter;

		private static NoFogBruh _instance;

		private static ConfigSyncBase _config;

		private static ILogIt _log;

		private Harmony _harmony;

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

		public string DisplayName => "No Fog Bruh";

		public string Version => "2.0.9";

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

		public static ILogIt Log => _log;

		[UsedImplicitly]
		private void Awake()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Invalid comparison between Unknown and I4
			_instance = this;
			Waiter = new Waiting();
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			LogManager.Init(PluginId, out _log);
			Initializer.LoadManagers(localization);
			_config = new ConfigRegistry(_instance);
			ModSplashManager.Register(new ModSplashDossier(_instance)
			{
				Tagline = "Configurable fog and environmental mist removal across biomes and weather conditions.",
				ShowOnStartup = ConfigRegistry.ShowSplashOnStartup,
				EnableTelemetry = ConfigRegistry.EnableTelemetry
			});
			Localizer.Waiter.StatusChanged += InitializeModule;
			DisableFogComponent.FeatureInitialized = true;
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				InitializeModule(this, EventArgs.Empty);
			}
		}

		public void InitializeModule(object send, EventArgs args)
		{
			if (!ValheimAwake)
			{
				ConfigRegistry.Waiter.ConfigurationComplete(configDone: true);
				ValheimAwake = true;
			}
		}

		private void OnDestroy()
		{
			FogTargetManager.Reset();
			_instance = null;
		}
	}
}
namespace NoFogBruh.Patches
{
	public class FejdStartupPatches
	{
		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		[HarmonyAfter(new string[] { "org.bepinex.helpers.LocalizationManager" })]
		[HarmonyBefore(new string[] { "org.bepinex.helpers.ItemManager" })]
		public static class FejdStartupAwakePatch
		{
			private static void Prefix()
			{
				FogTargetManager.Reset();
				NoFogBruh.Waiter.ValheimIsAwake(awakeFlag: true);
			}
		}
	}
}
namespace NoFogBruh.Features
{
	public class DisableFogComponent
	{
		[HarmonyPatch(typeof(EnvMan), "SetEnv")]
		private static class EnvManSetEnvPatch
		{
			private static void Postfix(EnvMan __instance, EnvSetup env)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				if ((int)SystemInfo.graphicsDeviceType != 4)
				{
					if (!EnableFog.Value)
					{
						RenderSettings.fogDensity = 0f;
					}
					if (!((Object)(object)EnvMan.instance == (Object)null) && env != null)
					{
						FogTargetManager.OnSetEnv(env.m_envObject);
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "Update")]
		private static class EnvManUpdatePatch
		{
			private static readonly int _snowGlintStrengthId = Shader.PropertyToID("_SnowGlintStrength");

			private static void Postfix(EnvMan __instance)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				if ((int)SystemInfo.graphicsDeviceType != 4 && !EnableSnowGlint.Value)
				{
					Shader.SetGlobalFloat(_snowGlintStrengthId, 0f);
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetParticleArrayEnabled")]
		private static class EnvManSetParticleArrayEnabledPatch
		{
			private static void Postfix(GameObject[] psystems, bool enabled)
			{
				if (psystems == null)
				{
					return;
				}
				GameObject[] array;
				if (!EnableMistEmitter.Value)
				{
					array = psystems;
					foreach (GameObject val in array)
					{
						if (!((Object)(object)val == (Object)null))
						{
							MistEmitter componentInChildren = val.GetComponentInChildren<MistEmitter>();
							if ((Object)(object)componentInChildren != (Object)null)
							{
								((Behaviour)componentInChildren).enabled = false;
							}
						}
					}
				}
				if (EnableDistantFog.Value)
				{
					return;
				}
				array = psystems;
				foreach (GameObject val2 in array)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						DistantFogEmitter componentInChildren2 = val2.GetComponentInChildren<DistantFogEmitter>();
						if ((Object)(object)componentInChildren2 != (Object)null)
						{
							componentInChildren2.SetEmit(false);
							((Behaviour)componentInChildren2).enabled = false;
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(ParticleMist), "Update")]
		private static class ParticleMistUpdatePatch
		{
			private static bool Prefix(ParticleMist __instance)
			{
				if (!EnableParticleMist.Value)
				{
					if ((Object)(object)__instance.m_ps != (Object)null && __instance.m_ps.particleCount > 0)
					{
						__instance.m_ps.Clear();
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(DistantFogEmitter), "Update")]
		private static class DistantFogEmitterUpdatePatch
		{
			private static bool Prefix(DistantFogEmitter __instance)
			{
				if (!EnableDistantFog.Value)
				{
					__instance.SetEmit(false);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PostProcessingBehaviour), "OnPreRender")]
		private static class PostProcessingBehaviourPatch
		{
			public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> instrs = instructions.ToList();
				FieldInfo ambientComponentField = AccessTools.DeclaredField(typeof(PostProcessingBehaviour), "m_AmbientOcclusion");
				FieldInfo fogComponentField = AccessTools.DeclaredField(typeof(PostProcessingBehaviour), "m_FogComponent");
				int skipstopA = 0;
				bool partADone = false;
				int skipstopB = 0;
				int i = 0;
				while (i < instrs.Count)
				{
					if (!partADone)
					{
						yield return instrs[i];
						if (i > 6 && instrs[i].opcode == OpCodes.Call && instrs[i + 1].opcode == OpCodes.Ldarg_0 && instrs[i + 2].opcode == OpCodes.Ldarg_0 && instrs[i + 3].opcode == OpCodes.Ldfld && instrs[i + 3].operand.Equals(ambientComponentField) && instrs[i + 4].opcode == OpCodes.Call)
						{
							CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
							if (instrs[i].labels.Count > 0)
							{
								CodeInstructionExtensions.MoveLabelsTo(instrs[i], val);
							}
							yield return val;
							yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
							yield return new CodeInstruction(OpCodes.Ldfld, (object)ambientComponentField);
							yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(DisableFogComponent), "SetAmbientSetting", (Type[])null, (Type[])null));
							skipstopA = i + 4;
							partADone = true;
						}
					}
					else
					{
						if ((skipstopB == 0 && i > skipstopA) || (i > skipstopB && skipstopB != 0))
						{
							yield return instrs[i];
						}
						if (i > 6 && instrs[i].opcode == OpCodes.Call && instrs[i + 1].opcode == OpCodes.Ldarg_0 && instrs[i + 2].opcode == OpCodes.Ldarg_0 && instrs[i + 3].opcode == OpCodes.Ldfld && instrs[i + 3].operand.Equals(fogComponentField) && instrs[i + 4].opcode == OpCodes.Call)
						{
							CodeInstruction val2 = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
							if (instrs[i].labels.Count > 0)
							{
								CodeInstructionExtensions.MoveLabelsTo(instrs[i], val2);
							}
							yield return val2;
							yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
							yield return new CodeInstruction(OpCodes.Ldfld, (object)fogComponentField);
							yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(DisableFogComponent), "SetFogSetting", (Type[])null, (Type[])null));
							skipstopB = i + 4;
						}
					}
					int num = i + 1;
					i = num;
				}
			}
		}

		public static bool FeatureInitialized;

		public static ConfigEntry<bool> EnableFog;

		public static ConfigEntry<bool> EnableAmbientComponent;

		public static ConfigEntry<bool> EnableGroundMist;

		public static ConfigEntry<bool> EnableFogClouds;

		public static ConfigEntry<bool> EnableDistantFog;

		public static ConfigEntry<bool> EnableMistEmitter;

		public static ConfigEntry<bool> EnableFogOceanMist;

		public static ConfigEntry<bool> EnableInteriorDust;

		public static ConfigEntry<bool> EnableMountainCaveMist;

		public static ConfigEntry<bool> EnableSnowGlint;

		public static ConfigEntry<bool> EnableBlizzardMist;

		public static ConfigEntry<bool> EnableMistlandsMist;

		public static ConfigEntry<bool> EnableParticleMist;

		public static ConfigEntry<bool> EnableAshlandsMist;

		public static ConfigEntry<bool> EnableAshlandsFaderFx;

		public static ConfigEntry<bool> EnableDeepNorthMist;

		public static ConfigEntry<bool> EnableDeepNorthFaderFx;

		static DisableFogComponent()
		{
			ConfigRegistry.Waiter.StatusChanged += delegate
			{
				RegisterConfigurationFile();
				FogTargetManager.Initialize();
			};
		}

		private static void RegisterConfigurationFile()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Expected O, but got Unknown
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Expected O, but got Unknown
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Expected O, but got Unknown
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Expected O, but got Unknown
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Expected O, but got Unknown
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Expected O, but got Unknown
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Expected O, but got Unknown
			ConfigSyncBase.UnsyncedConfig("General", "Enable Fog Component", value: false, new ConfigDescription("When enabled, will enable fog as the Allfather imagined. When disabled, there will be no fog.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableFog);
			ConfigSyncBase.UnsyncedConfig("General", "Enable Ambient Occlusion Component", value: false, new ConfigDescription("Enables the overall occlusion fog that gives Valheim it's soft glow", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }), ref EnableAmbientComponent);
			ConfigSyncBase.UnsyncedConfig("General", "Enable Ground Mist", value: false, new ConfigDescription("Enables Ground mist nearby the player", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 3
			} }), ref EnableGroundMist);
			ConfigSyncBase.UnsyncedConfig("General", "Enable Fog Clouds", value: false, new ConfigDescription("Enables Fog Clouds", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 4
			} }), ref EnableFogClouds);
			ConfigSyncBase.UnsyncedConfig("General", "Enable Distant Fog", value: false, new ConfigDescription("Enables Distant Fog visuals", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 5
			} }), ref EnableDistantFog);
			ConfigSyncBase.UnsyncedConfig("General", "Enable Mist Emitters", value: false, new ConfigDescription("Enables Mist Emitters for Particle Mist", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 6
			} }), ref EnableMistEmitter);
			ConfigSyncBase.UnsyncedConfig("Ocean", "Enable Ocean Mist", value: false, new ConfigDescription("Enables the mist when in Ocean", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableFogOceanMist);
			ConfigSyncBase.SyncedConfig("Black Forest", "Enable Troll Cave Mist", value: false, new ConfigDescription("Enables mist and fog on the interior parts of Troll Caves", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableInteriorDust);
			ConfigSyncBase.SyncedConfig("Mountain", "Enable Mountain Cave Mist", value: false, new ConfigDescription("Enables mist and fog on the interior parts of Mountains Caves", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableMountainCaveMist);
			ConfigSyncBase.UnsyncedConfig("Mountain", "Enable Snow Glint", value: false, new ConfigDescription("Enables blinding snow surface glint and specular reflections in Mountain snowfields", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }), ref EnableSnowGlint);
			ConfigSyncBase.UnsyncedConfig("Mountain", "Enable Snowstorm / Blizzard Fog", value: false, new ConfigDescription("Enables snowstorm, blizzard, and snow fog effects", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 3
			} }), ref EnableBlizzardMist);
			ConfigSyncBase.SyncedConfig("Mistlands", "Enable Mistlands Global Mist", value: false, new ConfigDescription("Enables magical mist in Mistlands", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableMistlandsMist);
			ConfigSyncBase.SyncedConfig("Mistlands", "Enable Particle Mist", value: false, new ConfigDescription("Enables dynamic volumetric particle mist in mist areas", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }), ref EnableParticleMist);
			ConfigSyncBase.UnsyncedConfig("Ashlands", "Enable Ashlands Global Mist", value: false, new ConfigDescription("Enables smokey mist in Ashlands", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableAshlandsMist);
			ConfigSyncBase.UnsyncedConfig("Ashlands", "Enable Ashlands FaderFX", value: false, new ConfigDescription("Enables fader effects that occur in Ashlands causing a foggy occlusion", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }), ref EnableAshlandsFaderFx);
			ConfigSyncBase.UnsyncedConfig("Deep North", "Enable Deep North Global Mist", value: false, new ConfigDescription("Enables mist and fader effects in Deep North", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnableDeepNorthMist);
			ConfigSyncBase.UnsyncedConfig("Deep North", "Enable Deep North FaderFX", value: false, new ConfigDescription("Enables fader effects that occur in Deep North causing a foggy occlusion", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }), ref EnableDeepNorthFaderFx);
		}

		private static void SetFogSetting(PostProcessingBehaviour instance, FogComponent fog)
		{
			if (EnableFog.Value)
			{
				instance.TryExecuteCommandBuffer<FogModel>((PostProcessingComponentCommandBuffer<FogModel>)(object)fog);
			}
			else
			{
				instance.RemoveCommandBuffer<FogModel>();
			}
		}

		private static void SetAmbientSetting(PostProcessingBehaviour instance, AmbientOcclusionComponent fog)
		{
			if (EnableAmbientComponent.Value)
			{
				instance.TryExecuteCommandBuffer<AmbientOcclusionModel>((PostProcessingComponentCommandBuffer<AmbientOcclusionModel>)(object)fog);
			}
			else
			{
				instance.RemoveCommandBuffer<AmbientOcclusionModel>();
			}
		}
	}
	public static class FogTargetManager
	{
		private class FogTarget
		{
			public ConfigEntry<bool> Config;

			public GameObject Target;

			public string RelativePath;

			public string LocationListPrefix;
		}

		private const float CheckIntervalSeconds = 3f;

		private const string EnvironmentRootPath = "_GameMain/_Environment";

		private static readonly List<FogTarget> _targets = new List<FogTarget>();

		private static Transform _environmentRoot;

		private static GameObject _lastEnvObject;

		private static float _nextCheckTime;

		private static bool _allTargetsResolved;

		private static bool _initialized;

		public static void Initialize()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			if (!_initialized && (int)SystemInfo.graphicsDeviceType != 4)
			{
				_initialized = true;
				_targets.Clear();
				RegisterTarget(DisableFogComponent.EnableGroundMist, "FollowPlayer/GroundMist");
				RegisterTarget(DisableFogComponent.EnableFog, "FollowPlayer/Mist");
				RegisterTarget(DisableFogComponent.EnableFogClouds, "FollowPlayer/FogClouds");
				RegisterTarget(DisableFogComponent.EnableInteriorDust, "FollowPlayer/InteriorDust");
				RegisterTarget(DisableFogComponent.EnableBlizzardMist, "FollowPlayer/SnowStorm");
				RegisterTarget(DisableFogComponent.EnableBlizzardMist, "FollowPlayer/Blizzard");
				RegisterTarget(DisableFogComponent.EnableFogOceanMist, "OceanMist");
				RegisterTarget(DisableFogComponent.EnableDistantFog, "Distant_fog_planes");
				RegisterLocationTarget(DisableFogComponent.EnableMistlandsMist, "_LocationList_Mistlands", "environment_effects/FollowPlayer/Mistlands_Globalmist");
				RegisterLocationTarget(DisableFogComponent.EnableMountainCaveMist, "_LocationList_MountainCaves", "environment/followplayer/env_mountain_cave/mist");
				RegisterLocationTarget(DisableFogComponent.EnableMountainCaveMist, "_LocationList_MountainCaves", "environment/followplayer/env_mountain_cave_hildir/mist");
				RegisterLocationTarget(DisableFogComponent.EnableAshlandsMist, "_LocationList_Ashlands", "environment_effects/FollowPlayer/Ashlands_Misty");
				RegisterLocationTarget(DisableFogComponent.EnableAshlandsFaderFx, "_LocationList_Ashlands", "environment_effects/FollowPlayer/Ashlands_FaderFX");
				RegisterLocationTarget(DisableFogComponent.EnableDeepNorthMist, "_LocationList_DeepNorth", "environment_effects/FollowPlayer/DeepNorth_Misty");
				RegisterLocationTarget(DisableFogComponent.EnableDeepNorthFaderFx, "_LocationList_DeepNorth", "environment_effects/FollowPlayer/DeepNorth_FaderFX");
				ResolveTargets();
				ApplyAll();
			}
		}

		private static void RegisterTarget(ConfigEntry<bool> config, string relativePath)
		{
			FogTarget target = new FogTarget
			{
				Config = config,
				RelativePath = relativePath,
				LocationListPrefix = null
			};
			if (config != null)
			{
				config.SettingChanged += delegate
				{
					ApplyTarget(target);
				};
			}
			_targets.Add(target);
		}

		private static void RegisterLocationTarget(ConfigEntry<bool> config, string locationListPrefix, string relativePath)
		{
			FogTarget target = new FogTarget
			{
				Config = config,
				RelativePath = relativePath,
				LocationListPrefix = locationListPrefix
			};
			if (config != null)
			{
				config.SettingChanged += delegate
				{
					ApplyTarget(target);
				};
			}
			_targets.Add(target);
		}

		public static void OnSetEnv(GameObject currentEnvObject)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			if (_initialized && (int)SystemInfo.graphicsDeviceType != 4)
			{
				if ((Object)(object)currentEnvObject != (Object)(object)_lastEnvObject)
				{
					_lastEnvObject = currentEnvObject;
					ApplyAll();
				}
				if (!_allTargetsResolved && Time.time >= _nextCheckTime)
				{
					_nextCheckTime = Time.time + 3f;
					ResolveTargets();
					ApplyAll();
				}
			}
		}

		public static void ResolveTargets()
		{
			if ((Object)(object)_environmentRoot == (Object)null)
			{
				GameObject val = GameObject.Find("_GameMain/_Environment");
				if ((Object)(object)val != (Object)null)
				{
					_environmentRoot = val.transform;
				}
			}
			List<LocationList> allLocationLists = LocationList.GetAllLocationLists();
			bool flag = allLocationLists != null && allLocationLists.Count > 0;
			bool allTargetsResolved = true;
			for (int i = 0; i < _targets.Count; i++)
			{
				FogTarget fogTarget = _targets[i];
				if ((Object)(object)fogTarget.Target != (Object)null)
				{
					continue;
				}
				if (fogTarget.LocationListPrefix == null)
				{
					if ((Object)(object)_environmentRoot != (Object)null)
					{
						Transform val2 = _environmentRoot.Find(fogTarget.RelativePath);
						if ((Object)(object)val2 != (Object)null)
						{
							fogTarget.Target = ((Component)val2).gameObject;
						}
					}
				}
				else if (flag)
				{
					for (int j = 0; j < allLocationLists.Count; j++)
					{
						LocationList val3 = allLocationLists[j];
						if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)null) && ((Object)((Component)val3).gameObject).name.StartsWith(fogTarget.LocationListPrefix))
						{
							Transform val4 = ((Component)val3).transform.Find(fogTarget.RelativePath);
							if ((Object)(object)val4 != (Object)null)
							{
								fogTarget.Target = ((Component)val4).gameObject;
								break;
							}
						}
					}
				}
				if ((Object)(object)fogTarget.Target == (Object)null)
				{
					allTargetsResolved = false;
				}
			}
			_allTargetsResolved = allTargetsResolved;
		}

		public static void ApplyAll()
		{
			for (int i = 0; i < _targets.Count; i++)
			{
				ApplyTarget(_targets[i]);
			}
		}

		private static void ApplyTarget(FogTarget target)
		{
			if ((Object)(object)target.Target != (Object)null && target.Config != null)
			{
				bool value = target.Config.Value;
				if (target.Target.activeSelf != value)
				{
					target.Target.SetActive(value);
				}
			}
		}

		public static void Reset()
		{
			_environmentRoot = null;
			_lastEnvObject = null;
			_allTargetsResolved = false;
			_nextCheckTime = 0f;
			for (int i = 0; i < _targets.Count; i++)
			{
				_targets[i].Target = null;
			}
		}
	}
}
namespace NoFogBruh.Configuration
{
	public class ConfigRegistry : ConfigSyncBase
	{
		internal static ConfigEntry<bool> ShowSplashOnStartup;

		internal static ConfigEntry<bool> EnableTelemetry;

		public static Waiting Waiter;

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

		public sealed override void InitializeConfigurationSettings()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			if (ConfigSyncBase._config != null)
			{
				ConfigSyncBase.UnsyncedConfig("Local Config", "Show Splash on Startup", value: true, new ConfigDescription("If enabled, displays the mod overview and links splash screen on game startup.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Order = 4
				} }), ref ShowSplashOnStartup);
				ConfigSyncBase.UnsyncedConfig("Local Config", "Enable Anonymous Telemetry", value: true, new ConfigDescription("If enabled, sends anonymous mod launch and heartbeat telemetry to help improve mod stability and track active versions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Order = 5
				} }), ref EnableTelemetry);
			}
		}
	}
	public class Waiting
	{
		public event EventHandler StatusChanged;

		public void ConfigurationComplete(bool configDone)
		{
			if (configDone)
			{
				this.StatusChanged?.Invoke(this, EventArgs.Empty);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ItemManager
{
	[PublicAPI]
	internal enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("blackforge")]
		BlackForge,
		[InternalName("piece_preptable")]
		FoodPreparationTable,
		[InternalName("piece_MeadCauldron")]
		MeadKetill,
		Custom
	}
	[PublicAPI]
	internal enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	internal class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	internal class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free;

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

		public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig,
				quality = quality
			});
		}
	}
	[PublicAPI]
	internal class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

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

		public void Add(string customTable, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				level = level,
				custom = customTable
			});
		}
	}
	[PublicAPI]
	internal class ItemRecipe
	{
		public readonly RequiredResourceList RequiredItems = new RequiredResourceList();

		public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList();

		public readonly CraftingStationList Crafting = new CraftingStationList();

		public int CraftAmount = 1;

		public bool RequireOnlyOneIngredient;

		public float QualityResultAmountMultiplier = 1f;

		public ConfigEntryBase? RecipeIsActive;
	}
	[PublicAPI]
	internal class Trade
	{
		public Trader Trader;

		public uint Price;

		public uint Stack = 1u;

		public string? RequiredGlobalKey;
	}
	[PublicAPI]
	[Flags]
	internal enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	internal struct Requirement
	{
		public string itemName;

		public int amount;

		public ConfigEntry<int>? amountConfig;

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

		public int level;

		public string? custom;
	}
	[Flags]
	internal enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[PublicAPI]
	internal class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true, bool dontScale = false)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min),
				levelMultiplier = levelMultiplier,
				dontScale = dontScale
			});
		}
	}
	internal struct DropTarget
	{
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;

		public bool dontScale;
	}
	internal enum Toggle
	{
		On = 1,
		Off = 0
	}
	[PublicAPI]
	internal class Item
	{
		private class ItemConfig
		{
			public ConfigEntry<string>? craft;

			public ConfigEntry<string>? upgrade;

			public ConfigEntry<CraftingTable> table;

			public ConfigEntry<int> tableLevel;

			public ConfigEntry<string> customTable;

			public ConfigEntry<int>? maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient;

			public ConfigEntry<float> qualityResultAmountMultiplier;
		}

		private class TraderConfig
		{
			public ConfigEntry<Trader> trader;

			public ConfigEntry<uint> price;

			public ConfigEntry<uint> stack;

			public ConfigEntry<string> requiredGlobalKey;
		}

		private class RequirementQuality
		{
			public int quality;
		}

		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string? Category;

			[UsedImplicitly]
			public Action<ConfigEntryBase>? CustomDrawer;

			[UsedImplicitly]
			public Action<IUguiDrawerScope>? CustomUguiDrawer;

			public Func<bool>? browsability;
		}

		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		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(delegate(string r)
				{
					string[] array = r.Split(new char[1] { ':' });
					int result;
					int result2;
					return new Requirement
					{
						itemName = array[0],
						amount = ((array.Length <= 1 || !int.TryParse(array[1], out result)) ? 1 : result),
						quality = ((array.Length > 2 && int.TryParse(array[2], out result2)) ? result2 : 0)
					};
				}).ToList())
			{
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select((Requirement r) => $"{r.itemName}:{r.amount}"));
			}

			public static ItemDrop? fetchByName(ObjectDB objectDB, string name)
			{
				GameObject itemPrefab = objectDB.GetItemPrefab(name);
				ItemDrop obj = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					LogManager.Log.Warning("The required item '" + name + "' does not exist.");
				}
				return obj;
			}

			public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade)
			{
				//IL_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>)((Requirement r) => r.itemName), (Func<Requirement, Requirement>)delegate(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((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();
				ItemDrop? ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		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(delegate(string r)
				{
					string[] array = r.Split(new char[1] { ':' });
					if (array.Length <= 2 || !int.TryParse(array[2], out var result))
					{
						result = 1;
					}
					if (array.Length <= 3 || !int.TryParse(array[3], out var result2))
					{
						result2 = result;
					}
					bool levelMultiplier = array.Length <= 4 || array[4] != "0";
					float result3;
					return new DropTarget
					{
						creature = array[0],
						chance = ((array.Length > 1 && float.TryParse(array[1], out result3)) ? result3 : 1f),
						min = result,
						max = result2,
						levelMultiplier = levelMultiplier
					};
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select((DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0")));
			}

			private static Character? fetchByName(ZNetScene netScene, string name)
			{
				GameObject prefab = netScene.GetPrefab(name);
				Character obj = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					LogManager.Log.Debug("The drop target character '" + name + "' does not exist.");
				}
				return obj;
			}

			public Dictionary<Character, Drop> toCharacterDrops(ZNetScene netScene, GameObject item, bool adjustLevel = false, bool adjustScaling = false)
			{
				//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_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: 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 = adjustLevel,
							m_dontScale = !adjustScaling
						};
					}
				}
				return dictionary;
			}
		}

		private static bool _initialized = false;

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

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

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

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();

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

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

		private static Dictionary<Item, ConfigEntry<bool>> itemDropEnabledConfig = new Dictionary<Item, ConfigEntry<bool>>();

		private static Dictionary<Item, ConfigEntry<bool>> itemDropScalingConfig = new Dictionary<Item, ConfigEntry<bool>>();

		private static Dictionary<Item, ConfigEntry<bool>> itemDropLevelingConfig = new Dictionary<Item, ConfigEntry<bool>>();

		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 string SectionName = string.Empty;

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable;

		private Configurability configurationVisible = Configurability.Full;

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

		private static object? configManager;

		private static BaseUnityPlugin? _plugin;

		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;

		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase? RecipeIsActive
		{
			get
			{
				return this[""].RecipeIsActive;
			}
			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 ItemRecipe value))
				{
					return value;
				}
				return Recipes[name] = new ItemRecipe();
			}
		}

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Expected O, but got Unknown
				if ((Object)(object)_plugin == (Object)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((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		public static void Init()
		{
			if (!_initialized)
			{
				_initialized = true;
			}
		}

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

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

		public Item(GameObject prefab, bool skipRegistering = false)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				LogManager.Log?.Warning("Attempted to initialize Item with a null prefab.");
				Prefab = null;
				return;
			}
			if (!skipRegistering)
			{
				PrefabManager.RegisterPrefab(prefab, addToObjectDb: true);
			}
			Prefab = prefab;
			registeredItems.Add(this);
			ItemDrop component = Prefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				itemDropMap[component] = this;
				if (component.m_itemData != null)
				{
					component.m_itemData.m_dropPrefab = Prefab;
				}
			}
		}

		public void ToggleConfigurationVisibility(Configurability visible)
		{
			configurationVisible = visible;
			if (itemDropConfigs.TryGetValue(this, out ConfigEntry<string> value))
			{
				Toggle((ConfigEntryBase)(object)value, Configurability.Drop);
			}
			if (itemCraftConfigs.TryGetValue(this, out Dictionary<string, ItemConfig> value2))
			{
				foreach (ItemConfig value4 in value2.Values)
				{
					ToggleObj(value4, Configurability.Recipe);
				}
			}
			foreach (Conversion conversion in Conversions)
			{
				if (conversion.config != null)
				{
					ToggleObj(conversion.config, Configurability.Recipe);
				}
			}
			foreach (KeyValuePair<ConfigEntryBase, Action> statsConfig in statsConfigs)
			{
				Toggle(statsConfig.Key, Configurability.Stats);
				if ((visible & Configurability.Stats) != Configurability.Disabled)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				for (int i = 0; i < tags.Length; i++)
				{
					if (tags[i] is ConfigurationManagerAttributes configurationManagerAttributes)
					{
						configurationManagerAttributes.Browsable = (visible & check) != Configurability.Disabled && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability());
					}
				}
			}
			void ToggleObj(object obj, Configurability check)
			{
				FieldInfo[] fields = obj.GetType().GetFields();
				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()
		{
			object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager);
			if (obj is bool && (bool)obj)
			{
				configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
			}
		}

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

		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 List<Recipe> value))
			{
				return;
			}
			foreach (Recipe item in value)
			{
				item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements);
			}
		}

		internal static void Patch_FejdStartup()
		{
			//IL_11ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_11cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_2483: Unknown result type (might be due to invalid IL or missing references)
			//IL_2490: Expected O, but got Unknown
			//IL_1293: Unknown result type (might be due to invalid IL or missing references)
			//IL_1296: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ec: Expected I4, but got Unknown
			//IL_0c57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c69: Expected O, but got Unknown
			//IL_0d45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d57: Expected O, but got Unknown
			//IL_0dc6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd3: Expected O, but got Unknown
			//IL_0e3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4a: Expected O, but got Unknown
			//IL_1420: Unknown result type (might be due to invalid IL or missing references)
			//IL_1423: Unknown result type (might be due to invalid IL or missing references)
			//IL_1425: Invalid comparison between Unknown and I4
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Expected O, but got Unknown
			//IL_1427: Unknown result type (might be due to invalid IL or missing references)
			//IL_142b: Invalid comparison between Unknown and I4
			//IL_0fcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe9: Expected O, but got Unknown
			//IL_1079: Unknown result type (might be due to invalid IL or missing references)
			//IL_1095: Expected O, but got Unknown
			//IL_142d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1431: Invalid comparison between Unknown and I4
			//IL_112e: Unknown result type (might be due to invalid IL or missing references)
			//IL_114a: Expected O, but got Unknown
			//IL_162c: Unknown result type (might be due to invalid IL or missing references)
			//IL_162f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1631: Invalid comparison between Unknown and I4
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Expected O, but got Unknown
			//IL_1633: Unknown result type (might be due to invalid IL or missing references)
			//IL_1637: Unknown result type (might be due to invalid IL or missing references)
			//IL_1639: Invalid comparison between Unknown and I4
			//IL_163b: Unknown result type (might be due to invalid IL or missing references)
			//IL_163f: Invalid comparison between Unknown and I4
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Expected O, but got Unknown
			//IL_1714: Unknown result type (might be due to invalid IL or missing references)
			//IL_1719: Unknown result type (might be due to invalid IL or missing references)
			//IL_171b: Unknown result type (might be due to invalid IL or missing references)
			//IL_171e: Invalid comparison between Unknown and I4
			//IL_1720: Unknown result type (might be due to invalid IL or missing references)
			//IL_1724: Invalid comparison between Unknown and I4
			//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Expected O, but got Unknown
			//IL_1793: Unknown result type (might be due to invalid IL or missing references)
			//IL_1796: Unknown result type (might be due to invalid IL or missing references)
			//IL_1798: Invalid comparison between Unknown and I4
			//IL_179a: Unknown result type (might be due to invalid IL or missing references)
			//IL_179e: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a0: Invalid comparison between Unknown and I4
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: Expected O, but got Unknown
			//IL_17a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a6: Invalid comparison between Unknown and I4
			//IL_18e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_18e6: Invalid comparison between Unknown and I4
			//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Expected O, but got Unknown
			//IL_1ae3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1aea: Invalid comparison between Unknown and I4
			//IL_1bb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bb8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bba: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bc0: Invalid comparison between Unknown and I4
			//IL_1c2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c32: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c34: Invalid comparison between Unknown and I4
			//IL_1859: Unknown result type (might be due to invalid IL or missing references)
			//IL_185e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c36: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c3a: Invalid comparison between Unknown and I4
			//IL_1c3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c40: Invalid comparison between Unknown and I4
			//IL_20ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_20b0: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			if (DefaultConfigurability != Configurability.Disabled)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item3 in registeredItems.Where((Item i) => i.configurability != Configurability.Disabled))
				{
					Item item = item3;
					string text = (string.IsNullOrEmpty(item.SectionName) ? item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name : item.SectionName);
					string englishName = new Regex("['[\"\\]]").Replace(Localizer.GetTranslation("English", text), "").Trim();
					string localizedName = Localization.instance.Localize(text).Trim();
					int order = 0;
					if ((item.configurability & Configurability.Recipe) != Configurability.Disabled)
					{
						itemCraftConfigs[item] = new Dictionary<string, ItemConfig>();
						foreach (string item4 in item.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item4;
							string text2 = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (configKey == "" && item.Configurable.HasValue && item.Crafting.Stations.Count == 0)
							{
								item.Crafting.Add(CraftingTable.Disabled, 1);
							}
							if (!item.Recipes.ContainsKey(configKey) || item.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig = (itemCraftConfigs[item][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							ConfigSyncBase.SyncedConfig(englishName, "Crafting Station" + text2, item.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}), ref cfg.table);
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							ConfigSyncBase.SyncedConfig(englishName, "Custom Crafting Station" + text2, item.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }), ref cfg.customTable);
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							ConfigSyncBase.SyncedConfig(englishName, "Crafting Station Level" + text2, item.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), ref cfg.tableLevel);
							cfg.tableLevel.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out List<Recipe> value))
								{
									value.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								ConfigSyncBase.SyncedConfig(englishName, "Maximum Crafting Station Level" + text2, (item.MaximumRequiredStationLevel == int.MaxValue) ? (item.Recipes[configKey].Crafting.Stations.First().level + item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), ref cfg.maximumTableLevel);
							}
							ConfigSyncBase.SyncedConfig(englishName, "Require only one resource" + text2, item.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									browsability = TableLevelBrowsability,
									Browsable = (TableLevelBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}), ref cfg.requireOneIngredient);
							ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = QualityResultBrowsability,
								Browsable = (QualityResultBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out List<Recipe> value))
								{
									foreach (Recipe item5 in value)
									{
										item5.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							ConfigSyncBase.SyncedConfig(englishName, "Quality Multiplier" + text2, item.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes }), ref cfg.qualityResultAmountMultiplier);
							cfg.qualityResultAmountMultiplier.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out List<Recipe> value))
								{
									foreach (Recipe item6 in value)
									{
										item6.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item.Recipes[configKey].RequiredItems.Free || item.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig3("Crafting Costs" + text2, new SerializedRequirements(item.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false);
							}
							ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
							if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_maxQuality > 1 && (!item.Recipes[configKey].RequiredUpgradeItems.Free || item.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig3("Upgrading Costs" + text2, new SerializedRequirements(item.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true);
							}
							if (cfg.craft != null)
							{
								cfg.craft.SettingChanged += ConfigChanged;
							}
							if (cfg.upgrade != null)
							{
								cfg.upgrade.SettingChanged += ConfigChanged;
							}
							void ConfigChanged(object o, EventArgs e)
							{
								item.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? ""));
							}
							bool CustomTableBrowsability()
							{
								return cfg.table.Value == CraftingTable.Custom;
							}
							bool ItemBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							bool QualityResultBrowsability()
							{
								return cfg.requireOneIngredient.Value == Toggle.On;
							}
							void TableConfigChanged(object o, EventArgs e)
							{
								item.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value);
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item7 in hideWhenNoneAttributes)
								{
									item7.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig3(string name, string value, string desc, bool isUpgrade)
							{
								//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
								//IL_00d7: Expected O, but got Unknown
								ConfigEntry<string> itemCfg = null;
								ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable(item, isUpgrade),
									CustomUguiDrawer = delegate(IUguiDrawerScope ui)
									{
										DrawRequirementsConfigTableUgui(ui, (ConfigEntryBase)(object)itemCfg);
									},
									Order = (order -= 1),
									browsability = ItemBrowsability,
									Browsable = (ItemBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								};
								hideWhenNoneAttributes.Add(configurationManagerAttributes3);
								ConfigSyncBase.SyncedConfig(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 }), ref itemCfg);
								return itemCfg;
							}
						}
						if ((item.configurability & Configurability.Drop) != Configurability.Disabled)
						{
							ConfigEntry<bool> dropsEnabledConfig = null;
							ConfigSyncBase.SyncedConfig(englishName, "Drops Enabled", value: false, new ConfigDescription("Enables " + englishName + " drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							}), ref dropsEnabledConfig);
							itemDropEnabledConfig[item] = dropsEnabledConfig;
							ConfigEntry<string> dropConfig = null;
							ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes
							{
								CustomDrawer = drawDropsConfigTable,
								CustomUguiDrawer = delegate(IUguiDrawerScope ui)
								{
									DrawDropsConfigTableUgui(ui, (ConfigEntryBase)(object)dropConfig);
								},
								Category = localizedName,
								Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
							};
							ConfigSyncBase.SyncedConfig(englishName, "Drops from", new SerializedDrop(item.DropsFrom.Drops).ToString(), new ConfigDescription("Creatures " + englishName + " drops from", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 }), ref dropConfig);
							itemDropConfigs[item] = dropConfig;
							ConfigEntry<bool> configEntry = null;
							ConfigSyncBase.SyncedConfig(englishName, "Adjust Drop Count By Level", value: false, new ConfigDescription("Enables Level/Star Factor on Drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							}), ref configEntry);
							itemDropLevelingConfig[item] = configEntry;
							ConfigEntry<bool> configEntry2 = null;
							ConfigSyncBase.SyncedConfig(englishName, "Adjust Drop Count by World Scaling", value: false, new ConfigDescription("Enables Scaling Factor on Drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							}), ref configEntry2);
							itemDropScalingConfig[item] = configEntry2;
							dropsEnabledConfig.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							configEntry2.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							configEntry.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							dropConfig.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							item.UpdateCharacterDrop(dropsEnabledConfig.Value);
						}
						for (int num = 0; num < item.Conversions.Count; num++)
						{
							string text3 = ((item.Conversions.Count > 1) ? $"{num + 1}. " : "");
							Conversion conversion = item.Conversions[num];
							conversion.config = new Conversion.ConversionConfig();
							int index = num;
							ConfigSyncBase.SyncedConfig(englishName, text3 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}), ref conversion.config.input);
							conversion.config.input.SettingChanged += delegate
							{
								if (index < item.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop val = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item.conversions[index].m_from = val;
										UpdatePiece();
									}
								}
							};
							ConfigSyncBase.SyncedConfig(englishName, text3 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}), ref conversion.config.piece);
							conversion.config.piece.SettingChanged += delegate
							{
								UpdatePiece();
							};
							ConfigSyncBase.SyncedConfig(englishName, text3 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}), ref conversion.config.customPiece);
							conversion.config.customPiece.SettingChanged += delegate
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance))
								{
									string text4 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value)));
									string activePiece = conversion.config.activePiece;
									if (conversion.config.activePiece != null)
									{
										GameObject prefab = ZNetScene.instance.GetPrefab(conversion.config.activePiece);
										Smelter val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Smelter>() : null);
										if ((Object)(object)val != (Object)null)
										{
											int num4 = val.m_conversion.IndexOf(item.conversions[index]);
											if (num4 >= 0)
											{
												Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
												foreach (Smelter val2 in array3)
												{
													if ((Object)(object)val2 != (Object)null && Utils.GetPrefabName(((Component)val2).gameObject) == activePiece)
													{
														val2.m_conversion.RemoveAt(num4);
													}
												}
												val.m_conversion.RemoveAt(num4);
											}
										}
										conversion.config.activePiece = null;
									}
									if ((Object)(object)item.conversions[index].m_from != (Object)null && conversion.config.piece.Value != ConversionPiece.Disabled)
									{
										GameObject prefab2 = ZNetScene.instance.GetPrefab(text4);
										if ((Object)(object)prefab2 != (Object)null && (Object)(object)prefab2.GetComponent<Smelter>() != (Object)null)
										{
											conversion.config.activePiece = text4;
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val3 in array3)
											{
												if ((Object)(object)val3 != (Object)null && Utils.GetPrefabName(((Component)val3).gameObject) == text4)
												{
													val3.m_conversion.Add(item.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item.configurability & Configurability.Stats) != Configurability.Disabled)
					{
						item.statsConfigs.Clear();
						SharedData shared = item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ItemType itemType = shared.m_itemType;
						statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData val) => val.m_weight, delegate(SharedData val, float value)
						{
							val.m_weight = value;
						});
						statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData val) => val.m_value, delegate(SharedData val, int value)
						{
							val.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 val) => val.m_maxDurability, delegate(SharedData val, float value)
							{
								val.m_maxDurability = value;
							});
							statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData val) => val.m_durabilityPerLevel, delegate(SharedData val, float value)
							{
								val.m_durabilityPerLevel = value;
							});
							statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData val) => val.m_movementModifier, delegate(SharedData val, float value)
							{
								val.m_movementModifier = value;
							});
						}
						if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData val) => val.m_blockPower, delegate(SharedData val, float value)
							{
								val.m_blockPower = value;
							});
							statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData val) => val.m_blockPowerPerLevel, delegate(SharedData val, float value)
							{
								val.m_blockPowerPerLevel = value;
							});
							statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData val) => val.m_deflectionForce, delegate(SharedData val, float value)
							{
								val.m_deflectionForce = value;
							});
							statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData val) => val.m_deflectionForcePerLevel, delegate(SharedData val, float value)
							{
								val.m_deflectionForcePerLevel = value;
							});
							statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData val) => val.m_timedBlockBonus, delegate(SharedData val, float value)
							{
								val.m_timedBlockBonus = value;
							});
						}
						else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData val) => val.m_armor, delegate(SharedData val, float value)
							{
								val.m_armor = value;
							});
							statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData val) => val.m_armorPerLevel, delegate(SharedData val, float value)
							{
								val.m_armorPerLevel = value;
							});
						}
						SkillType skillType = shared.m_skillType;
						if (((int)skillType == 7 || (int)skillType == 12) ? true : false)
						{
							statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData val) => val.m_toolTier, delegate(SharedData val, int value)
							{
								val.m_toolTier = value;
							});
						}
						if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							Dictionary<DamageType, DamageModifier> modifiers = shared.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier);
							DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType));
							DamageType[] array = new DamageType[5];
							RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
							foreach (DamageType damageType in first.Except((IEnumerable<DamageType>)(object)array))
							{
								statcfg<DamageModifier>(((object)Unsafe.As<DamageType, DamageType>(ref damageType)/*cast due to .constrained prefix*/).ToString() + " Resistance", ((object)Unsafe.As<DamageType, DamageType>(ref damageType)/*cast due to .constrained prefix*/).ToString() + " resistance of " + englishName + ".", (SharedData _) => (!modifiers.TryGetValue(damageType, out var value)) ? DamageModifier.None : value, delegate(SharedData val2, DamageModifier value)
								{
									//IL_0002: Unknown result type (might be due to invalid IL or missing references)
									//IL_000b: Unknown result type (might be due to invalid IL or missing references)
									//IL_0010: Unknown result type (might be due to invalid IL or missing references)
									//IL_0018: Unknown result type (might be due to invalid IL or missing references)
									//IL_001d: Unknown result type (might be due to invalid IL or missing references)
									//IL_001e: Unknown result type (might be due to invalid IL or missing references)
									//IL_002a: Unknown result type (might be due to invalid IL or missing references)
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									//IL_0035: Unknown result type (might be due to invalid IL or missing references)
									//IL_0077: Unknown result type (might be due to invalid IL or missing references)
									//IL_0054: Unknown result type (might be due to invalid IL or missing references)
									DamageModPair val = new DamageModPair
									{
										m_type = damageType,
										m_modifier = (DamageModifier)value
									};
									for (int i = 0; i < val2.m_damageModifiers.Count; i++)
									{
										if (val2.m_damageModifiers[i].m_type == damageType)
										{
											if (value == DamageModifier.None)
											{
												val2.m_damageModifiers.RemoveAt(i);
											}
											else
											{
												val2.m_damageModifiers[i] = val;
											}
											return;
										}
									}
									if (value != DamageModifier.None)
									{
										val2.m_damageModifiers.Add(val);
									}
								});
							}
						}
						if ((int)itemType == 2 && shared.m_food > 0f)
						{
							statcfg<float>("Health", "Health value of " + englishName + ".", (SharedData val) => val.m_food, delegate(SharedData val, float value)
							{
								val.m_food = value;
							});
							statcfg<float>("Stamina", "Stamina value of " + englishName + ".", (SharedData val) => val.m_foodStamina, delegate(SharedData val, float value)
							{
								val.m_foodStamina = value;
							});
							statcfg<float>("Eitr", "Eitr value of " + englishName + ".", (SharedData val) => val.m_foodEitr, delegate(SharedData val, float value)
							{
								val.m_foodEitr = value;
							});
							statcfg<float>("Duration", "Duration of " + englishName + ".", (SharedData val) => val.m_foodBurnTime, delegate(SharedData val, float value)
							{
								val.m_foodBurnTime = value;
							});
							statcfg<float>("Health Regen", "Health regen value of " + englishName + ".", (SharedData val) => val.m_foodRegen, delegate(SharedData val, float value)
							{
								val.m_foodRegen = value;
							});
						}
						if ((int)shared.m_skillType == 10)
						{
							statcfg<float>("Health Cost", "Health cost of " + englishName + ".", (SharedData val) => val.m_attack.m_attackHealth, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackHealth = value;
							});
							statcfg<float>("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData val) => val.m_attack.m_attackHealthPercentage, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackHealthPercentage = value;
							});
						}
						skillType = shared.m_skillType;
						if (skillType - 9 <= 1)
						{
							statcfg<float>("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData val) => val.m_attack.m_attackEitr, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackEitr = value;
							});
						}
						if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Knockback", "Knockback of " + englishName + ".", (SharedData val) => val.m_attackForce, delegate(SharedData val, float value)
							{
								val.m_attackForce = value;
							});
							statcfg<float>("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData val) => val.m_backstabBonus, delegate(SharedData val, float value)
							{
								val.m_backstabBonus = value;
							});
							statcfg<float>("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData val) => val.m_attack.m_attackStamina, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackStamina = value;
							});
							SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_damage = val;
							});
							SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_slash = val;
							});
							SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_pierce = val;
							});
							SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_blunt = val;
							});
							SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_chop = val;
							});
							SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_pickaxe = val;
							});
							SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_fire = val;
							});
							SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_poison = val;
							});
							SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_frost = val;
							});
							SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_lightning = val;
							});
							SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_spirit = val;
							});
							if ((int)itemType == 4)
							{
								statcfg<int>("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData val) => val.m_attack.m_projectileBursts, delegate(SharedData val, int value)
								{
									val.m_attack.m_projectileBursts = value;
								});
								statcfg<float>("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData val) => val.m_attack.m_burstInterval, delegate(SharedData val, float value)
								{
									val.m_attack.m_burstInterval = value;
								});
								statcfg<float>("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData val) => val.m_attack.m_projectileAccuracyMin, delegate(SharedData val, float value)
								{
									val.m_attack.m_projectileAccuracyMin = value;
								});
								statcfg<float>("Accuracy", "Accuracy for " + englishName + ".", (SharedData val) => val.m_attack.m_projectileAccuracy, delegate(SharedData val, float value)
								{
									val.m_attack.m_projectileAccuracy = value;
								});
								statcfg<float>("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData val) => val.m_attack.m_projectileVelMin, delegate(SharedData val, float value)
								{
									val.m_attack.m_projectileVelMin = value;
								});
								statcfg<float>("Velocity", "Velocity for " + englishName + ".", (SharedData val) => val.m_attack.m_projectileVel, delegate(SharedData val, float value)
								{
									val.m_attack.m_projectileVel = value;
								});
								statcfg<float>("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData val) => val.m_attack.m_drawDurationMin, delegate(SharedData val, float value)
								{
									val.m_attack.m_drawDurationMin = value;
								});
								statcfg<float>("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData val) => val.m_attack.m_drawStaminaDrain, delegate(SharedData val, float value)
								{
									val.m_attack.m_drawStaminaDrain = value;
								});
							}
						}
					}
					List<ConfigurationManagerAttributes> traderAttributes;
					if ((item.configurability & Configurability.Trader) != Configurability.Disabled)
					{
						traderAttributes = new List<ConfigurationManagerAttributes>();
						ConfigEntry<Trader> configEntry3 = null;
						ConfigSyncBase.SyncedConfig(englishName, "Trader Selling", item.Trade.Trader, new ConfigDescription("Which traders sell " + englishName + ".", (AcceptableValueBase)null, new object[1]
						{
							new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								Browsable = ((item.configurationVisible & Configurability.Trader) != 0),
								Category = localizedName
							}
						}), ref configEntry3);
						item.traderConfig = new TraderConfig
						{
							trader = configEntry3
						};
						item.traderConfig.trader.SettingChanged += delegate
						{
							item.ReloadTraderConfiguration();
							foreach (ConfigurationManagerAttributes item8 in traderAttributes)
							{
								item8.Browsable = TraderBrowsability();
							}
							reloadConfigDisplay();
						};
						item.traderConfig.price = traderConfig<uint>("Trader Price", item.Trade.Price, "Price of " + englishName + " at the trader.");
						item.traderConfig.stack = traderConfig<uint>("Trader Stack", item.Trade.Stack, "Stack size of " + englishName + " in the trader. Also known as the number of items sold by a trader in one transaction.");
						item.traderConfig.requiredGlobalKey = traderConfig<string>("Trader Required Global Key", item.Trade.RequiredGlobalKey ?? "", "Required global key to unlock " + englishName + " at the trader.");
						if (item.traderConfig.trader.Value != Trader.None)
						{
							PrefabManager.AddItemToTrader(item.Prefab, item.traderConfig.trader.Value, item.traderConfig.price.Value, item.traderConfig.stack.Value, item.traderConfig.requiredGlobalKey.Value);
						}
					}
					else if (item.Trade.Trader != Trader.None)
					{
						PrefabManager.AddItemToTrader(item.Prefab, item.Trade.Trader, item.Trade.Price, item.Trade.Stack, item.Trade.RequiredGlobalKey);
					}
					void SetDmg(string dmgType, Func<DamageTypes, float> readDmg, setDmgFunc setDmg)
					{
						statcfg<float>(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData val) => readDmg(val.m_damages), delegate(SharedData val2, float val)
						{
							setDmg(ref val2.m_damages, val);
						});
						statcfg<float>(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData val) => readDmg(val.m_damagesPerLevel), delegate(SharedData val2, float val)
						{
							setDmg(ref val2.m_damagesPerLevel, val);
						});
					}
					bool TraderBrowsability()
					{
						return item.traderConfig.trader.Value != Trader.None;
					}
					void statcfg<T>(string configName, string description, Func<SharedData, T> readDefault, Action<SharedData, T> setValue) where T : notnull
					{
						//IL_007e: Unknown result type (might be due to invalid IL or missing references)
						//IL_008f: Expected O, but got Unknown
						SharedData shared2 = item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ConfigEntry<T> cfg2 = null;
						ConfigSyncBase.SyncedConfig(englishName, configName, readDefault(shared2), new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
						{
							new ConfigurationManagerAttributes
							{
								Category = localizedName,
								Browsable = ((item.configurationVisible & Configurability.Stats) != 0)
							}
						}), ref cfg2);
						if ((item.configurationVisible & Configurability.Stats) != Configurability.Disabled)
						{
							setValue(shared2, cfg2.Value);
						}
						item.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig);
						cfg2.SettingChanged += delegate
						{
							if ((item.configurationVisible & Configurability.Stats) != Configurability.Disabled)
							{
								ApplyConfig();
							}
						};
						void ApplyConfig()
						{
							item.ApplyToAllInstances(delegate(ItemData val)
							{
								setValue(val.m_shared, cfg2.Value);
							});
						}
					}
					ConfigEntry<T> traderConfig<T>(string name, T value, string desc) where T : notnull
					{
						//IL_009b: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a8: Expected O, but got Unknown
						ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes
						{
							Order = (order -= 1),
							browsability = TraderBrowsability,
							Browsable = (TraderBrowsability() && (item.configurationVisible & Configurability.Trader) != 0),
							Category = localizedName
						};
						traderAttributes.Add(configurationManagerAttributes3);
						ConfigEntry<T> configEntry4 = null;
						ConfigSyncBase.SyncedConfig(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 }), ref configEntry4);
						configEntry4.SettingChanged += delegate
						{
							item.ReloadTraderConfiguration();
						};
						return configEntry4;
					}
				}
				if (saveOnConfigSet)
				{
					plugin.Config.SaveOnConfigSet = true;
					plugin.Config.Save();
				}
			}
			configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			foreach (Item registeredItem in registeredItems)
			{
				Item item2 = registeredItem;
				foreach (KeyValuePair<string, ItemRecipe> recipe in item2.Recipes)
				{
					KeyValuePair<string, ItemRecipe> kv = recipe;
					RequiredResourceList[] array2 = new RequiredResourceList[2]
					{
						kv.Value.RequiredItems,
						kv.Value.RequiredUpgradeItems
					};
					foreach (RequiredResourceList requiredResourceList in array2)
					{
						for (int num3 = 0; num3 < requiredResourceList.Requirements.Count; num3++)
						{
							ConfigEntry<int> amountCfg;
							int resourceIndex;
							if ((item2.configurability & Configurability.Recipe) != Configurability.Disabled)
							{
								amountCfg = requiredResourceList.Requirements[num3].amountConfig;
								if (amountCfg != null)
								{
									resourceIndex = num3;
									amountCfg.SettingChanged += ConfigChanged2;
								}
							}
							void ConfigChanged2(object o, EventArgs e)
							{
								if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(kv.Key, out List<Recipe> value))
								{
									foreach (Recipe item9 in value)
									{
										item9.m_resources[resourceIndex].m_amount = amountCfg.Value;
									}
								}
							}
						}
					}
				}
				item2.InitializeNewRegisteredItem();
			}
			ConfigSyncBase.SaveConfigFile();
		}

		private void InitializeNewRegisteredItem()
		{
			foreach (KeyValuePair<string, ItemRecipe> recipe in Recipes)
			{
				KeyValuePair<string, ItemRecipe> kv = recipe;
				ConfigEntryBase enabledCfg = kv.Value.RecipeIsActive;
				if (enabledCfg != null)
				{
					((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged));
				}
				void ConfigChanged(object o, EventArgs e)
				{
					if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(kv.Key, out List<Recipe> value))
					{
						foreach (Recipe item in value)
						{
							item.m_enabled = (int)enabledCfg.BoxedValue != 0;
						}
					}
				}
			}
		}

		public void ReloadCraftingConfiguration()
		{
			if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name)) == (Object)null)
			{
				registerRecipesInObjectDB(ObjectDB.instance);
				ObjectDB.instance.m_items.Add(Prefab);
				ObjectDB.instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab);
				ZNetScene.instance.m_prefabs.Add(Prefab);
				ZNetScene.instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab);
			}
			foreach (string item in Recipes.Keys.DefaultIfEmpty(""))
			{
				if (Recipes.TryGetValue(item, out ItemRecipe value) && value.Crafting.Stations.Count > 0)
				{
					UpdateItemTableConfig(item, value.Crafting.Stations.First().Table, value.Crafting.Stations.First().custom ?? "");
					UpdateCraftConfig(item, new SerializedRequirements(value.RequiredItems.Requirements), new SerializedRequirements(value.RequiredUpgradeItems.Requirements));
				}
			}
		}

		private void ReloadTraderConfiguration()
		{
			if (traderConfig.trader.Value == Trader.None)
			{
				PrefabManager.RemoveItemFromTrader(Prefab);
			}
			else
			{
				PrefabManager.AddItemToTrader(Prefab, traderConfig.trader.Value, traderConfig.price.Value, traderConfig.stack.Value, traderConfig.requiredGlobalKey.Value);
			}
		}

		public static void ApplyToAllInstances(GameObject prefab, Action<ItemData> cal