Decompiled source of WeatherTweaks v1.0.1

WeatherTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConsoleTables;
using HarmonyLib;
using LethalLevelLoader;
using LethalNetworkAPI;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MrovLib;
using MrovLib.Compatibility;
using MrovLib.Events;
using Newtonsoft.Json;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
using WeatherRegistry;
using WeatherRegistry.Definitions;
using WeatherRegistry.Events;
using WeatherRegistry.Modules;
using WeatherRegistry.Patches;
using WeatherTweaks.Compatibility;
using WeatherTweaks.Definitions;
using WeatherTweaks.Modules;
using WeatherTweaks.NetcodePatcher;
using WeatherTweaks.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("WeatherRegistry")]
[assembly: AssemblyCompany("WeatherTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+8ef2a5e17a579ec4e5f7e94c9737374c14853b63")]
[assembly: AssemblyProduct("WeatherTweaks")]
[assembly: AssemblyTitle("WeatherTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WeatherTweaks
{
	[HarmonyPatch(typeof(TimeOfDay))]
	public static class ChangeMidDay
	{
		internal static Random random;

		internal static ProgressingWeatherType currentWeather = null;

		internal static List<ProgressingWeatherEntry> weatherEntries = new List<ProgressingWeatherEntry>();

		internal static float LastCheckedEntry = 0f;

		internal static ProgressingWeatherEntry CurrentEntry = null;

		internal static ManualLogSource logger = Logger.CreateLogSource("WeatherTweaks ChangeMidDay");

		internal static ProgressingWeatherEntry NextEntry => weatherEntries.FirstOrDefault();

		internal static float NextEntryTime
		{
			get
			{
				if (NextEntry == null)
				{
					return 0f;
				}
				return NextEntry.DayTime;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("MoveTimeOfDay")]
		internal static void MoveTimeOfDayPatch(TimeOfDay __instance)
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost && !((Object)(object)currentWeather == (Object)null))
			{
				float normalizedTimeOfDay = __instance.normalizedTimeOfDay;
				if (normalizedTimeOfDay >= NextEntryTime)
				{
					RunProgressingEntryActions(normalizedTimeOfDay);
				}
			}
		}

		internal static void RunProgressingEntryActions(float normalizedTimeOfDay)
		{
			weatherEntries.RemoveAll((ProgressingWeatherEntry entry) => entry.DayTime < LastCheckedEntry);
			foreach (ProgressingWeatherEntry weatherEntry in weatherEntries)
			{
				if (normalizedTimeOfDay > weatherEntry.DayTime && weatherEntry.DayTime > LastCheckedEntry)
				{
					logger.LogInfo((object)$"Changing weather to {weatherEntry.GetWeather().Name} at {weatherEntry.DayTime}");
					float num = (float)random.NextDouble();
					if (num > weatherEntry.Chance)
					{
						logger.LogWarning((object)$"Random roll failed - got {num}, needed {weatherEntry.Chance} or lower");
						LastCheckedEntry = weatherEntry.DayTime;
						break;
					}
					NetworkedConfig.SetProgressingWeatherEntry(weatherEntry);
					((MonoBehaviour)TimeOfDay.Instance).StartCoroutine(DoMidDayChange(weatherEntry));
					LastCheckedEntry = weatherEntry.DayTime;
					CurrentEntry = weatherEntry;
					break;
				}
			}
		}

		internal static IEnumerator DoMidDayChange(ProgressingWeatherEntry entry)
		{
			if (entry == null)
			{
				logger.LogError((object)"ProgressingWeatherEntry is null");
				yield return null;
			}
			logger.LogMessage((object)$"Changing weather to {entry.GetWeather().Name} at {entry.DayTime}, chance {entry.Chance} - is player inside? {EntranceTeleportPatch.isPlayerInside}");
			HUDManager.Instance.ReadDialogue(entry.GetDialogueSegment().ToArray());
			yield return (object)new WaitForSeconds(3f);
			WeatherTweaksWeather weatherTweaksWeather = Variables.WeatherTweaksTypes.FirstOrDefault((WeatherTweaksWeather type) => ((Weather)type).Name == entry.GetWeather().Name);
			logger.LogWarning((object)$"{((Weather)weatherTweaksWeather).Name} {((Weather)weatherTweaksWeather).Type} {((Weather)weatherTweaksWeather).VanillaWeatherType}");
			StartOfRound.Instance.currentLevel.currentWeather = ((Weather)weatherTweaksWeather).VanillaWeatherType;
			TimeOfDay.Instance.currentLevelWeather = ((Weather)weatherTweaksWeather).VanillaWeatherType;
			GameNetworkManager.Instance.localPlayerController.currentAudioTrigger.weatherEffect = (int)((Weather)weatherTweaksWeather).VanillaWeatherType;
			CurrentEntry = entry;
			WeatherController.SetWeatherEffects(((Weather)weatherTweaksWeather).VanillaWeatherType);
		}

		internal static void ShipLandingPatch(SelectableLevel currentLevel, Weather currentWeather)
		{
			if (currentWeather is ProgressingWeatherType progressingWeatherType)
			{
				SetCurrentWeather(progressingWeatherType);
			}
		}

		internal static void SetCurrentWeather(ProgressingWeatherType weather)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			logger.LogInfo((object)("Setting current weather to " + ((Weather)weather).Name));
			Reset();
			if (random == null)
			{
				random = new Random(StartOfRound.Instance.randomMapSeed);
			}
			currentWeather = weather;
			weatherEntries = weather.WeatherEntries.ToList();
			CurrentEntry = new ProgressingWeatherEntry
			{
				DayTime = 0f,
				Chance = 1f,
				Weather = (WeatherResolvable)new WeatherTypeResolvable(weather.StartingWeather.WeatherType)
			};
			weatherEntries.Sort((ProgressingWeatherEntry a, ProgressingWeatherEntry b) => a.DayTime.CompareTo(b.DayTime));
			NetworkedConfig.SetProgressingWeatherEntry(CurrentEntry);
			((MonoBehaviour)TimeOfDay.Instance).StartCoroutine(DoMidDayChange(CurrentEntry));
		}

		internal static void Reset()
		{
			currentWeather = null;
			LastCheckedEntry = 0f;
			weatherEntries = new List<ProgressingWeatherEntry>();
		}
	}
	public class LevelListConfigHandler : LevelListConfigHandler
	{
		public LevelListConfigHandler(string defaultValue, bool enabled = true)
			: base(defaultValue, enabled)
		{
		}

		public void CreateConfigEntry(string configTitle, ConfigDescription configDescription = null)
		{
			((ConfigHandler<SelectableLevel[], string>)(object)this).ConfigEntry = ConfigManager.configFile.Bind<string>("Foggy patch", configTitle, ((ConfigHandler<SelectableLevel[], string>)(object)this).DefaultValue, configDescription);
		}
	}
	public class ConfigHelper
	{
		public static Weather GetWeatherFromString(string weatherName)
		{
			return ConfigHelper.ResolveStringToWeather(weatherName);
		}
	}
	public class ConfigManager
	{
		internal static ConfigFile configFile;

		public static LevelListConfigHandler FoggyIgnoreLevels;

		public static ConfigManager Instance { get; private set; }

		public static ConfigEntry<bool> LogWeatherSelection { get; private set; }

		public static ConfigEntry<bool> LogWeatherVariables { get; private set; }

		public static ConfigEntry<bool> LogLogs { get; private set; }

		public static ConfigEntry<int> FirstDaySeed { get; private set; }

		public static ConfigEntry<bool> FirstDaySpecial { get; private set; }

		public static ConfigEntry<bool> FirstDayRandomSeed { get; private set; }

		public static ConfigEntry<bool> UncertainWeatherEnabled { get; private set; }

		public static ConfigEntry<bool> GenerateSpecialWeatherEntries { get; private set; }

		public static ConfigEntry<bool> AlwaysUncertain { get; private set; }

		public static ConfigEntry<bool> AlwaysUnknown { get; private set; }

		public static ConfigEntry<bool> AlwaysClear { get; private set; }

		public static ConfigEntry<float> GameLengthMultiplier { get; private set; }

		public static ConfigEntry<float> GamePlayersMultiplier { get; private set; }

		public static ConfigEntry<float> MaxMultiplier { get; private set; }

		public static ConfigEntry<bool> ScaleDownClearWeather { get; private set; }

		public static void Init(ConfigFile config)
		{
			Instance = new ConfigManager(config);
		}

		private ConfigManager(ConfigFile config)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			configFile = config;
			LogWeatherSelection = configFile.Bind<bool>("Debug", "LogWeatherSelection", true, "Log weather selection");
			LogWeatherVariables = configFile.Bind<bool>("Debug", "LogWeatherVariables", true, "Log resolving weather variables");
			LogLogs = configFile.Bind<bool>("Debug", "Logs", true, "Log logging logs");
			UncertainWeatherEnabled = configFile.Bind<bool>("Uncertain Weathers", "UncertainWeatherEnabled", true, "Enable uncertain weather mechanic: some planets will not display current weather");
			MaxMultiplier = configFile.Bind<float>("Multiplier Settings", "MaxMultiplier", 0.8f, new ConfigDescription("Maximum difficulty multiplier (between 0 and 1). Overrides GameLengthMultiplier and GamePlayersMultiplier", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ScaleDownClearWeather = configFile.Bind<bool>("Multiplier Settings", "ScaleDownClearWeather", true, "Scale down clear weather's weight to keep its % chance the same, no matter how many weathers are in the pool");
			GameLengthMultiplier = configFile.Bind<float>("Difficulty Multiplier Settings", "GameLengthMultiplier", 0.05f, "Difficulty multiplier - game length (quotas done)");
			GamePlayersMultiplier = configFile.Bind<float>("Difficulty Multiplier Settings", "GamePlayersMultiplier", 0.01f, "Difficulty multiplier - players amount");
			FirstDaySeed = configFile.Bind<int>("First Day", "FirstDaySeed", 0, "Seed for the first day's weather.");
			FirstDaySpecial = configFile.Bind<bool>("First Day", "FirstDaySpecial", true, "Enable a vanilla-like weather picking algorithm for the first day.");
			FirstDayRandomSeed = configFile.Bind<bool>("First Day", "FirstDayRandomSeed", true, "Use random seed for the first day's weather. Works independently from ButteryFixes.");
			GenerateSpecialWeatherEntries = configFile.Bind<bool>("Special Weather Configs", "GenerateSpecialWeatherEntries", false, "Generate special weather entries' in Registry config.");
			AlwaysUncertain = configFile.Bind<bool>("Special Modes", "AlwaysUncertain", false, "Always make weather uncertain");
			AlwaysUnknown = configFile.Bind<bool>("Special Modes", "AlwaysUnknown", false, "Always make weather unknown");
			AlwaysClear = configFile.Bind<bool>("Special Modes", "AlwaysClear", false, "Always make weather clear - good for testing");
			FoggyIgnoreLevels = new LevelListConfigHandler("", enabled: false);
			FoggyIgnoreLevels.CreateConfigEntry("Foggy patch", new ConfigDescription("Levels to blacklist foggy patch from applying on (semicolon-separated)", (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	public static class DisplayTable
	{
		public static void DisplayWeathersTable()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (!Variables.IsSetupFinished)
			{
				return;
			}
			ConsoleTable val = new ConsoleTable(new string[3] { "Planet", "Level weather", "Uncertain weather" });
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return;
			}
			List<SelectableLevel> sortedLevels = LevelHelper.SortedLevels;
			foreach (SelectableLevel item in sortedLevels)
			{
				bool flag = UncertainWeather.uncertainWeathers.ContainsKey(item.PlanetName);
				val.AddRow(new object[3]
				{
					StringResolver.GetNumberlessName(item),
					Variables.GetPlanetCurrentWeather(item, uncertain: false),
					flag ? UncertainWeather.uncertainWeathers[item.PlanetName] : ""
				});
			}
			Plugin.logger.LogMessage((object)("Currently set weathers: \n" + val.ToMinimalString()));
		}
	}
	internal class GameInteraction
	{
		internal static Logger logger = new Logger("WeatherTweaks GameInteraction", ConfigManager.LogLogs);

		internal static void SetWeatherEffects(TimeOfDay timeOfDay, List<ImprovedWeatherEffect> weatherEffects)
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			if (!Variables.IsSetupFinished)
			{
				logger.LogDebug((object)"Setup not finished, skipping setting weather effects");
				return;
			}
			logger.LogDebug((object)$"Setting weather effects for {timeOfDay.currentLevel.PlanetName}: {weatherEffects.Count} effects");
			if (weatherEffects == null)
			{
				logger.LogDebug((object)"No weather effects to set");
				return;
			}
			Variables.CurrentEffects = weatherEffects;
			List<LevelWeatherType> list = new List<LevelWeatherType>();
			List<ImprovedWeatherEffect> list2 = new List<ImprovedWeatherEffect>();
			foreach (Weather weather in WeatherManager.Weathers)
			{
				if (!((Object)(object)weather.Effect == (Object)null))
				{
					ImprovedWeatherEffect effect = weather.Effect;
					if (weatherEffects.Contains(effect))
					{
						list2.Add(effect);
					}
					Plugin.logger.LogDebug((object)("Disabling effect from weather: " + weather.Name));
					effect.DisableEffect(true);
				}
			}
			foreach (Weather weather2 in WeatherManager.Weathers)
			{
				ImprovedWeatherEffect effect2 = weather2.Effect;
				if (weatherEffects.Contains(effect2))
				{
					logger.LogDebug((object)("Enabling effect from weather: " + weather2.Name));
					if (!EntranceTeleportPatch.isPlayerInside)
					{
						weather2.Effect.EffectEnabled = true;
					}
					else
					{
						logger.LogWarning((object)"Player is inside, skipping effect object activation");
						weather2.Effect.DisableEffect(true);
					}
					if (effect2.SunAnimatorBool != "" && effect2.SunAnimatorBool != null)
					{
						list.Add(weather2.VanillaWeatherType);
					}
				}
			}
		}
	}
	public class Init
	{
		public static void InitMethod()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Expected O, but got Unknown
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Expected O, but got Unknown
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Expected O, but got Unknown
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Expected O, but got Unknown
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Expected O, but got Unknown
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Expected O, but got Unknown
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown
			//IL_0471: Expected O, but got Unknown
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Expected O, but got Unknown
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Expected O, but got Unknown
			//IL_04e7: Expected O, but got Unknown
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Expected O, but got Unknown
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Expected O, but got Unknown
			//IL_055d: Expected O, but got Unknown
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Expected O, but got Unknown
			//IL_05a6: Expected O, but got Unknown
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Expected O, but got Unknown
			//IL_05ef: Expected O, but got Unknown
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Expected O, but got Unknown
			//IL_0638: Expected O, but got Unknown
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Expected O, but got Unknown
			//IL_0681: Expected O, but got Unknown
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Expected O, but got Unknown
			//IL_06da: Expected O, but got Unknown
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Expected O, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Expected O, but got Unknown
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Expected O, but got Unknown
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Expected O, but got Unknown
			//IL_0733: Expected O, but got Unknown
			new CombinedWeatherType("Eclipsed + Flooded", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)4)
			});
			new CombinedWeatherType("Foggy + Rainy", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1)
			});
			new CombinedWeatherType("Eclipsed + Rainy", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1)
			});
			new CombinedWeatherType("Stormy + Rainy", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1)
			});
			new CombinedWeatherType("Stormy + Flooded", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)4)
			});
			new CombinedWeatherType("Foggy + Flooded", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)4)
			});
			new CombinedWeatherType("Foggy + Eclipsed", new List<WeatherResolvable>(2)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5)
			});
			new CombinedWeatherType("Stormy + Rainy + Eclipsed", new List<WeatherResolvable>(3)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5)
			});
			new CombinedWeatherType("Stormy + Rainy + Flooded", new List<WeatherResolvable>(3)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)4)
			});
			new CombinedWeatherType("Stormy + Rainy + Flooded + Eclipsed", new List<WeatherResolvable>(4)
			{
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)4),
				(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5)
			});
			if (((CompatibilityBase)Plugin.MrovWeathersCompat).IsModPresent)
			{
				new CombinedWeatherType("Rainy + Blackout", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1),
					(WeatherResolvable)new WeatherNameResolvable("blackout")
				});
				new CombinedWeatherType("Foggy + Blackout", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3),
					(WeatherResolvable)new WeatherNameResolvable("blackout")
				});
				new CombinedWeatherType("Eclipsed + Blackout", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5),
					(WeatherResolvable)new WeatherNameResolvable("blackout")
				});
			}
			if (((CompatibilityBase)Plugin.LethalElementsCompat).IsModPresent)
			{
				new CombinedWeatherType("Stormy + Solar Flare", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2),
					(WeatherResolvable)new WeatherNameResolvable("solarflare")
				});
				new CombinedWeatherType("Foggy + Solar Flare", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3),
					(WeatherResolvable)new WeatherNameResolvable("solarflare")
				});
				new CombinedWeatherType("Foggy + Snowfall", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3),
					(WeatherResolvable)new WeatherNameResolvable("snowfall")
				});
				new CombinedWeatherType("Eclipsed + Snowfall", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5),
					(WeatherResolvable)new WeatherNameResolvable("snowfall")
				});
			}
			if (((CompatibilityBase)Plugin.MrovWeathersCompat).IsModPresent && ((CompatibilityBase)Plugin.LethalElementsCompat).IsModPresent)
			{
				new CombinedWeatherType("Blackout + Solar Flare", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherNameResolvable("blackout"),
					(WeatherResolvable)new WeatherNameResolvable("solarflare")
				});
				new CombinedWeatherType("Blackout + Snowfall", new List<WeatherResolvable>(2)
				{
					(WeatherResolvable)new WeatherNameResolvable("blackout"),
					(WeatherResolvable)new WeatherNameResolvable("snowfall")
				});
			}
			new ProgressingWeatherType("None > Foggy", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)(-1)), new List<ProgressingWeatherEntry>(2)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.25f,
					Chance = 0.8f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3)
				},
				new ProgressingWeatherEntry
				{
					DayTime = 0.75f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3)
				}
			});
			new ProgressingWeatherType("None > Stormy", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)(-1)), new List<ProgressingWeatherEntry>(2)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.35f,
					Chance = 0.35f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2)
				},
				new ProgressingWeatherEntry
				{
					DayTime = 0.75f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2)
				}
			});
			new ProgressingWeatherType("Eclipsed > Foggy", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5), new List<ProgressingWeatherEntry>(2)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.4f,
					Chance = 0.5f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3)
				},
				new ProgressingWeatherEntry
				{
					DayTime = 0.85f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3)
				}
			});
			new ProgressingWeatherType("Foggy > None", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)3), new List<ProgressingWeatherEntry>(1)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.45f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)(-1))
				}
			});
			new ProgressingWeatherType("Eclipsed > None", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5), new List<ProgressingWeatherEntry>(1)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.66f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)(-1))
				}
			});
			new ProgressingWeatherType("Stormy > Rainy", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)2), new List<ProgressingWeatherEntry>(1)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.55f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1)
				}
			});
			new ProgressingWeatherType("Rainy > Eclipsed", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)1), new List<ProgressingWeatherEntry>(1)
			{
				new ProgressingWeatherEntry
				{
					DayTime = 0.66f,
					Chance = 1f,
					Weather = (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)5)
				}
			});
			if (((CompatibilityBase)Plugin.MrovWeathersCompat).IsModPresent)
			{
				new ProgressingWeatherType("None > Blackout", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)(-1)), new List<ProgressingWeatherEntry>(1)
				{
					new ProgressingWeatherEntry
					{
						DayTime = 0.66f,
						Chance = 1f,
						Weather = (WeatherResolvable)new WeatherNameResolvable("blackout")
					}
				});
			}
			if (((CompatibilityBase)Plugin.LethalElementsCompat).IsModPresent)
			{
				new ProgressingWeatherType("None > Heatwave", (WeatherResolvable)new WeatherTypeResolvable((LevelWeatherType)(-1)), new List<ProgressingWeatherEntry>(1)
				{
					new ProgressingWeatherEntry
					{
						DayTime = 0.45f,
						Chance = 1f,
						Weather = (WeatherResolvable)new WeatherNameResolvable("heatwave")
					}
				});
			}
		}
	}
	internal class NetworkedConfig
	{
		public static LethalNetworkVariable<string> currentWeatherStringsSynced = new LethalNetworkVariable<string>("previousWeatherStrings");

		public static LethalNetworkVariable<string> currentProgressingWeatherEntry = new LethalNetworkVariable<string>("currentProgressingWeatherEntry");

		public static void Init()
		{
			currentWeatherStringsSynced.OnValueChanged += WeatherDisplayDataReceived;
			currentProgressingWeatherEntry.OnValueChanged += ProgressingWeatherEntryReceived;
		}

		public static void WeatherDisplayDataReceived(string weatherData)
		{
			Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(weatherData);
			if (dictionary != null && !((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				Plugin.logger.LogInfo((object)("Received weather display data " + weatherData + " from server, applying"));
				UncertainWeather.uncertainWeathers = dictionary;
				StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
			}
		}

		public static void ProgressingWeatherEntryReceived(string progressingWeatherEntry)
		{
			ProgressingWeatherEntry progressingWeatherEntry2 = JsonConvert.DeserializeObject<ProgressingWeatherEntry>(progressingWeatherEntry);
			if (progressingWeatherEntry2 != null && !((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				Plugin.logger.LogWarning((object)("Received progressing weather entry data " + progressingWeatherEntry + " from server, applying"));
				((MonoBehaviour)TimeOfDay.Instance).StartCoroutine(ChangeMidDay.DoMidDayChange(progressingWeatherEntry2));
			}
		}

		public static void SetDisplayWeather(Dictionary<string, string> uncertainWeathers)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			string text = JsonConvert.SerializeObject((object)uncertainWeathers, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			});
			currentWeatherStringsSynced.Value = text;
			Plugin.logger.LogInfo((object)("Set weather display data on server: " + text));
		}

		public static void SetProgressingWeatherEntry(ProgressingWeatherEntry entry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			string text = JsonConvert.SerializeObject((object)entry, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			});
			Plugin.logger.LogInfo((object)("Set progressing weather entry on server: " + text));
			currentProgressingWeatherEntry.Value = text;
		}
	}
	[HarmonyPatch(typeof(EclipseWeather))]
	[HarmonyPatch(typeof(FloodWeather))]
	[HarmonyPatch(typeof(StormyWeather))]
	[HarmonyPatch(typeof(RoundManager))]
	internal class BasegameWeatherPatch
	{
		internal static Logger logger = new Logger("WeatherTweaks BaseGameWeatherPatches", ConfigManager.LogLogs);

		internal static Harmony harmony = new Harmony("WeatherTweaks.BaseGame");

		private static FieldInfo metalObjects = AccessTools.Field(typeof(StormyWeather), "metalObjects");

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(EclipseWeather), "OnEnable")]
		private static IEnumerable<CodeInstruction> EclipseOnEnablePatch(IEnumerable<CodeInstruction> instructions)
		{
			return CurrentWeatherVariablePatch(instructions, (LevelWeatherType)5, "EclipseWeather.OnEnable");
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(FloodWeather), "OnEnable")]
		private static IEnumerable<CodeInstruction> FloodedOnEnablePatch(IEnumerable<CodeInstruction> instructions)
		{
			return CurrentWeatherVariablePatch(instructions, (LevelWeatherType)4, "FloodWeather.OnEnable");
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(FloodWeather), "OnGlobalTimeSync")]
		private static IEnumerable<CodeInstruction> FloodedOnGlobalTimeSyncPatch(IEnumerable<CodeInstruction> instructions)
		{
			return CurrentWeatherVariable2Patch(instructions, (LevelWeatherType)4, "FloodWeather.OnGlobalTimeSync");
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(FloodWeather), "Update")]
		private static IEnumerable<CodeInstruction> FloodedUpdatePatch(IEnumerable<CodeInstruction> instructions)
		{
			return CurrentWeatherVariablePatch(instructions, (LevelWeatherType)4, "FloodWeather.Update");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FloodWeather), "OnEnable")]
		private static void FloodedOnEnablePostfix(FloodWeather __instance)
		{
			__instance.floodLevelOffset = Mathf.Clamp(TimeOfDay.Instance.globalTime / 1080f, 0f, 100f) * Variables.GetLevelWeatherVariable((LevelWeatherType)4, variable2: true);
			logger.LogWarning((object)$"Enabling FloodWeather with level offset {__instance.floodLevelOffset}");
		}

		internal static IEnumerable<CodeInstruction> VariablePatch(IEnumerable<CodeInstruction> instructions, LevelWeatherType weatherType, string wherefrom, bool variable1 = true)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			logger.LogInfo((object)$"Patching {wherefrom} for {weatherType}");
			CodeMatcher codeMatcher = new CodeMatcher(instructions, (ILGenerator)null);
			CodeMatch val = new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "currentWeatherVariable"), (string)null);
			CodeMatch val2 = new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "currentWeatherVariable2"), (string)null);
			codeMatcher = codeMatcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "Instance", (Type[])null, (Type[])null), (string)null),
				variable1 ? val : val2
			});
			logger.LogDebug((object)$"Matched Ldfld for {wherefrom} for {weatherType}");
			codeMatcher.Repeat((Action<CodeMatcher>)delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Expected I4, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Expected O, but got Unknown
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Expected O, but got Unknown
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Expected O, but got Unknown
				logger.LogInfo((object)$"Matched Ldfld for {wherefrom} for {weatherType}");
				codeMatcher.RemoveInstruction();
				codeMatcher.RemoveInstruction();
				codeMatcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldc_I4, (object)(int)weatherType)
				});
				codeMatcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldc_I4, (object)((!variable1) ? 1 : 0))
				});
				codeMatcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Variables), "GetLevelWeatherVariable", (Type[])null, (Type[])null))
				});
			}, (Action<string>)null);
			logger.LogDebug((object)$"Patched {wherefrom} for {weatherType}");
			return codeMatcher.InstructionEnumeration();
		}

		internal static IEnumerable<CodeInstruction> CurrentWeatherVariablePatch(IEnumerable<CodeInstruction> instructions, LevelWeatherType weatherType, string wherefrom)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return VariablePatch(instructions, weatherType, wherefrom);
		}

		internal static IEnumerable<CodeInstruction> CurrentWeatherVariable2Patch(IEnumerable<CodeInstruction> instructions, LevelWeatherType weatherType, string wherefrom)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return VariablePatch(instructions, weatherType, wherefrom, variable1: false);
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(StormyWeather), "DetermineNextStrikeInterval")]
		private static IEnumerable<CodeInstruction> StormyDetermineNextStrikePatch(IEnumerable<CodeInstruction> instructions)
		{
			return CurrentWeatherVariablePatch(instructions, (LevelWeatherType)2, "StormyWeather.DetermineNextStrikeInterval");
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(StormyWeather), "LightningStrikeRandom")]
		private static IEnumerable<CodeInstruction> StormyLightningStrikeRandomPatch(IEnumerable<CodeInstruction> instructions)
		{
			return CurrentWeatherVariablePatch(instructions, (LevelWeatherType)2, "StormyWeather.StormyLightningStrikeRandomPatch");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StormyWeather), "OnEnable")]
		private static void StormyOnEnablePostfix(StormyWeather __instance)
		{
			__instance.timeAtLastStrike = TimeOfDay.Instance.globalTime + 45f;
			logger.LogWarning((object)$"StormyWeather.Enable: {__instance.randomThunderTime} {__instance.timeAtLastStrike}");
		}

		[HarmonyPatch(typeof(StormyWeather), "OnDisable")]
		[HarmonyPostfix]
		public static void Fix_StormyNullRef(ref StormyWeather __instance)
		{
			((List<GrabbableObject>)metalObjects.GetValue(__instance)).Clear();
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(RoundManager), "SpawnOutsideHazards")]
		private static IEnumerable<CodeInstruction> SpawnOutsideHazardsPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			CodeMatcher codeMatcher = new CodeMatcher(instructions, (ILGenerator)null);
			codeMatcher = codeMatcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "Instance", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "currentLevelWeather"), (string)null)
			});
			logger.LogDebug((object)"Matched Ldfld for RoundManager.SpawnOutsideHazards");
			codeMatcher.Repeat((Action<CodeMatcher>)delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Expected O, but got Unknown
				codeMatcher.RemoveInstruction();
				codeMatcher.RemoveInstruction();
				codeMatcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldc_I4, (object)1)
				});
				codeMatcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Variables), "LevelHasWeather", (Type[])null, (Type[])null))
				});
			}, (Action<string>)null);
			return codeMatcher.InstructionEnumeration();
		}
	}
	public static class DisableAllWeathers
	{
		internal static void DisableAllWeather()
		{
			ChangeMidDay.Reset();
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				NetworkedConfig.SetProgressingWeatherEntry(null);
			}
		}
	}
	internal class LobbyCompatibilityCompatibility
	{
		public static void Init()
		{
			Plugin.logger.LogWarning((object)"LobbyCompatibility detected, registering plugin with LobbyCompatibility.");
			Version version = Version.Parse("1.0.1");
			PluginHelper.RegisterPlugin("WeatherTweaks", version, (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class SetPlanetsWeatherPatch
	{
		[HarmonyPatch("SetPlanetsWeather")]
		[HarmonyPrefix]
		[HarmonyAfter(new string[] { "mrov.WeatherRegistry" })]
		private static bool GameMethodPatch(int connectedPlayersOnServer, StartOfRound __instance)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogMessage((object)"SetPlanetsWeather called.");
			if (!Variables.IsSetupFinished || !WeatherManager.IsSetupFinished)
			{
				Plugin.logger.LogWarning((object)"Setup not finished");
				return true;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				Plugin.logger.LogWarning((object)"Instance is null");
				return true;
			}
			List<SelectableLevel> gameLevels = Variables.GetGameLevels();
			if (gameLevels == null)
			{
				Plugin.logger.LogWarning((object)"Levels are null");
				return true;
			}
			ChangeMidDay.Reset();
			EntranceTeleportPatch.isPlayerInside = false;
			bool hasValue = GameNetworkManager.Instance.currentLobby.HasValue;
			if (((NetworkBehaviour)__instance).IsHost)
			{
				Dictionary<string, string> displayWeather = UncertainWeather.GenerateUncertainty();
				NetworkedConfig.SetDisplayWeather(displayWeather);
				__instance.SetMapScreenInfoToCurrentLevel();
				if (hasValue)
				{
					Lobby? currentLobby = GameNetworkManager.Instance.currentLobby;
					if (currentLobby.HasValue)
					{
						Lobby valueOrDefault = currentLobby.GetValueOrDefault();
						((Lobby)(ref valueOrDefault)).SetData("WeatherTweaks", "true");
					}
				}
			}
			return false;
		}

		[HarmonyPatch("SetPlanetsWeather")]
		[HarmonyPostfix]
		private static void DisplayCurrentWeathers()
		{
			DisplayTable.DisplayWeathersTable();
		}
	}
	[BepInPlugin("WeatherTweaks", "WeatherTweaks", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[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 Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Event <>9__6_0;

			public static Event <>9__6_1;

			public static ParameterEvent<(SelectableLevel level, Weather weather)> <>9__6_2;

			public static ParameterEvent<(SelectableLevel level, Weather weather)> <>9__6_3;

			public static Event <>9__6_4;

			public static ParameterEvent<Terminal> <>9__6_5;

			public static ParameterEvent<StartOfRound> <>9__6_6;

			internal void <Awake>b__6_0()
			{
				DisableAllWeathers.DisableAllWeather();
			}

			internal void <Awake>b__6_1()
			{
				TerminalStartPatch.Start();
			}

			internal void <Awake>b__6_2((SelectableLevel level, Weather weather) args)
			{
				FoggyPatch.ToggleFogExclusionZones(args.level, enable: false);
			}

			internal void <Awake>b__6_3((SelectableLevel level, Weather weather) args)
			{
				ChangeMidDay.ShipLandingPatch(args.level, args.weather);
			}

			internal void <Awake>b__6_4()
			{
				FoggyPatch.ToggleFogExclusionZones(StartOfRound.Instance.currentLevel);
			}

			internal void <Awake>b__6_5(Terminal terminal)
			{
				TerminalPatch.Postfix();
			}

			internal void <Awake>b__6_6(StartOfRound startofround)
			{
				Reset.ResetThings();
			}
		}

		internal static ManualLogSource logger;

		internal static Logger DebugLogger = new Logger("WeatherTweaks", (ConfigEntry<bool>)null);

		internal static bool IsLLLPresent = false;

		internal static GeneralImprovementsCompat GeneralImprovements;

		internal static MrovWeathersCompat MrovWeathersCompat;

		internal static LethalElementsCompat LethalElementsCompat;

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("WeatherTweaks");
			val.PatchAll();
			NetworkedConfig.Init();
			UncertainWeather.Init();
			WeatherRegistryEvent disableAllWeathers = EventManager.DisableAllWeathers;
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				Event val2 = delegate
				{
					DisableAllWeathers.DisableAllWeather();
				};
				<>c.<>9__6_0 = val2;
				obj = (object)val2;
			}
			((CustomEvent)disableAllWeathers).AddListener((Event)obj);
			WeatherRegistryEvent setupFinished = EventManager.SetupFinished;
			object obj2 = <>c.<>9__6_1;
			if (obj2 == null)
			{
				Event val3 = delegate
				{
					TerminalStartPatch.Start();
				};
				<>c.<>9__6_1 = val3;
				obj2 = (object)val3;
			}
			((CustomEvent)setupFinished).AddListener((Event)obj2);
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).AddListener((ParameterEvent<(SelectableLevel, Weather)>)delegate((SelectableLevel level, Weather weather) args)
			{
				FoggyPatch.ToggleFogExclusionZones(args.level, enable: false);
			});
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).AddListener((ParameterEvent<(SelectableLevel, Weather)>)delegate((SelectableLevel level, Weather weather) args)
			{
				ChangeMidDay.ShipLandingPatch(args.level, args.weather);
			});
			WeatherRegistryEvent disableAllWeathers2 = EventManager.DisableAllWeathers;
			object obj3 = <>c.<>9__6_4;
			if (obj3 == null)
			{
				Event val4 = delegate
				{
					FoggyPatch.ToggleFogExclusionZones(StartOfRound.Instance.currentLevel);
				};
				<>c.<>9__6_4 = val4;
				obj3 = (object)val4;
			}
			((CustomEvent)disableAllWeathers2).AddListener((Event)obj3);
			if (Settings.WeatherSelectionAlgorithm != WeatherCalculation.VanillaAlgorithm)
			{
				Settings.WeatherSelectionAlgorithm = (WeatherSelectionAlgorithm)(object)WeatherCalculation.weatherTweaksWeatherAlgorithm;
			}
			EventManager.TerminalStart.AddListener((ParameterEvent<Terminal>)delegate
			{
				TerminalPatch.Postfix();
			});
			EventManager.LobbyDisabled.AddListener((ParameterEvent<StartOfRound>)delegate
			{
				Reset.ResetThings();
			});
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader"))
			{
				LLL.Init();
			}
			MethodInfo method = typeof(StartOfRound).GetMethod("SetPlanetsWeather");
			val.Unpatch((MethodBase)method, (HarmonyPatchType)2, "imabatby.lethallevelloader");
			GeneralImprovements = new GeneralImprovementsCompat("ShaosilGaming.GeneralImprovements");
			MrovWeathersCompat = new MrovWeathersCompat("MrovWeathers");
			LethalElementsCompat = new LethalElementsCompat("voxx.LethalElementsPlugin", "1.3.0");
			if (Chainloader.PluginInfos.ContainsKey("xxxstoner420bongmasterxxx.open_monitors"))
			{
				OpenMonitorsCompat.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LobbyCompatibilityCompatibility.Init();
			}
			Init.InitMethod();
			logger.LogInfo((object)"\n                  .::.                  \n                  :==:                  \n         :-.      :==:      .-:         \n        .-==-.    .::.    .-===.        \n          .-=-  .:----:.  -==.          \n              -==========-              \n             ==============             \n               .-==========- :-----     \n         :-==-:. .=========- :-----     \n       .========:   .-=====             \n       ============-. :==-              \n       -=============. .  -==.          \n        :-==========:     .-==-.        \n            ......          .-:         ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin WeatherTweaks is loaded!");
		}
	}
	public static class TerminalPatch
	{
		public static void Postfix()
		{
			if (((CompatibilityBase)Plugin.GeneralImprovements).IsModPresent)
			{
				Plugin.logger.LogInfo((object)"GeneralImprovements is present");
				GeneralImprovementsCompat.Init();
			}
		}
	}
	internal class UncertainTypes
	{
		public class Uncertain : UncertainWeatherType
		{
			public Uncertain()
				: base("Uncertain")
			{
			}

			public override string CreateUncertaintyString(SelectableLevel level, Random random)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				LevelWeatherType weather = level.currentWeather;
				List<RandomWeatherWithVariables> list = level.randomWeathers.Where((RandomWeatherWithVariables w) => w.weatherType != weather).ToList();
				if (list.Count == 0)
				{
					return ((object)(LevelWeatherType)(ref weather)).ToString();
				}
				RandomWeatherWithVariables val = list[random.Next(list.Count)];
				if (random.Next(0, 3) == 0)
				{
					return $"{val.weatherType}?";
				}
				return $"{weather}?";
			}
		}

		public class Uncertain5050 : UncertainWeatherType
		{
			public Uncertain5050()
				: base("Uncertain5050")
			{
			}

			public override string CreateUncertaintyString(SelectableLevel level, Random random)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				LevelWeatherType weather = level.currentWeather;
				List<RandomWeatherWithVariables> list = level.randomWeathers.Where((RandomWeatherWithVariables w) => w.weatherType != weather).ToList();
				if (list.Count == 0)
				{
					return ((object)(LevelWeatherType)(ref weather)).ToString();
				}
				RandomWeatherWithVariables val = list[random.Next(list.Count)];
				if (random.Next(0, 1) == 0)
				{
					return $"{weather}/{val.weatherType}";
				}
				return $"{val.weatherType}/{weather}";
			}
		}

		public class Unknown : UncertainWeatherType
		{
			public Unknown()
				: base("Unknown")
			{
			}

			public override string CreateUncertaintyString(SelectableLevel level, Random random)
			{
				return "[UNKNOWN]";
			}
		}
	}
	internal class UncertainWeather
	{
		public static Dictionary<string, string> uncertainWeathers = new Dictionary<string, string>();

		public static List<UncertainWeatherType> uncertainWeatherTypes = new List<UncertainWeatherType>();

		public static void Init()
		{
			Plugin.logger.LogInfo((object)"UncertainWeather initialized.");
			uncertainWeatherTypes = new List<UncertainWeatherType>(3)
			{
				new UncertainTypes.Uncertain(),
				new UncertainTypes.Uncertain5050(),
				new UncertainTypes.Unknown()
			};
		}

		public static Dictionary<string, string> GenerateUncertainty()
		{
			uncertainWeathers.Clear();
			if (!ConfigManager.UncertainWeatherEnabled.Value)
			{
				Plugin.logger.LogInfo((object)"Uncertain weathers are disabled.");
				return uncertainWeathers;
			}
			if (StartOfRound.Instance.gameStats.daysSpent == 0 && !ConfigManager.AlwaysUncertain.Value && !ConfigManager.AlwaysUnknown.Value)
			{
				Plugin.logger.LogInfo((object)"It's the first day, no uncertainty will be generated.");
				return uncertainWeathers;
			}
			Plugin.logger.LogInfo((object)"GenerateUncertainty called.");
			StartOfRound instance = StartOfRound.Instance;
			Random random = new Random(instance.randomMapSeed + 31);
			int num = Mathf.Clamp((int)((double)Mathf.Clamp(instance.planetsWeatherRandomCurve.Evaluate((float)random.NextDouble()) * 0.4f, 0f, 1f) * (double)Variables.GameLevels.Count), 1, Variables.GameLevels.Count - 2);
			if (ConfigManager.AlwaysUncertain.Value || ConfigManager.AlwaysUnknown.Value)
			{
				num = Variables.GameLevels.Count;
			}
			Plugin.logger.LogDebug((object)$"howManyPlanetsUncertain: {num}");
			List<SelectableLevel> list = new List<SelectableLevel>();
			for (int i = 0; i < num; i++)
			{
				SelectableLevel val = Variables.GameLevels[random.Next(Variables.GameLevels.Count)];
				if (!((Object)(object)val == (Object)(object)LevelHelper.CompanyMoon))
				{
					if (!list.Contains(val))
					{
						list.Add(val);
					}
					else
					{
						i--;
					}
				}
			}
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			List<UncertainWeatherType> list2 = new List<UncertainWeatherType>();
			foreach (UncertainWeatherType uncertainWeatherType in uncertainWeatherTypes)
			{
				if (uncertainWeatherType.Enabled.Value)
				{
					list2.Add(uncertainWeatherType);
				}
			}
			if (ConfigManager.AlwaysUnknown.Value)
			{
				Plugin.logger.LogDebug((object)"Setting possible types to only unknown.");
				list2 = new List<UncertainWeatherType>(1)
				{
					new UncertainTypes.Unknown()
				};
			}
			Plugin.logger.LogDebug((object)$"uncertainTypes: {list2.Count}");
			if (list2.Count == 0)
			{
				Plugin.logger.LogInfo((object)"No uncertain types are enabled, skipping uncertainty generation.");
				return uncertainWeathers;
			}
			foreach (SelectableLevel item in list)
			{
				int index = random.Next(list2.Count);
				string text = list2[index].CreateUncertaintyString(item, random);
				Plugin.logger.LogDebug((object)("Rolled type: " + list2[index].Name + ", setting its uncertainty to " + text + "."));
				dictionary.Add(item.PlanetName, text);
			}
			uncertainWeathers = dictionary;
			return dictionary;
		}
	}
	internal class Variables
	{
		internal static bool IsSetupFinished = false;

		public static List<CombinedWeatherType> CombinedWeathers = new List<CombinedWeatherType>();

		public static List<ProgressingWeatherType> ProgressingWeathers = new List<ProgressingWeatherType>();

		private static List<WeatherTweaksWeather> _weatherTweaksTypes = new List<WeatherTweaksWeather>();

		public static List<ImprovedWeatherEffect> CurrentEffects = new List<ImprovedWeatherEffect>();

		internal static List<SelectableLevel> GameLevels => LevelHelper.Levels;

		internal static Weather NoneWeather => WeatherManager.NoneWeather;

		public static List<LevelWeatherType> CombinedWeatherTypes => CombinedWeathers.Select((CombinedWeatherType x) => ((Weather)x).VanillaWeatherType).ToList();

		public static List<LevelWeatherType> ProgressingWeatherTypes => ProgressingWeathers.Select((ProgressingWeatherType x) => ((Weather)x).VanillaWeatherType).ToList();

		public static List<Weather> WeatherTypes => WeatherManager.Weathers;

		public static List<WeatherTweaksWeather> WeatherTweaksTypes
		{
			get
			{
				if (_weatherTweaksTypes.Count == 0)
				{
					foreach (Weather weatherType in WeatherTypes)
					{
						if (!((Object)(object)weatherType == (Object)null))
						{
							if (weatherType is WeatherTweaksWeather item)
							{
								Plugin.logger.LogDebug((object)("Weather " + weatherType.Name + " is a WeatherTweaks weather"));
								_weatherTweaksTypes.Add(item);
							}
							else
							{
								_weatherTweaksTypes.Add(new WeatherTweaksWeather(weatherType));
							}
						}
					}
				}
				return _weatherTweaksTypes;
			}
			set
			{
				_weatherTweaksTypes = value;
			}
		}

		public static List<WeatherTweaksWeather> SpecialWeathers => CombinedWeathers.Cast<WeatherTweaksWeather>().Concat(ProgressingWeathers).ToList();

		public static List<LevelWeatherType> WeatherTweaksWeathers => SpecialWeathers.Select((WeatherTweaksWeather x) => ((Weather)x).VanillaWeatherType).ToList();

		public static WeatherTweaksWeather CurrentLevelWeather => GetFullWeatherType(StartOfRound.Instance.currentLevel.currentWeather);

		public static WeatherTweaksWeather GetCurrentWeather()
		{
			if (CurrentLevelWeather.CustomType == CustomWeatherType.Progressing)
			{
				if (ChangeMidDay.CurrentEntry == null)
				{
					Plugin.logger.LogWarning((object)"Current entry is null");
					return CurrentLevelWeather;
				}
				return (WeatherTweaksWeather)(object)ChangeMidDay.CurrentEntry.GetWeather();
			}
			return CurrentLevelWeather;
		}

		internal static Dictionary<int, LevelWeatherType> GetWeatherData(string weatherData)
		{
			return JsonConvert.DeserializeObject<Dictionary<int, LevelWeatherType>>(weatherData);
		}

		internal static List<SelectableLevel> GetGameLevels()
		{
			return GameLevels;
		}

		internal static List<WeatherTweaksWeather> GetPlanetWeatherTypes(SelectableLevel level, bool specialWeathers = false)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			List<LevelWeatherType> planetPossibleWeathers = WeatherManager.GetPlanetPossibleWeathers(level);
			if (planetPossibleWeathers.Count() == 0)
			{
				Plugin.logger.LogError((object)"Random weathers are empty");
				return new List<WeatherTweaksWeather>();
			}
			List<WeatherTweaksWeather> list = new List<WeatherTweaksWeather>();
			foreach (WeatherTweaksWeather weatherTweaksType in WeatherTweaksTypes)
			{
				if (planetPossibleWeathers.Contains(((Weather)weatherTweaksType).VanillaWeatherType))
				{
					list.Add(weatherTweaksType);
				}
			}
			if (specialWeathers)
			{
				foreach (WeatherTweaksWeather weather in SpecialWeathers)
				{
					switch (weather.CustomType)
					{
					case CustomWeatherType.Combined:
					{
						CombinedWeatherType combinedWeatherType = CombinedWeathers.Find((CombinedWeatherType x) => ((Weather)x).Name == ((Weather)weather).Name);
						if (combinedWeatherType.CanWeatherBeApplied(level))
						{
							list.Add(weather);
						}
						break;
					}
					case CustomWeatherType.Progressing:
					{
						ProgressingWeatherType progressingWeatherType = ProgressingWeathers.Find((ProgressingWeatherType x) => ((Weather)x).Name == ((Weather)weather).Name);
						if (progressingWeatherType.CanWeatherBeApplied(level))
						{
							list.Add(weather);
						}
						break;
					}
					}
				}
			}
			return list.Distinct().ToList();
		}

		public static string GetPlanetCurrentWeather(SelectableLevel level, bool uncertain = true)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			bool flag = UncertainWeather.uncertainWeathers.ContainsKey(level.PlanetName);
			if (!IsSetupFinished)
			{
				Plugin.DebugLogger.LogDebug((object)"Setup is not finished yet");
				return ((object)(LevelWeatherType)(ref level.currentWeather)).ToString();
			}
			if (flag && uncertain)
			{
				Plugin.DebugLogger.LogDebug((object)("Getting uncertain weather for " + level.PlanetName));
				return UncertainWeather.uncertainWeathers[level.PlanetName];
			}
			Plugin.DebugLogger.LogDebug((object)("Getting current weather for " + level.PlanetName));
			Weather weather = WeatherManager.GetWeather(level.currentWeather);
			return weather.Name;
		}

		public static WeatherTweaksWeather GetPlanetCurrentWeatherType(SelectableLevel level)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetFullWeatherType(level.currentWeather);
		}

		public static float GetLevelWeatherVariable(LevelWeatherType weatherType, bool variable2 = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			Logger val = new Logger("WeatherTweaks Variables", ConfigManager.LogWeatherVariables);
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				Plugin.logger.LogError((object)"StartOfRound is null");
				return 0f;
			}
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			Weather weather = WeatherManager.GetWeather(weatherType);
			RandomWeatherWithVariables val2 = ((IEnumerable<RandomWeatherWithVariables>)currentLevel.randomWeathers).FirstOrDefault((Func<RandomWeatherWithVariables, bool>)((RandomWeatherWithVariables x) => x.weatherType == weatherType));
			if (val2 == null || (Object)(object)currentLevel == (Object)null)
			{
				val.LogWarning((object)$"Level {StringResolver.GetNumberlessName(currentLevel)} doesn't have weather variables defined for weather {weatherType}!");
				return variable2 ? weather.Effect.DefaultVariable2 : weather.Effect.DefaultVariable1;
			}
			Plugin.DebugLogger.LogDebug((object)$"Got weather variables for {currentLevel.PlanetName}:{weatherType} with variables {val2.weatherVariable} {val2.weatherVariable2}");
			if (variable2)
			{
				return val2.weatherVariable2;
			}
			return val2.weatherVariable;
		}

		public static LevelWeatherType LevelHasWeather(LevelWeatherType weatherType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)$"Checking if level has weather {weatherType}");
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)currentLevel == (Object)null)
			{
				Plugin.logger.LogError((object)$"Failed to get weather variables for {currentLevel.PlanetName}:{weatherType}");
				return (LevelWeatherType)(-1);
			}
			WeatherTweaksWeather planetCurrentWeatherType = GetPlanetCurrentWeatherType(currentLevel);
			Plugin.logger.LogDebug((object)$"Level has weather {((Weather)planetCurrentWeatherType).Type}?");
			switch (planetCurrentWeatherType.CustomType)
			{
			case CustomWeatherType.Combined:
			{
				CombinedWeatherType combinedWeatherType = (CombinedWeatherType)planetCurrentWeatherType;
				if (combinedWeatherType.WeatherTypes.Any((WeatherResolvable x) => x.WeatherType == weatherType))
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			case CustomWeatherType.Progressing:
			{
				ProgressingWeatherType progressingWeatherType = (ProgressingWeatherType)planetCurrentWeatherType;
				if (progressingWeatherType.DoesHaveWeatherHappening(weatherType))
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			default:
				if (((Weather)planetCurrentWeatherType).VanillaWeatherType == weatherType)
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			return (LevelWeatherType)(-1);
		}

		internal static Weather GetVanillaWeatherType(LevelWeatherType weatherType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return WeatherTypes.Find((Weather x) => x.VanillaWeatherType == weatherType);
		}

		internal static WeatherTweaksWeather GetFullWeatherType(Weather weatherType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetFullWeatherType(weatherType.VanillaWeatherType);
		}

		internal static WeatherTweaksWeather GetFullWeatherType(LevelWeatherType weatherType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)$"Getting full weather type for {weatherType}");
			return WeatherTweaksTypes.Find((WeatherTweaksWeather x) => ((Weather)x).VanillaWeatherType == weatherType);
		}

		internal static int GetWeatherLevelWeight(SelectableLevel level, LevelWeatherType weatherType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return WeatherManager.GetWeather(weatherType).GetWeight(level);
		}

		internal static WeightHandler<Weather> GetPlanetWeightedList(SelectableLevel level, float difficulty = 0f)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Invalid comparison between Unknown and I4
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Invalid comparison between Unknown and I4
			Logger val = new Logger("WeatherTweaks WeatherSelection", ConfigManager.LogWeatherSelection);
			WeightHandler<Weather> val2 = new WeightHandler<Weather>();
			WeightHandler<LevelWeatherType> weatherTypeWeights = new WeightHandler<LevelWeatherType>();
			difficulty = Math.Clamp(difficulty, 0f, ConfigManager.MaxMultiplier.Value);
			int possibleWeathersWeightSum = 0;
			List<WeatherTweaksWeather> weatherTypes = GetPlanetWeatherTypes(level, specialWeathers: true);
			WeatherTweaksTypes.Where((WeatherTweaksWeather weatherType) => weatherType.CustomType == CustomWeatherType.Normal).ToList().ForEach(delegate(WeatherTweaksWeather weatherType)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				int weatherLevelWeight = GetWeatherLevelWeight(level, ((Weather)weatherType).VanillaWeatherType);
				weatherTypeWeights.Add(((Weather)weatherType).VanillaWeatherType, weatherLevelWeight);
				if (weatherTypes.Contains(weatherType))
				{
					possibleWeathersWeightSum += weatherLevelWeight;
				}
			});
			weatherTypeWeights.Add((LevelWeatherType)(-1), GetWeatherLevelWeight(level, (LevelWeatherType)(-1)));
			foreach (WeatherTweaksWeather weatherType2 in weatherTypes)
			{
				int num = weatherTypeWeights.Get(((Weather)weatherType2).VanillaWeatherType);
				if (ConfigManager.ScaleDownClearWeather.Value && (int)((Weather)weatherType2).VanillaWeatherType == -1)
				{
					int weight = NoneWeather.GetWeight(level);
					int sum = weatherTypeWeights.Sum;
					double value = weight * Math.Max(possibleWeathersWeightSum, 1) / Math.Max(sum, 1);
					num = Convert.ToInt32(value);
					val.LogDebug((object)$"Scaling down clear weather weight from {weight} to {num} : ({weight} * {possibleWeathersWeightSum} / {sum}) == {num}");
				}
				if (weatherType2.CustomType == CustomWeatherType.Combined)
				{
					CombinedWeatherType combinedWeatherType = CombinedWeathers.Find((CombinedWeatherType x) => ((Weather)x).Name == ((Weather)weatherType2).Name);
					if (!combinedWeatherType.CanWeatherBeApplied(level))
					{
						val.LogDebug((object)("Combined weather: " + ((Weather)combinedWeatherType).Name + " can't be applied"));
						continue;
					}
					num = ((Weather)combinedWeatherType).GetWeight(level);
				}
				else if (weatherType2.CustomType == CustomWeatherType.Progressing)
				{
					num = ((Weather)weatherType2).GetWeight(level);
				}
				if (difficulty != 0f && (int)((Weather)weatherType2).VanillaWeatherType == -1)
				{
					num = (int)((float)num * (1f - difficulty));
				}
				val.LogDebug((object)$"{((Weather)weatherType2).Name} has weight {num}");
				val2.Add((Weather)(object)weatherType2, num);
			}
			return val2;
		}
	}
	internal class WeatherCalculation
	{
		internal class WeatherTweaksWeatherAlgorithm : WeatherSelectionAlgorithm
		{
			public override Dictionary<SelectableLevel, LevelWeatherType> SelectWeathers(int connectedPlayersOnServer, StartOfRound startOfRound)
			{
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				//IL_0332: Unknown result type (might be due to invalid IL or missing references)
				Plugin.logger.LogMessage((object)"SetWeathers called.");
				if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
				{
					Plugin.logger.LogMessage((object)"Not a host, cannot generate weather!");
					return null;
				}
				previousDayWeather.Clear();
				Random random = ((WeatherSelectionAlgorithm)this).GetRandom(startOfRound);
				Dictionary<SelectableLevel, Weather> dictionary = new Dictionary<SelectableLevel, Weather>();
				List<LevelWeatherType> vanillaWeathers = Defaults.VanillaWeathers;
				List<SelectableLevel> gameLevels = Variables.GetGameLevels();
				int daysSpent = startOfRound.gameStats.daysSpent;
				int timesFulfilledQuota = TimeOfDay.Instance.timesFulfilledQuota;
				int num = daysSpent % 3;
				if (daysSpent == 0 && ConfigManager.FirstDaySpecial.Value)
				{
					return ((WeatherSelectionAlgorithm)firstDayWeathersAlgorithm).SelectWeathers(connectedPlayersOnServer, startOfRound);
				}
				float num2 = (float)timesFulfilledQuota * ConfigManager.GameLengthMultiplier.Value;
				float num3 = (float)StartOfRound.Instance.livingPlayers * ConfigManager.GamePlayersMultiplier.Value;
				float num4 = num2 + num3;
				Plugin.logger.LogDebug((object)$"Difficulty multiplier: {num4}");
				foreach (SelectableLevel level in gameLevels)
				{
					previousDayWeather[level.PlanetName] = level.currentWeather;
					if (ConfigManager.AlwaysClear.Value)
					{
						Plugin.logger.LogDebug((object)"AlwaysClear is true, setting weather to None");
						dictionary[level] = Variables.NoneWeather;
						continue;
					}
					if (level.overrideWeather)
					{
						Plugin.logger.LogDebug((object)$"Override weather present, changing weather to {level.overrideWeatherType}");
						dictionary[level] = (Weather)(object)Variables.WeatherTweaksTypes.Find((WeatherTweaksWeather x) => ((Weather)x).VanillaWeatherType == level.overrideWeatherType && x.CustomType == CustomWeatherType.Normal);
						continue;
					}
					Plugin.logger.LogDebug((object)"-------------");
					Plugin.logger.LogDebug((object)(level.PlanetName ?? ""));
					Plugin.logger.LogDebug((object)$"previousDayWeather: {previousDayWeather[level.PlanetName]}");
					if ((int)previousDayWeather[level.PlanetName] == 0)
					{
						previousDayWeather[level.PlanetName] = (LevelWeatherType)(-1);
					}
					dictionary[level] = Variables.NoneWeather;
					WeightHandler<Weather> planetWeightedList = Variables.GetPlanetWeightedList(level);
					Weather val = planetWeightedList.Random();
					dictionary[level] = val;
					Plugin.logger.LogDebug((object)("Selected weather: " + val.Name));
					try
					{
						Plugin.logger.LogDebug((object)$"Chance for that was {planetWeightedList.Get(val)} / {planetWeightedList.Sum} ({(float)planetWeightedList.Get(val) / (float)planetWeightedList.Sum * 100f}%)");
					}
					catch
					{
					}
				}
				Plugin.logger.LogDebug((object)"-------------");
				Dictionary<SelectableLevel, LevelWeatherType> dictionary2 = new Dictionary<SelectableLevel, LevelWeatherType>();
				foreach (KeyValuePair<SelectableLevel, Weather> item in dictionary)
				{
					dictionary2[item.Key] = item.Value.VanillaWeatherType;
				}
				return dictionary2;
			}
		}

		internal class FirstDayWeathersAlgorithm : WeatherSelectionAlgorithm
		{
			public List<string> PlanetsWithoutWeather { get; set; }

			public override Random GetRandom(StartOfRound startOfRound)
			{
				Random random = new Random(startOfRound.randomMapSeed);
				int seed = ConfigManager.FirstDaySeed.Value;
				if (ConfigManager.FirstDayRandomSeed.Value)
				{
					seed = random.Next(0, 10000000);
				}
				return new Random(seed);
			}

			public override Dictionary<SelectableLevel, LevelWeatherType> SelectWeathers(int connectedPlayersOnServer, StartOfRound startOfRound)
			{
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_0464: Unknown result type (might be due to invalid IL or missing references)
				Plugin.logger.LogInfo((object)"First day, setting predefined weather conditions");
				List<SelectableLevel> gameLevels = Variables.GetGameLevels();
				Dictionary<SelectableLevel, Weather> dictionary = new Dictionary<SelectableLevel, Weather>();
				List<string> noWeatherOnStartPlanets = new List<string>(2) { "41 Experimentation", "56 Vow" };
				List<SelectableLevel> list = gameLevels.Where((SelectableLevel level) => !noWeatherOnStartPlanets.Contains(level.PlanetName)).ToList();
				Random random = ((WeatherSelectionAlgorithm)this).GetRandom(startOfRound);
				if (gameLevels.Count > 9)
				{
					int num = (int)((double)gameLevels.Count * 0.5);
					Plugin.logger.LogDebug((object)$"Planets without weather: {num + 2}");
					for (int i = 0; i < num; i++)
					{
						string planetName = list[random.Next(0, list.Count)].PlanetName;
						noWeatherOnStartPlanets.Add(planetName);
						list.RemoveAll((SelectableLevel level) => level.PlanetName == planetName);
					}
				}
				PlanetsWithoutWeather = noWeatherOnStartPlanets;
				foreach (SelectableLevel level2 in Variables.GameLevels)
				{
					string planetName2 = level2.PlanetName;
					Plugin.logger.LogDebug((object)("planet: " + planetName2));
					if (ConfigManager.AlwaysClear.Value)
					{
						Plugin.logger.LogDebug((object)"AlwaysClear is true, setting weather to None");
						dictionary[level2] = Variables.NoneWeather;
						continue;
					}
					if (level2.overrideWeather)
					{
						Plugin.logger.LogDebug((object)$"Override weather present, changing weather to {level2.overrideWeatherType}");
						dictionary[level2] = (Weather)(object)Variables.WeatherTweaksTypes.Find((WeatherTweaksWeather x) => ((Weather)x).VanillaWeatherType == level2.overrideWeatherType && x.CustomType == CustomWeatherType.Normal);
						continue;
					}
					List<WeatherTweaksWeather> list2 = (from randomWeather in Variables.GetPlanetWeatherTypes(level2)
						where (int)((Weather)randomWeather).VanillaWeatherType != -1 && (int)((Weather)randomWeather).VanillaWeatherType != 0 && randomWeather.CustomType == CustomWeatherType.Normal
						select randomWeather).ToList();
					string text = JsonConvert.SerializeObject((object)list2.Select(delegate(WeatherTweaksWeather x)
					{
						//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)
						LevelWeatherType vanillaWeatherType = ((Weather)x).VanillaWeatherType;
						return ((object)(LevelWeatherType)(ref vanillaWeatherType)).ToString();
					}).ToList());
					list2.RemoveAll((WeatherTweaksWeather x) => (int)((Weather)x).VanillaWeatherType == 5);
					if (list2.Count == 0 || list2 == null)
					{
						dictionary[level2] = Variables.NoneWeather;
						Plugin.logger.LogDebug((object)("No random weathers for " + planetName2 + ", skipping"));
						continue;
					}
					if (PlanetsWithoutWeather.Contains(planetName2))
					{
						dictionary[level2] = Variables.NoneWeather;
						Plugin.logger.LogDebug((object)("Skipping " + planetName2 + " (predefined)"));
						continue;
					}
					bool flag = random.Next(0, 100) < 5;
					WeatherTweaksWeather selectedRandom = list2[random.Next(0, list2.Count)];
					if (flag)
					{
						Plugin.logger.LogDebug((object)("Setting eclipsed for " + planetName2));
						if (!list2.Any((WeatherTweaksWeather x) => (int)((Weather)x).VanillaWeatherType == 5))
						{
							Plugin.logger.LogDebug((object)("Eclipsed not possible for " + planetName2 + ", setting random weather"));
						}
						else
						{
							selectedRandom = list2.First((WeatherTweaksWeather x) => (int)((Weather)x).VanillaWeatherType == 5);
						}
					}
					Weather val = (Weather)(object)Variables.WeatherTweaksTypes.Find((WeatherTweaksWeather x) => ((Weather)x).VanillaWeatherType == ((Weather)selectedRandom).VanillaWeatherType && x.CustomType == CustomWeatherType.Normal);
					dictionary[level2] = val;
					Plugin.logger.LogDebug((object)("Set weather for " + planetName2 + ": " + val.Name));
				}
				if ((Object)(object)CompanyMoon != (Object)null)
				{
					dictionary[CompanyMoon] = Variables.NoneWeather;
				}
				Dictionary<SelectableLevel, LevelWeatherType> dictionary2 = new Dictionary<SelectableLevel, LevelWeatherType>();
				foreach (KeyValuePair<SelectableLevel, Weather> item in dictionary)
				{
					dictionary2[item.Key] = item.Value.VanillaWeatherType;
				}
				return dictionary2;
			}
		}

		internal static Dictionary<string, LevelWeatherType> previousDayWeather = new Dictionary<string, LevelWeatherType>();

		internal static FirstDayWeathersAlgorithm firstDayWeathersAlgorithm = new FirstDayWeathersAlgorithm();

		internal static WeatherTweaksWeatherAlgorithm weatherTweaksWeatherAlgorithm = new WeatherTweaksWeatherAlgorithm();

		internal static SelectableLevel CompanyMoon => LevelHelper.CompanyMoon;
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WeatherTweaks";

		public const string PLUGIN_NAME = "WeatherTweaks";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace WeatherTweaks.Patches
{
	internal class FoggyPatch
	{
		public static void CreateEffectOverrides()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			Plugin.logger.LogInfo((object)"CreateEffectOverrides called");
			Weather weather = WeatherManager.GetWeather((LevelWeatherType)3);
			ImprovedWeatherEffect val = new ImprovedWeatherEffect(weather.Effect.EffectObject, Object.Instantiate<GameObject>(weather.Effect.WorldObject));
			GameObject worldObject = val.WorldObject;
			LocalVolumetricFog component = worldObject.GetComponent<LocalVolumetricFog>();
			LocalVolumetricFog item = ChangeFogParams(component);
			List<LocalVolumetricFog> list = worldObject.GetComponents<LocalVolumetricFog>().ToList();
			list.Remove(component);
			list.Add(item);
			val.WorldObject = worldObject;
			foreach (SelectableLevel level in LevelHelper.Levels)
			{
				if (!((ConfigHandler<SelectableLevel[], string>)(object)ConfigManager.FoggyIgnoreLevels).Value.Contains(level))
				{
					WeatherEffectOverride val2 = new WeatherEffectOverride(weather, level, val);
				}
			}
		}

		public static LocalVolumetricFog ChangeFogParams(LocalVolumetricFog Fog)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogInfo((object)"ChangeFog called");
			Plugin.logger.LogInfo((object)$"is null? {(Object)(object)Fog == (Object)null}");
			try
			{
				LocalVolumetricFogArtistParameters parameters = Fog.parameters;
				Plugin.DebugLogger.LogWarning((object)$"FOG: {((Object)Fog).name} {parameters.size} {((Component)Fog).transform.position} {parameters.albedo} {parameters.meanFreePath}");
				((Component)Fog).transform.position = new Vector3(((Component)Fog).transform.position.x, ((Component)Fog).transform.position.y + 128f, ((Component)Fog).transform.position.z);
				parameters.albedo = new Color(0.25f, 0.35f, 0.55f, 1f);
				parameters.meanFreePath = 11f;
				parameters.falloffMode = (LocalVolumetricFogFalloffMode)0;
				parameters.distanceFadeEnd = 200f;
				parameters.distanceFadeStart = 0f;
				parameters.blendingMode = (LocalVolumetricFogBlendingMode)1;
				parameters.size.y += 256f;
				parameters.size.x *= 5f;
				parameters.size.z *= 5f;
				Plugin.DebugLogger.LogWarning((object)$"FOG: {((Object)Fog).name} {parameters.size} {((Component)Fog).transform.position} {parameters.albedo} {parameters.meanFreePath}");
				Fog.parameters = parameters;
			}
			catch (Exception)
			{
				Plugin.logger.LogWarning((object)"Failed to change fog");
			}
			return Fog;
		}

		public static void ToggleFogExclusionZones(SelectableLevel level, bool enable = true)
		{
			Plugin.logger.LogDebug((object)"DisableFogExclusionZones called");
			List<GameObject> list = (from obj in Object.FindObjectsOfType<GameObject>()
				where ((Object)obj).name == "FogExclusionZone"
				select obj).ToList();
			foreach (GameObject item in list)
			{
				if (!(((Object)item.transform.parent).name == "HangarShip"))
				{
					Plugin.DebugLogger.LogDebug((object)$"Setting fog exclusion zone {((Object)item).name} (parent {((Object)item.transform.parent).name}) to {enable}");
					item.SetActive(enable);
				}
			}
		}
	}
	public class Reset
	{
		public static void ResetThings()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Variables.CurrentEffects.Clear();
			Variables.IsSetupFinished = false;
			Variables.WeatherTweaksTypes.Clear();
			WeatherTweaksWeather[] array = Object.FindObjectsOfType<WeatherTweaksWeather>();
			foreach (WeatherTweaksWeather weatherTweaksWeather in array)
			{
				if ((int)((Weather)weatherTweaksWeather).Type == 1 || (int)((Weather)weatherTweaksWeather).Type == 0)
				{
					Object.Destroy((Object)(object)weatherTweaksWeather);
				}
			}
		}
	}
	public class TerminalStartPatch
	{
		public static void Start()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Variables.CurrentEffects.Clear();
			Settings.ScreenMapColors.Add("+", Color.white);
			Settings.ScreenMapColors.Add("/", Color.white);
			Settings.ScreenMapColors.Add(">", Color.white);
			Settings.ScreenMapColors.Add("?", Color.white);
			Settings.ScreenMapColors.Add("[UNKNOWN]", new Color(0.29f, 0.29f, 0.29f));
			FoggyPatch.CreateEffectOverrides();
			Variables.IsSetupFinished = true;
			StartOfRound.Instance.SetPlanetsWeather(0);
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}
	}
}
namespace WeatherTweaks.Modules
{
	public abstract class UncertainWeatherType
	{
		public string Name;

