Decompiled source of WeatherTweaksExperimental v0.23.0

WeatherTweaks.dll

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

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

		internal static WeatherTweaks.Definitions.Types.ProgressingWeatherType currentWeather = null;

		internal static List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry> weatherEntries = new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>();

		internal static float LastCheckedEntry = 0f;

		internal static WeatherTweaks.Definitions.Types.ProgressingWeatherEntry CurrentEntry = null;

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

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

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

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

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

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

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

		internal static void Reset()
		{
			currentWeather = null;
			LastCheckedEntry = 0f;
			weatherEntries = new List<WeatherTweaks.Definitions.Types.ProgressingWeatherEntry>();
		}
	}
	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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (!Variables.IsSetupFinished)
			{
				return;
			}
			ConsoleTable val = new ConsoleTable(new string[3] { "Planet", "Level weather", "Uncertain weather" });
			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)
			{
				Plugin.logger.LogWarning((object)$"Level: {item.PlanetName}, is null: {(Object)(object)item == (Object)null}");
				bool flag = UncertainWeather.uncertainWeathers.ContainsKey(item.PlanetName);
				Plugin.logger.LogDebug((object)$"Is uncertain weather: {flag}");
				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, WeatherTweaksWeather> weatherData)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			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))
				{
					WeatherTweaksWeather fullWeatherType = Variables.GetFullWeatherType((Weather)(object)weatherData[planetName]);
					item.currentWeather = ((Weather)fullWeatherType).VanillaWeatherType;
					logger.LogDebug((object)("Setting weather for " + planetName + " to " + ((Weather)fullWeatherType).Name));
				}
				else
				{
					Plugin.logger.LogWarning((object)("Weather data for " + planetName + " somehow not found, skipping"));
				}
			}
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}

		internal static void SetWeather(WeatherTweaksWeather weatherType)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			currentLevel.currentWeather = ((Weather)weatherType).VanillaWeatherType;
			logger.LogDebug((object)("Setting weather for " + currentLevel.PlanetName + " to " + ((Weather)weatherType).Name));
		}

		internal static void SetWeatherEffects(TimeOfDay timeOfDay, List<ImprovedWeatherEffect> weatherEffects)
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			if (!Variables.IsSetupFinished)
			{
				logger.LogDebug((object)"Setup not finished, skipping setting weather effects");
				return;
			}
			logger.LogDebug((object)$"Setting weather effects for {timeOfDay.currentLevel.PlanetName}: {weatherEffects.Count} effects");
			if (weatherEffects == null)
			{
				logger.LogDebug((object)"No weather effects to set");
				return;
			}
			Variables.CurrentEffects = weatherEffects;
			List<LevelWeatherType> list = new List<LevelWeatherType>();
			List<ImprovedWeatherEffect> list2 = new List<ImprovedWeatherEffect>();
			foreach (Weather weather in WeatherManager.Weathers)
			{
				if (!((Object)(object)weather.Effect == (Object)null))
				{
					ImprovedWeatherEffect effect = weather.Effect;
					if (weatherEffects.Contains(effect))
					{
						list2.Add(effect);
					}
					Plugin.logger.LogDebug((object)("Disabling effect from weather: " + weather.Name));
					effect.DisableEffect(true);
				}
			}
			foreach (Weather weather2 in WeatherManager.Weathers)
			{
				ImprovedWeatherEffect effect2 = weather2.Effect;
				if (weatherEffects.Contains(effect2))
				{
					logger.LogDebug((object)("Enabling effect from weather: " + weather2.Name));
					if (!EntranceTeleportPatch.isPlayerInside)
					{
						weather2.Effect.EffectEnabled = true;
					}
					else
					{
						logger.LogWarning((object)"Player is inside, skipping effect object activation");
						weather2.Effect.DisableEffect(true);
					}
					if (effect2.SunAnimatorBool != "" && effect2.SunAnimatorBool != null)
					{
						list.Add(weather2.VanillaWeatherType);
					}
				}
			}
		}
	}
	internal class NetworkedConfig
	{
		public static LethalNetworkVariable<string> currentWeatherStringsSynced = new LethalNetworkVariable<string>("previousWeatherStrings");

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

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

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

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

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

		public static void SetWeatherType(WeatherType weatherType)
		{
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

			public static ParameterEvent<Terminal> <>9__4_3;

			public static ParameterEvent<StartOfRound> <>9__4_4;

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

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

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

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

			internal void <Awake>b__4_4(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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("WeatherTweaks");
			val.PatchAll();
			NetworkedConfig.Init();
			UncertainWeather.Init();
			WeatherRegistryEvent disableAllWeathers = EventManager.DisableAllWeathers;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				Event val2 = delegate
				{
					DisableAllWeathers.DisableAllWeather();
				};
				<>c.<>9__4_0 = val2;
				obj = (object)val2;
			}
			((CustomEvent)disableAllWeathers).AddListener((Event)obj);
			WeatherRegistryEvent setupFinished = EventManager.SetupFinished;
			object obj2 = <>c.<>9__4_1;
			if (obj2 == null)
			{
				Event val3 = delegate
				{
					TerminalStartPatch.Start();
				};
				<>c.<>9__4_1 = val3;
				obj2 = (object)val3;
			}
			((CustomEvent)setupFinished).AddListener((Event)obj2);
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).AddListener((ParameterEvent<(SelectableLevel, Weather)>)delegate((SelectableLevel level, Weather weather) args)
			{
				ShipLandingPatches.ShipLandingPatch(args.level, args.weather);
			});
			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 val4 = new Weather("Cloudy", new ImprovedWeatherEffect((GameObject)null, (GameObject)null)
			{
				SunAnimatorBool = "overcast"
			});
			val4.Color = new Color(0f, 1f, 0.55f, 1f);
			val4.Config.ScrapAmountMultiplier = new FloatConfigHandler(1.6f, true);
			val4.Config.ScrapValueMultiplier = new FloatConfigHandler(0.8f, true);
			val4.Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(new string[2] { "Eclipsed@200", "Stormy@80" }, true);
			val4.Config.DefaultWeight = new IntegerConfigHandler(25, true);
			Weather val5 = val4;
			WeatherManager.RegisterWeather(val5);
			WeatherCalculation.WeatherSelectionAlgorithm = (WeatherSelectionAlgorithm)(object)WeatherCalculation.weatherTweaksWeatherAlgorithm;
			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_0053: 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_0053: 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_0053: 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_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				LevelWeatherType weather = level.currentWeather;
				List<RandomWeatherWithVariables> list = level.randomWeathers.Where((RandomWeatherWithVariables w) => w.weatherType != weather).ToList();
				if (list.Count == 0)
				{
					return ((object)(LevelWeatherType)(ref weather)).ToString();
				}
				RandomWeatherWithVariables val = list[random.Next(list.Count)];
				if (random.Next(0, 3) == 0)
				{
					return $"{val.weatherType}?";
				}
				return $"{weather}?";
			}
		}

		public class Uncertain5050 : WeatherTweaks.Modules.Types.UncertainWeatherType
		{
			public Uncertain5050()
				: base("Uncertain5050")
			{
			}

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

		public class Unknown : 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 bool IsSetupFinished = false;

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

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

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

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

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

		internal static Weather NoneWeather => WeatherManager.NoneWeather;

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

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

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

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

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

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

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

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

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

		internal static List<SelectableLevel> GetGameLevels(bool includeCompanyMoon = false)
		{
			if (includeCompanyMoon)
			{
				return GameLevels;
			}
			return GameLevels.Where((SelectableLevel x) => (Object)(object)x != (Object)(object)LevelHelper.CompanyMoon).ToList();
		}

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

		public static string GetPlanetCurrentWeather(SelectableLevel level, bool uncertain = true)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			bool flag = UncertainWeather.uncertainWeathers.ContainsKey(level.PlanetName);
			if (flag && uncertain)
			{
				Plugin.DebugLogger.LogDebug((object)("Getting uncertain weather for " + level.PlanetName));
				return UncertainWeather.uncertainWeathers[level.PlanetName];
			}
			Plugin.DebugLogger.LogDebug((object)("Getting current weather for " + level.PlanetName));
			Weather weather = WeatherManager.GetWeather(level.currentWeather);
			Plugin.logger.LogWarning((object)$"Current weather: {weather}");
			return weather.Name;
		}

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

		public static float GetLevelWeatherVariable(LevelWeatherType weatherType, bool variable2 = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)$"Checking if level has weather {weatherType}");
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)currentLevel == (Object)null)
			{
				Plugin.logger.LogError((object)$"Failed to get weather variables for {currentLevel.PlanetName}:{weatherType}");
				return (LevelWeatherType)(-1);
			}
			WeatherTweaksWeather planetCurrentWeatherType = GetPlanetCurrentWeatherType(currentLevel);
			Plugin.logger.LogDebug((object)$"Level has weather {((Weather)planetCurrentWeatherType).Type}?");
			switch (planetCurrentWeatherType.CustomType)
			{
			case CustomWeatherType.Combined:
			{
				WeatherTweaks.Definitions.Types.CombinedWeatherType combinedWeatherType = (WeatherTweaks.Definitions.Types.CombinedWeatherType)planetCurrentWeatherType;
				if (combinedWeatherType.WeatherTypes.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)planetCurrentWeatherType;
				if (progressingWeatherType.DoesHaveWeatherHappening(weatherType))
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			default:
				if (((Weather)planetCurrentWeatherType).VanillaWeatherType == weatherType)
				{
					Plugin.logger.LogWarning((object)$"Level {currentLevel.PlanetName} has weather {weatherType}");
					return weatherType;
				}
				break;
			}
			return (LevelWeatherType)(-1);
		}

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

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

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

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

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

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

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

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

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

		internal static FirstDayWeathersAlgorithm firstDayWeathersAlgorithm = new FirstDayWeathersAlgorithm();

		internal static WeatherTweaksWeatherAlgorithm weatherTweaksWeatherAlgorithm = new WeatherTweaksWeatherAlgorithm();

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

		public const string PLUGIN_NAME = "WeatherTweaks";

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

		private static Assembly assembly;

		private static Harmony harmony;

		internal static void Init()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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;
		}
	}
	[HarmonyPatch(typeof(WeatherManager))]
	internal class WeatherRegistryPatches
	{
		[HarmonyPatch(typeof(SetMapScreenInfoToCurrentLevelPatch))]
		[HarmonyPatch("GetDisplayWeatherString")]
		[HarmonyPostfix]
		internal static void GetDisplayWeatherStringPatch(ref string __result, SelectableLevel level, Weather weather)
		{
			Plugin.logger.LogDebug((object)("Getting display weather string for " + level.PlanetName));
			__result = Variables.GetPlanetCurrentWeather(level);
		}

		[HarmonyPatch(typeof(WeatherManager))]
		[HarmonyPatch("GetCurrentWeatherName")]
		[HarmonyPostfix]
		internal static void GetCurrentWeatherNamePatch(ref string __result, SelectableLevel level)
		{
			__result = Variables.GetPlanetCurrentWeather(level, uncertain: false);
		}

		[HarmonyPatch(typeof(SetPlanetsWeatherPatch))]
		[HarmonyPatch("GameMethodPatch")]
		[HarmonyPrefix]
		internal static bool GameMethodPatch()
		{
			return Variables.IsSetupFinished;
		}

		[HarmonyPatch(typeof(SpawnScrapInLevelPatches))]
		[HarmonyPatch("ChangeMultipliers")]
		[HarmonyPostfix]
		internal static void ChangeMultipliersPatch(RoundManager __0)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				WeatherTweaksWeather planetCurrentWeatherType = Variables.GetPlanetCurrentWeatherType(StartOfRound.Instance.currentLevel);
				Plugin.DebugLogger.LogDebug((object)("Changing multipliers for weather " + ((Weather)planetCurrentWeatherType).Name));
				var (scrapValueMultiplier, scrapAmountMultiplier) = planetCurrentWeatherType.GetDefaultMultiplierData();
				switch (planetCurrentWeatherType.CustomType)
				{
				case CustomWeatherType.Combined:
				case CustomWeatherType.Progressing:
					__0.scrapValueMultiplier = scrapValueMultiplier;
					__0.scrapAmountMultiplier = scrapAmountMultiplier;
					break;
				default:
					Plugin.logger.LogError((object)$"Unknown weather type {((Weather)planetCurrentWeatherType).Type}");
					break;
				case CustomWeatherType.Normal:
					break;
				}
			}
		}
	}
	public class OpenMonitorsPatch
	{
		private static string guid = "xxxstoner420bongmasterxxx.open_monitors";

		public static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			Plugin.logger.LogDebug((object)"OpenMonitorsPatch Init");
			Harmony val = new Harmony("WeatherTweaks.OpenMonitors");
			val.Unpatch((MethodBase)typeof(StartOfRound).GetMethod("SetMapScreenInfoToCurrentLevel", BindingFlags.Instance | BindingFlags.Public), (HarmonyPatchType)0, guid);
			Plugin.logger.LogWarning((object)"Unpatched StartOfRound.SetMapScreenInfoToCurrentLevel");
			val.Unpatch((MethodBase)typeof(Terminal).GetMethod("TextPostProcess", BindingFlags.Instance | BindingFlags.NonPublic), (HarmonyPatchType)0, guid);
			Plugin.logger.LogWarning((object)"Unpatched Terminal.TextPostProcess");
		}
	}
	public class Reset
	{
		public static void ResetThings()
		{
			Variables.CurrentEffects.Clear();
			Variables.IsSetupFinished = false;
		}
	}
	internal class ShipLandingPatches
	{
		internal static void ShipLandingPatch(SelectableLevel currentLevel, Weather currentWeather)
		{
			if (currentWeather is WeatherTweaks.Definitions.Types.ProgressingWeatherType currentWeather2)
			{
				ChangeMidDay.SetCurrentWeather(currentWeather2);
			}
		}
	}
	public class TerminalStartPatch
	{
		public static void Start()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			Variables.CurrentEffects.Clear();
			Plugin.logger.LogWarning((object)"Terminal start start");
			Settings.ScreenMapColors.Add("+", Color.white);
			Settings.ScreenMapColors.Add("/", Color.white);
			Settings.ScreenMapColors.Add(">", Color.white);
			Settings.ScreenMapColors.Add("?", Color.white);
			Settings.ScreenMapColors.Add("[UNKNOWN]", new Color(0.29f, 0.29f, 0.29f));
			Variables.WeatherTweaksTypes.ForEach(delegate
			{
			});
			Variables.IsSetupFinished = true;
			StartOfRound.Instance.SetPlanetsWeather(0);
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}
	}
}
namespace WeatherTweaks.Modules
{
	internal class Types
	{
		public abstract class UncertainWeatherType
		{
			public string Name;

