Decompiled source of NoFogBruh v2.1.4

plugins/NoFogBruh.dll

Decompiled 3 weeks 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.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.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Valheim.SettingsGui;
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.1.4.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.4.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.1.4")]
	[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.1.4";

		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.1.4";

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

		public static ILogIt Log => _log;

		[UsedImplicitly]
		private void Awake()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			_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 = ConfigSyncBase.ShowSplashOnStartup
			});
			Localizer.Waiter.StatusChanged += InitializeModule;
			DisableFogComponent.FeatureInitialized = true;
			WeatherEventsComponent.FeatureInitialized = true;
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			if (GUIManager.IsHeadless())
			{
				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[] { "vapok.common.LocalizationManager", "org.bepinex.helpers.LocalizationManager" })]
		[HarmonyBefore(new string[] { "vapok.common.ItemManager", "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)
			{
				if (!GUIManager.IsHeadless())
				{
					if (EnableFog != null && !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)
			{
				if (!GUIManager.IsHeadless() && EnableSnowGlint != null && !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 != null && !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 == null || 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 != null && !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 != null && !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 != null && EnableFog.Value)
			{
				instance.TryExecuteCommandBuffer<FogModel>((PostProcessingComponentCommandBuffer<FogModel>)(object)fog);
			}
			else
			{
				instance.RemoveCommandBuffer<FogModel>();
			}
		}

		private static void SetAmbientSetting(PostProcessingBehaviour instance, AmbientOcclusionComponent fog)
		{
			if (EnableAmbientComponent != null && 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()
		{
			if (!_initialized && !GUIManager.IsHeadless())
			{
				_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)
		{
			if (_initialized && !GUIManager.IsHeadless())
			{
				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()
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			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)
						{
							continue;
						}
						Scene scene = ((Component)val3).gameObject.scene;
						if (!((Scene)(ref scene)).IsValid() || !((Object)((Component)val3).gameObject).name.StartsWith(fogTarget.LocationListPrefix))
						{
							continue;
						}
						Transform val4 = ((Component)val3).transform.Find(fogTarget.RelativePath);
						if ((Object)(object)val4 != (Object)null)
						{
							scene = ((Component)val4).gameObject.scene;
							if (((Scene)(ref scene)).IsValid())
							{
								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)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)target.Target != (Object)null))
			{
				return;
			}
			Scene scene = target.Target.scene;
			if (!((Scene)(ref scene)).IsValid() || target.Config == null)
			{
				return;
			}
			try
			{
				bool value = target.Config.Value;
				if (target.Target.activeSelf != value)
				{
					target.Target.SetActive(value);
				}
			}
			catch (Exception ex)
			{
				NoFogBruh.Log.Debug("Failed to apply fog target '" + target.RelativePath + "': " + ex.Message);
			}
		}

		public static void Reset()
		{
			_environmentRoot = null;
			_lastEnvObject = null;
			_allTargetsResolved = false;
			_nextCheckTime = 0f;
			for (int i = 0; i < _targets.Count; i++)
			{
				_targets[i].Target = null;
			}
		}
	}
	public class WeatherEventsComponent
	{
		[HarmonyPatch(typeof(EnvMan), "GetAvailableEnvironments")]
		private static class EnvManGetAvailableEnvironmentsPatch
		{
			private static void Postfix(EnvMan __instance, BiomeSector biome, ref List<EnvEntry> __result)
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Expected O, but got Unknown
				if (__result == null || __result.Count == 0)
				{
					return;
				}
				__result.RemoveAll((EnvEntry entry) => entry != null && !IsEnvironmentEnabled(entry.m_environment));
				if (__result.Count == 0)
				{
					EnvSetup fallbackEnvironment = GetFallbackEnvironment(__instance, biome);
					if (fallbackEnvironment != null)
					{
						__result.Add(new EnvEntry
						{
							m_environment = fallbackEnvironment.m_name,
							m_weight = 1f,
							m_env = fallbackEnvironment
						});
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "GetEnvironmentOverride")]
		private static class EnvManGetEnvironmentOverridePatch
		{
			private static void Postfix(EnvMan __instance, ref string __result)
			{
				if (!string.IsNullOrEmpty(__result) && !IsEnvironmentEnabled(__result))
				{
					if (!string.IsNullOrEmpty(__instance.m_debugEnv) && !IsEnvironmentEnabled(__instance.m_debugEnv))
					{
						__instance.m_debugEnv = "";
					}
					__result = null;
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "QueueEnvironment", new Type[] { typeof(string) })]
		private static class EnvManQueueEnvironmentStringPatch
		{
			private static void Prefix(EnvMan __instance, ref string name)
			{
				if (!string.IsNullOrEmpty(name) && !IsEnvironmentEnabled(name))
				{
					EnvSetup fallbackEnvironment = GetFallbackEnvironment(__instance);
					if (fallbackEnvironment != null)
					{
						name = fallbackEnvironment.m_name;
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "QueueEnvironment", new Type[] { typeof(EnvSetup) })]
		private static class EnvManQueueEnvironmentPatch
		{
			private static void Prefix(EnvMan __instance, ref EnvSetup env)
			{
				if (env != null && !IsEnvironmentEnabled(env.m_name))
				{
					EnvSetup fallbackEnvironment = GetFallbackEnvironment(__instance);
					if (fallbackEnvironment != null)
					{
						env = fallbackEnvironment;
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetForceEnvironment")]
		private static class EnvManSetForceEnvironmentPatch
		{
			private static void Prefix(EnvMan __instance, ref string env)
			{
				if (!string.IsNullOrEmpty(env) && !IsEnvironmentEnabled(env))
				{
					EnvSetup fallbackEnvironment = GetFallbackEnvironment(__instance);
					if (fallbackEnvironment != null)
					{
						env = fallbackEnvironment.m_name;
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetEnv", new Type[]
		{
			typeof(EnvSetup),
			typeof(float),
			typeof(float),
			typeof(float),
			typeof(float),
			typeof(float)
		})]
		private static class EnvManSetEnvPatch
		{
			private static void Prefix(EnvMan __instance, ref EnvSetup env)
			{
				if (env != null && !IsEnvironmentEnabled(env.m_name))
				{
					EnvSetup fallbackEnvironment = GetFallbackEnvironment(__instance);
					if (fallbackEnvironment != null)
					{
						env = fallbackEnvironment;
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "Awake")]
		private static class EnvManAwakePatch
		{
			private static void Postfix(EnvMan __instance)
			{
				if ((Object)(object)__instance == (Object)null || __instance.m_environments == null)
				{
					return;
				}
				foreach (EnvSetup environment in __instance.m_environments)
				{
					if (environment != null)
					{
						RegisterDynamicEnvironment(environment.m_name);
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "AppendEnvironment")]
		private static class EnvManAppendEnvironmentPatch
		{
			private static void Postfix(EnvSetup env)
			{
				if (env != null)
				{
					RegisterDynamicEnvironment(env.m_name);
				}
			}
		}

		public static bool FeatureInitialized;

		private const string SectionWorld = "Weather Events - World";

		private const string SectionBoss = "Weather Events - Boss";

		private const string SectionDungeon = "Weather Events - Dungeon";

		private const string SectionRaid = "Weather Events - Raid";

		public static ConfigEntry<bool> EnableMisty;

		public static ConfigEntry<bool> EnableDeepForestMist;

		public static ConfigEntry<bool> EnableRain;

		public static ConfigEntry<bool> EnableLightRain;

		public static ConfigEntry<bool> EnableThunderStorm;

		public static ConfigEntry<bool> EnableSwampRain;

		public static ConfigEntry<bool> EnableSnow;

		public static ConfigEntry<bool> EnableSnowStorm;

		public static ConfigEntry<bool> EnableTwilightSnow;

		public static ConfigEntry<bool> EnableTwilightSnowStorm;

		public static ConfigEntry<bool> EnableMistlandsRain;

		public static ConfigEntry<bool> EnableMistlandsThunder;

		public static ConfigEntry<bool> EnableAshlandsMisty;

		public static ConfigEntry<bool> EnableAshlandsAshrain;

		public static ConfigEntry<bool> EnableAshlandsCinderrain;

		public static ConfigEntry<bool> EnableAshlandsStorm;

		public static ConfigEntry<bool> EnableAshlandsMeteorshower;

		public static ConfigEntry<bool> EnableAshlandsSeastorm;

		public static ConfigEntry<bool> EnableAshrain;

		public static ConfigEntry<bool> EnableDarklandsDark;

		public static ConfigEntry<bool> EnableNofogts;

		public static ConfigEntry<bool> EnableEikthyr;

		public static ConfigEntry<bool> EnableEikthyrNoLightning;

		public static ConfigEntry<bool> EnableGDKing;

		public static ConfigEntry<bool> EnableBonemass;

		public static ConfigEntry<bool> EnableModer;

		public static ConfigEntry<bool> EnableGoblinKing;

		public static ConfigEntry<bool> EnableQueen;

		public static ConfigEntry<bool> EnableFader;

		public static ConfigEntry<bool> EnableDNBossroom;

		public static ConfigEntry<bool> EnableCrypt;

		public static ConfigEntry<bool> EnableSunkenCrypt;

		public static ConfigEntry<bool> EnableCaves;

		public static ConfigEntry<bool> EnableCavesHildir;

		public static ConfigEntry<bool> EnableCryptHildir;

		public static ConfigEntry<bool> EnableInfectedMine;

		public static ConfigEntry<bool> EnableGhosts;

		public static ConfigEntry<bool> EnableJotunInvasionMeadows;

		public static ConfigEntry<bool> EnableJotunInvasionBlackforest;

		public static ConfigEntry<bool> EnableJotunInvasionSwamp;

		public static ConfigEntry<bool> EnableJotunInvasionMountain;

		public static ConfigEntry<bool> EnableJotunInvasionPlains;

		public static ConfigEntry<bool> EnableJotunInvasionMistlands;

		public static ConfigEntry<bool> EnableMorkhalla;

		public static ConfigEntry<bool> EnableTheHollow;

		private static readonly Dictionary<string, ConfigEntry<bool>> _weatherConfigs;

		private static bool _initialized;

		static WeatherEventsComponent()
		{
			FeatureInitialized = false;
			_weatherConfigs = new Dictionary<string, ConfigEntry<bool>>(StringComparer.OrdinalIgnoreCase);
			ConfigRegistry.Waiter.StatusChanged += delegate
			{
				RegisterConfigurationFile();
			};
		}

		private static void RegisterConfigurationFile()
		{
			if (!_initialized)
			{
				_initialized = true;
				RegisterWeatherConfig("Weather Events - World", "Misty", "Enable Misty Weather", "Enables dense fog weather in Meadows, Black Forest, Plains, and Ocean.", 1, ref EnableMisty);
				RegisterWeatherConfig("Weather Events - World", "DeepForest Mist", "Enable Deep Forest Mist Weather", "Enables mist and fog weather in Black Forest.", 2, ref EnableDeepForestMist);
				RegisterWeatherConfig("Weather Events - World", "Rain", "Enable Rain Weather", "Enables standard rain in Meadows, Black Forest, Plains, and Ocean.", 3, ref EnableRain);
				RegisterWeatherConfig("Weather Events - World", "LightRain", "Enable Light Rain Weather", "Enables light rain and drizzle in Meadows, Plains, and Ocean.", 4, ref EnableLightRain);
				RegisterWeatherConfig("Weather Events - World", "ThunderStorm", "Enable Thunderstorm Weather", "Enables heavy thunderstorms and sea storms in Meadows, Plains, and Ocean.", 5, ref EnableThunderStorm);
				RegisterWeatherConfig("Weather Events - World", "SwampRain", "Enable Swamp Rain Weather", "Enables continuous rain and gloom in Swamp.", 6, ref EnableSwampRain);
				RegisterWeatherConfig("Weather Events - World", "Snow", "Enable Snow Weather", "Enables snowfall in Mountain and Deep North.", 7, ref EnableSnow);
				RegisterWeatherConfig("Weather Events - World", "SnowStorm", "Enable Snowstorm Weather", "Enables snowstorms and blizzards in Mountain and Deep North.", 8, ref EnableSnowStorm);
				RegisterWeatherConfig("Weather Events - World", "Twilight_Snow", "Enable Twilight Snow Weather", "Enables twilight snowfall in Mountain.", 9, ref EnableTwilightSnow);
				RegisterWeatherConfig("Weather Events - World", "Twilight_SnowStorm", "Enable Twilight Snowstorm Weather", "Enables twilight snowstorms in Mountain.", 10, ref EnableTwilightSnowStorm);
				RegisterWeatherConfig("Weather Events - World", "Mistlands_rain", "Enable Mistlands Rain Weather", "Enables rainfall in Mistlands.", 11, ref EnableMistlandsRain);
				RegisterWeatherConfig("Weather Events - World", "Mistlands_thunder", "Enable Mistlands Thunder Weather", "Enables thunderstorms in Mistlands.", 12, ref EnableMistlandsThunder);
				RegisterWeatherConfig("Weather Events - World", "Ashlands_Misty", "Enable Ashlands Mist Weather", "Enables foggy mist weather in Ashlands.", 13, ref EnableAshlandsMisty);
				RegisterWeatherConfig("Weather Events - World", "Ashlands_Ashrain", "Enable Ashlands Ash Rain Weather", "Enables ash rain in Ashlands.", 14, ref EnableAshlandsAshrain);
				RegisterWeatherConfig("Weather Events - World", "Ashlands_Cinderrain", "Enable Ashlands Cinder Rain Weather", "Enables cinder rain in Ashlands.", 15, ref EnableAshlandsCinderrain);
				RegisterWeatherConfig("Weather Events - World", "Ashlands_Storm", "Enable Ashlands Storm Weather", "Enables heavy storms in Ashlands.", 16, ref EnableAshlandsStorm);
				RegisterWeatherConfig("Weather Events - World", "Ashlands_Meteorshower", "Enable Ashlands Meteor Shower Weather", "Enables meteor showers in Ashlands.", 17, ref EnableAshlandsMeteorshower);
				RegisterWeatherConfig("Weather Events - World", "Ashlands_Seastorm", "Enable Ashlands Sea Storm Weather", "Enables boiling sea storms in Ashlands.", 18, ref EnableAshlandsSeastorm);
				RegisterWeatherConfig("Weather Events - World", "Ashrain", "Enable Legacy Ash Rain Weather", "Enables legacy ash rain in Ashlands.", 19, ref EnableAshrain);
				RegisterWeatherConfig("Weather Events - World", "Darklands_dark", "Enable Darklands Dark Weather", "Enables darklands environmental darkness.", 20, ref EnableDarklandsDark);
				RegisterWeatherConfig("Weather Events - World", "nofogts", "Enable Internal NoFog Weather", "Enables internal nofog thunderstorm weather.", 21, ref EnableNofogts);
				RegisterWeatherConfig("Weather Events - Boss", "Eikthyr", "Enable Eikthyr Weather", "Enables storm and lightning weather during Eikthyr boss fight.", 1, ref EnableEikthyr);
				RegisterWeatherConfig("Weather Events - Boss", "Eikthyr_no_lightning", "Enable Eikthyr No Lightning Weather", "Enables storm without lightning during Eikthyr boss fight.", 2, ref EnableEikthyrNoLightning);
				RegisterWeatherConfig("Weather Events - Boss", "GDKing", "Enable The Elder Weather", "Enables overcast root weather during The Elder boss fight.", 3, ref EnableGDKing);
				RegisterWeatherConfig("Weather Events - Boss", "Bonemass", "Enable Bonemass Weather", "Enables murky swamp weather during Bonemass boss fight.", 4, ref EnableBonemass);
				RegisterWeatherConfig("Weather Events - Boss", "Moder", "Enable Moder Weather", "Enables freezing blizzard weather during Moder boss fight.", 5, ref EnableModer);
				RegisterWeatherConfig("Weather Events - Boss", "GoblinKing", "Enable Yagluth Weather", "Enables fiery atmospheric weather during Yagluth boss fight.", 6, ref EnableGoblinKing);
				RegisterWeatherConfig("Weather Events - Boss", "Queen", "Enable The Queen Weather", "Enables infested chamber weather during The Queen boss fight.", 7, ref EnableQueen);
				RegisterWeatherConfig("Weather Events - Boss", "Fader", "Enable Fader Weather", "Enables ash vortex weather during Fader boss fight.", 8, ref EnableFader);
				RegisterWeatherConfig("Weather Events - Boss", "DN_Bossroom", "Enable Deep North Boss Room Weather", "Enables Deep North boss arena weather.", 9, ref EnableDNBossroom);
				RegisterWeatherConfig("Weather Events - Dungeon", "Crypt", "Enable Burial Chambers Weather", "Enables interior crypt gloom in Black Forest Burial Chambers.", 1, ref EnableCrypt);
				RegisterWeatherConfig("Weather Events - Dungeon", "SunkenCrypt", "Enable Sunken Crypt Weather", "Enables interior wet gloom in Swamp Sunken Crypts.", 2, ref EnableSunkenCrypt);
				RegisterWeatherConfig("Weather Events - Dungeon", "Caves", "Enable Mountain Caves Weather", "Enables interior mist and cold in Mountain Frost Caves.", 3, ref EnableCaves);
				RegisterWeatherConfig("Weather Events - Dungeon", "CavesHildir", "Enable Hildir Frost Caves Weather", "Enables interior mist in Hildir Mountain Caves.", 4, ref EnableCavesHildir);
				RegisterWeatherConfig("Weather Events - Dungeon", "CryptHildir", "Enable Hildir Sunken Crypt Weather", "Enables interior mist in Hildir Sunken Crypts.", 5, ref EnableCryptHildir);
				RegisterWeatherConfig("Weather Events - Dungeon", "InfectedMine", "Enable Infected Mine Weather", "Enables interior mist and spores in Mistlands Infected Mines.", 6, ref EnableInfectedMine);
				RegisterWeatherConfig("Weather Events - Raid", "Ghosts", "Enable Ghosts Raid Weather", "Enables ghostly mist during ghost raid encounters.", 1, ref EnableGhosts);
				RegisterWeatherConfig("Weather Events - Raid", "JotunInvasion_meadows", "Enable Meadows Invasion Raid Weather", "Enables atmospheric distortion during Meadows Jotun invasions.", 2, ref EnableJotunInvasionMeadows);
				RegisterWeatherConfig("Weather Events - Raid", "JotunInvasion_blackforest", "Enable Black Forest Invasion Raid Weather", "Enables atmospheric distortion during Black Forest Jotun invasions.", 3, ref EnableJotunInvasionBlackforest);
				RegisterWeatherConfig("Weather Events - Raid", "JotunInvasion_swamp", "Enable Swamp Invasion Raid Weather", "Enables atmospheric distortion during Swamp Jotun invasions.", 4, ref EnableJotunInvasionSwamp);
				RegisterWeatherConfig("Weather Events - Raid", "JotunInvasion_mountain", "Enable Mountain Invasion Raid Weather", "Enables atmospheric distortion during Mountain Jotun invasions.", 5, ref EnableJotunInvasionMountain);
				RegisterWeatherConfig("Weather Events - Raid", "JotunInvasion_plains", "Enable Plains Invasion Raid Weather", "Enables atmospheric distortion during Plains Jotun invasions.", 6, ref EnableJotunInvasionPlains);
				RegisterWeatherConfig("Weather Events - Raid", "JotunInvasion_mistlands", "Enable Mistlands Invasion Raid Weather", "Enables atmospheric distortion during Mistlands Jotun invasions.", 7, ref EnableJotunInvasionMistlands);
				RegisterWeatherConfig("Weather Events - Raid", "Morkhalla", "Enable Morkhalla Raid Weather", "Enables Morkhalla event weather.", 8, ref EnableMorkhalla);
				RegisterWeatherConfig("Weather Events - Raid", "TheHollow", "Enable The Hollow Raid Weather", "Enables The Hollow event weather.", 9, ref EnableTheHollow);
			}
		}

		private static void RegisterWeatherConfig(string section, string envName, string configKey, string description, int order, ref ConfigEntry<bool> configEntry)
		{
			//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_0020: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			ConfigSyncBase.SyncedConfig(section, configKey, value: true, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = order
			} }), ref configEntry);
			if (configEntry != null)
			{
				configEntry.SettingChanged += delegate
				{
					OnWeatherSettingChanged();
				};
				_weatherConfigs[envName] = configEntry;
			}
		}

		public static void RegisterDynamicEnvironment(string envName)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			if (!_initialized || string.IsNullOrEmpty(envName) || envName.IndexOf("clear", StringComparison.OrdinalIgnoreCase) >= 0 || _weatherConfigs.ContainsKey(envName))
			{
				return;
			}
			string text = DetermineSection(envName);
			ConfigEntry<bool> configEntry = null;
			ConfigSyncBase.SyncedConfig(text, "Enable " + envName + " Weather", value: true, new ConfigDescription("Enables " + envName + " weather event.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 50
			} }), ref configEntry);
			if (configEntry != null)
			{
				configEntry.SettingChanged += delegate
				{
					OnWeatherSettingChanged();
				};
				_weatherConfigs[envName] = configEntry;
			}
		}

		private static string DetermineSection(string envName)
		{
			if (envName.IndexOf("boss", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return "Weather Events - Boss";
			}
			if (envName.IndexOf("crypt", StringComparison.OrdinalIgnoreCase) >= 0 || envName.IndexOf("cave", StringComparison.OrdinalIgnoreCase) >= 0 || envName.IndexOf("mine", StringComparison.OrdinalIgnoreCase) >= 0 || envName.IndexOf("dungeon", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return "Weather Events - Dungeon";
			}
			if (envName.IndexOf("invasion", StringComparison.OrdinalIgnoreCase) >= 0 || envName.IndexOf("raid", StringComparison.OrdinalIgnoreCase) >= 0 || IsRaidEnvironment(envName))
			{
				return "Weather Events - Raid";
			}
			return "Weather Events - World";
		}

		private static bool IsRaidEnvironment(string envName)
		{
			RandEventSystem instance = RandEventSystem.instance;
			if ((Object)(object)instance == (Object)null || instance.m_events == null)
			{
				return false;
			}
			foreach (RandomEvent @event in instance.m_events)
			{
				if (@event != null && string.Equals(@event.m_forceEnvironment, envName, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsEnvironmentEnabled(string envName)
		{
			if (string.IsNullOrEmpty(envName))
			{
				return true;
			}
			if (envName.IndexOf("clear", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
			if (_weatherConfigs.TryGetValue(envName, out var value))
			{
				return value?.Value ?? true;
			}
			return true;
		}

		private static void OnWeatherSettingChanged()
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			if ((Object)(object)EnvMan.instance == (Object)null)
			{
				return;
			}
			if (!string.IsNullOrEmpty(EnvMan.instance.m_debugEnv) && !IsEnvironmentEnabled(EnvMan.instance.m_debugEnv))
			{
				EnvMan.instance.m_debugEnv = "";
			}
			FieldInfo fieldInfo = AccessTools.DeclaredField(typeof(EnvMan), "m_forceEnv");
			if (fieldInfo != null)
			{
				string text = (string)fieldInfo.GetValue(EnvMan.instance);
				if (!string.IsNullOrEmpty(text) && !IsEnvironmentEnabled(text))
				{
					fieldInfo.SetValue(EnvMan.instance, "");
				}
			}
			FieldInfo fieldInfo2 = AccessTools.DeclaredField(typeof(EnvMan), "m_environmentPeriod");
			if (fieldInfo2 != null)
			{
				fieldInfo2.SetValue(EnvMan.instance, -1L);
			}
			EnvSetup fallbackEnvironment = GetFallbackEnvironment(EnvMan.instance);
			if (fallbackEnvironment == null)
			{
				return;
			}
			FieldInfo fieldInfo3 = AccessTools.DeclaredField(typeof(EnvMan), "m_nextEnv");
			if (fieldInfo3 != null)
			{
				EnvSetup val = (EnvSetup)fieldInfo3.GetValue(EnvMan.instance);
				if (val != null && !IsEnvironmentEnabled(val.m_name))
				{
					fieldInfo3.SetValue(EnvMan.instance, fallbackEnvironment);
				}
			}
			EnvSetup currentEnvironment = EnvMan.instance.GetCurrentEnvironment();
			if (currentEnvironment != null && !IsEnvironmentEnabled(currentEnvironment.m_name))
			{
				FieldInfo fieldInfo4 = AccessTools.DeclaredField(typeof(EnvMan), "m_forceInstantEnvSwitchTimer");
				if (fieldInfo4 != null)
				{
					fieldInfo4.SetValue(EnvMan.instance, 2f);
				}
				FieldInfo fieldInfo5 = AccessTools.DeclaredField(typeof(EnvMan), "m_currentEnv");
				if (fieldInfo5 != null)
				{
					fieldInfo5.SetValue(EnvMan.instance, fallbackEnvironment);
				}
				MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(EnvMan), "QueueEnvironment", new Type[1] { typeof(EnvSetup) }, (Type[])null);
				if (methodInfo != null)
				{
					methodInfo.Invoke(EnvMan.instance, new object[1] { fallbackEnvironment });
				}
			}
		}

		public static EnvSetup GetFallbackEnvironment(EnvMan envMan)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			if ((Object)(object)envMan == (Object)null)
			{
				return null;
			}
			EnvSetup env = envMan.GetEnv("Clear");
			if (env != null)
			{
				return env;
			}
			MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(EnvMan), "GetDefaultEnv", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				return (EnvSetup)methodInfo.Invoke(envMan, null);
			}
			return null;
		}

		public static EnvSetup GetFallbackEnvironment(EnvMan envMan, BiomeSector biome)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			if ((Object)(object)envMan == (Object)null)
			{
				return null;
			}
			MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(EnvMan), "GetBiomeEnvSetup", new Type[1] { typeof(Biome) }, (Type[])null);
			if (methodInfo != null)
			{
				BiomeEnvSetup val = (BiomeEnvSetup)methodInfo.Invoke(envMan, new object[1] { biome.Biome });
				if (val != null && val.m_environments != null)
				{
					foreach (EnvEntry environment in val.m_environments)
					{
						if (environment != null && environment.m_environment != null && environment.m_environment.IndexOf("clear", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							EnvSetup env = envMan.GetEnv(environment.m_environment);
							if (env != null)
							{
								return env;
							}
						}
					}
				}
			}
			return GetFallbackEnvironment(envMan);
		}
	}
}
namespace NoFogBruh.Configuration
{
	public class ConfigRegistry : ConfigSyncBase
	{
		public static Waiting Waiter;

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

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

		public void ConfigurationComplete(bool configDone)
		{
			if (configDone)
			{
				this.StatusChanged?.Invoke(this, EventArgs.Empty);
			}
		}
	}
}
namespace 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;

		private static readonly MethodBase? _itemTarget;

		private static readonly List<Item> registeredItems;

		private static readonly Dictionary<ItemDrop, Item> itemDropMap;

		private static Dictionary<Item, Dictionary<string, List<Recipe>>> activeRecipes;

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenCraftRecipes;

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenUpgradeRecipes;

		private static Dictionary<Item, Dictionary<string, ItemConfig>> itemCraftConfigs;

		private static Dictionary<Item, ConfigEntry<string>> itemDropConfigs;

		private static Dictionary<Item, ConfigEntry<bool>> itemDropEnabledConfig;

		private static Dictionary<Item, ConfigEntry<bool>> itemDropScalingConfig;

		private static Dictionary<Item, ConfigEntry<bool>> itemDropLevelingConfig;

		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;

		public string SectionName = string.Empty;

		public static Configurability DefaultConfigurability;

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

		static Item()
		{
			_initialized = false;
			_itemTarget = AccessTools.DeclaredMethod(typeof(Item), "Patch_FejdStartup", (Type[])null, (Type[])null);
			registeredItems = new List<Item>();
			itemDropMap = new Dictionary<ItemDrop, Item>();
			activeRecipes = new Dictionary<Item, Dictionary<string, List<Recipe>>>();
			hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();
			hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();
			itemCraftConfigs = new Dictionary<Item, Dictionary<string, ItemConfig>>();
			itemDropConfigs = new Dictionary<Item, ConfigEntry<string>>();
			itemDropEnabledConfig = new Dictionary<Item, ConfigEntry<bool>>();
			itemDropScalingConfig = new Dictionary<Item, ConfigEntry<bool>>();
			itemDropLevelingConfig = new Dictionary<Item, ConfigEntry<bool>>();
			requirementQuality = new ConditionalWeakTable<Requirement, RequirementQuality>();
			DefaultConfigurability = Configurability.Full;
			if (_itemTarget != null)
			{
				DynamicPatches.Register(_itemTarget, 848123570u, "Ei8+Ngs6LzgzPik=");
			}
		}

		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_11e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_11e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_249a: Unknown result type (might be due to invalid IL or missing references)
			//IL_24a7: Expected O, but got Unknown
			//IL_12aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_1303: Expected I4, but got Unknown
			//IL_0c6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c80: Expected O, but got Unknown
			//IL_0d5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6e: Expected O, but got Unknown
			//IL_0ddd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dea: Expected O, but got Unknown
			//IL_0e54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e61: Expected O, but got Unknown
			//IL_1437: Unknown result type (might be due to invalid IL or missing references)
			//IL_143a: Unknown result type (might be due to invalid IL or missing references)
			//IL_143c: Invalid comparison between Unknown and I4
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Expected O, but got Unknown
			//IL_143e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1442: Invalid comparison between Unknown and I4
			//IL_0fe4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1000: Expected O, but got Unknown
			//IL_1090: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ac: Expected O, but got Unknown
			//IL_1444: Unknown result type (might be due to invalid IL or missing references)
			//IL_1448: Invalid comparison between Unknown and I4
			//IL_1145: Unknown result type (might be due to invalid IL or missing references)
			//IL_1161: Expected O, but got Unknown
			//IL_1643: Unknown result type (might be due to invalid IL or missing references)
			//IL_1646: Unknown result type (might be due to invalid IL or missing references)
			//IL_1648: Invalid comparison between Unknown and I4
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Expected O, but got Unknown
			//IL_164a: Unknown result type (might be due to invalid IL or missing references)
			//IL_164e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1650: Invalid comparison between Unknown and I4
			//IL_1652: Unknown result type (might be due to invalid IL or missing references)
			//IL_1656: Invalid comparison between Unknown and I4
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Expected O, but got Unknown
			//IL_172b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1730: Unknown result type (might be due to invalid IL or missing references)
			//IL_1732: Unknown result type (might be due to invalid IL or missing references)
			//IL_1735: Invalid comparison between Unknown and I4
			//IL_1737: Unknown result type (might be due to invalid IL or missing references)
			//IL_173b: Invalid comparison between Unknown and I4
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Expected O, but got Unknown
			//IL_17aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_17af: Invalid comparison between Unknown and I4
			//IL_17b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b7: Invalid comparison between Unknown and I4
			//IL_07df: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Expected O, but got Unknown
			//IL_17b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_17bd: Invalid comparison between Unknown and I4
			//IL_18fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_18fd: Invalid comparison between Unknown and I4
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0901: Expected O, but got Unknown
			//IL_1afa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b01: Invalid comparison between Unknown and I4
			//IL_1bca: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd7: Invalid comparison between Unknown and I4
			//IL_1c46: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c49: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c4b: Invalid comparison between Unknown and I4
			//IL_1870: Unknown result type (might be due to invalid IL or missing references)
			//IL_1875: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c51: Invalid comparison between Unknown and I4
			//IL_1c53: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c57: Invalid comparison between Unknown and I4
			//IL_20c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_20c7: Invalid comparison between Unknown and I4
			if (_itemTarget != null)
			{
				DynamicPatches.Patch(_itemTarget);
			}
			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)v