Decompiled source of BetaWeatherTweaksBeta v0.22.0

WeatherTweaks.dll

Decompiled 3 months 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 WeatherRegistry;
using WeatherRegistry.Events;
using WeatherRegistry.Patches;
using WeatherTweaks.Definitions;
using WeatherTweaks.Modules;
using WeatherTweaks.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[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("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+027a6166645265a284ffecce5c07f10b344aacb0")]
[assembly: AssemblyProduct("WeatherTweaks")]
[assembly: AssemblyTitle("WeatherTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 float lastCheckedEntry = 0f;

		internal static Random random;

		internal static WeatherTweaks.Definitions.Types.ProgressingWeatherEntry currentEntry;

		internal static WeatherTweaks.Definitions.Types.ProgressingWeatherEntry nextEntry;

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

		[HarmonyPostfix]
		[HarmonyPatch("MoveTimeOfDay")]
		internal static void MoveTimeOfDayPatch(TimeOfDay __instance)
		{
			if (Variables.CurrentLevelWeather.Type == CustomWeatherType.Progressing && ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				float normalizedTimeOfDay = __instance.normalizedTimeOfDay;
				float num = ((nextEntry != null) ? nextEntry.DayTime : 0f);
				if (normalizedTimeOfDay >= num)
				{
					RunProgressingEntryActions(normalizedTimeOfDay);
				}
			}
		}

		internal static void RunProgressingEntryActions(float normalizedTimeOfDay)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			WeatherType currentWeather = Variables.CurrentLevelWeather;
			if (random == null)
			{
				random = new Random(StartOfRound.Instance.randomMapSeed);
			}
			if (currentEntry == null)
			{
				currentEntry = new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0f,
					Chance = 1f,
					Weather = currentWeather.weatherType
				};
			}
			WeatherTweaks.Definitions.Types.ProgressingWeatherType progressingWeatherType = Variables.ProgressingWeatherTypes.First((WeatherTweaks.Definitions.Types.ProgressingWeatherType weather) => weather.Name == currentWeather.Name);
			List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry> weatherEntries = progressingWeatherType.WeatherEntries;
			weatherEntries.RemoveAll((WeatherTweaks.Definitions.Types.ProgressingWeatherEntry entry) => entry.DayTime < lastCheckedEntry);
			nextEntry = weatherEntries.FirstOrDefault((WeatherTweaks.Definitions.Types.ProgressingWeatherEntry entry) => entry.DayTime > lastCheckedEntry);
			foreach (WeatherTweaks.Definitions.Types.ProgressingWeatherEntry item in weatherEntries)
			{
				if (normalizedTimeOfDay > item.DayTime && item.DayTime > lastCheckedEntry)
				{
					logger.LogInfo((object)$"Changing weather to {item.GetWeatherType().Name} at {item.DayTime}");
					float num = (float)random.NextDouble();
					if (num > item.Chance)
					{
						logger.LogWarning((object)$"Random roll failed - got {num}, needed {item.Chance} or lower");
						lastCheckedEntry = item.DayTime;
						break;
					}
					NetworkedConfig.SetProgressingWeatherEntry(item);
					NetworkedConfig.SetWeatherEffects(new List<Weather>(1) { item.GetWeatherType().Weather });
					((MonoBehaviour)TimeOfDay.Instance).StartCoroutine(DoMidDayChange(item));
					lastCheckedEntry = item.DayTime;
					currentEntry = item;
					break;
				}
			}
		}

		internal static IEnumerator DoMidDayChange(WeatherTweaks.Definitions.Types.ProgressingWeatherEntry entry)
		{
			if (entry == null)
			{
				logger.LogError((object)"ProgressingWeatherEntry is null");
				yield return null;
			}
			logger.LogWarning((object)$"Changing weather to {entry.GetWeatherType().Name} at {entry.DayTime}, chance {entry.Chance} - is player inside? {EntranceTeleportPatch.isPlayerInside}");
			HUDManager.Instance.ReadDialogue(entry.GetDialogueSegment().ToArray());
			yield return (object)new WaitForSeconds(3f);
			WeatherType fullWeatherType = Variables.GetFullWeatherType(entry.GetWeatherType());
			logger.LogWarning((object)$"{fullWeatherType.Name} {fullWeatherType.Type} {fullWeatherType.weatherType}");
			StartOfRound.Instance.currentLevel.currentWeather = fullWeatherType.weatherType;
			TimeOfDay.Instance.currentLevelWeather = fullWeatherType.weatherType;
			GameNetworkManager.Instance.localPlayerController.currentAudioTrigger.weatherEffect = (int)fullWeatherType.weatherType;
			currentEntry = entry;
			GameInteraction.SetWeatherEffects(TimeOfDay.Instance, new List<ImprovedWeatherEffect>(1) { fullWeatherType.Weather.Effect });
		}
	}
	public abstract class ConfigHandler<T, CT> : ConfigHandler<T, CT>
	{
		public ConfigHandler(CT defaultValue, string configTitle, ConfigDescription configDescription = null)
		{
			((ConfigHandler<T, CT>)this).DefaultValue = defaultValue;
			((ConfigHandler<T, CT>)this).ConfigEntry = ConfigManager.configFile.Bind<CT>("5> Foggy patch", configTitle, ((ConfigHandler<T, CT>)this).DefaultValue, configDescription);
		}
	}
	public class LevelListConfigHandler : ConfigHandler<SelectableLevel[], string>
	{
		public override SelectableLevel[] Value => ConfigHelper.ConvertStringToLevels(((ConfigHandler<SelectableLevel[], string>)this).ConfigEntry.Value);

		public LevelListConfigHandler(string defaultValue, string configTitle, ConfigDescription configDescription)
			: base(defaultValue, configTitle, configDescription)
		{
		}

		public void SetNewLevelsToIgnore(SelectableLevel[] levels)
		{
			string value = (((ConfigHandler<SelectableLevel[], string>)this).DefaultValue = string.Join(";", levels.Select((SelectableLevel level) => StringResolver.GetNumberlessName(level))) + ";");
			((ConfigHandler<SelectableLevel[], string>)this).ConfigEntry.Value = value;
		}
	}
	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> 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_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			configFile = config;
			LogWeatherSelection = configFile.Bind<bool>("0> Debug", "LogWeatherSelection", true, "Log weather selection");
			LogWeatherVariables = configFile.Bind<bool>("0> Debug", "LogWeatherVariables", true, "Log resolving weather variables");
			LogLogs = configFile.Bind<bool>("0> Debug", "Logs", true, "Log logging logs");
			UncertainWeatherEnabled = configFile.Bind<bool>("1> Uncertain weather", "UncertainWeatherEnabled", true, "Enable uncertain weather mechanic");
			MaxMultiplier = configFile.Bind<float>("2> Multipliers", "MaxMultiplier", 0.8f, "Maximum difficulty multiplier (between 0 and 1)");
			ScaleDownClearWeather = configFile.Bind<bool>("2> Multipliers", "ScaleDownClearWeather", true, "Scale down clear weather's weight based on planet's available random weathers to match % chance ");
			GameLengthMultiplier = configFile.Bind<float>("2a> Difficulty multipliers", "GameLengthMultiplier", 0.05f, "Difficulty multiplier - game length (quotas done)");
			GamePlayersMultiplier = configFile.Bind<float>("2a> Difficulty multipliers", "GamePlayersMultiplier", 0.01f, "Difficulty multiplier - players amount");
			FirstDaySeed = configFile.Bind<int>("3> First day", "FirstDaySeed", 0, "Seed for the first day's weather");
			FirstDaySpecial = configFile.Bind<bool>("3> First day", "FirstDaySpecial", true, "Enable special weather picking algorithm for the first day");
			FirstDayRandomSeed = configFile.Bind<bool>("3> First day", "FirstDayRandomSeed", true, "Use random seed for the first day's weather");
			AlwaysUncertain = configFile.Bind<bool>("4> Special modes", "AlwaysUncertain", false, "Always make weather uncertain");
			AlwaysUnknown = configFile.Bind<bool>("4> Special modes", "AlwaysUnknown", false, "Always make weather unknown");
			AlwaysClear = configFile.Bind<bool>("4> Special modes", "AlwaysClear", false, "Always make weather clear - good for testing");
			FoggyIgnoreLevels = new LevelListConfigHandler("", "FoggyIgnoreLevels", new ConfigDescription("Levels to ignore applying foggy weather patch on", (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	public static class DisplayTable
	{
		public static void DisplayWeathersTable()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (!Variables.IsSetupFinished)
			{
				return;
			}
			ConsoleTable val = new ConsoleTable(new string[3] { "Planet", "Level weather", "Uncertain weather" });
			Plugin.logger.LogWarning((object)$"Displaying weathers table, instance: {StartOfRound.Instance}");
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				return;
			}
			List<SelectableLevel> gameLevels = Variables.GetGameLevels();
			foreach (SelectableLevel item in gameLevels)
			{
				bool flag = UncertainWeather.uncertainWeathers.ContainsKey(item.PlanetName);
				val.AddRow(new object[3]
				{
					item.PlanetName,
					Variables.GetPlanetCurrentWeather(item, uncertain: false),
					flag ? UncertainWeather.uncertainWeathers[item.PlanetName] : ""
				});
			}
			Plugin.logger.LogInfo((object)("Currently set weathers: \n" + val.ToMinimalString()));
		}
	}
	internal class GameInteraction
	{
		internal static Logger logger = new Logger("WeatherTweaks GameInteraction", ConfigManager.LogLogs);

		internal static void SetWeather(Dictionary<string, WeatherType> weatherData)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogMessage((object)"Setting weather");
			List<SelectableLevel> gameLevels = Variables.GetGameLevels();
			foreach (SelectableLevel item in gameLevels)
			{
				string planetName = item.PlanetName;
				logger.LogDebug((object)("Setting weather for " + planetName));
				if (weatherData.ContainsKey(planetName))
				{
					WeatherType fullWeatherType = Variables.GetFullWeatherType(weatherData[planetName]);
					item.currentWeather = fullWeatherType.weatherType;
					Variables.CurrentWeathers[item] = fullWeatherType;
					logger.LogDebug((object)("Setting weather for " + planetName + " to " + fullWeatherType.Name));
				}
				else
				{
					Plugin.logger.LogWarning((object)("Weather data for " + planetName + " somehow not found, skipping"));
				}
			}
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}

		internal static void SetWeather(WeatherType weatherType)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			currentLevel.currentWeather = weatherType.weatherType;
			Variables.CurrentWeathers[currentLevel] = weatherType;
			logger.LogDebug((object)("Setting weather for " + currentLevel.PlanetName + " to " + weatherType.Name));
		}

		internal static void SetWeatherEffects(TimeOfDay timeOfDay, List<ImprovedWeatherEffect> weatherEffects)
		{
			//IL_014d: 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>();
			foreach (Weather weather in WeatherManager.Weathers)
			{
				if ((Object)(object)weather.Effect == (Object)null)
				{
					continue;
				}
				ImprovedWeatherEffect effect = weather.Effect;
				if (weatherEffects.Contains(effect))
				{
					logger.LogDebug((object)("Enabling effect from weather: " + weather.Name));
					if (!EntranceTeleportPatch.isPlayerInside)
					{
						weather.Effect.EffectEnabled = true;
					}
					else
					{
						logger.LogWarning((object)"Player is inside, skipping effect object activation");
						weather.Effect.DisableEffect(true);
					}
					if (effect.SunAnimatorBool != "" && effect.SunAnimatorBool != null)
					{
						list.Add(weather.VanillaWeatherType);
					}
				}
				else
				{
					logger.LogDebug((object)("Disabling effect: " + weather.Name));
					weather.Effect.DisableEffect(true);
				}
			}
			if (list.Count == 0)
			{
				SunAnimator.OverrideSunAnimator((LevelWeatherType)(-1));
				return;
			}
			list.Distinct().ToList().ForEach(delegate(LevelWeatherType loopWeatherType)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				SunAnimator.OverrideSunAnimator(loopWeatherType);
			});
		}
	}
	internal class NetworkedConfig
	{
		public static LethalNetworkVariable<string> currentWeatherDictionarySynced = new LethalNetworkVariable<string>("previousWeather");

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

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

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

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

		public static void Init()
		{
			currentWeatherDictionarySynced.OnValueChanged += WeatherDataReceived;
			currentWeatherStringsSynced.OnValueChanged += WeatherDisplayDataReceived;
			weatherEffectsSynced.OnValueChanged += WeatherEffectsReceived;
			weatherTypeSynced.OnValueChanged += WeatherTypeReceived;
			currentProgressingWeatherEntry.OnValueChanged += ProgressingWeatherEntryReceived;
		}

		public static void WeatherDataReceived(string weatherData)
		{
			Dictionary<string, WeatherType> currentWeather = JsonConvert.DeserializeObject<Dictionary<string, WeatherType>>(weatherData);
			Plugin.logger.LogWarning((object)weatherData.Count());
			if (weatherData == null || ((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				return;
			}
			Plugin.logger.LogInfo((object)("Received weather data " + weatherData + " from server, applying"));
			GameInteraction.SetWeather(currentWeather);
			DisplayTable.DisplayWeathersTable();
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
			Dictionary<SelectableLevel, WeatherType> dictionary = new Dictionary<SelectableLevel, WeatherType>();
			List<SelectableLevel> gameLevels = Variables.GetGameLevels(includeCompanyMoon: true);
			Variables.CurrentWeathers = new Dictionary<SelectableLevel, WeatherType>();
			gameLevels.ToList().ForEach(delegate(SelectableLevel level)
			{
				KeyValuePair<string, WeatherType> keyValuePair = currentWeather.FirstOrDefault((KeyValuePair<string, WeatherType> x) => x.Key == level.PlanetName);
				if (keyValuePair.Key != null)
				{
					Variables.CurrentWeathers.Add(level, keyValuePair.Value);
				}
			});
		}

		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 WeatherEffectsReceived(string weatherEffects)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)("Received weather effects: " + weatherEffects));
			List<Weather> source = JsonConvert.DeserializeObject<List<Weather>>(weatherEffects);
			List<ImprovedWeatherEffect> list = new List<ImprovedWeatherEffect>();
			if (list == null)
			{
				return;
			}
			foreach (Weather weather in WeatherManager.Weathers)
			{
				if (source.Select((Weather deserialized) => deserialized.VanillaWeatherType).Contains(weather.VanillaWeatherType))
				{
					list.Add(weather.Effect);
				}
			}
			Plugin.logger.LogInfo((object)("Received weather effects data " + weatherEffects + " from server, applying"));
			list.ForEach(delegate(ImprovedWeatherEffect effect)
			{
				Plugin.logger.LogDebug((object)$"Effect: {effect}");
			});
			GameInteraction.SetWeatherEffects(TimeOfDay.Instance, list);
		}

		public static void WeatherTypeReceived(string weatherType)
		{
			//IL_0059: 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)
			WeatherType weatherType2 = JsonConvert.DeserializeObject<WeatherType>(weatherType);
			if (weatherType2 != null && !((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				Plugin.logger.LogWarning((object)("Received weather type data " + weatherType + " from server, applying"));
				Variables.CurrentLevelWeather = Variables.GetFullWeatherType(weatherType2);
				StartOfRound.Instance.currentLevel.currentWeather = Variables.CurrentLevelWeather.weatherType;
			}
		}

		public static void ProgressingWeatherEntryReceived(string progressingWeatherEntry)
		{
			WeatherTweaks.Definitions.Types.ProgressingWeatherEntry progressingWeatherEntry2 = JsonConvert.DeserializeObject<WeatherTweaks.Definitions.Types.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 SetWeather(Dictionary<string, WeatherType> currentWeathers)
		{
			//IL_0003: 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_0015: Expected O, but got Unknown
			string text = JsonConvert.SerializeObject((object)currentWeathers, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			});
			currentWeatherDictionarySynced.Value = text;
			Plugin.logger.LogInfo((object)("Set weather data on server: " + text));
		}

		public static void SetDisplayWeather(Dictionary<string, string> uncertainWeathers)
		{
			//IL_0003: 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_0015: 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 SetWeatherEffects(List<Weather> weathers)
		{
			//IL_009d: 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_00af: Expected O, but got Unknown
			Plugin.logger.LogDebug((object)$"Setting weather effects: {weathers}");
			if (weathers != null)
			{
				weathers.ForEach(delegate(Weather weather)
				{
					Plugin.logger.LogDebug((object)$"Weather: {weather}");
				});
				weathers.Select((Weather weather) => (int)weather.VanillaWeatherType != -1);
				Variables.CurrentEffects.RemoveAll((ImprovedWeatherEffect effect) => (Object)(object)effect == (Object)null);
				string text = JsonConvert.SerializeObject((object)weathers, (Formatting)0, new JsonSerializerSettings
				{
					ReferenceLoopHandling = (ReferenceLoopHandling)1
				});
				if (!(text == weatherEffectsSynced.Value))
				{
					weatherEffectsSynced.Value = text;
					Plugin.logger.LogInfo((object)("Set weather effects on server: " + text));
				}
			}
		}

		public static void SetWeatherType(WeatherType weatherType)
		{
			//IL_0003: 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_0015: Expected O, but got Unknown
			string text = JsonConvert.SerializeObject((object)weatherType, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			});
			Plugin.logger.LogInfo((object)("Set weather type on server: " + text));
			weatherTypeSynced.Value = text;
		}

		public static void SetProgressingWeatherEntry(WeatherTweaks.Definitions.Types.ProgressingWeatherEntry entry)
		{
			//IL_0003: 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_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Expected I4, but got Unknown
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Expected O, but got Unknown
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: 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_0002: 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_0002: 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 + 25f;
			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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: 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 Logger logger = new Logger("WeatherTweaks TimeOfDay", ConfigManager.LogLogs);

		internal static void DisableAllWeather()
		{
			ChangeMidDay.lastCheckedEntry = 0f;
			ChangeMidDay.currentEntry = null;
			ChangeMidDay.nextEntry = null;
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				NetworkedConfig.SetWeatherEffects(new List<Weather>());
				NetworkedConfig.SetWeatherType(null);
				NetworkedConfig.SetProgressingWeatherEntry(null);
				ChangeMidDay.random = null;
			}
		}
	}
	[HarmonyPatch(typeof(EntranceTeleport))]
	internal class EntranceTeleportPatch
	{
		internal static Logger logger = new Logger("WeatherTweaks EntranceTeleport", ConfigManager.LogLogs);

		internal static bool isPlayerInside = false;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")]
		private static void TeleportPlayerPatch(EntranceTeleport __instance)
		{
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Invalid comparison between Unknown and I4
			logger.LogDebug((object)("TeleportPlayerPatch called with " + ((Object)__instance).name));
			isPlayerInside = __instance.isEntranceToBuilding;
			if (isPlayerInside)
			{
				logger.LogDebug((object)"Player is inside");
				return;
			}
			logger.LogDebug((object)"Player is outside");
			List<ImprovedWeatherEffect> list = new List<ImprovedWeatherEffect>();
			WeatherType currentWeather = Variables.GetCurrentWeather();
			if (currentWeather.Type == CustomWeatherType.Combined)
			{
				WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeatherType = (WeatherTweaks.Definitions.Types.CombinedWeatherType)currentWeather;
				list = combinedWeatherType.Weathers.Select((Weather weather) => weather.Effect).ToList();
			}
			else
			{
				list = new List<ImprovedWeatherEffect>(1) { currentWeather.Weather.Effect };
			}
			foreach (Weather weather in WeatherManager.Weathers)
			{
				logger.LogDebug((object)("Weather: " + weather.Name));
				if ((int)weather.Type != 0)
				{
					if (list.Contains(weather.Effect))
					{
						weather.Effect.EffectEnabled = true;
					}
					else
					{
						weather.Effect.DisableEffect(false);
					}
				}
			}
		}
	}
	internal class LobbyCompatibilityCompatibility
	{
		public static void Init()
		{
			Plugin.logger.LogWarning((object)"LobbyCompatibility detected, registering plugin with LobbyCompatibility.");
			Version version = Version.Parse("0.0.1");
			PluginHelper.RegisterPlugin("WeatherTweaks", version, (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	internal class OpeningDoorsSequencePatch
	{
		internal static void SetWeatherEffects(SelectableLevel level, Weather weather)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			WeatherType fullWeatherType = Variables.GetFullWeatherType(Variables.CurrentWeathers[level]);
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				if (fullWeatherType.Type == CustomWeatherType.Combined)
				{
					Plugin.logger.LogWarning((object)"WeatherType is CombinedWeatherType");
					WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeatherType = (WeatherTweaks.Definitions.Types.CombinedWeatherType)fullWeatherType;
					NetworkedConfig.SetWeatherEffects(combinedWeatherType.Weathers);
				}
				else
				{
					NetworkedConfig.SetWeatherEffects(new List<Weather>(1) { fullWeatherType.Weather });
				}
			}
			Variables.CurrentLevelWeather = fullWeatherType;
			Plugin.logger.LogWarning((object)("Landing at " + SharedMethods.GetNumberlessPlanetName(TimeOfDay.Instance.currentLevel) + " with weather " + JsonConvert.SerializeObject((object)fullWeatherType, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			})));
		}

		[HarmonyPatch("RunWeatherPatches")]
		[HarmonyPostfix]
		internal static void RunWeatherPatches()
		{
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class SetPlanetsWeatherPatch
	{
		[HarmonyPatch("SetPlanetsWeather")]
		[HarmonyPrefix]
		[HarmonyAfter(new string[] { "mrov.WeatherRegistry", "imabatby.lethallevelloader" })]
		private static bool GameMethodPatch(int connectedPlayersOnServer, StartOfRound __instance)
		{
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogMessage((object)"SetPlanetsWeather called.");
			if (!Variables.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.lastCheckedEntry = 0f;
			EntranceTeleportPatch.isPlayerInside = false;
			bool hasValue = GameNetworkManager.Instance.currentLobby.HasValue;
			Lobby valueOrDefault;
			if (((NetworkBehaviour)__instance).IsHost)
			{
				Variables.CurrentWeathers = new Dictionary<SelectableLevel, WeatherType>();
				Dictionary<string, WeatherType> weather = WeatherCalculation.NewWeathers(__instance);
				GameInteraction.SetWeather(weather);
				NetworkedConfig.SetWeather(weather);
				Dictionary<string, string> displayWeather = UncertainWeather.GenerateUncertainty();
				NetworkedConfig.SetDisplayWeather(displayWeather);
				__instance.SetMapScreenInfoToCurrentLevel();
				if (hasValue)
				{
					Lobby? currentLobby = GameNetworkManager.Instance.currentLobby;
					if (currentLobby.HasValue)
					{
						valueOrDefault = currentLobby.GetValueOrDefault();
						((Lobby)(ref valueOrDefault)).SetData("WeatherTweaks", "true");
					}
				}
			}
			else
			{
				Plugin.logger.LogMessage((object)"Not a host");
				if (hasValue)
				{
					Lobby? currentLobby = GameNetworkManager.Instance.currentLobby;
					object obj;
					if (!currentLobby.HasValue)
					{
						obj = null;
					}
					else
					{
						valueOrDefault = currentLobby.GetValueOrDefault();
						obj = ((Lobby)(ref valueOrDefault)).GetData("WeatherTweaks");
					}
					if (obj == null)
					{
						Plugin.logger.LogMessage((object)"Mod not detected on host, falling back to vanilla");
						return true;
					}
					Plugin.logger.LogMessage((object)"Detected mod on host, waiting for weather data");
				}
				Plugin.logger.LogDebug((object)("Current data: " + NetworkedConfig.currentWeatherDictionarySynced.Value));
			}
			return false;
		}

		[HarmonyPatch("SetPlanetsWeather")]
		[HarmonyPostfix]
		private static void DisplayCurrentWeathers()
		{
			DisplayTable.DisplayWeathersTable();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public static class TextPostProcessPatch
	{
		internal static Logger logger = new Logger("WeatherTweaks Terminal", ConfigManager.LogLogs);

		[HarmonyPatch("TextPostProcess")]
		[HarmonyPrefix]
		[HarmonyPriority(700)]
		private static bool PatchGameMethod(ref string modifiedDisplayText, TerminalNode node)
		{
			if (node.buyRerouteToMoon == -2)
			{
				logger.LogDebug((object)"buyRerouteToMoon == -2");
				Regex regex = new Regex("\\ It is (\\n)*currently.+\\[currentPlanetTime].+");
				if (regex.IsMatch(modifiedDisplayText))
				{
					modifiedDisplayText = regex.Replace(modifiedDisplayText, "");
				}
			}
			if (((Object)node).name == "MoonsCatalogue")
			{
				Regex regex2 = new Regex("\\[planetTime\\]");
				modifiedDisplayText = regex2.Replace(modifiedDisplayText, "");
			}
			return true;
		}
	}
	[BepInPlugin("WeatherTweaks", "WeatherTweaks", "0.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__4_0;

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

			public static Event <>9__4_2;

			public static Event <>9__4_3;

			public static ParameterEvent<Terminal> <>9__4_4;

			public static ParameterEvent<StartOfRound> <>9__4_5;

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

			internal void <Awake>b__4_1((SelectableLevel level, Weather weather) data)
			{
				OpeningDoorsSequencePatch.SetWeatherEffects(data.level, data.weather);
			}

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

			internal void <Awake>b__4_3()
			{
				Variables.PopulateWeathers();
			}

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

			internal void <Awake>b__4_5(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 GeneralImprovementsWeather GeneralImprovements;

		private void Awake()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_013f: 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: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			logger = ((BaseUnityPlugin)this).Logger;
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("WeatherTweaks");
			val.PatchAll();
			NetworkedConfig.Init();
			UncertainWeather.Init();
			new CombinedEclipsedFlooded();
			new CombinedFoggyRainy();
			new CombinedStormyFlooded();
			new CombinedStormyRainy();
			new CombinedEclipsedRainy();
			new CombinedMadness();
			new CombinedFoggyFlooded();
			new CombinedFoggyEclipsed();
			new CombinedStormyRainyEclipsed();
			new CombinedStormyRainyFlooded();
			new ProgressingNoneFoggy();
			new ProgressingNoneStormy();
			new ProgressingEclipsedFoggy();
			new ProgressingFoggyNone();
			new ProgressingHiddenEclipsed();
			new ProgressingStormyRainy();
			new ProgressingRainyEclipsed();
			new ProgressingMadness();
			Settings.SelectWeathers = false;
			WeatherRegistryEvent disableAllWeathers = EventManager.DisableAllWeathers;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				Event val2 = delegate
				{
					DisableAllWeathers.DisableAllWeather();
				};
				<>c.<>9__4_0 = val2;
				obj = (object)val2;
			}
			((CustomEvent)disableAllWeathers).AddListener((Event)obj);
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).AddListener((ParameterEvent<(SelectableLevel, Weather)>)delegate((SelectableLevel level, Weather weather) data)
			{
				OpeningDoorsSequencePatch.SetWeatherEffects(data.level, data.weather);
			});
			WeatherRegistryEvent setupFinished = EventManager.SetupFinished;
			object obj2 = <>c.<>9__4_2;
			if (obj2 == null)
			{
				Event val3 = delegate
				{
					TerminalStartPatch.Start();
				};
				<>c.<>9__4_2 = val3;
				obj2 = (object)val3;
			}
			((CustomEvent)setupFinished).AddListener((Event)obj2);
			WeatherRegistryEvent setupFinished2 = EventManager.SetupFinished;
			object obj3 = <>c.<>9__4_3;
			if (obj3 == null)
			{
				Event val4 = delegate
				{
					Variables.PopulateWeathers();
				};
				<>c.<>9__4_3 = val4;
				obj3 = (object)val4;
			}
			((CustomEvent)setupFinished2).AddListener((Event)obj3);
			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 GeneralImprovementsWeather("ShaosilGaming.GeneralImprovements");
			if (Chainloader.PluginInfos.ContainsKey("xxxstoner420bongmasterxxx.open_monitors"))
			{
				OpenMonitorsPatch.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("com.zealsprince.malfunctions"))
			{
				Malfunctions.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LobbyCompatibilityCompatibility.Init();
			}
			Weather val5 = new Weather("Cloudy", new ImprovedWeatherEffect((GameObject)null, (GameObject)null)
			{
				SunAnimatorBool = "overcast"
			});
			val5.Color = new Color(0f, 0.62f, 0.55f, 1f);
			val5.ScrapAmountMultiplier = 1.6f;
			val5.ScrapValueMultiplier = 0.8f;
			val5.DefaultWeatherToWeatherWeights = new string[2] { "Eclipsed@200", "Stormy@80" };
			val5.DefaultWeight = 10;
			Weather val6 = val5;
			WeatherManager.RegisterWeather(val6);
			logger.LogInfo((object)"\r\n                  .::.                  \r\n                  :==:                  \r\n         :-.      :==:      .-:         \r\n        .-==-.    .::.    .-===.        \r\n          .-=-  .:----:.  -==.          \r\n              -==========-              \r\n             ==============             \r\n               .-==========- :-----     \r\n         :-==-:. .=========- :-----     \r\n       .========:   .-=====             \r\n       ============-. :==-              \r\n       -=============. .  -==.          \r\n        :-==========:     .-==-.        \r\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");
				GeneralImprovementsWeather.Init();
			}
		}
	}
	internal class CombinedEclipsedFlooded : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedEclipsedFlooded()
			: base("Eclipsed + Flooded", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)5,
				(LevelWeatherType)4
			})
		{
		}
	}
	internal class CombinedFoggyRainy : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedFoggyRainy()
			: base("Foggy + Rainy", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)3,
				(LevelWeatherType)1
			})
		{
		}
	}
	internal class CombinedEclipsedRainy : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedEclipsedRainy()
			: base("Eclipsed + Rainy", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)5,
				(LevelWeatherType)1
			})
		{
		}
	}
	internal class CombinedStormyRainy : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedStormyRainy()
			: base("Stormy + Rainy", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)2,
				(LevelWeatherType)1
			})
		{
		}
	}
	internal class CombinedStormyFlooded : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedStormyFlooded()
			: base("Stormy + Flooded", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)2,
				(LevelWeatherType)4
			})
		{
		}
	}
	internal class CombinedFoggyFlooded : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedFoggyFlooded()
			: base("Foggy + Flooded", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)3,
				(LevelWeatherType)4
			})
		{
		}
	}
	internal class CombinedFoggyEclipsed : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedFoggyEclipsed()
			: base("Foggy + Eclipsed", new List<LevelWeatherType>(2)
			{
				(LevelWeatherType)3,
				(LevelWeatherType)5
			})
		{
		}
	}
	internal class CombinedStormyRainyEclipsed : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedStormyRainyEclipsed()
			: base("Stormy + Rainy + Eclipsed", new List<LevelWeatherType>(3)
			{
				(LevelWeatherType)2,
				(LevelWeatherType)1,
				(LevelWeatherType)5
			})
		{
		}
	}
	internal class CombinedStormyRainyFlooded : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedStormyRainyFlooded()
			: base("Stormy + Rainy + Flooded", new List<LevelWeatherType>(3)
			{
				(LevelWeatherType)2,
				(LevelWeatherType)1,
				(LevelWeatherType)4
			})
		{
		}
	}
	internal class CombinedMadness : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedMadness()
			: base("Madness", new List<LevelWeatherType>(5)
			{
				(LevelWeatherType)3,
				(LevelWeatherType)5,
				(LevelWeatherType)1,
				(LevelWeatherType)2,
				(LevelWeatherType)4
			}, 0.02f)
		{
		}
	}
	internal class ProgressingNoneFoggy : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingNoneFoggy()
			: base("None > Foggy", (LevelWeatherType)(-1), new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(2)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.25f,
					Chance = 0.8f,
					Weather = (LevelWeatherType)3
				},
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.75f,
					Chance = 1f,
					Weather = (LevelWeatherType)3
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingNoneStormy : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingNoneStormy()
			: base("None > Stormy", (LevelWeatherType)(-1), new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(2)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.35f,
					Chance = 0.35f,
					Weather = (LevelWeatherType)2
				},
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.75f,
					Chance = 1f,
					Weather = (LevelWeatherType)2
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingEclipsedFoggy : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingEclipsedFoggy()
			: base("Eclipsed > Foggy", (LevelWeatherType)5, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(2)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.4f,
					Chance = 0.5f,
					Weather = (LevelWeatherType)3
				},
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.85f,
					Chance = 1f,
					Weather = (LevelWeatherType)3
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingFoggyNone : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingFoggyNone()
			: base("Foggy > None", (LevelWeatherType)3, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(1)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.45f,
					Chance = 1f,
					Weather = (LevelWeatherType)(-1)
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingHiddenEclipsed : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingHiddenEclipsed()
			: base("Eclipsed > None", (LevelWeatherType)5, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(1)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.66f,
					Chance = 1f,
					Weather = (LevelWeatherType)(-1)
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingStormyRainy : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingStormyRainy()
			: base("Stormy > Rainy", (LevelWeatherType)2, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(1)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.55f,
					Chance = 1f,
					Weather = (LevelWeatherType)1
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingRainyEclipsed : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingRainyEclipsed()
			: base("Rainy > Eclipsed", (LevelWeatherType)1, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(1)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.66f,
					Chance = 1f,
					Weather = (LevelWeatherType)5
				}
			})
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingMadness : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingMadness()
			: base(">Madness>", (LevelWeatherType)5, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(3)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.1f,
					Chance = 0.5f,
					Weather = (LevelWeatherType)4
				},
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.4f,
					Chance = 0.5f,
					Weather = (LevelWeatherType)3
				},
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.65f,
					Chance = 1f,
					Weather = (LevelWeatherType)2
				}
			}, 0.1f)
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class ProgressingTesting : WeatherTweaks.Definitions.Types.ProgressingWeatherType
	{
		public ProgressingTesting()
			: base("> Testing >", (LevelWeatherType)5, new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>(1)
			{
				new WeatherTweaks.Definitions.Types.ProgressingWeatherEntry
				{
					DayTime = 0.2f,
					Chance = 1f,
					Weather = (LevelWeatherType)(-1)
				}
			}, 500f)
		{
		}//IL_002b: Unknown result type (might be due to invalid IL or missing references)

	}
	internal class UncertainTypes
	{
		public class Uncertain : WeatherTweaks.Modules.Types.UncertainWeatherType
		{
			public Uncertain()
				: base("Uncertain")
			{
			}

			public override string CreateUncertaintyString(SelectableLevel level, Random random)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: 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_007e: 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 : WeatherTweaks.Modules.Types.UncertainWeatherType
		{
			public Uncertain5050()
				: base("Uncertain5050")
			{
			}

			public override string CreateUncertaintyString(SelectableLevel level, Random random)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: 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 : WeatherTweaks.Modules.Types.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<WeatherTweaks.Modules.Types.UncertainWeatherType> uncertainWeatherTypes = new List<WeatherTweaks.Modules.Types.UncertainWeatherType>();

		public static void Init()
		{
			Plugin.logger.LogInfo((object)"UncertainWeather initialized.");
			uncertainWeatherTypes = new List<WeatherTweaks.Modules.Types.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 item = Variables.GameLevels[random.Next(Variables.GameLevels.Count)];
				if (!list.Contains(item))
				{
					list.Add(item);
				}
				else
				{
					i--;
				}
			}
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			List<WeatherTweaks.Modules.Types.UncertainWeatherType> list2 = new List<WeatherTweaks.Modules.Types.UncertainWeatherType>();
			foreach (WeatherTweaks.Modules.Types.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<WeatherTweaks.Modules.Types.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 item2 in list)
			{
				int index = random.Next(list2.Count);
				string text = list2[index].CreateUncertaintyString(item2, random);
				Plugin.logger.LogDebug((object)("Rolled type: " + list2[index].Name + ", setting its uncertainty to " + text + "."));
				dictionary.Add(item2.PlanetName, text);
			}
			uncertainWeathers = dictionary;
			return dictionary;
		}
	}
	internal class Variables
	{
		internal static List<SelectableLevel> GameLevels = new List<SelectableLevel>();

		internal static bool IsSetupFinished = false;

		internal static WeatherType NoneWeather;

		public static List<WeatherType> WeatherTypes = new List<WeatherType>();

		public static List<WeatherTweaks.Definitions.Types.CombinedWeatherType> CombinedWeatherTypes = new List<WeatherTweaks.Definitions.Types.CombinedWeatherType>();

		public static List<WeatherTweaks.Definitions.Types.ProgressingWeatherType> ProgressingWeatherTypes = new List<WeatherTweaks.Definitions.Types.ProgressingWeatherType>();

		public static Dictionary<SelectableLevel, WeatherType> CurrentWeathers = new Dictionary<SelectableLevel, WeatherType>();

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

		public static WeatherType CurrentLevelWeather;

		public static WeatherType GetCurrentWeather()
		{
			if (CurrentLevelWeather.Type == CustomWeatherType.Progressing)
			{
				if (ChangeMidDay.currentEntry == null)
				{
					Plugin.logger.LogWarning((object)"Current entry is null");
					return CurrentLevelWeather;
				}
				return ChangeMidDay.currentEntry.GetWeatherType();
			}
			return CurrentLevelWeather;
		}

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

		internal static List<SelectableLevel> GetGameLevels(bool includeCompanyMoon = false)
		{
			Plugin.logger.LogDebug((object)$"Getting game levels, {includeCompanyMoon}");
			List<SelectableLevel> list = SharedMethods.GetGameLevels();
			if (!includeCompanyMoon)
			{
				list = list.Where((SelectableLevel level) => level.PlanetName != "71 Gordion").ToList();
			}
			GameLevels = list;
			return list;
		}

		internal static List<WeatherType> GetPlanetWeatherTypes(SelectableLevel level)
		{
			//IL_0067: 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<WeatherType>();
			}
			List<WeatherType> list = new List<WeatherType>();
			foreach (WeatherType weather in WeatherTypes)
			{
				if (planetPossibleWeathers.Contains(weather.weatherType) && weather.Type == CustomWeatherType.Normal)
				{
					list.Add(weather);
				}
				switch (weather.Type)
				{
				case CustomWeatherType.Combined:
				{
					WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeatherType = CombinedWeatherTypes.Find((WeatherTweaks.Definitions.Types.CombinedWeatherType x) => x.Name == weather.Name);
					if (combinedWeatherType.CanWeatherBeApplied(level))
					{
						list.Add(weather);
					}
					break;
				}
				case CustomWeatherType.Progressing:
				{
					WeatherTweaks.Definitions.Types.ProgressingWeatherType progressingWeatherType = ProgressingWeatherTypes.Find((WeatherTweaks.Definitions.Types.ProgressingWeatherType x) => x.Name == weather.Name);
					if (progressingWeatherType.CanWeatherBeApplied(level))
					{
						list.Add(weather);
					}
					break;
				}
				}
			}
			return list.Distinct().ToList();
		}

		internal static Dictionary<string, WeatherType> GetAllPlanetWeathersDictionary()
		{
			Dictionary<string, WeatherType> weathers = new Dictionary<string, WeatherType>();
			CurrentWeathers.ToList().ForEach(delegate(KeyValuePair<SelectableLevel, WeatherType> weather)
			{
				weathers.Add(weather.Key.PlanetName, weather.Value);
			});
			return weathers;
		}

		internal static void PopulateWeathers()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)"Populating weathers");
			if ((Object)(object)TimeOfDay.Instance == (Object)null)
			{
				Plugin.logger.LogError((object)"TimeOfDay is null");
				return;
			}
			WeatherEffect[] effects = TimeOfDay.Instance.effects;
			WeatherTypes.Clear();
			if (effects == null || effects.Count() == 0)
			{
				Plugin.logger.LogWarning((object)"Effects are null");
			}
			NoneWeather = new WeatherType("None", CustomWeatherType.Normal)
			{
				Weather = WeatherManager.NoneWeather,
				weatherType = (LevelWeatherType)(-1)
			};
			WeatherTypes.Add(NoneWeather);
			foreach (Weather weather in WeatherManager.Weathers)
			{
				WeatherType item = new WeatherType(((Object)weather).name, CustomWeatherType.Normal)
				{
					Weather = weather,
					weatherType = weather.VanillaWeatherType
				};
				WeatherTypes.Add(item);
			}
			CombinedWeatherTypes.ForEach(delegate(WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeather)
			{
				if (!combinedWeather.Enabled.Value)
				{
					Plugin.logger.LogDebug((object)("Combined weather: " + combinedWeather.Name + " is disabled"));
				}
				else
				{
					Plugin.logger.LogDebug((object)("Adding combined weather: " + combinedWeather.Name));
					WeatherTypes.Add(combinedWeather);
				}
			});
			ProgressingWeatherTypes.ForEach(delegate(WeatherTweaks.Definitions.Types.ProgressingWeatherType progressingWeather)
			{
				if (!progressingWeather.Enabled.Value)
				{
					Plugin.logger.LogDebug((object)("Progressing weather: " + progressingWeather.Name + " is disabled"));
				}
				else
				{
					Plugin.logger.LogDebug((object)("Adding progressing weather: " + progressingWeather.Name));
					WeatherTypes.Add(progressingWeather);
				}
			});
		}

		public static string GetPlanetCurrentWeather(SelectableLevel level, bool uncertain = true)
		{
			bool flag = UncertainWeather.uncertainWeathers.ContainsKey(level.PlanetName);
			if (flag && uncertain)
			{
				return UncertainWeather.uncertainWeathers[level.PlanetName];
			}
			if (!CurrentWeathers.ContainsKey(level))
			{
				return ((object)(LevelWeatherType)(ref level.currentWeather)).ToString();
			}
			return CurrentWeathers[level].Name;
		}

		public static WeatherType GetPlanetCurrentWeatherType(SelectableLevel level)
		{
			WeatherType value;
			return GetFullWeatherType(CurrentWeathers.TryGetValue(level, out value) ? value : NoneWeather);
		}

		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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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;
			RandomWeatherWithVariables val2 = currentLevel.randomWeathers.First((RandomWeatherWithVariables x) => x.weatherType == weatherType);
			if (val2 == null || (Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)currentLevel == (Object)null)
			{
				val.LogError((object)$"Failed to get weather variables for {currentLevel.PlanetName}:{weatherType}");
				return 0f;
			}
			val.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_0048: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			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);
			}
			WeatherType value;
			WeatherType fullWeatherType = GetFullWeatherType(CurrentWeathers.TryGetValue(currentLevel, out value) ? value : NoneWeather);
			Plugin.logger.LogDebug((object)fullWeatherType.Type);
			switch (fullWeatherType.Type)
			{
			case CustomWeatherType.Combined:
			{
				WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeatherType = (WeatherTweaks.Definitions.Types.CombinedWeatherType)fullWeatherType;
				if (combinedWeatherType.LevelWeatherTypes.Any((LevelWeatherType x) => x == weatherType))
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			case CustomWeatherType.Progressing:
			{
				WeatherTweaks.Definitions.Types.ProgressingWeatherType progressingWeatherType = (WeatherTweaks.Definitions.Types.ProgressingWeatherType)fullWeatherType;
				if (progressingWeatherType.DoesHaveWeatherHappening(weatherType))
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			default:
				if (fullWeatherType.Weather.VanillaWeatherType == weatherType)
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			return (LevelWeatherType)(-1);
		}

		internal static WeatherType 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((WeatherType x) => x.weatherType == weatherType && x.Type == CustomWeatherType.Normal);
		}

		internal static WeatherType GetFullWeatherType(WeatherType weatherType)
		{
			Plugin.logger.LogDebug((object)("Getting full weather type for " + weatherType.Name));
			return WeatherTypes.Find((WeatherType x) => x.Name == weatherType.Name);
		}

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

		internal static WeightHandler<WeatherType> GetPlanetWeightedList(SelectableLevel level, float difficulty = 0f)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_00ec: 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_0111: Invalid comparison between Unknown and I4
			//IL_020e: 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)
			//IL_0338: Invalid comparison between Unknown and I4
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			Logger val = new Logger("WeatherTweaks WeatherSelection", ConfigManager.LogWeatherSelection);
			WeightHandler<WeatherType> val2 = new WeightHandler<WeatherType>();
			WeightHandler<LevelWeatherType> weatherTypeWeights = new WeightHandler<LevelWeatherType>();
			difficulty = Math.Clamp(difficulty, 0f, ConfigManager.MaxMultiplier.Value);
			int possibleWeathersWeightSum = 0;
			List<WeatherType> weatherTypes = GetPlanetWeatherTypes(level);
			WeatherTypes.Where((WeatherType weatherType) => weatherType.Type == CustomWeatherType.Normal).ToList().ForEach(delegate(WeatherType weatherType)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				int weatherLevelWeight = GetWeatherLevelWeight(level, weatherType.weatherType);
				weatherTypeWeights.Add(weatherType.weatherType, weatherLevelWeight);
				if (weatherTypes.Contains(weatherType))
				{
					possibleWeathersWeightSum += weatherLevelWeight;
				}
			});
			weatherTypeWeights.Add((LevelWeatherType)(-1), GetWeatherLevelWeight(level, (LevelWeatherType)(-1)));
			foreach (WeatherType weatherType2 in weatherTypes)
			{
				int num = weatherTypeWeights.Get(weatherType2.weatherType);
				if (ConfigManager.ScaleDownClearWeather.Value && (int)weatherType2.weatherType == -1)
				{
					int weight = NoneWeather.Weather.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.Type == CustomWeatherType.Combined)
				{
					WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeatherType = CombinedWeatherTypes.Find((WeatherTweaks.Definitions.Types.CombinedWeatherType x) => x.Name == weatherType2.Name);
					if (!combinedWeatherType.CanWeatherBeApplied(level))
					{
						val.LogDebug((object)("Combined weather: " + combinedWeatherType.Name + " can't be applied"));
						continue;
					}
					num = Mathf.RoundToInt((float)weatherTypeWeights.Get(combinedWeatherType.weatherType) * combinedWeatherType.WeightModify);
					val.LogDebug((object)$"Weight of combined weather: {combinedWeatherType.Name} is {num}");
				}
				else if (weatherType2.Type == CustomWeatherType.Progressing)
				{
					WeatherTweaks.Definitions.Types.ProgressingWeatherType progressingWeatherType = ProgressingWeatherTypes.Find((WeatherTweaks.Definitions.Types.ProgressingWeatherType x) => x.Name == weatherType2.Name);
					if (!progressingWeatherType.CanWeatherBeApplied(level))
					{
						val.LogDebug((object)("Progressing weather: " + progressingWeatherType.Name + " can't be applied"));
						continue;
					}
					num = Mathf.RoundToInt((float)weatherTypeWeights.Get(weatherType2.weatherType) * progressingWeatherType.WeightModify);
					val.LogDebug((object)$"Weight of progressing weather: {progressingWeatherType.Name} is {num}");
				}
				if (difficulty != 0f && (int)weatherType2.weatherType == -1)
				{
					num = (int)((float)num * (1f - difficulty));
				}
				val.LogDebug((object)$"{weatherType2.Name} has weight {num}");
				val2.Add(weatherType2, num);
			}
			return val2;
		}
	}
	internal class WeatherCalculation
	{
		internal static Dictionary<string, LevelWeatherType> previousDayWeather = new Dictionary<string, LevelWeatherType>();

		internal static SelectableLevel CompanyMoon;

		internal static Dictionary<string, WeatherType> NewWeathers(StartOfRound startOfRound)
		{
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Invalid comparison between Unknown and I4
			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();
			int seed = startOfRound.randomMapSeed + 31;
			Random random = new Random(seed);
			Dictionary<string, LevelWeatherType> dictionary = VanillaWeathers(0, startOfRound);
			Dictionary<string, WeatherType> dictionary2 = new Dictionary<string, WeatherType>();
			List<LevelWeatherType> list = new List<LevelWeatherType>(7)
			{
				(LevelWeatherType)(-1),
				(LevelWeatherType)0,
				(LevelWeatherType)1,
				(LevelWeatherType)2,
				(LevelWeatherType)3,
				(LevelWeatherType)4,
				(LevelWeatherType)5
			};
			CompanyMoon = StartOfRound.Instance.levels.ToList().Find((SelectableLevel level) => level.PlanetName == "71 Gordion");
			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)
			{
				seed = ConfigManager.FirstDaySeed.Value;
				if (ConfigManager.FirstDayRandomSeed.Value)
				{
					seed = random.Next(0, 10000000);
				}
				random = new Random(seed);
				List<string> noWeatherOnStartPlanets = new List<string>(2) { "41 Experimentation", "56 Vow" };
				List<SelectableLevel> list2 = gameLevels.Where((SelectableLevel level) => !noWeatherOnStartPlanets.Contains(level.PlanetName)).ToList();
				if (gameLevels.Count > 9)
				{
					int num2 = (int)((double)gameLevels.Count * 0.5);
					Plugin.logger.LogDebug((object)$"Planets without weather: {num2 + 2}");
					for (int i = 0; i < num2; i++)
					{
						string planetName = list2[random.Next(0, list2.Count)].PlanetName;
						noWeatherOnStartPlanets.Add(planetName);
						list2.RemoveAll((SelectableLevel level) => level.PlanetName == planetName);
					}
				}
				return FirstDayWeathers(gameLevels, noWeatherOnStartPlanets, random);
			}
			float num3 = (float)timesFulfilledQuota * ConfigManager.GameLengthMultiplier.Value;
			float num4 = (float)StartOfRound.Instance.livingPlayers * ConfigManager.GamePlayersMultiplier.Value;
			float num5 = num3 + num4;
			Plugin.logger.LogDebug((object)$"Difficulty multiplier: {num5}");
			foreach (SelectableLevel level2 in gameLevels)
			{
				previousDayWeather[level2.PlanetName] = level2.currentWeather;
				LevelWeatherType val = (LevelWeatherType)((!dictionary.ContainsKey(level2.PlanetName)) ? (-1) : ((int)dictionary[level2.PlanetName]));
				if (ConfigManager.AlwaysClear.Value)
				{
					Plugin.logger.LogDebug((object)"AlwaysClear is true, setting weather to None");
					dictionary2[level2.PlanetName] = Variables.NoneWeather;
					continue;
				}
				if (level2.overrideWeather)
				{
					Plugin.logger.LogDebug((object)$"Override weather present, changing weather to {level2.overrideWeatherType}");
					dictionary2[level2.PlanetName] = Variables.WeatherTypes.Find((WeatherType x) => x.weatherType == level2.overrideWeatherType && x.Type == CustomWeatherType.Normal);
					continue;
				}
				Plugin.logger.LogDebug((object)"-------------");
				Plugin.logger.LogDebug((object)(level2.PlanetName ?? ""));
				Plugin.logger.LogDebug((object)$"previousDayWeather: {previousDayWeather[level2.PlanetName]}");
				if ((int)previousDayWeather[level2.PlanetName] == 0)
				{
					previousDayWeather[level2.PlanetName] = (LevelWeatherType)(-1);
				}
				dictionary2[level2.PlanetName] = Variables.NoneWeather;
				WeightHandler<WeatherType> planetWeightedList = Variables.GetPlanetWeightedList(level2);
				WeatherType weatherType = planetWeightedList.Random();
				dictionary2[level2.PlanetName] = weatherType;
				Variables.CurrentWeathers[level2] = weatherType;
				Plugin.logger.LogDebug((object)("Selected weather: " + weatherType.Name));
				try
				{
					Plugin.logger.LogDebug((object)$"Chance for that was {planetWeightedList.Get(weatherType)} / {planetWeightedList.Sum} ({(float)planetWeightedList.Get(weatherType) / (float)planetWeightedList.Sum * 100f}%)");
				}
				catch
				{
				}
			}
			if ((Object)(object)CompanyMoon != (Object)null)
			{
				Variables.CurrentWeathers[CompanyMoon] = Variables.NoneWeather;
				dictionary2[CompanyMoon.PlanetName] = Variables.NoneWeather;
			}
			Plugin.logger.LogDebug((object)"-------------");
			return dictionary2;
		}

		private static Dictionary<string, WeatherType> FirstDayWeathers(List<SelectableLevel> levels, List<string> planetsWithoutWeather, Random random)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogInfo((object)"First day, setting predefined weather conditions");
			Dictionary<string, WeatherType> dictionary = new Dictionary<string, WeatherType>();
			foreach (SelectableLevel level in levels)
			{
				string planetName = level.PlanetName;
				Plugin.logger.LogDebug((object)("planet: " + planetName));
				if (ConfigManager.AlwaysClear.Value)
				{
					Plugin.logger.LogDebug((object)"AlwaysClear is true, setting weather to None");
					dictionary[level.PlanetName] = Variables.NoneWeather;
					continue;
				}
				if (level.overrideWeather)
				{
					Plugin.logger.LogDebug((object)$"Override weather present, changing weather to {level.overrideWeatherType}");
					dictionary[level.PlanetName] = Variables.WeatherTypes.Find((WeatherType x) => x.weatherType == level.overrideWeatherType && x.Type == CustomWeatherType.Normal);
					continue;
				}
				List<WeatherType> list = (from randomWeather in Variables.GetPlanetWeatherTypes(level)
					where (int)randomWeather.weatherType != -1 && (int)randomWeather.weatherType != 0 && randomWeather.Type == CustomWeatherType.Normal
					select randomWeather).ToList();
				string text = JsonConvert.SerializeObject((object)list.Select((WeatherType x) => ((object)(LevelWeatherType)(ref x.weatherType)).ToString()).ToList());
				list.RemoveAll((WeatherType x) => (int)x.weatherType == 5);
				if (list.Count == 0 || list == null)
				{
					dictionary[planetName] = Variables.NoneWeather;
					Plugin.logger.LogDebug((object)("No random weathers for " + planetName + ", skipping"));
					continue;
				}
				if (planetsWithoutWeather.Contains(planetName))
				{
					dictionary[planetName] = Variables.NoneWeather;
					Plugin.logger.LogDebug((object)("Skipping " + planetName + " (predefined)"));
					continue;
				}
				bool flag = random.Next(0, 100) < 5;
				WeatherType selectedRandom = list[random.Next(0, list.Count)];
				if (flag)
				{
					Plugin.logger.LogDebug((object)("Setting eclipsed for " + planetName));
					if (!list.Any((WeatherType x) => (int)x.weatherType == 5))
					{
						Plugin.logger.LogDebug((object)("Eclipsed not possible for " + planetName + ", setting random weather"));
					}
					else
					{
						selectedRandom = list.First((WeatherType x) => (int)x.weatherType == 5);
					}
				}
				WeatherType weatherType2 = (dictionary[planetName] = Variables.WeatherTypes.Find((WeatherType x) => x.weatherType == selectedRandom.weatherType && x.Type == CustomWeatherType.Normal));
				Variables.CurrentWeathers[level] = weatherType2;
				Plugin.logger.LogDebug((object)("Set weather for " + planetName + ": " + weatherType2.Name));
			}
			if ((Object)(object)CompanyMoon != (Object)null)
			{
				Variables.CurrentWeathers[CompanyMoon] = Variables.NoneWeather;
				dictionary[CompanyMoon.PlanetName] = Variables.NoneWeather;
			}
			return dictionary;
		}

		private static Dictionary<string, LevelWeatherType> VanillaWeathers(int connectedPlayersOnServer, StartOfRound startOfRound)
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, LevelWeatherType> dictionary = new Dictionary<string, LevelWeatherType>();
			Random random = new Random(startOfRound.randomMapSeed + 31);
			List<SelectableLevel> list = startOfRound.levels.ToList();
			float num = 1f;
			if (connectedPlayersOnServer + 1 > 1 && startOfRound.daysPlayersSurvivedInARow > 2 && startOfRound.daysPlayersSurvivedInARow % 3 == 0)
			{
				num = (float)random.Next(15, 25) / 10f;
			}
			int num2 = Mathf.Clamp((int)((double)Mathf.Clamp(startOfRound.planetsWeatherRandomCurve.Evaluate((float)random.NextDouble()) * num, 0f, 1f) * (double)startOfRound.levels.Length), 0, startOfRound.levels.Length);
			for (int i = 0; i < num2; i++)
			{
				SelectableLevel val = list[random.Next(0, list.Count)];
				if (val.randomWeathers != null && val.randomWeathers.Length != 0)
				{
					dictionary[val.PlanetName] = val.randomWeathers[random.Next(0, val.randomWeathers.Length)].weatherType;
				}
				list.Remove(val);
			}
			return dictionary;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WeatherTweaks";

		public const string PLUGIN_NAME = "WeatherTweaks";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace WeatherTweaks.Patches
{
	internal class Malfunctions
	{
		private static Type StartOfRoundPatches;

		private static Assembly assembly;

		private static Harmony harmony;

		internal static void Init()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			assembly = ((object)Chainloader.PluginInfos["com.zealsprince.malfunctions"].Instance).GetType().Assembly;
			StartOfRoundPatches = AccessTools.TypeByName("Malfunctions.Patches.StartOfRoundPatches");
			if (StartOfRoundPatches == null)
			{
				Plugin.logger.LogError((object)"Could not find StartOfRoundPatches class in Malfunctions assembly");
			}
			else
			{
				Plugin.logger.LogDebug((object)"Found StartOfRoundPatches class in Malfunctions assembly");
			}
			harmony = new Harmony("WeatherTweaks.Malfunctions");
			HarmonyMethod val = new HarmonyMethod(typeof(Malfunctions).GetMethod("EclipseOnEnablePatch"));
			harmony.Patch((MethodBase)AccessTools.Method(StartOfRoundPatches, "OverwriteMapScreenInfo", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static IEnumerable<CodeInstruction> EclipseOnEnablePatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			ManualLogSource logger = Plugin.logger;
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null)
			});
			val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher match)
			{
				match.RemoveInstructions(3);
			}, (Action<string>)null);
			return val.InstructionEnumeration();
		}
	}
	public class GeneralImprovementsWeather : CompatibilityBase
	{
		private static Type type;

		private static FieldInfo weatherMonitorsField;

		private static FieldInfo fancyMonitorsField;

		private static int frame = 0;

		internal static Logger logger = new Logger("WeatherTweaks GI", ConfigManager.LogLogs);

		public GeneralImprovementsWeather(string guid, string version = null)
			: base(guid, version)
		{
		}

		public static void Init()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			string key = "ShaosilGaming.GeneralImprovements";
			Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
			if (pluginInfos.ContainsKey(key))
			{
				string text = "GeneralImprovements.Utilities";
				string text2 = "MonitorsHelper";
				Assembly getModAssembly = ((CompatibilityBase)Plugin.GeneralImprovements).GetModAssembly;
				type = getModAssembly.GetType(text + "." + text2);
				if (type != null)
				{
					Plugin.logger.LogWarning((object)"GeneralImprovements found, patching weather displays");
					MethodInfo method = type.GetMethod("UpdateGenericTextList", BindingFlags.Static | BindingFlags.NonPublic);
					weatherMonitorsField = type.GetField("_weatherMonitorTexts", BindingFlags.Static | BindingFlags.NonPublic);
					fancyMonitorsField = type.GetField("_fancyWeatherMonitorTexts", BindingFlags.Static | BindingFlags.NonPublic);
					Harmony val = new Harmony("WeatherTweaks.GeneralImprovements");
					HarmonyMethod val2 = new HarmonyMethod(typeof(GeneralImprovementsWeather).GetMethod("TextPatch", BindingFlags.Static | BindingFlags.Public));
					val.Patch((MethodBase)method, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		public static void TextPatch(List<TextMeshProUGUI> textList, ref string text)
		{
			bool isWeatherMonitor = false;
			List<TextMeshProUGUI> weathermonitors = weatherMonitorsField.GetValue(null) as List<TextMeshProUGUI>;
			List<TextMeshProUGUI> fancymonitors = fancyMonitorsField.GetValue(null) as List<TextMeshProUGUI>;
			CollectionExtensions.Do<TextMeshProUGUI>((IEnumerable<TextMeshProUGUI>)textList, (Action<TextMeshProUGUI>)delegate(TextMeshProUGUI monitor)
			{
				if (!((Object)(object)monitor == (Object)null) && (weathermonitors.Contains(monitor) || fancymonitors.Contains(monitor)))
				{
					isWeatherMonitor = true;
				}
			});
			if (!isWeatherMonitor)
			{
				return;
			}
			string planetCurrentWeather = Variables.GetPlanetCurrentWeather(StartOfRound.Instance.currentLevel);
			bool flag = ((object)(LevelWeatherType)(ref StartOfRound.Instance.currentLevel.currentWeather)).ToString() != planetCurrentWeather;
			if (text.Contains("WEATHER:\n"))
			{
				string text2 = "WEATHER:\n" + planetCurrentWeather;
				logger.LogDebug((object)("Changing " + text.Replace("\n", " ") + " to " + text2.Replace("\n", " ")));
				text = text2;
			}
			else if (flag)
			{
				text = "???????????????????????????????????";
				text = Regex.Replace(text, "[?]", (Match m) => (frame++ % 20 == 0) ? " " : m.Value);
				text = Regex.Replace(text, ".{8}", "$0\n");
				text = Regex.Replace(text, "(?<=\\n.*\\n.*\\n.*\\n).+", "");
				frame++;
				if (frame == 20)
				{
					frame = 0;
				}
			}
		}
	}
	public static class LLL
	{
		internal static Logger logger = new Logger("WeatherTweaks LLL", ConfigManager.LogLogs);

		internal static void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Harmony val = new Harmony("WeatherTweaks.LLL");
			if (((CompatibilityBase)Plugin.LLL).IsModPresent)
			{
				logger.LogWarning((object)"Patching LethalLevelLoader");
				val.Patch((MethodBase)AccessTools.Method(typeof(TerminalManager), "GetWeatherConditions", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LLL), "PatchNewLLL", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				logger.LogWarning((object)"Patching Old LethalLevelLoader");
				val.Patch((MethodBase)AccessTools.Method(typeof(TerminalManager), "GetWeatherConditions", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(LLL), "PatchOldLLL", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			Plugin.IsLLLPresent = true;
		}

		private static void PatchNewLLL(ExtendedLevel extendedLevel, ref string __result)
		{
			__result = PatchLLL(extendedLevel.SelectableLevel);
		}

		private static void PatchOldLLL(SelectableLevel selectableLevel, ref string __result)
		{
			__result = PatchLLL(selectableLevel);
		}

		private static string PatchLLL(SelectableLevel selectableLevel)
		{
			string text = Variables.GetPlanetCurrentWeather(selectableLevel);
			logger.LogDebug((object)("GetMoonConditions " + selectableLevel.PlanetName + "::" + text));
			if (text == "None")
			{
				text = "";
			}
			else if (!text.Contains("[") && !text.Contains("]"))
			{
				text = "(" + text + ")";
			}
			return text;
		}
	}
	[Ha