Decompiled source of LethalElementsBeta v1.2.71

voxx.LethalElementsPlugin.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using TerraMesh;
using TerraMesh.Utils;
using Unity.AI.Navigation;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering.RendererUtils;
using UnityEngine.SceneManagement;
using UnityEngine.VFX;
using UnityEngine.VFX.Utility;
using VoxxWeatherPlugin.Behaviours;
using VoxxWeatherPlugin.Compatibility;
using VoxxWeatherPlugin.Patches;
using VoxxWeatherPlugin.Utils;
using VoxxWeatherPlugin.Weathers;
using WeatherRegistry;
using voxx.LethalElementsPlugin.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("voxx.LethalElementsPlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A plugin adding new weather types to Lethal Company")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+e4a62b0f2817b0e120d4c35304edd9f25805378a")]
[assembly: AssemblyProduct("voxx.LethalElementsPlugin")]
[assembly: AssemblyTitle("voxx.LethalElementsPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 VoxxWeatherPlugin
{
	[BepInPlugin("voxx.LethalElementsPlugin", "voxx.LethalElementsPlugin", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class VoxxWeatherPlugin : BaseUnityPlugin
	{
		private Harmony harmony;

		public static VoxxWeatherPlugin instance;

		internal static ManualLogSource StaticLogger;

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			instance = this;
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			NetcodePatcher();
			Configuration.Initialize(((BaseUnityPlugin)this).Info.Metadata);
			harmony = new Harmony("voxx.LethalElementsPlugin");
			WeatherTypeLoader.LoadLevelManipulator();
			if (Configuration.EnableSolarFlareWeather.Value)
			{
				WeatherTypeLoader.RegisterFlareWeather();
				harmony.PatchAll(typeof(FlarePatches));
				if (!Configuration.DistortOnlyVoiceDuringSolarFlare.Value)
				{
					harmony.PatchAll(typeof(FlareOptionalWalkiePatches));
					((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin optional solar flare patches successfully applied!");
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin solar flare patches successfully applied!");
			}
			if (Configuration.EnableHeatwaveWeather.Value)
			{
				WeatherTypeLoader.RegisterHeatwaveWeather();
				harmony.PatchAll(typeof(HeatwavePatches));
				((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin heatwave patches successfully applied!");
			}
			if (Configuration.EnableToxicSmogWeather.Value)
			{
				WeatherTypeLoader.RegisterToxicSmogWeather();
				harmony.PatchAll(typeof(ToxicPatches));
				((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin toxic smog patches successfully applied!");
			}
			if (Configuration.EnableBlizzardWeather.Value || Configuration.EnableSnowfallWeather.Value)
			{
				harmony.PatchAll(typeof(SnowPatches));
				((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin snow patches successfully applied!");
				if (Configuration.EnableSnowfallWeather.Value)
				{
					WeatherTypeLoader.RegisterSnowfallWeather();
				}
				if (Configuration.EnableBlizzardWeather.Value)
				{
					harmony.PatchAll(typeof(BlizzardPatches));
					((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin blizzard patches successfully applied!");
					WeatherTypeLoader.RegisterBlizzardWeather();
				}
				MethodInfo method = typeof(SnowPatches).GetMethod("EnemySnowHindrancePatch", BindingFlags.Static | BindingFlags.NonPublic);
				DynamicHarmonyPatcher.PatchAllTypes(typeof(EnemyAI), "Update", method, PatchType.Postfix, harmony, SnowPatches.unaffectedEnemyTypes);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"voxx.LethalElementsPlugin enemy snow hindrance patches successfully applied!");
			}
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader"))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalLevelLoader detected!");
				LLLCompat.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("Zaggy1024.OpenBodyCams"))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"OpenBodyCams detected!");
				OpenCamsCompat.Init();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin voxx.LethalElementsPlugin is loaded!");
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class Debug
	{
		private static ManualLogSource Logger => VoxxWeatherPlugin.StaticLogger;

		public static void Log(string message)
		{
			Logger.LogInfo((object)message);
		}

		public static void LogError(string message)
		{
			Logger.LogError((object)message);
		}

		public static void LogWarning(string message)
		{
			Logger.LogWarning((object)message);
		}

		public static void LogDebug(string message)
		{
			Logger.LogDebug((object)message);
		}

		public static void LogMessage(string message)
		{
			Logger.LogMessage((object)message);
		}

		public static void LogFatal(string message)
		{
			Logger.LogFatal((object)message);
		}
	}
	public enum PatchType
	{
		Prefix,
		Postfix,
		Transpiler
	}
	public class DynamicHarmonyPatcher
	{
		public static void PatchAllTypes(Type baseType, string methodToPatch, MethodInfo patchMethod, PatchType patchType, Harmony harmonyInstance, HashSet<Type>? blackList = null)
		{
			List<Type> list = FindDerivedTypes(baseType, methodToPatch);
			if (blackList != null)
			{
				list.RemoveAll(blackList.Contains);
			}
			PatchMethodsInTypes(list, methodToPatch, patchMethod, patchType, harmonyInstance);
		}

		private static List<Type> FindDerivedTypes(Type baseType, string methodName)
		{
			List<Type> list = new List<Type>();
			Assembly[] array;
			if (Configuration.patchModdedEnemies.Value)
			{
				Debug.LogDebug("Searching for modded enemy types...");
				array = AppDomain.CurrentDomain.GetAssemblies();
			}
			else
			{
				Debug.LogDebug("Patching vanilla enemy types...");
				array = new Assembly[1] { typeof(EnemyAI).Assembly };
			}
			Assembly[] array2 = array;
			foreach (Assembly assembly in array2)
			{
				try
				{
					Type[] types = assembly.GetTypes();
					foreach (Type type in types)
					{
						if (baseType.IsAssignableFrom(type) && type != baseType && !type.IsAbstract && !type.IsInterface)
						{
							MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
							if (method != null && method.DeclaringType != baseType)
							{
								list.Add(type);
							}
						}
					}
				}
				catch (Exception)
				{
					Debug.LogDebug("Error loading types from assembly: " + assembly.FullName);
				}
			}
			return list;
		}

		private static void PatchMethodsInTypes(List<Type> typesToPatch, string methodName, MethodInfo patchMethod, PatchType patchType, Harmony harmonyInstance)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			if (typesToPatch == null || typesToPatch.Count == 0)
			{
				Debug.LogWarning("No types to patch provided.");
				return;
			}
			if (string.IsNullOrEmpty(methodName))
			{
				Debug.LogError("Method name cannot be null or empty.");
				return;
			}
			if (patchMethod == null)
			{
				Debug.LogError("Patch method cannot be null.");
				return;
			}
			if (harmonyInstance == null)
			{
				Debug.LogError("Harmony instance cannot be null.");
				return;
			}
			foreach (Type item in typesToPatch)
			{
				try
				{
					MethodInfo method = item.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method == null)
					{
						Debug.LogWarning("Method '" + methodName + "' not found on type '" + item.FullName + "'. Skipping.");
						continue;
					}
					HarmonyMethod val = new HarmonyMethod(patchMethod);
					switch (patchType)
					{
					case PatchType.Prefix:
						harmonyInstance.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						break;
					case PatchType.Postfix:
						harmonyInstance.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						break;
					case PatchType.Transpiler:
						harmonyInstance.Patch((MethodBase)method, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
						break;
					default:
						Debug.LogError($"Invalid patch type: '{patchType}'.");
						break;
					}
					Debug.LogDebug("Patched '" + methodName + "' in '" + item.FullName + "' using method " + patchMethod.Name);
				}
				catch (Exception arg)
				{
					Debug.LogError($"Error patching '{methodName}' in '{item.FullName}': {arg}");
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "voxx.LethalElementsPlugin";

		public const string PLUGIN_NAME = "voxx.LethalElementsPlugin";

		public const string PLUGIN_VERSION = "1.3.0";
	}
}
namespace VoxxWeatherPlugin.Utils
{
	public static class Configuration
	{
		public static ConfigEntry<bool> EnableHeatwaveWeather;

		public static ConfigEntry<bool> EnableSolarFlareWeather;

		public static ConfigEntry<bool> EnableSnowfallWeather;

		public static ConfigEntry<bool> EnableBlizzardWeather;

		public static ConfigEntry<bool> EnableToxicSmogWeather;

		public static ConfigEntry<float> HeatwaveParticlesSpawnRate;

		public static ConfigEntry<float> TimeUntilStrokeMin;

		public static ConfigEntry<float> TimeUntilStrokeMax;

		public static ConfigEntry<float> HeathazeDistortionStrength;

		public static ConfigEntry<float> HeathazeFilterMultiplier;

		public static ConfigEntry<uint> AuroraHeight;

		public static ConfigEntry<float> AuroraSpawnAreaBox;

		public static ConfigEntry<float> AuroraVisibilityThreshold;

		public static ConfigEntry<float> AuroraSpawnRate;

		public static ConfigEntry<float> AuroraSize;

		public static ConfigEntry<bool> DistortOnlyVoiceDuringSolarFlare;

		public static ConfigEntry<float> BatteryDrainMultiplier;

		public static ConfigEntry<bool> DrainBatteryInFacility;

		public static ConfigEntry<bool> DoorMalfunctionEnabled;

		public static ConfigEntry<float> DoorMalfunctionChance;

		public static ConfigEntry<float> NoiseStaticLevel;

		public static ConfigEntry<float> minSnowHeight;

		public static ConfigEntry<float> maxSnowHeight;

		public static ConfigEntry<float> minTimeToFullSnow;

		public static ConfigEntry<float> maxTimeToFullSnow;

		public static ConfigEntry<bool> freezeWater;

		public static ConfigEntry<float> underSnowFilterMultiplier;

		public static ConfigEntry<float> frostbiteFilterMultiplier;

		public static ConfigEntry<int> frostbiteDamage;

		public static ConfigEntry<float> frostbiteDamageInterval;

		public static ConfigEntry<float> timeToWarmUp;

		public static ConfigEntry<bool> enableEasterEgg;

		public static ConfigEntry<bool> patchModdedEnemies;

		public static ConfigEntry<bool> snowAffectsEnemies;

		public static ConfigEntry<string> enemySnowBlacklist;

		public static ConfigEntry<float> minSnowHeightBlizzard;

		public static ConfigEntry<float> maxSnowHeightBlizzard;

		public static ConfigEntry<float> minTimeToFullSnowBlizzard;

		public static ConfigEntry<float> maxTimeToFullSnowBlizzard;

		public static ConfigEntry<float> minTimeUntilFrostbite;

		public static ConfigEntry<float> maxTimeUntilFrostbite;

		public static ConfigEntry<float> minWindForce;

		public static ConfigEntry<float> maxWindForce;

		public static ConfigEntry<float> minWaveInterval;

		public static ConfigEntry<float> maxWaveInterval;

		public static ConfigEntry<int> minWaveCount;

		public static ConfigEntry<int> maxWaveCount;

		public static ConfigEntry<int> chillingWaveDamage;

		public static ConfigEntry<float> blizzardAmbientVolume;

		public static ConfigEntry<float> blizzardWaveVolume;

		public static ConfigEntry<float> snowParticlesMultiplier;

		public static ConfigEntry<float> blizzardWaveParticlesMultiplier;

		public static ConfigEntry<bool> snowVfxLighting;

		public static ConfigEntry<bool> blizzardWaveVfxLighting;

		public static ConfigEntry<bool> enableBlizzardFog;

		public static ConfigEntry<bool> useOpaqueSnowMaterial;

		public static ConfigEntry<bool> snowCastsShadows;

		public static ConfigEntry<bool> addFootprints;

		public static ConfigEntry<int> trackedEntityNumber;

		public static ConfigEntry<int> depthBufferResolution;

		public static ConfigEntry<int> trackerMapResolution;

		public static ConfigEntry<int> snowDepthMapResolution;

		public static ConfigEntry<bool> bakeSnowDepthMipmaps;

		public static ConfigEntry<int> PCFKernelSize;

		public static ConfigEntry<int> minTesselationFactor;

		public static ConfigEntry<int> maxTesselationFactor;

		public static ConfigEntry<bool> adaptiveTesselation;

		public static ConfigEntry<bool> softSnowEdges;

		public static ConfigEntry<bool> enableSnowTracks;

		public static ConfigEntry<bool> enableVFXCollisions;

		public static ConfigEntry<bool> asyncProcessing;

		public static ConfigEntry<string> meshProcessingWhitelist;

		public static ConfigEntry<bool> subdivideMesh;

		public static ConfigEntry<bool> smoothMesh;

		public static ConfigEntry<bool> useLevelBounds;

		public static ConfigEntry<bool> refineMesh;

		public static ConfigEntry<bool> carveHoles;

		public static ConfigEntry<bool> useMeshCollider;

		public static ConfigEntry<int> targetVertexCount;

		public static ConfigEntry<int> minMeshStep;

		public static ConfigEntry<int> maxMeshStep;

		public static ConfigEntry<float> falloffRatio;

		public static ConfigEntry<float> ToxicDamageInterval;

		public static ConfigEntry<int> ToxicDamageAmount;

		public static ConfigEntry<float> PoisoningRemovalMultiplier;

		public static ConfigEntry<float> MinFreePath;

		public static ConfigEntry<float> MaxFreePath;

		public static ConfigEntry<int> MinFumesAmount;

		public static ConfigEntry<int> MaxFumesAmount;

		public static ConfigEntry<float> FactoryAmountMultiplier;

		public static ConfigFile Config { get; private set; }

		internal static void Initialize(BepInPlugin metadata)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected O, but got Unknown
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Expected O, but got Unknown
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Expected O, but got Unknown
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Expected O, but got Unknown
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Expected O, but got Unknown
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Expected O, but got Unknown
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Expected O, but got Unknown
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Expected O, but got Unknown
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Expected O, but got Unknown
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Expected O, but got Unknown
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Expected O, but got Unknown
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Expected O, but got Unknown
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f5: Expected O, but got Unknown
			//IL_0727: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Expected O, but got Unknown
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_076d: Expected O, but got Unknown
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a9: Expected O, but got Unknown
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Expected O, but got Unknown
			//IL_0817: Unknown result type (might be due to invalid IL or missing references)
			//IL_0821: Expected O, but got Unknown
			//IL_0853: Unknown result type (might be due to invalid IL or missing references)
			//IL_085d: Expected O, but got Unknown
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Expected O, but got Unknown
			//IL_08cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Expected O, but got Unknown
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0906: Expected O, but got Unknown
			//IL_092d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0937: Expected O, but got Unknown
			//IL_095f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0969: Expected O, but got Unknown
			//IL_099b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a5: Expected O, but got Unknown
			//IL_09d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e1: Expected O, but got Unknown
			//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1d: Expected O, but got Unknown
			//IL_0a4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a59: Expected O, but got Unknown
			//IL_0b3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b48: Expected O, but got Unknown
			//IL_0b7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b84: Expected O, but got Unknown
			//IL_0bb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbd: Expected O, but got Unknown
			//IL_0bef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf9: Expected O, but got Unknown
			//IL_0c40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4a: Expected O, but got Unknown
			//IL_0c71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7b: Expected O, but got Unknown
			//IL_0ca3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cad: Expected O, but got Unknown
			//IL_0e4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e59: Expected O, but got Unknown
			//IL_0e83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8d: Expected O, but got Unknown
			//IL_0eb8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec2: Expected O, but got Unknown
			//IL_0ef4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0efe: Expected O, but got Unknown
			//IL_0f30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3a: Expected O, but got Unknown
			//IL_0f61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f6b: Expected O, but got Unknown
			//IL_0f9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa7: Expected O, but got Unknown
			//IL_0fd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe3: Expected O, but got Unknown
			//IL_1015: Unknown result type (might be due to invalid IL or missing references)
			//IL_101f: Expected O, but got Unknown
			//IL_104a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1054: Expected O, but got Unknown
			//IL_107f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1089: Expected O, but got Unknown
			//IL_10bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c5: Expected O, but got Unknown
			string configPath = Paths.ConfigPath;
			Config = new ConfigFile(Utility.CombinePaths(new string[2]
			{
				configPath,
				metadata.GUID + ".cfg"
			}), false, metadata);
			EnableHeatwaveWeather = Config.Bind<bool>("Weather", "EnableHeatwaveWeather", true, "Enable or disable Heatwave weather");
			EnableSolarFlareWeather = Config.Bind<bool>("Weather", "EnableSolarFlareWeather", true, "Enable or disable Solar Flare weather");
			EnableSnowfallWeather = Config.Bind<bool>("Weather", "EnableSnowfallWeather", true, "Enable or disable Snowfall weather");
			EnableBlizzardWeather = Config.Bind<bool>("Weather", "EnableBlizzardWeather", true, "Enable or disable Blizzard weather");
			EnableToxicSmogWeather = Config.Bind<bool>("Weather", "EnableToxicSmogWeather", true, "Enable or disable Toxic Smog weather");
			HeatwaveParticlesSpawnRate = Config.Bind<float>("Heatwave", "ParticlesSpawnRate", 20f, new ConfigDescription("Spawn rate of Heatwave particles. Particles per second", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 42f), Array.Empty<object>()));
			TimeUntilStrokeMin = Config.Bind<float>("Heatwave", "TimeUntilStrokeMin", 40f, new ConfigDescription("Minimal time in seconds until heatstroke (min)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 9999f), Array.Empty<object>()));
			TimeUntilStrokeMax = Config.Bind<float>("Heatwave", "TimeUntilStrokeMax", 80f, new ConfigDescription("Maximal time in seconds until heatstroke (max). Must be higher than min! Actual time is random between min and max", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 9999f), Array.Empty<object>()));
			HeathazeDistortionStrength = Config.Bind<float>("Heatwave", "HeathazeDistortionStrength", 8f, new ConfigDescription("Strength of the heat haze distortion effect. Higher values make the distortion more intense", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 99f), Array.Empty<object>()));
			HeathazeFilterMultiplier = Config.Bind<float>("Heatwave", "HeathazeFilterMultiplier", 1f, new ConfigDescription("Multiplier for the heat haze filter. Lower values make the filter less intense. 0 will disable the filter", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			AuroraHeight = Config.Bind<uint>("SolarFlare", "AuroraHeight", 120u, "Height of the Aurora effect above the ground");
			AuroraSpawnAreaBox = Config.Bind<float>("SolarFlare", "AuroraSpawnArea", 500f, "Size of the Aurora spawn area. The Aurora effect will spawn randomly within this square area. VFX may disappear at certain angles if the area is too small or too large.");
			AuroraVisibilityThreshold = Config.Bind<float>("SolarFlare", "AuroraVisibilityThreshold", 9f, "Light threshold when Aurora becomes visible (in Lux). Increase to make it more visible.");
			AuroraSpawnRate = Config.Bind<float>("SolarFlare", "AuroraSpawnRate", 0.1f, new ConfigDescription("Spawn rate of Aurora effects. Auroras per second", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 32f), Array.Empty<object>()));
			AuroraSize = Config.Bind<float>("SolarFlare", "AuroraSize", 100f, "Size of the Aurora 'strips' in the sky");
			DistortOnlyVoiceDuringSolarFlare = Config.Bind<bool>("SolarFlare", "DistortOnlyVoice", true, "Distort only player voice during Solar Flare (true) or all sounds (false) on a walkie-talkie");
			BatteryDrainMultiplier = Config.Bind<float>("SolarFlare", "BatteryDrainMultiplier", 1f, new ConfigDescription("Multiplier for additional battery drain during Solar Flare. 1.0 is normal drain, 0.5 is half drain, 2.0 is double drain, 0 no additional drain, etc. Default value is equal to 60 - 200 % faster drain depending on the type of flare.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			DrainBatteryInFacility = Config.Bind<bool>("SolarFlare", "DrainBatteryInFacility", false, "Drain item battery even when inside a facility during Solar Flare");
			DoorMalfunctionEnabled = Config.Bind<bool>("SolarFlare", "DoorMalfunctionEnabled", true, "Enable or disable door malfunction during Average and Strong Solar Flare");
			DoorMalfunctionChance = Config.Bind<float>("SolarFlare", "DoorMalfunctionChance", 0.5f, new ConfigDescription("Chance of metal doors opening/closing by themselves during Solar Flare. 0.1 is 10% chance, 0.5 is 50% chance, 1.0 is 100% chance. Low chance might cause you to get soft locked behind a door in the facility!", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			NoiseStaticLevel = Config.Bind<float>("SolarFlare", "NoiseStaticLevel", 0.001f, new ConfigDescription("Level of static noise from the walkie talkie during Solar Flare. This is signal amplitude, the actual volume in dB will follow a logarithmic scale. For example the volume for value 0.1 relative to 0.2 is not reduced by 100%, it's actually by ~log10(0.2/0.1) %", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			minSnowHeight = Config.Bind<float>("Snowfall", "minSnowHeight", 1.7f, new ConfigDescription("Minimum snow height at the end of the day in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			maxSnowHeight = Config.Bind<float>("Snowfall", "maxSnowHeight", 3f, new ConfigDescription("Maximum snow height at the end of the day in meters. Actual snow height is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			minTimeToFullSnow = Config.Bind<float>("Snowfall", "minTimeToFullSnow", 0.5f, new ConfigDescription("Minimum fraction of the day until snow reaches max height. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			maxTimeToFullSnow = Config.Bind<float>("Snowfall", "maxTimeToFullSnow", 0.8f, new ConfigDescription("Maximum fraction of the day until snow reaches max height. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			freezeWater = Config.Bind<bool>("Snowfall", "freezeWater", true, "Freeze water during snowfall and blizzard weather");
			underSnowFilterMultiplier = Config.Bind<float>("Snowfall", "underSnowFilterMultiplier", 1f, new ConfigDescription("Multiplier for the effect visible when player's head is covered in snow. Lower values make the filter less intense. 0 will disable the filter", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			frostbiteFilterMultiplier = Config.Bind<float>("Snowfall", "frostbiteFilterMultiplier", 1f, new ConfigDescription("Multiplier for the frostbite filter. Lower values make the filter less intense. 0 will disable the filter", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			frostbiteDamage = Config.Bind<int>("Snowfall", "frostbiteDamage", 10, new ConfigDescription("Maximum damage dealt by frostbite effect. When first signs of frostbite occur damage is set to 50% of this value and then grows to 100%.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 99), Array.Empty<object>()));
			frostbiteDamageInterval = Config.Bind<float>("Snowfall", "frostbiteDamageInterval", 20f, new ConfigDescription("Time in seconds between frostbite damage ticks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			timeToWarmUp = Config.Bind<float>("Snowfall", "timeToWarmUp", 20f, new ConfigDescription("Time in seconds to warm up from the MAXIMUM frostbite effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			enableEasterEgg = Config.Bind<bool>("Snowfall", "enableEasterEgg", true, "Allow festivities during snowfall weather during special time of the year.");
			patchModdedEnemies = Config.Bind<bool>("Snowfall", "patchModdedEnemies", false, "Attempt to patch modded enemies to be affected by snowfall weather (only works if they inherit from vanilla EnemyAI class)).");
			snowAffectsEnemies = Config.Bind<bool>("Snowfall", "snowAffectsEnemies", true, "HOST ONLY! Allow snowfall weather to affect enemies. If disabled enemies will not be slowed down by snow.");
			enemySnowBlacklist = Config.Bind<string>("Snowfall", "enemySpawnBlacklist", "Docile Locust Bees;Red Locust Bees", "List of OUTSIDE enemies that will be blocked from spawning during snowfall AND blizzard. Separate with a semicolon, exact match (including spaces, but not case sensitive).");
			minSnowHeightBlizzard = Config.Bind<float>("Blizzard", "minSnowHeightBlizzard", 1f, new ConfigDescription("Minimum snow height at the end of the day in meters during blizzard weather. Actual snow height is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			maxSnowHeightBlizzard = Config.Bind<float>("Blizzard", "maxSnowHeightBlizzard", 1.8f, new ConfigDescription("Maximum snow height at the end of the day in meters during blizzard weather. Actual snow height is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			minTimeToFullSnowBlizzard = Config.Bind<float>("Blizzard", "minTimeToFullSnowBlizzard", 0.1f, new ConfigDescription("Minimum fraction of the day until snow reaches max height during blizzard weather. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			maxTimeToFullSnowBlizzard = Config.Bind<float>("Blizzard", "maxTimeToFullSnowBlizzard", 0.2f, new ConfigDescription("Maximum fraction of the day until snow reaches max height during blizzard weather. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			minTimeUntilFrostbite = Config.Bind<float>("Blizzard", "minTimeUntilFrostbite", 40f, new ConfigDescription("Minimum time in seconds until frostbite reaches full intensity, effect starts to affect the player at 50% of chosen time. Actual time is random between min and max. Snowfall weather will only use 40% of this value as a constant.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			maxTimeUntilFrostbite = Config.Bind<float>("Blizzard", "maxTimeUntilFrostbite", 100f, new ConfigDescription("Maximum time in seconds until frostbite reaches full intensity, effect starts to affect the player at 50% of chosen time. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			minWindForce = Config.Bind<float>("Blizzard", "minWindForce", 0.37f, new ConfigDescription("Minimum wind force during blizzard weather. Actual wind force is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			maxWindForce = Config.Bind<float>("Blizzard", "maxWindForce", 0.6f, new ConfigDescription("Maximum wind force during blizzard weather. At very high values you might not be able to move while standing in deep snow! Actual wind force is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			minWaveInterval = Config.Bind<float>("Blizzard", "minWaveInterval", 60f, new ConfigDescription("Minimum time in seconds between chilling waves of frost. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			maxWaveInterval = Config.Bind<float>("Blizzard", "maxWaveInterval", 180f, new ConfigDescription("Maximum time in seconds between chilling waves of frost. Actual time is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			minWaveCount = Config.Bind<int>("Blizzard", "minWaveCount", 1, new ConfigDescription("Minimum number of chilling waves of frost that will strike in succession. Actual number is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 99), Array.Empty<object>()));
			maxWaveCount = Config.Bind<int>("Blizzard", "maxWaveCount", 5, new ConfigDescription("Maximum number of chilling waves of frost that will strike in succession. Actual number is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 99), Array.Empty<object>()));
			chillingWaveDamage = Config.Bind<int>("Blizzard", "chillingWaveDamage", 20, new ConfigDescription("Damage dealt by each chilling wave of frost if you get caught in one.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 99), Array.Empty<object>()));
			blizzardAmbientVolume = Config.Bind<float>("Blizzard", "blizzardAmbientVolume", 1f, new ConfigDescription("Volume of the blizzard ambient sound. 0 is silent, 1 is full volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			blizzardWaveVolume = Config.Bind<float>("Blizzard", "blizzardWaveVolume", 1f, new ConfigDescription("Volume of the blizzard wave sound. 0 is silent, 1 is full volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			snowParticlesMultiplier = Config.Bind<float>("Snow Graphics", "snowParticlesMultiplier", 1f, new ConfigDescription("Multiplier for the amount of snow/blizzard particles. Lower values may reduce performance impact but also visual quality.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			blizzardWaveParticlesMultiplier = Config.Bind<float>("Snow Graphics", "blizzardWaveParticlesMultiplier", 1f, new ConfigDescription("Multiplier for the amount of blizzard wave particles. Lower values may reduce performance impact but also reduce density of particles.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			enableBlizzardFog = Config.Bind<bool>("Snow Graphics", "enableBlizzardFog", true, "Enable blizzard fog effect. Disabling this can improve performance, at the cost of visual quality.");
			snowVfxLighting = Config.Bind<bool>("Snow Graphics", "snowVfxLighting", false, "Determines if snow particles are affected by shadows and lighting. Disabling this will make snow particles appear the same regardless of lighting conditions, but significantly improves the performance.");
			blizzardWaveVfxLighting = Config.Bind<bool>("Snow Graphics", "blizzardWaveVfxLighting", false, "Determines if blizzard wave particles are affected by shadows and lighting. Disabling this will make blizzard wave particles appear the same regardless of lighting conditions, but significantly improves the performance.");
			useOpaqueSnowMaterial = Config.Bind<bool>("Snow Graphics", "useOpaqueSnowMaterial", false, "Use opaque snow material. Disabling this will use a transparent snow material, which will allow for more realistic snow overlay rendering, but will not work with the posterization effect.");
			snowCastsShadows = Config.Bind<bool>("Snow Graphics", "snowCastsShadows", false, "Snow will cast shadows on the terrain. Disabling this will improve performance, this is quite resource intensive!");
			addFootprints = Config.Bind<bool>("Snow Graphics", "addFootprints", false, "Override level settings and enable vanilla footprints during the weather. Disabling this will use the level settings for footprints.");
			trackedEntityNumber = Config.Bind<int>("Snow Graphics", "trackedEntityNumber", 64, new ConfigDescription("Number of entities that will be tracked for snow depth, INCLUDING all players. If there are more entities than this number their speed won't be affected by snow. For a better efficiency should be an even number.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 256), Array.Empty<object>()));
			depthBufferResolution = Config.Bind<int>("Snow Graphics", "depthBufferResolution", 2048, new ConfigDescription("Resolution of the depth buffer used to capture the level and remove snow under objects. Higher values increase quality but also memory usage. MUST be a power of 2 : 512, 1024, 2048, etc.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(256, 8192), Array.Empty<object>()));
			trackerMapResolution = Config.Bind<int>("Snow Graphics", "trackerMapResolution", 256, new ConfigDescription("Resolution of the map used to render snow tracks. Higher values increase quality but also memory usage. MUST be a power of 2!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(32, 1024), Array.Empty<object>()));
			snowDepthMapResolution = Config.Bind<int>("Snow Graphics", "snowDepthMapResolution", 1024, new ConfigDescription("Resolution of the baked texture used to store snow depth data. Higher values increase quality but also memory usage. MUST be a power of 2!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(256, 8192), Array.Empty<object>()));
			bakeSnowDepthMipmaps = Config.Bind<bool>("Snow Graphics", "bakeSnowDepthMipmaps", false, "Generate mipmaps for the snow depth map. Disabling this will reduce memory usage at the cost of quality.");
			PCFKernelSize = Config.Bind<int>("Snow Graphics", "PCFKernelSize", 12, new ConfigDescription("Kernel size for Percentage Closer Filtering. Higher values increase will produce smoother snow 'shadows' under objects, but will slow baking and thus level loading times.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>()));
			minTesselationFactor = Config.Bind<int>("Snow Graphics", "minTesselationFactor", 4, new ConfigDescription("Minimum tesselation factor for snow material. Higher values increase quality but also memory usage. Number represents how many times each triangle is divided, and how detailed snow geometry will appear.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 32), Array.Empty<object>()));
			maxTesselationFactor = Config.Bind<int>("Snow Graphics", "maxTesselationFactor", 16, new ConfigDescription("Maximum tesselation factor for snow material. Higher values increase quality but also memory usage. Number represents how many times each triangle is divided.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 32), Array.Empty<object>()));
			adaptiveTesselation = Config.Bind<bool>("Snow Graphics", "adaptiveTesselation", true, "Enable adaptive tesselation for snow material. This will apply max tesselation factor only to areas with rapid snow height changes, like around snow tracks, trees or roofs.");
			softSnowEdges = Config.Bind<bool>("Snow Graphics", "softSnowEdges", false, "Enable soft snow edges. This will use depth buffer to blend snow with covered objects better. May cause visual artifacts in areas of rapid relief changes.");
			enableSnowTracks = Config.Bind<bool>("Snow Graphics", "enableSnowTracks", true, "Enable snow tracks. This will render snow tracks on the ground where player or enemies walk and will affect walking speed. Disabling this will improve performance.");
			enableVFXCollisions = Config.Bind<bool>("Snow Graphics", "Enable VFX Collisions", true, "Enable VFX collisions for blizzard wind. This will render an additional depth buffer to make snow particles collide with the terrain and objects. Disabling this will improve performance.");
			asyncProcessing = Config.Bind<bool>("Mesh & Terrain Processing", "asyncProcessing", true, "Enable asynchronous mesh and terrain processing. Disabling this will process everything in the main thread, which will increase loading times.");
			meshProcessingWhitelist = Config.Bind<string>("Mesh & Terrain Processing", "meshProcessingWhitelist", "Offense;Assurance;Artifice;Experimentation;March", "List of moons that will be included for additional mesh processing. Only put moons that have MESH terrains in this list and you see visual artifacts with snow on them (like thin triangles, spikes or disjoined surfaces). Separate with a semicolon, exact match (including spaces, but not case sensitive).");
			subdivideMesh = Config.Bind<bool>("Mesh & Terrain Processing", "subdivideMesh", true, "Subdivide EXISTING terrain meshes to create more detailed snow geometry. Disabling this will slightly reduce memory usage but may cause visual artifacts.");
			smoothMesh = Config.Bind<bool>("Mesh & Terrain Processing", "smoothMesh", true, "Smooth EXISTING terrain meshes to create a better vertex distribution for tesselation. Disabling this if collision glitches on steep terrain appear.");
			useLevelBounds = Config.Bind<bool>("Mesh & Terrain Processing", "useLevelBounds", true, "Use level bounds to limit mesh and terrain processing to the playable area. Disabling this will process the whole level, which will improve the entire levels geometry, but will increase loading times");
			refineMesh = Config.Bind<bool>("Mesh & Terrain Processing", "refineMesh", true, "TerraMesh. Refine the mesh produced FROM TERRAIN to remove possible thin triangles. Disabling this may slightly speed up loading, but will cause degraded mesh quality.");
			carveHoles = Config.Bind<bool>("Mesh & Terrain Processing", "carveHoles", true, "TerraMesh. Copy holes from terrain onto the mesh. Disabling this will cause terrain holes to be filled instead.");
			useMeshCollider = Config.Bind<bool>("Mesh & Terrain Processing", "useMeshCollider", false, "TerraMesh. Use mesh collider for the produced mesh, this will also copy trees from terrain. Disabling this will use the default terrain collider.");
			targetVertexCount = Config.Bind<int>("Mesh & Terrain Processing", "targetVertexCount", -1, new ConfigDescription("TerraMesh. Target vertex count for the produced mesh within specified bounds. -1 means minMeshStep is used to determine quality of the mesh, at values > 0 minMeshStep will be recalculated, so that the number of vertices could match this target value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 500000), Array.Empty<object>()));
			minMeshStep = Config.Bind<int>("Mesh & Terrain Processing", "minMeshStep", 1, new ConfigDescription("TerraMesh. Minimum step size for the produced mesh. Higher values increase speed but reduce quality. 1 is the highest quality and will copy terrain exactly. 2 will skip every second vertex, etc.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 128), Array.Empty<object>()));
			maxMeshStep = Config.Bind<int>("Mesh & Terrain Processing", "maxMeshStep", 32, new ConfigDescription("TerraMesh. Maximum step size for the produced mesh. Outside of calculated playable level bounds the step size will be gradually increased to this value. Step size will rounded up to the nearest power of 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 128), Array.Empty<object>()));
			falloffRatio = Config.Bind<float>("Mesh & Terrain Processing", "falloffRatio", 3f, new ConfigDescription("TerraMesh. How fast the step size increases outside of calculated playable level bounds. Higher values increase speed but reduce quality. 1 is linear falloff, 2 is quadratic, 3 is cubic, etc.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 16f), Array.Empty<object>()));
			ToxicDamageInterval = Config.Bind<float>("Toxic Smog", "ToxicDamageInterval", 2f, new ConfigDescription("Time in seconds between toxic smog damage ticks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 9999f), Array.Empty<object>()));
			ToxicDamageAmount = Config.Bind<int>("Toxic Smog", "ToxicDamageAmount", 4, new ConfigDescription("Amount of damage dealt by toxic smog effect.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			PoisoningRemovalMultiplier = Config.Bind<float>("Toxic Smog", "PoisoningRemovalMultiplier", 0.5f, new ConfigDescription("Multiplier for the rate at which poisoning effect is removed. 1.0 is normal rate, 0.5 is half rate, 2.0 is double rate, 0 no removal. Values are in comparison to gain rate.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			MinFreePath = Config.Bind<float>("Toxic Smog", "MinFreePath", 8f, new ConfigDescription("Minimum free path length for toxic smog in meters. Actual free path length is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 256f), Array.Empty<object>()));
			MaxFreePath = Config.Bind<float>("Toxic Smog", "MaxFreePath", 25f, new ConfigDescription("Maximum free path length for toxic smog in meters. Actual free path length is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 256f), Array.Empty<object>()));
			MinFumesAmount = Config.Bind<int>("Toxic Smog", "MinFumesAmount", 40, new ConfigDescription("Minimum amount of fumes spawned outside. Actual amount is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 256), Array.Empty<object>()));
			MaxFumesAmount = Config.Bind<int>("Toxic Smog", "MaxFumesAmount", 75, new ConfigDescription("Maximum amount of fumes spawned outside. Actual amount is random between min and max.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 256), Array.Empty<object>()));
			FactoryAmountMultiplier = Config.Bind<float>("Toxic Smog", "FactoryAmountMultiplier", 0.5f, new ConfigDescription("Multiplier for the amount of fumes placed in the interior with respect to outside. Keep in mind that their amount is also multiplied by a dungeon size!", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
		}
	}
	[Serializable]
	public struct EntitySnowData
	{
		public Vector3 w;

		public Vector2 uv;

		public int textureIndex;

		public float snowThickness;

		public EntitySnowData()
		{
			//IL_0006: 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)
			w = default(Vector3);
			uv = default(Vector2);
			textureIndex = 0;
			snowThickness = 0f;
			Reset();
		}

		public void Reset()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			w = Vector3.zero;
			uv = Vector2.zero;
			textureIndex = -1;
			snowThickness = 0f;
		}
	}
	public static class RandomExtensions
	{
		public static float NextDouble(this Random random, float min, float max)
		{
			if (min > max)
			{
				float num = max;
				max = min;
				min = num;
				Debug.LogWarning("Minimum value for random range must be less than maximum value. Switching them around!");
			}
			return (float)random.NextDouble() * (max - min) + min;
		}

		internal static IEnumerator BakeMasks(this Texture2DArray snowMasks, List<GameObject> objectsToBake, Material bakeMaterial, int bakeResolution = 1024, int submeshIndex = 0)
		{
			if (objectsToBake.Count == 0)
			{
				Debug.LogDebug("No objects to bake!");
				yield break;
			}
			if (snowMasks.depth != objectsToBake.Count)
			{
				Debug.LogError("The depth of the snowMasks texture array must be equal to the number of objects to bake!");
				yield break;
			}
			Stopwatch sw = new Stopwatch();
			RenderTexture tempRT = RenderTexture.GetTemporary(bakeResolution, bakeResolution, 0, (RenderTextureFormat)11);
			((Texture)tempRT).wrapMode = (TextureWrapMode)1;
			((Texture)tempRT).filterMode = (FilterMode)2;
			RenderTexture blurRT1 = RenderTexture.GetTemporary(bakeResolution, bakeResolution, 0, (RenderTextureFormat)11);
			((Texture)blurRT1).wrapMode = (TextureWrapMode)1;
			((Texture)blurRT1).filterMode = (FilterMode)2;
			RenderTexture blurRT2 = RenderTexture.GetTemporary(bakeResolution, bakeResolution, 0, (RenderTextureFormat)11);
			((Texture)blurRT2).wrapMode = (TextureWrapMode)1;
			((Texture)blurRT2).filterMode = (FilterMode)2;
			Texture2D maskLayer = new Texture2D(bakeResolution, bakeResolution, (TextureFormat)20, false);
			((Texture)maskLayer).wrapMode = (TextureWrapMode)1;
			((Texture)maskLayer).filterMode = (FilterMode)2;
			for (int textureIndex = 0; textureIndex < objectsToBake.Count; textureIndex++)
			{
				sw.Restart();
				GameObject val = objectsToBake[textureIndex];
				MeshFilter component = val.GetComponent<MeshFilter>();
				Mesh val2 = ((component != null) ? component.sharedMesh : null);
				if ((Object)(object)val2 == (Object)null)
				{
					Debug.LogError("No mesh found on object to bake with name: " + ((Object)val).name + "!");
					yield break;
				}
				Debug.LogDebug("Baking mask for " + ((Object)val).name + " with texture index " + textureIndex + " and submesh index " + submeshIndex);
				RenderTexture active = RenderTexture.active;
				RenderTexture.active = tempRT;
				GL.Clear(true, true, Color.clear);
				Matrix4x4 localToWorldMatrix = val.transform.localToWorldMatrix;
				if (bakeMaterial != null && bakeMaterial.SetPass(0))
				{
					Graphics.DrawMeshNow(val2, localToWorldMatrix, submeshIndex);
				}
				sw.Stop();
				Debug.LogDebug("Baking took " + sw.ElapsedMilliseconds + " ms");
				sw.Restart();
				Graphics.Blit((Texture)(object)tempRT, blurRT1, bakeMaterial, 1);
				Graphics.Blit((Texture)(object)blurRT1, blurRT2, bakeMaterial, 2);
				RenderTexture.active = blurRT2;
				maskLayer.ReadPixels(new Rect(0f, 0f, (float)bakeResolution, (float)bakeResolution), 0, 0);
				Graphics.CopyTexture((Texture)(object)maskLayer, 0, 0, (Texture)(object)snowMasks, textureIndex, 0);
				sw.Stop();
				Debug.LogDebug("Blurring took " + sw.ElapsedMilliseconds + " ms");
				RenderTexture.active = active;
				yield return null;
			}
			RenderTexture.ReleaseTemporary(tempRT);
			RenderTexture.ReleaseTemporary(blurRT1);
			RenderTexture.ReleaseTemporary(blurRT2);
			Object.Destroy((Object)(object)maskLayer);
		}

		public static GameObject Duplicate(this GameObject original, bool disableShadows = true, bool removeCollider = true, bool noChildren = true)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			List<Transform> list = new List<Transform>();
			if (noChildren)
			{
				foreach (Transform item in original.transform)
				{
					Transform val = item;
					list.Add(val);
					val.SetParent((Transform)null);
				}
			}
			GameObject val2 = Object.Instantiate<GameObject>(original);
			if (noChildren)
			{
				foreach (Transform item2 in list)
				{
					item2.SetParent(original.transform);
				}
			}
			((Object)val2).name = ((Object)original).name + "_Copy";
			val2.transform.SetParent(original.transform.parent);
			val2.transform.localPosition = original.transform.localPosition;
			val2.transform.localRotation = original.transform.localRotation;
			val2.transform.localScale = original.transform.localScale;
			MeshRenderer[] componentsInChildren = val2.GetComponentsInChildren<MeshRenderer>();
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val3 in array)
			{
				((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
			}
			if (!disableShadows)
			{
				MeshRenderer component = original.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
				}
				component = val2.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).shadowCastingMode = (ShadowCastingMode)1;
				}
			}
			if (removeCollider)
			{
				Collider[] componentsInChildren2 = val2.GetComponentsInChildren<Collider>();
				Collider[] array2 = componentsInChildren2;
				foreach (Collider val4 in array2)
				{
					Object.Destroy((Object)(object)val4);
				}
			}
			return val2;
		}

		public static void RestoreShader(this Material material)
		{
			Shader shader = Shader.Find(((Object)material.shader).name);
			material.shader = shader;
		}

		public static void SpawnAtPosition(this Item itemToSpawn, Vector3 spawnPosition, int scrapValue = 7)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)itemToSpawn == (Object)null)
			{
				Debug.LogError("Error: Item to spawn is null.");
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(itemToSpawn.spawnPrefab, spawnPosition, Quaternion.identity);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.scrapValue = scrapValue;
			NetworkObject component2 = val.GetComponent<NetworkObject>();
			component2.Spawn(false);
		}

		public static string CleanMoonName(this string moonName)
		{
			return moonName.Replace(" ", "").Replace("_", "").Replace("-", "")
				.ToLower();
		}

		public static void WhiteOut(this RenderTexture rt)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = rt;
			GL.Clear(true, true, Color.white);
			RenderTexture.active = active;
		}

		public static IEnumerator AsCoroutine(this Task task)
		{
			while (!task.IsCompleted)
			{
				yield return null;
			}
			if (task.IsFaulted)
			{
				Debug.LogError("Task failed: " + task.Exception);
			}
		}

		public static IEnumerator NavMeshRebuildCoroutine(this NavMeshSurface navMeshSurface, AsyncOperation asyncOperation, Stopwatch sw)
		{
			sw.Restart();
			while (!asyncOperation.isDone)
			{
				yield return null;
			}
			sw.Stop();
			Debug.LogDebug($"NavMesh rebaked in {sw.ElapsedMilliseconds} ms");
		}
	}
	internal class PlayerEffectsManager
	{
		public static bool isInHeatZone = false;

		public static bool isInColdZone = false;

		public static bool isPoisoned = false;

		public static bool isUnderSnow = false;

		public static float heatTransferRate = 1f;

		public static float normalizedTemperature = 0f;

		public static float poisoningStrength = 0f;

		private static readonly float underSnowFadeSpeed = 0.5f;

		internal static Volume? heatEffectVolume;

		internal static Volume? freezeEffectVolume;

		internal static Volume? underSnowVolume;

		public static float HeatSeverity => Mathf.Clamp01(normalizedTemperature);

		public static float ColdSeverity => Mathf.Clamp01(0f - normalizedTemperature);

		private static float UnderSnowVisualMultiplier => Configuration.underSnowFilterMultiplier.Value;

		private static float HeatVisualMultiplier => Configuration.HeathazeFilterMultiplier.Value;

		private static float ColdVisualMultiplier => Configuration.frostbiteFilterMultiplier.Value;

		internal static void SetPlayerTemperature(float temperatureDelta)
		{
			normalizedTemperature = Mathf.Clamp(normalizedTemperature + temperatureDelta * heatTransferRate, -1f, 1f);
			if ((Object)(object)heatEffectVolume != (Object)null)
			{
				heatEffectVolume.weight = HeatSeverity * HeatVisualMultiplier;
			}
			if ((Object)(object)freezeEffectVolume != (Object)null)
			{
				freezeEffectVolume.weight = ColdVisualMultiplier * Mathf.Min(ColdSeverity / SnowPatches.frostbiteThreshold * 0.9f, (0.1f * ColdSeverity + 0.9f - SnowPatches.frostbiteThreshold) / (1f - SnowPatches.frostbiteThreshold));
			}
		}

		internal static void ResetPlayerTemperature(float temperatureDelta)
		{
			SetPlayerTemperature((0f - Mathf.Sign(normalizedTemperature)) * temperatureDelta);
		}

		internal static void SetPoisoningEffect(float poisonDelta)
		{
			poisoningStrength = Mathf.Clamp01(poisoningStrength + poisonDelta * 0.25f);
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			float weight = HUDManager.Instance.drunknessFilter.weight;
			float num = Mathf.Max(weight, poisoningStrength);
			HUDManager.Instance.drunknessFilter.weight = num;
			HUDManager.Instance.gasImageAlpha.alpha = HUDManager.Instance.drunknessFilter.weight * 1.5f;
			SoundManager.Instance.playerVoicePitchTargets[localPlayerController.playerClientId] = ((num <= 0.15f) ? 1f : (1f + num));
		}

		internal static void SetUnderSnowEffect(float weightDelta)
		{
			if (!((Object)(object)underSnowVolume == (Object)null))
			{
				float num = Mathf.Clamp01(underSnowVolume.weight + weightDelta / underSnowFadeSpeed);
				underSnowVolume.weight = num * UnderSnowVisualMultiplier;
			}
		}
	}
	internal static class SnowfallShaderIDs
	{
		internal static readonly int FadeValue = Shader.PropertyToID("_FadeValue");

		internal static readonly int DepthTex = Shader.PropertyToID("_DepthTex");

		internal static readonly int FootprintsTex = Shader.PropertyToID("_FootprintsTex");

		internal static readonly int LightViewProjection = Shader.PropertyToID("_LightViewProjection");

		internal static readonly int FootprintsViewProjection = Shader.PropertyToID("_FootprintsViewProjection");

		internal static readonly int ShadowBias = Shader.PropertyToID("_ShadowBias");

		internal static readonly int PCFKernelSize = Shader.PropertyToID("_PCFKernelSize");

		internal static readonly int SnowNoisePower = Shader.PropertyToID("_SnowNoisePower");

		internal static readonly int SnowNoiseScale = Shader.PropertyToID("_SnowNoiseScale");

		internal static readonly int SnowNoiseScaleOverlay = Shader.PropertyToID("_SnowNoiseScaleOverlay");

		internal static readonly int MaxSnowHeight = Shader.PropertyToID("_MaxSnowHeight");

		internal static readonly int SnowOcclusionBias = Shader.PropertyToID("_SnowOcclusionBias");

		internal static readonly int BaseTessellationFactor = Shader.PropertyToID("_BaseTessellationFactor");

		internal static readonly int MaxTessellationFactor = Shader.PropertyToID("_MaxTessellationFactor");

		internal static readonly int isAdaptiveTessellation = Shader.PropertyToID("_isAdaptiveTesselation");

		internal static readonly int ShipPosition = Shader.PropertyToID("_ShipPosition");

		internal static readonly int Emission = Shader.PropertyToID("_Emission");

		internal static readonly int SnowMasks = Shader.PropertyToID("_SnowMaskTex");

		internal static readonly int BlurKernelSize = Shader.PropertyToID("_BlurKernelSize");

		internal static readonly int TexIndex = Shader.PropertyToID("_TexIndex");

		internal static readonly int NormalStrength = Shader.PropertyToID("_NormalStrength");

		internal static readonly int SnowColor = Shader.PropertyToID("_SnowColor");

		internal static readonly int SnowBaseColor = Shader.PropertyToID("_SnowBaseColor");

		internal static readonly int BlizzardFogColor = Shader.PropertyToID("_BlizzardFogColor");

		internal static readonly int Metallic = Shader.PropertyToID("_Metallic");

		internal static readonly int IsDepthFade = Shader.PropertyToID("_EnableDepthFade");
	}
	internal static class ToxicShaderIDs
	{
		internal static readonly int FumesColor = Shader.PropertyToID("_FumesColor");
	}
	public enum TrackerType
	{
		Footprints,
		FootprintsLowCapacity,
		Shovel,
		Item
	}
	public static class SnowTrackersManager
	{
		internal static GameObject? snowTrackersContainer;

		public static Dictionary<MonoBehaviour, VisualEffect> snowTrackersDict = new Dictionary<MonoBehaviour, VisualEffect>();

		public static Dictionary<MonoBehaviour, VisualEffect> snowShovelDict = new Dictionary<MonoBehaviour, VisualEffect>();

		private static readonly int isTrackingID = Shader.PropertyToID("isTracking");

		public static void RegisterFootprintTracker(MonoBehaviour obj, TrackerType trackerVariant, float particleSize = 1f, float lifetimeMultiplier = 1f, float footprintStrength = 1f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)snowTrackersContainer == (Object)null)
			{
				snowTrackersContainer = new GameObject("SnowTrackersContainer");
				Object.DontDestroyOnLoad((Object)(object)snowTrackersContainer);
			}
			VisualEffectAsset visualEffectAsset = (VisualEffectAsset)(trackerVariant switch
			{
				TrackerType.Footprints => SnowfallVFXManager.snowTrackersDict?["footprintsTrackerVFX"], 
				TrackerType.FootprintsLowCapacity => SnowfallVFXManager.snowTrackersDict?["lowcapFootprintsTrackerVFX"], 
				TrackerType.Shovel => SnowfallVFXManager.snowTrackersDict?["shovelVFX"], 
				TrackerType.Item => SnowfallVFXManager.snowTrackersDict?["itemTrackerVFX"], 
				_ => null, 
			});
			GameObject val = new GameObject("FootprintsTracker_" + trackerVariant.ToString() + "_" + ((Object)obj).name);
			Transform transform = val.transform;
			GameObject? obj2 = snowTrackersContainer;
			transform.SetParent((obj2 != null) ? obj2.transform : null);
			val.transform.localPosition = Vector3.zero;
			val.transform.localScale = Vector3.one;
			val.layer = LayerMask.NameToLayer("Vehicle");
			VisualEffect val2 = val.AddComponent<VisualEffect>();
			val2.visualEffectAsset = visualEffectAsset;
			if (trackerVariant == TrackerType.Shovel)
			{
				val.transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
				snowShovelDict.Add(obj, val2);
				return;
			}
			val.transform.localRotation = Quaternion.identity;
			val2.SetFloat("particleSize", particleSize);
			val2.SetFloat("lifetimeMultiplier", lifetimeMultiplier);
			val2.SetFloat("footprintStrength", footprintStrength);
			snowTrackersDict.Add(obj, val2);
		}

		public static void UpdateFootprintTracker(MonoBehaviour obj, bool enableTracker, Vector3 offset = default(Vector3))
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (Configuration.enableSnowTracks.Value && snowTrackersDict.TryGetValue(obj, out VisualEffect value))
			{
				((Component)value).transform.position = ((Component)obj).transform.position + offset;
				if (value.GetBool(isTrackingID) ^ enableTracker)
				{
					value.SetBool(isTrackingID, enableTracker);
				}
			}
		}

		public static void PlayFootprintTracker(MonoBehaviour obj, TrackerType trackerVariant, bool playCondition = false)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<MonoBehaviour, VisualEffect> dictionary = ((trackerVariant != TrackerType.Shovel) ? snowTrackersDict : snowShovelDict);
			if (dictionary.TryGetValue(obj, out var value) && playCondition)
			{
				((Component)value).transform.position = ((Component)obj).transform.position;
				if (value != null)
				{
					value.Play();
				}
			}
		}

		internal static void AddFootprintTracker(MonoBehaviour obj, float particleSize, float lifetimeMultiplier, float footprintStrength)
		{
			if (!Configuration.enableSnowTracks.Value)
			{
				return;
			}
			if (!(obj is PlayerControllerB))
			{
				if (!(obj is EnemyAI))
				{
					if (!(obj is GrabbableObject))
					{
						if (obj is VehicleController)
						{
							RegisterFootprintTracker(obj, TrackerType.Footprints, particleSize, lifetimeMultiplier, footprintStrength);
						}
					}
					else
					{
						RegisterFootprintTracker(obj, TrackerType.Item, particleSize, lifetimeMultiplier, footprintStrength);
					}
				}
				else
				{
					RegisterFootprintTracker(obj, TrackerType.FootprintsLowCapacity, particleSize, lifetimeMultiplier, footprintStrength);
				}
			}
			else
			{
				RegisterFootprintTracker(obj, TrackerType.Footprints, particleSize, lifetimeMultiplier, footprintStrength);
			}
			if (obj is Shovel)
			{
				RegisterFootprintTracker(obj, TrackerType.Shovel);
			}
		}

		internal static void CleanupFootprintTrackers(Dictionary<MonoBehaviour, VisualEffect> trackersDict)
		{
			Debug.LogDebug("Cleaning up snow footprint trackers");
			List<MonoBehaviour> list = new List<MonoBehaviour>();
			foreach (KeyValuePair<MonoBehaviour, VisualEffect> item in trackersDict)
			{
				if ((Object)(object)item.Key == (Object)null)
				{
					if ((Object)(object)item.Value != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)item.Value).gameObject);
					}
					list.Add(item.Key);
				}
			}
			Debug.LogDebug($"Removing {list.Count} previously destroyed entries from snow footprint trackers");
			foreach (MonoBehaviour item2 in list)
			{
				trackersDict.Remove(item2);
			}
		}

		internal static void ToggleFootprintTrackers(bool enable)
		{
			GameObject? obj = snowTrackersContainer;
			if (obj != null)
			{
				obj.SetActive(enable);
			}
		}
	}
	public class WeatherAssetLoader
	{
		private static readonly Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>();

		public static T? LoadAsset<T>(string bundleName, string assetName) where T : Object
		{
			AssetBundle val = LoadBundle(bundleName);
			if ((Object)(object)val == (Object)null)
			{
				return default(T);
			}
			return val.LoadAsset<T>(assetName);
		}

		private static AssetBundle? LoadBundle(string bundleName)
		{
			if (loadedBundles.ContainsKey(bundleName))
			{
				return loadedBundles[bundleName];
			}
			string location = Assembly.GetExecutingAssembly().Location;
			string directoryName = Path.GetDirectoryName(location);
			string text = Path.Combine(directoryName, bundleName);
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val != (Object)null)
			{
				loadedBundles.Add(bundleName, val);
			}
			else
			{
				Debug.LogError("Failed to load AssetBundle: " + bundleName);
			}
			return val;
		}

		public static void UnloadAllBundles()
		{
			foreach (AssetBundle value in loadedBundles.Values)
			{
				value.Unload(true);
			}
			loadedBundles.Clear();
		}
	}
	public class WeatherTypeLoader
	{
		internal static string bundleName = "voxxweather.assetbundle";

		public static void RegisterHeatwaveWeather()
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = WeatherAssetLoader.LoadAsset<GameObject>(bundleName, "HeatwaveWeatherContainer");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError("Failed to load Heatwave Weather assets. Weather registration failed.");
				return;
			}
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			HeatwaveWeather componentInChildren = val2.GetComponentInChildren<HeatwaveWeather>(true);
			GameObject gameObject = ((Component)componentInChildren).gameObject;
			gameObject.SetActive(false);
			HeatwaveVFXManager componentInChildren2 = val2.GetComponentInChildren<HeatwaveVFXManager>(true);
			GameObject gameObject2 = ((Component)componentInChildren2).gameObject;
			gameObject2.SetActive(false);
			componentInChildren.VFXManager = componentInChildren2;
			VisualEffectAsset val3 = WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "HeatwaveVFX");
			if ((Object)(object)val3 == (Object)null)
			{
				Debug.LogError("Failed to load Heatwave Weather visual assets. Weather registration failed.");
				return;
			}
			VisualEffect component = componentInChildren2.heatwaveParticlePrefab.GetComponent<VisualEffect>();
			component.visualEffectAsset = val3;
			component.SetFloat("particleSpawnRate", Configuration.HeatwaveParticlesSpawnRate.Value);
			component.SetFloat("distortionScale", Configuration.HeathazeDistortionStrength.Value);
			val2.SetActive(true);
			ImprovedWeatherEffect val4 = new ImprovedWeatherEffect(gameObject2, gameObject)
			{
				SunAnimatorBool = ""
			};
			Weather val5 = new Weather(componentInChildren.WeatherName, val4);
			val5.DefaultLevelFilters = new string[26]
			{
				"Experimentation", "Assurance", "Offense", "Embrion", "Artifice", "EGypt", "Aquatis", "Affliction", "Penumbra", "EchoReach",
				"Harloth", "Celestria", "Derelict", "Infernis", "Etern", "Atlantica", "Junic", "Fission", "Mantif", "Sierra",
				"Cambrian", "Orion", "Vertigo", "Collateral", "Devastation", "RelayStation"
			};
			val5.LevelFilteringOption = (FilteringOption)0;
			val5.Color = new Color(1f, 0.5f, 0f);
			val5.ScrapAmountMultiplier = 1.2f;
			val5.ScrapValueMultiplier = 0.9f;
			val5.DefaultWeight = 100;
			Weather val6 = val5;
			WeatherManager.RegisterWeather(val6);
			Debug.Log("voxx.LethalElementsPlugin: Heatwave weather registered!");
		}

		public static void RegisterFlareWeather()
		{
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = WeatherAssetLoader.LoadAsset<GameObject>(bundleName, "SolarFlareWeatherContainer");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError("Failed to load Solar Flare Weather assets. Weather registration failed.");
				return;
			}
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			SolarFlareWeather componentInChildren = val2.GetComponentInChildren<SolarFlareWeather>(true);
			GameObject gameObject = ((Component)componentInChildren).gameObject;
			gameObject.SetActive(false);
			SolarFlareVFXManager componentInChildren2 = val2.GetComponentInChildren<SolarFlareVFXManager>(true);
			GameObject gameObject2 = ((Component)componentInChildren2).gameObject;
			gameObject2.SetActive(false);
			componentInChildren.VFXManager = componentInChildren2;
			VisualEffectAsset val3 = WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "CoronaVFX");
			VisualEffectAsset val4 = WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "AuroraVFX");
			if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
			{
				Debug.LogError("Failed to load Solar Flare Weather visual assets. Weather registration failed.");
				return;
			}
			componentInChildren2.flareObject.GetComponent<VisualEffect>().visualEffectAsset = val3;
			VisualEffect component = componentInChildren2.auroraObject.GetComponent<VisualEffect>();
			component.visualEffectAsset = val4;
			component.SetUInt("spawnHeight", Configuration.AuroraHeight.Value);
			component.SetFloat("spawnBoxSize", Configuration.AuroraSpawnAreaBox.Value);
			component.SetFloat("auroraSize", Configuration.AuroraSize.Value);
			component.SetFloat("particleSpawnRate", Configuration.AuroraSpawnRate.Value);
			val2.SetActive(true);
			ImprovedWeatherEffect val5 = new ImprovedWeatherEffect(gameObject2, gameObject)
			{
				SunAnimatorBool = ""
			};
			Weather val6 = new Weather(componentInChildren.WeatherName, val5);
			val6.DefaultLevelFilters = new string[1] { "Gordion" };
			val6.LevelFilteringOption = (FilteringOption)1;
			val6.Color = Color.yellow;
			val6.ScrapAmountMultiplier = 0.95f;
			val6.ScrapValueMultiplier = 1.25f;
			val6.DefaultWeight = 100;
			Weather val7 = val6;
			WeatherManager.RegisterWeather(val7);
			Debug.Log("voxx.LethalElementsPlugin: Solar flare weather registered!");
		}

		public static void RegisterBlizzardWeather()
		{
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = WeatherAssetLoader.LoadAsset<GameObject>(bundleName, "BlizzardWeatherContainer");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError("Failed to load Blizzard Weather assets. Weather registration failed.");
				return;
			}
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			BlizzardWeather blizzardWeather = (BlizzardWeather.Instance = val2.GetComponentInChildren<BlizzardWeather>(true));
			GameObject gameObject = ((Component)blizzardWeather).gameObject;
			gameObject.SetActive(false);
			BlizzardVFXManager componentInChildren = val2.GetComponentInChildren<BlizzardVFXManager>(true);
			GameObject gameObject2 = ((Component)componentInChildren).gameObject;
			gameObject2.SetActive(false);
			blizzardWeather.VFXManager = componentInChildren;
			VisualEffectAsset val3 = (Configuration.snowVfxLighting.Value ? WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "BlizzardVFXLit") : WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "BlizzardVFX"));
			VisualEffectAsset val4 = (Configuration.blizzardWaveVfxLighting.Value ? WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "BlizzardWaveVFXLit") : WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "BlizzardWaveVFX"));
			if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
			{
				Debug.LogError("Failed to load Blizzard Weather visual assets. Weather registration failed.");
				return;
			}
			VisualEffect component = componentInChildren.snowVFXContainer.GetComponent<VisualEffect>();
			component.visualEffectAsset = val3;
			component.SetFloat("spawnRateMultiplier", Configuration.snowParticlesMultiplier.Value);
			component.SetBool("isCollisionEnabled", Configuration.enableVFXCollisions.Value);
			component.SetBool("fogEnabled", Configuration.enableBlizzardFog.Value);
			Camera componentInChildren2 = ((Component)component).GetComponentInChildren<Camera>(true);
			((Behaviour)componentInChildren2).enabled = Configuration.enableVFXCollisions.Value;
			VisualEffect componentInChildren3 = componentInChildren.blizzardWaveContainer.GetComponentInChildren<VisualEffect>(true);
			componentInChildren3.visualEffectAsset = val4;
			componentInChildren3.SetFloat("spawnRateMultiplier", Configuration.blizzardWaveParticlesMultiplier.Value);
			componentInChildren3.SetBool("isCollisionEnabled", Configuration.enableVFXCollisions.Value);
			componentInChildren3.SetBool("fogEnabled", Configuration.enableBlizzardFog.Value);
			Camera componentInChildren4 = componentInChildren.blizzardWaveContainer.GetComponentInChildren<Camera>(true);
			((Behaviour)componentInChildren4).enabled = Configuration.enableVFXCollisions.Value;
			AudioSource component2 = ((Component)componentInChildren).GetComponent<AudioSource>();
			component2.volume = Configuration.blizzardAmbientVolume.Value;
			AudioSource componentInChildren5 = componentInChildren.blizzardWaveContainer.GetComponentInChildren<AudioSource>(true);
			componentInChildren5.volume = Configuration.blizzardWaveVolume.Value;
			val2.SetActive(true);
			ImprovedWeatherEffect val5 = new ImprovedWeatherEffect(gameObject2, gameObject)
			{
				SunAnimatorBool = "overcast"
			};
			Weather val6 = new Weather(blizzardWeather.WeatherName, val5);
			val6.DefaultLevelFilters = new string[36]
			{
				"Gordion", "Experimentation", "Assurance", "Offense", "Embrion", "EGypt", "Penumbra", "EchoReach", "Infernis", "Atlantica",
				"Gloom", "Orion", "Vertigo", "RelayStation", "Vaporization", "Praetor", "Lithium", "Arcadia", "Sector", "Ichor",
				"AtlasAbyss", "Asteroid13", "Asteroid14", "Fray", "Desolation", "Cosmocos", "Junic", "Detritus", "CaltPrime", "Vow",
				"Makron", "Attenuation", "Argent", "Humidity", "Sierra", "Black Mesa"
			};
			val6.LevelFilteringOption = (FilteringOption)1;
			val6.Color = Color.cyan;
			val6.ScrapAmountMultiplier = 1.4f;
			val6.ScrapValueMultiplier = 0.9f;
			val6.DefaultWeight = 75;
			Weather val7 = val6;
			WeatherManager.RegisterWeather(val7);
			Debug.Log("voxx.LethalElementsPlugin: Blizzard weather registered!");
		}

		public static void RegisterSnowfallWeather()
		{
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = WeatherAssetLoader.LoadAsset<GameObject>(bundleName, "SnowWeatherContainer");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError("Failed to load Snowfall Weather assets. Weather registration failed.");
				return;
			}
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			SnowfallWeather snowfallWeather = (SnowfallWeather.Instance = val2.GetComponentInChildren<SnowfallWeather>(true));
			GameObject gameObject = ((Component)snowfallWeather).gameObject;
			gameObject.SetActive(false);
			SnowfallVFXManager componentInChildren = val2.GetComponentInChildren<SnowfallVFXManager>(true);
			GameObject gameObject2 = ((Component)componentInChildren).gameObject;
			gameObject2.SetActive(false);
			snowfallWeather.VFXManager = componentInChildren;
			string[] first = new string[4] { "footprintsTrackerVFX", "lowcapFootprintsTrackerVFX", "itemTrackerVFX", "shovelVFX" };
			SnowfallVFXManager.snowTrackersDict = first.Zip(componentInChildren.footprintsTrackerVFX, (string k, VisualEffectAsset v) => new { k, v }).ToDictionary(x => x.k, x => x.v);
			VisualEffectAsset val3 = (Configuration.snowVfxLighting.Value ? WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "SnowVFXLit") : WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "SnowVFX"));
			if ((Object)(object)val3 == (Object)null)
			{
				Debug.LogError("Failed to load Snowfall Weather visual assets. Weather registration failed.");
				return;
			}
			VisualEffect component = componentInChildren.snowVFXContainer.GetComponent<VisualEffect>();
			component.visualEffectAsset = val3;
			component.SetFloat("spawnRateMultiplier", Configuration.snowParticlesMultiplier.Value);
			val2.SetActive(true);
			ImprovedWeatherEffect val4 = new ImprovedWeatherEffect(gameObject2, gameObject)
			{
				SunAnimatorBool = "overcast"
			};
			Weather val5 = new Weather(snowfallWeather.WeatherName, val4);
			val5.DefaultLevelFilters = new string[34]
			{
				"Gordion", "Assurance", "Embrion", "Sierra", "EGypt", "Penumbra", "EchoReach", "Infernis", "Atlantica", "Gloom",
				"Orion", "Vertigo", "RelayStation", "Vaporization", "Praetor", "Lithium", "Arcadia", "Sector", "Ichor", "AtlasAbyss",
				"Asteroid13", "Asteroid14", "Fray", "Desolation", "Cosmocos", "Junic", "Detritus", "CaltPrime", "Submersion", "Maritopia",
				"Cambrian", "Halation", "Black Mesa", "Baykal"
			};
			val5.LevelFilteringOption = (FilteringOption)1;
			val5.Color = Color.blue;
			val5.ScrapAmountMultiplier = 1.5f;
			val5.ScrapValueMultiplier = 0.75f;
			val5.DefaultWeight = 100;
			Weather val6 = val5;
			WeatherManager.RegisterWeather(val6);
			Debug.Log("voxx.LethalElementsPlugin: Snowfall weather registered!");
		}

		public static bool LoadLevelManipulator()
		{
			GameObject val = WeatherAssetLoader.LoadAsset<GameObject>(bundleName, "LevelManipulatorContainer");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError("Failed to load Level Manipulator assets. Disabling weather effects.");
				return false;
			}
			val.SetActive(true);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)val2);
			((Object)val2).hideFlags = (HideFlags)61;
			LevelManipulator component = val2.GetComponent<LevelManipulator>();
			Shader val3 = WeatherAssetLoader.LoadAsset<Shader>(bundleName, "SnowLitPass");
			Shader val4 = WeatherAssetLoader.LoadAsset<Shader>(bundleName, "SnowLitVertBakedPass");
			Shader val5 = WeatherAssetLoader.LoadAsset<Shader>(bundleName, "SnowLitVertBakedOpaquePass");
			if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
			{
				Debug.LogError("Failed to restore Snow visual assets. Visual effects may not work correctly.");
				return false;
			}
			component.snowOverlayMaterial.shader = val3;
			component.snowVertexMaterial.shader = val4;
			component.snowVertexOpaqueMaterial.shader = val5;
			component.snowVertexMaterial.SetFloat(SnowfallShaderIDs.IsDepthFade, Configuration.softSnowEdges.Value ? 1f : 0f);
			return true;
		}

		public static void RegisterToxicSmogWeather()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = WeatherAssetLoader.LoadAsset<GameObject>(bundleName, "ToxicSmogWeatherContainer");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError("Failed to load Toxic Fog Weather assets. Weather registration failed.");
				return;
			}
			val.SetActive(false);
			GameObject val2 = Object.Instantiate<GameObject>(val);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			ToxicSmogWeather componentInChildren = val2.GetComponentInChildren<ToxicSmogWeather>(true);
			GameObject gameObject = ((Component)componentInChildren).gameObject;
			gameObject.SetActive(false);
			ToxicSmogVFXManager componentInChildren2 = val2.GetComponentInChildren<ToxicSmogVFXManager>(true);
			GameObject gameObject2 = ((Component)componentInChildren2).gameObject;
			gameObject2.SetActive(false);
			componentInChildren.VFXManager = componentInChildren2;
			VisualEffectAsset val3 = WeatherAssetLoader.LoadAsset<VisualEffectAsset>(bundleName, "ToxicFumesVFX");
			if ((Object)(object)val3 == (Object)null)
			{
				Debug.LogError("Failed to load Toxic Fog Weather visual assets. Weather registration failed.");
				return;
			}
			GameObject? hazardPrefab = componentInChildren2.hazardPrefab;
			VisualEffect val4 = ((hazardPrefab != null) ? hazardPrefab.GetComponent<VisualEffect>() : null);
			val4.visualEffectAsset = val3;
			val2.SetActive(true);
			ImprovedWeatherEffect val5 = new ImprovedWeatherEffect(gameObject2, gameObject)
			{
				SunAnimatorBool = ""
			};
			Weather val6 = new Weather(componentInChildren.WeatherName, val5);
			val6.DefaultLevelFilters = new string[2] { "Gordion", "Derelict" };
			val6.LevelFilteringOption = (FilteringOption)1;
			val6.Color = new Color(0.413f, 0.589f, 0.21f);
			val6.ScrapAmountMultiplier = 1.3f;
			val6.ScrapValueMultiplier = 0.7f;
			val6.DefaultWeight = 100;
			Weather val7 = val6;
			WeatherManager.RegisterWeather(val7);
			Debug.Log("voxx.LethalElementsPlugin: Toxic Smog weather registered!");
		}
	}
}
namespace VoxxWeatherPlugin.Patches
{
	[HarmonyPatch]
	internal class BlizzardPatches
	{
		[HarmonyPatch(typeof(MouthDogAI), "DetectNoise")]
		[HarmonyPrefix]
		private static void DogSoundMufflingPatch(MouthDogAI __instance, ref float noiseLoudness)
		{
			BlizzardWeather? instance = BlizzardWeather.Instance;
			if (instance != null && instance.IsActive && ((EnemyAI)__instance).isOutside)
			{
				noiseLoudness *= Mathf.Clamp(1f - BlizzardWeather.Instance.windForce, 0.6f, 1f);
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "CancelSpecialTriggerAnimations")]
		[HarmonyPrefix]
		private static bool LadderWindPatch(PlayerControllerB __instance)
		{
			BlizzardWeather? instance = BlizzardWeather.Instance;
			if (instance != null && instance.IsActive && __instance.isClimbingLadder && BlizzardWeather.Instance.isLocalPlayerInWind && PlayerEffectsManager.ColdSeverity < 0.8f)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class FlarePatches
	{
		internal static Random random = new Random();

		internal static Random seededRandom = new Random(42);

		internal static Transform? originalTeleporterPosition;

		internal static float batteryDrainMultiplier => Mathf.Clamp(Configuration.BatteryDrainMultiplier.Value, 0f, 99f);

		internal static bool drainBatteryInFacility => Configuration.DrainBatteryInFacility.Value;

		internal static bool doorMalfunctionEnabled => Configuration.DoorMalfunctionEnabled.Value;

		[HarmonyPatch(typeof(PlayerVoiceIngameSettings), "OnDisable")]
		[HarmonyPrefix]
		private static void FilterCacheCleanerPatch(PlayerVoiceIngameSettings __instance)
		{
			if ((Object)(object)__instance.voiceAudio != (Object)null)
			{
				WalkieDistortionManager.ClearFilterCache(__instance.voiceAudio);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "UpdatePlayerVoiceEffects")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> VoiceDistorterPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlayerControllerB), "isPlayerDead"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null)
			});
			if (val.IsValid)
			{
				val.Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[4]
				{
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					new CodeInstruction(OpCodes.Ldloc_1, (object)null),
					new CodeInstruction(OpCodes.Ldloc_S, (object)4),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(WalkieDistortionManager), "UpdateVoiceChatDistortion", (Type[])null, (Type[])null))
				});
			}
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(GrabbableObject), "Update")]
		[HarmonyPrefix]
		private static void GrabbableDischargePatch(GrabbableObject __instance)
		{
			SolarFlareWeather? instance = SolarFlareWeather.Instance;
			if (instance != null && instance.IsActive && SolarFlareWeather.Instance?.flareData != null && ((NetworkBehaviour)__instance).IsOwner && __instance.hasBeenHeld && __instance.itemProperties.requiresBattery && (!__instance.isInFactory || drainBatteryInFacility) && (double)__instance.insertedBattery.charge > 0.0 && !__instance.itemProperties.itemIsTrigger)
			{
				Battery insertedBattery = __instance.insertedBattery;
				insertedBattery.charge -= 2f * SolarFlareWeather.Instance.flareData.ScreenDistortionIntensity * batteryDrainMultiplier * Time.deltaTime / __instance.itemProperties.batteryUsage;
			}
		}

		[HarmonyPatch(typeof(HUDManager), "UseSignalTranslatorClientRpc")]
		[HarmonyPrefix]
		private static void SignalTranslatorDistortionPatch(ref string signalMessage)
		{
			SolarFlareWeather? instance = SolarFlareWeather.Instance;
			if (instance == null || !instance.IsActive || SolarFlareWeather.Instance?.flareData == null)
			{
				return;
			}
			float num = SolarFlareWeather.Instance.flareData.RadioDistortionIntensity * 0.5f;
			char[] array = signalMessage.ToCharArray();
			for (int i = 0; i < array.Length; i++)
			{
				if (random.NextDouble() < (double)num)
				{
					array[i] = (char)random.Next(32, 127);
				}
			}
			signalMessage = new string(array);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TeleporterDistortionTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[10]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ShipTeleporter), "teleporterPosition"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Transform), "get_position", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)160f, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(PlayerControllerB), "TeleportPlayer", (Type[])null, (Type[])null), (string)null)
			});
			val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(FlarePatches), "TeleporterPositionDistorter", (Type[])null, (Type[])null))
			});
			val.Advance(12);
			val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(FlarePatches), "TeleporterPositionRestorer", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static void TeleporterPositionDistorter(ShipTeleporter teleporter)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			SolarFlareWeather? instance = SolarFlareWeather.Instance;
			if (instance == null || !instance.IsActive || SolarFlareWeather.Instance?.flareData == null)
			{
				return;
			}
			originalTeleporterPosition = teleporter.teleporterPosition;
			GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
			if (outsideAINodes.Length != 0)
			{
				int num = seededRandom.Next(0, outsideAINodes.Length);
				Transform transform = outsideAINodes[num].transform;
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(transform.position, ref val, 10f, -1))
				{
					transform.position = ((NavMeshHit)(ref val)).position;
					teleporter.teleporterPosition = transform;
				}
			}
		}

		private static void TeleporterPositionRestorer(ShipTeleporter teleporter)
		{
			SolarFlareWeather? instance = SolarFlareWeather.Instance;
			if (instance != null && instance.IsActive && SolarFlareWeather.Instance?.flareData != null)
			{
				teleporter.teleporterPosition = originalTeleporterPosition;
			}
		}

		[HarmonyPatch(typeof(TerminalAccessibleObject), "CallFunctionFromTerminal")]
		[HarmonyPrefix]
		private static bool DoorTerminalBlocker(TerminalAccessibleObject __instance)
		{
			SolarFlareWeather? instance = SolarFlareWeather.Instance;
			if (instance != null && instance.IsActive && SolarFlareWeather.Instance?.flareData != null && doorMalfunctionEnabled && SolarFlareWeather.Instance.flareData.IsDoorMalfunction && __instance.isBigDoor && seededRandom.NextDouble() < 0.8999999761581421)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(RadarBoosterItem), "EnableRadarBooster")]
		[HarmonyPrefix]
		private static void SignalBoosterPrefix(RadarBoosterItem __instance, ref bool enable)
		{
			SolarFlareWeather? instance = SolarFlareWeather.Instance;
			if (instance != null && instance.IsActive && SolarFlareWeather.Instance?.flareData != null)
			{
				if (enable)
				{
					SolarFlareWeather.Instance.flareData.RadioDistortionIntensity /= 3f;
					SolarFlareWeather.Instance.flareData.ScreenDistortionIntensity /= 3f;
					SolarFlareWeather.Instance.flareData.RadioFrequencyShift /= 4f;
					SolarFlareWeather.Instance.flareData.RadioBreakthroughLength += 0.25f;
				}
				else if (__instance.radarEnabled)
				{
					SolarFlareWeather.Instance.flareData.RadioDistortionIntensity *= 3f;
					SolarFlareWeather.Instance.flareData.ScreenDistortionIntensity *= 3f;
					SolarFlareWeather.Instance.flareData.RadioFrequencyShift *= 4f;
					SolarFlareWeather.Instance.flareData.RadioBreakthroughLength -= 0.25f;
				}
			}
		}
	}
	[HarmonyPatch]
	internal class FlareOptionalWalkiePatches
	{
		[HarmonyPatch(typeof(WalkieTalkie), "Start")]
		[HarmonyPrefix]
		private static void WalkieDistortionPatch(WalkieTalkie __instance)
		{
			((Component)__instance).gameObject.AddComponent<WalkieDistortionManager>();
		}

		[HarmonyPatch(typeof(WalkieTalkie), "TimeAllAudioSources")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> RadioDistorterPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001e: Unknown result type (might