		public ConfigEntry<bool> Enabled;

		public abstract string CreateUncertaintyString(SelectableLevel level, Random random);

		public UncertainWeatherType(string name)
		{
			Name = name;
			Plugin.logger.LogDebug((object)("Creating UncertainWeatherType: " + Name));
			Enabled = ConfigManager.configFile.Bind<bool>("1a> Uncertain mechanics", Name + " Enabled", true, "Enable " + Name + " uncertainty");
		}
	}
}
namespace WeatherTweaks.Definitions
{
	public class CombinedWeatherType : WeatherTweaksWeather
	{
		private List<Weather> _weathers = new List<Weather>();

		public float WeightModify;

		public List<Weather> Weathers
		{
			get
			{
				if (_weathers.Count == 0)
				{
					_weathers = WeatherTypes.Select((WeatherResolvable weatherType) => WeatherManager.GetWeather(weatherType.WeatherType)).ToList();
				}
				return _weathers;
			}
			private set
			{
				_weathers = value;
			}
		}

		public WeatherTweaksConfig Config => (WeatherTweaksConfig)(object)((Weather)this).Config;

		public bool Enabled => ((ConfigHandler<bool, bool>)(object)Config.EnableWeather).Value;

		public new bool CanWeatherBeApplied(SelectableLevel level)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled)
			{
				return false;
			}
			RandomWeatherWithVariables[] randomWeathers = level.randomWeathers;
			List<LevelWeatherType> list = Weathers.Select((Weather weather) => weather.VanillaWeatherType).ToList();
			RandomWeatherWithVariables[] array = randomWeathers;
			foreach (RandomWeatherWithVariables val in array)
			{
				if (list.Contains(val.weatherType))
				{
					list.Remove(val.weatherType);
				}
			}
			return list.Count == 0;
		}

		public override (float valueMultiplier, float amountMultiplier) GetDefaultMultiplierData()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			WeatherMultiplierData weatherMultiplierData = new WeatherMultiplierData(((Weather)this).VanillaWeatherType, 0f, 0f);
			foreach (Weather weather in Weathers)
			{
				weatherMultiplierData.valueMultiplier += weather.ScrapValueMultiplier * 0.45f;
				weatherMultiplierData.spawnMultiplier += weather.ScrapAmountMultiplier * 0.45f;
			}
			return (weatherMultiplierData.valueMultiplier, weatherMultiplierData.spawnMultiplier);
		}

		public override void Init()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			int num = (int)Weathers.Average((Weather weather) => weather.DefaultWeight);
			((RegistryWeatherConfig)Config).DefaultWeight = new IntegerConfigHandler((int)((float)num * WeightModify / (float)Weathers.Count), true);
			base.Init();
		}

		public CombinedWeatherType(string name, List<WeatherResolvable> weathers, float weightModifier = 0.2f)
			: base(name, CustomWeatherType.Combined, weathers.ToArray())
		{
			if (weathers.Count != 0)
			{
				WeightModify = weightModifier;
				((Weather)this).Name = name;
				base.CustomType = CustomWeatherType.Combined;
				Plugin.logger.LogDebug((object)("Created CombinedWeatherType: " + ((Weather)this).Name));
				Variables.CombinedWeathers.Add(this);
				WeatherManager.RegisterWeather((Weather)(object)this);
			}
		}
	}
	[JsonObject(/*Could not decode attribute arguments.*/)]
	public class ProgressingWeatherEntry
	{
		[JsonProperty]
		public float DayTime;

		[JsonProperty]
		public float Chance = 0.8f;

		[JsonProperty]
		public WeatherResolvable Weather;

		public string WeatherName;

		internal Weather GetWeather()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return WeatherManager.GetWeather(Weather.WeatherType);
		}

		internal List<DialogueSegment> GetDialogueSegment()
		{
			//IL_0007: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			return new List<DialogueSegment>(1)
			{
				new DialogueSegment
				{
					speakerText = "Weather Forecast",
					bodyText = "The weather will be changing to " + GetWeather().Name,
					waitTime = 7f
				}
			};
		}
	}
	public class ProgressingWeatherType : WeatherTweaksWeather
	{
		public List<ProgressingWeatherEntry> WeatherEntries = new List<ProgressingWeatherEntry>();

		public WeatherResolvable StartingWeather;

		private Weather _weather;

		public float WeightModify;

		public bool Enabled => ((ConfigHandler<bool, bool>)(object)Config.EnableWeather).Value;

		public Weather Weather
		{
			get
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_weather == (Object)null)
				{
					_weather = WeatherManager.GetWeather(StartingWeather.WeatherType);
				}
				return _weather;
			}
			set
			{
				_weather = value;
			}
		}

		public WeatherTweaksConfig Config => (WeatherTweaksConfig)(object)((Weather)this).Config;

		public new bool CanWeatherBeApplied(SelectableLevel level)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled)
			{
				return false;
			}
			RandomWeatherWithVariables[] randomWeathers = level.randomWeathers;
			List<LevelWeatherType> list = WeatherEntries.Select((ProgressingWeatherEntry entry) => entry.Weather.WeatherType).Append(StartingWeather.WeatherType).Distinct()
				.ToList();
			list.RemoveAll((LevelWeatherType weather) => (int)weather == -1);
			RandomWeatherWithVariables[] array = randomWeathers;
			foreach (RandomWeatherWithVariables val in array)
			{
				if (list.Contains(val.weatherType))
				{
					list.Remove(val.weatherType);
				}
			}
			return list.Count == 0;
		}

		public override void Init()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			int num = (int)(from entry in WeatherEntries.ToList()
				select entry.GetWeather()).Average((Weather weather) => weather.DefaultWeight);
			((RegistryWeatherConfig)Config).DefaultWeight = new IntegerConfigHandler((int)((float)num * WeightModify / (float)WeatherEntries.Count), true);
			base.Init();
		}

		public override (float valueMultiplier, float amountMultiplier) GetDefaultMultiplierData()
		{
			//IL_0001: Unknown result type (migh