			public ConfigEntry<bool> Enabled;

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

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

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

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

			public new float WeightModify => ((ConfigHandler<float, float>)(object)Config.WeightModify).Value;

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

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

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

			public override void Init()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				Weather weather = WeatherManager.GetWeather(base.BaseWeatherType);
				int num = (int)((float)weather.DefaultWeight * WeightModify);
				((RegistryWeatherConfig)Config).DefaultWeight = new IntegerConfigHandler(num, false);
				base.Init();
			}

			public CombinedWeatherType(string name, List<LevelWeatherType> weathers, float weightModifier = 0.15f)
				: base(name, CustomWeatherType.Combined, weathers.ToArray())
			{
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Expected O, but got Unknown
				if (weathers.Count != 0)
				{
					Plugin.logger.LogWarning((object)$"{Config} is null? {Config == null}");
					Config.WeightModify = new FloatConfigHandler(weightModifier, true);
					((Weather)this).Name = name;
					base.CustomType = CustomWeatherType.Combined;
					Plugin.logger.LogDebug((object)("Created CombinedWeatherType: " + ((Weather)this).Name));
					Variables.CombinedWeathers.Add(this);
					WeatherManager.RegisterWeather((Weather)(object)this);
				}
			}
		}

		[JsonObject(/*Could not decode attribute arguments.*/)]
		public c