Decompiled source of BetaWeatherTweaksBeta v0.24.5

WeatherTweaks.dll

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

[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.24.5.0")]
[assembly: AssemblyInformationalVersion("0.24.5+bcab6391410f289554b311e0804a553cce4a2ba9")]
[assembly: AssemblyProduct("WeatherTweaks")]
[assembly: AssemblyTitle("WeatherTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WeatherRegistry
{
	public class Init
	{
		public static void InitMethod()
		{
			new CombinedEclipsedFlooded();
			new CombinedFoggyRainy();
			new CombinedStormyFlooded();
			new CombinedStormyRainy();
			new CombinedEclipsedRainy();
			new CombinedFoggyFlooded();
			new CombinedFoggyEclipsed();
			new CombinedStormyRainyEclipsed();
			new CombinedStormyRainyFlooded();
			new CombinedStormyRainyFloodedEclipsed();
			new ProgressingNoneFoggy();
			new ProgressingNoneStormy();
			new ProgressingEclipsedFoggy();
			new ProgressingFoggyNone();
			new ProgressingHiddenEclipsed();
			new ProgressingStormyRainy();
			new ProgressingRainyEclipsed();
		}
	}
}
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 class LevelListConfigHandler : LevelListConfigHandler
	{
		public LevelListConfigHandler(string defaultValue, bool enabled = true)
			: base(defaultValue, enabled)
		{
		}

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

		public static LevelListConfigHandler FoggyIgnoreLevels;

		public static ConfigManager Instance { get; private set; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		internal static void 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.24.5");
			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.24.5")]
	[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__5_0;

			public static Event <>9__5_1;

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

			public static Event <>9__5_3;

			public static ParameterEvent<Terminal> <>9__5_4;

			public static ParameterEvent<StartOfRound> <>9__5_5;

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

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

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

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

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

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

		internal static ManualLogSource logger;

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

		internal static bool IsLLLPresent = false;

		internal static GeneralImprovementsWeather GeneralImprovements;

		internal static Weather BlackoutWeather;

		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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Expected O, but got Unknown
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Expected O, but got Unknown
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Expected O, but got Unknown
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: 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__5_0;
			if (obj == null)
			{
				Event val2 = delegate
				{
					DisableAllWeathers.DisableAllWeather();
				};
				<>c.<>9__5_0 = val2;
				obj = (object)val2;
			}
			((CustomEvent)disableAllWeathers).AddListener((Event)obj);
			WeatherRegistryEvent setupFinished = EventManager.SetupFinished;
			object obj2 = <>c.<>9__5_1;
			if (obj2 == null)
			{
				Event val3 = delegate
				{
					TerminalStartPatch.Start();
				};
				<>c.<>9__5_1 = val3;
				obj2 = (object)val3;
			}
			((CustomEvent)setupFinished).AddListener((Event)obj2);
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).AddListener((ParameterEvent<(SelectableLevel, Weather)>)delegate((SelectableLevel level, Weather weather) args)
			{
				FoggyPatch.ToggleFogExclusionZones(args.level, enable: false);
			});
			WeatherRegistryEvent disableAllWeathers2 = EventManager.DisableAllWeathers;
			object obj3 = <>c.<>9__5_3;
			if (obj3 == null)
			{
				Event val4 = delegate
				{
					FoggyPatch.ToggleFogExclusionZones(StartOfRound.Instance.currentLevel);
				};
				<>c.<>9__5_3 = val4;
				obj3 = (object)val4;
			}
			((CustomEvent)disableAllWeathers2).AddListener((Event)obj3);
			if (WeatherCalculation.WeatherSelectionAlgorithm != WeatherCalculation.VanillaAlgorithm)
			{
				WeatherCalculation.WeatherSelectionAlgorithm = (WeatherSelectionAlgorithm)(object)WeatherCalculation.weatherTweaksWeatherAlgorithm;
			}
			EventManager.TerminalStart.AddListener((ParameterEvent<Terminal>)delegate
			{
				TerminalPatch.Postfix();
			});
			EventManager.LobbyDisabled.AddListener((ParameterEvent<StartOfRound>)delegate
			{
				Reset.ResetThings();
			});
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader"))
			{
				LLL.Init();
			}
			MethodInfo method = typeof(StartOfRound).GetMethod("SetPlanetsWeather");
			val.Unpatch((MethodBase)method, (HarmonyPatchType)2, "imabatby.lethallevelloader");
			GeneralImprovements = new GeneralImprovementsWeather("ShaosilGaming.GeneralImprovements");
			if (Chainloader.PluginInfos.ContainsKey("xxxstoner420bongmasterxxx.open_monitors"))
			{
				OpenMonitorsPatch.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("com.zealsprince.malfunctions"))
			{
				Malfunctions.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LobbyCompatibilityCompatibility.Init();
			}
			Weather val5 = new Weather("Cloudy", new ImprovedWeatherEffect((GameObject)null, (GameObject)null)
			{
				SunAnimatorBool = "overcast"
			});
			val5.Color = new Color(0f, 1f, 0.55f, 1f);
			val5.Config.ScrapAmountMultiplier = new FloatConfigHandler(1.6f, true);
			val5.Config.ScrapValueMultiplier = new FloatConfigHandler(0.8f, true);
			val5.Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(new string[2] { "Eclipsed@50", "Stormy@80" }, true);
			val5.Config.DefaultWeight = new IntegerConfigHandler(25, true);
			Weather val6 = val5;
			WeatherManager.RegisterWeather(val6);
			GameObject val7 = Object.Instantiate<GameObject>(new GameObject
			{
				name = "BlackoutWeather"
			});
			((Object)val7).hideFlags = (HideFlags)61;
			val7.AddComponent<Blackout>();
			Object.DontDestroyOnLoad((Object)(object)val7);
			AssetBundle val8 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "blackout"));
			AnimationClip animationClip = val8.LoadAsset<AnimationClip>("BlackoutSunClip");
			Weather val9 = new Weather("Blackout", new ImprovedWeatherEffect((GameObject)null, val7)
			{
				SunAnimatorBool = "eclipse"
			})
			{
				Color = new Color(0.2f, 0.2f, 0.2f, 1f),
				Config = 
				{
					ScrapAmountMultiplier = new FloatConfigHandler(0.65f, true)
				},
				Config = 
				{
					ScrapValueMultiplier = new FloatConfigHandler(1.7f, true)
				},
				Config = 
				{
					DefaultWeight = new IntegerConfigHandler(25, true)
				},
				Config = 
				{
					LevelWeights = new LevelWeightsConfigHandler("Rend@200; Dine@200; Titan@200", true)
				},
				Config = 
				{
					WeatherToWeatherWeights = new WeatherWeightsConfigHandler("None@200; Cloudy@250", true)
				},
				AnimationClip = animationClip
			};
			WeatherManager.RegisterWeather(val9);
			BlackoutWeather = val9;
			Init.InitMethod();
			logger.LogInfo((object)"\n                  .::.                  \n                  :==:                  \n         :-.      :==:      .-:         \n        .-==-.    .::.    .-===.        \n          .-=-  .:----:.  -==.          \n              -==========-              \n             ==============             \n               .-==========- :-----     \n         :-==-:. .=========- :-----     \n       .========:   .-=====             \n       ============-. :==-              \n       -=============. .  -==.          \n        :-==========:     .-==-.        \n            ......          .-:         ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin WeatherTweaks is loaded!");
		}
	}
	public static class TerminalPatch
	{
		public static void Postfix()
		{
			if (((CompatibilityBase)Plugin.GeneralImprovements).IsModPresent)
			{
				Plugin.logger.LogInfo((object)"GeneralImprovements is present");
				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 CombinedStormyRainyFloodedEclipsed : WeatherTweaks.Definitions.Types.CombinedWeatherType
	{
		public CombinedStormyRainyFloodedEclipsed()
			: base("Stormy + Rainy + Flooded + Eclipsed", new List<LevelWeatherType>(4)
			{
				(LevelWeatherType)2,
				(LevelWeatherType)1,
				(LevelWeatherType)4,
				(LevelWeatherType)5
			})
		{
		}
	}
	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 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;
			}
			set
			{
				_weatherTweaksTypes = value;
			}
		}

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

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

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

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

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

		internal static List<SelectableLevel> GetGameLevels(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_0084: Unknown result type (might be due to invalid IL or missing references)
			bool flag = UncertainWeather.uncertainWeathers.ContainsKey(level.PlanetName);
			if (!IsSetupFinished)
			{
				Plugin.DebugLogger.LogDebug((object)"Setup is not finished yet");
				return ((object)(LevelWeatherType)(ref level.currentWeather)).ToString();
			}
			if (flag && uncertain)
			{
				Plugin.DebugLogger.LogDebug((object)("Getting uncertain weather for " + level.PlanetName));
				return UncertainWeather.uncertainWeathers[level.PlanetName];
			}
			Plugin.DebugLogger.LogDebug((object)("Getting current weather for " + level.PlanetName));
			Weather weather = WeatherManager.GetWeather(level.currentWeather);
			return weather.Name;
		}

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

		public static float GetLevelWeatherVariable(LevelWeatherType weatherType, bool variable2 = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0088: 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)
			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;
			}
			Plugin.DebugLogger.LogDebug((object)$"Got weather variables for {currentLevel.PlanetName}:{weatherType} with variables {val2.weatherVariable} {val2.weatherVariable2}");
			if (variable2)
			{
				return val2.weatherVariable2;
			}
			return val2.weatherVariable;
		}

		public static LevelWeatherType LevelHasWeather(LevelWeatherType weatherType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)$"Checking if level has weather {weatherType}");
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)currentLevel == (Object)null)
			{
				Plugin.logger.LogError((object)$"Failed to get weather variables for {currentLevel.PlanetName}:{weatherType}");
				return (LevelWeatherType)(-1);
			}
			WeatherTweaksWeather planetCurrentWeatherType = GetPlanetCurrentWeatherType(currentLevel);
			Plugin.logger.LogDebug((object)$"Level has weather {((Weather)planetCurrentWeatherType).Type}?");
			switch (planetCurrentWeatherType.CustomType)
			{
			case CustomWeatherType.Combined:
			{
				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.24.5";
	}
}
namespace WeatherTweaks.Weathers
{
	public class Blackout : MonoBehaviour
	{
		public class LightUtils
		{
			public static List<Light> GetLightsInScene(string sceneName)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				List<Light> list = new List<Light>();
				Scene sceneByName = SceneManager.GetSceneByName(sceneName);
				if (!((Scene)(ref sceneByName)).isLoaded)
				{
					Plugin.DebugLogger.LogWarning((object)("Scene " + sceneName + " is not loaded!"));
					return list;
				}
				GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
				GameObject[] array = rootGameObjects;
				foreach (GameObject val in array)
				{
					Light[] componentsInChildren = val.GetComponentsInChildren<Light>(true);
					list.AddRange(componentsInChildren);
				}
				return list;
			}

			public static List<Light> GetLightsUnderParent(Transform parent, bool includeInactive = true)
			{
				List<Light> list = new List<Light>();
				if ((Object)(object)parent == (Object)null)
				{
					return list;
				}
				Light[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Light>(includeInactive);
				list.AddRange(componentsInChildren);
				return list;
			}

			public static List<Light> GetLightsInSceneUnderParent(string sceneName, string parentName, bool includeInactive = true)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				List<Light> list = new List<Light>();
				Scene sceneByName = SceneManager.GetSceneByName(sceneName);
				if (!((Scene)(ref sceneByName)).isLoaded)
				{
					Plugin.DebugLogger.LogWarning((object)("Scene " + sceneName + " is not loaded!"));
					return list;
				}
				GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
				GameObject[] array = rootGameObjects;
				foreach (GameObject val in array)
				{
					if (((Object)val).name == parentName)
					{
						list.AddRange(GetLightsUnderParent(val.transform, includeInactive));
						break;
					}
					Transform val2 = val.transform.Find(parentName);
					if ((Object)(object)val2 != (Object)null)
					{
						list.AddRange(GetLightsUnderParent(val2, includeInactive));
						break;
					}
				}
				return list;
			}

			public static Dictionary<string, List<Light>> GetLightsInScenes(string[] sceneNames)
			{
				Dictionary<string, List<Light>> dictionary = new Dictionary<string, List<Light>>();
				foreach (string text in sceneNames)
				{
					dictionary[text] = GetLightsInScene(text);
				}
				return dictionary;
			}

			public static Light[] GetAllLightsInScene(bool includeInactive = true)
			{
				return Resources.FindObjectsOfTypeAll<Light>();
			}

			public static Light[] GetActiveLightsInScene()
			{
				return Object.FindObjectsOfType<Light>();
			}

			public static List<Light> GetLightsByType(LightType lightType)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Light[] allLightsInScene = GetAllLightsInScene();
				List<Light> list = new List<Light>();
				Light[] array = allLightsInScene;
				foreach (Light val in array)
				{
					if (val.type == lightType)
					{
						list.Add(val);
					}
				}
				return list;
			}
		}

		private List<Light> AllPoweredLights = new List<Light>();

		private Dictionary<GrabbableObject, Light> Flashlights = new Dictionary<GrabbableObject, Light>();

		private Logger Logger = new Logger("Blackout", (ConfigEntry<bool>)null);

		private float FloodlightRange = 44f;

		private float FloodlightAngle = 116.7f;

		private float FloodlightIntensity = 762f;

		private void OnEnable()
		{
			if (!WeatherManager.IsSetupFinished)
			{
				return;
			}
			LungProp val = Object.FindObjectOfType<LungProp>();
			AllPoweredLights = LightUtils.GetLightsInScene(StartOfRound.Instance.currentLevel.sceneName);
			Logger.LogInfo((object)$"Found {AllPoweredLights.Count} lights in scene {StartOfRound.Instance.currentLevel.sceneName}");
			HDAdditionalLightData val2 = default(HDAdditionalLightData);
			foreach (Light allPoweredLight in AllPoweredLights)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)allPoweredLight).transform.parent == (Object)(object)((Component)val).gameObject.transform)
				{
					Plugin.logger.LogDebug((object)("Skipping light " + ((Object)allPoweredLight).name + " (parent " + ((Object)((Component)allPoweredLight).transform.parent).name + ")"));
					((Component)allPoweredLight).gameObject.TryGetComponent<HDAdditionalLightData>(ref val2);
					if ((Object)(object)val2 != (Object)null)
					{
						val2.SetIntensity(600f);
					}
				}
				else
				{
					Logger.LogDebug((object)("Disabling light " + ((Object)allPoweredLight).name + " (parent " + ((Object)((Component)allPoweredLight).transform.parent).name + ")"));
					((Component)allPoweredLight).gameObject.SetActive(false);
				}
			}
			RoundManager.Instance.SwitchPower(true);
			RoundManager.Instance.TurnOnAllLights(false);
			BreakerBox val3 = Object.FindObjectOfType<BreakerBox>();
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).gameObject.SetActive(false);
			}
			GameObject val4 = GameObject.Find("Sun");
			if ((Object)(object)val4 != (Object)null)
			{
				val4.SetActive(false);
			}
			try
			{
				Transform component = GameObject.Find("ShipLightsPost").GetComponent<Transform>();
				List<Light> lightsUnderParent = LightUtils.GetLightsUnderParent(component);
				Logger.LogInfo((object)$"Found {lightsUnderParent.Count} floodlights in scene SampleSceneRelay");
				HDAdditionalLightData val5 = default(HDAdditionalLightData);
				foreach (Light item in lightsUnderParent)
				{
					((Component)item).gameObject.TryGetComponent<HDAdditionalLightData>(ref val5);
					if ((Object)(object)val5 != (Object)null)
					{
						val5.SetIntensity(30000f);
						val5.SetSpotAngle(120f, 0f);
						val5.SetRange(600f);
					}
				}
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)$"Error while trying to modify floodlights: {arg}");
			}
		}

		private void OnDisable()
		{
			if (!WeatherManager.IsSetupFinished)
			{
				return;
			}
			AllPoweredLights.Clear();
			try
			{
				Transform component = GameObject.Find("ShipLightsPost").GetComponent<Transform>();
				List<Light> lightsUnderParent = LightUtils.GetLightsUnderParent(component);
				Logger.LogInfo((object)$"Found {lightsUnderParent.Count} floodlights in scene SampleSceneRelay");
				HDAdditionalLightData val = default(HDAdditionalLightData);
				foreach (Light item in lightsUnderParent)
				{
					((Component)item).gameObject.TryGetComponent<HDAdditionalLightData>(ref val);
					if ((Object)(object)val != (Object)null)
					{
						val.SetIntensity(FloodlightIntensity);
						val.SetSpotAngle(FloodlightAngle, 0f);
						val.SetRange(FloodlightRange);
					}
				}
			}
			catch (Exception arg)
			{
				Logger.LogWarning((object)$"Error while trying to modify floodlights: {arg}");
			}
		}
	}
}
namespace WeatherTweaks.Patches
{
	internal class FoggyPatch
	{
		public static void CreateEffectOverrides()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			Plugin.logger.LogInfo((object)"CreateEffectOverrides called");
			Weather weather = WeatherManager.GetWeather((LevelWeatherType)3);
			ImprovedWeatherEffect val = new ImprovedWeatherEffect(weather.Effect.EffectObject, Object.Instantiate<GameObject>(weather.Effect.WorldObject));
			GameObject worldObject = val.WorldObject;
			LocalVolumetricFog component = worldObject.GetComponent<LocalVolumetricFog>();
			LocalVolumetricFog item = ChangeFogParams(component);
			List<LocalVolumetricFog> list = worldObject.GetComponents<LocalVolumetricFog>().ToList();
			list.Remove(component);
			list.Add(item);
			val.WorldObject = worldObject;
			foreach (SelectableLevel level in LevelHelper.Levels)
			{
				if (!((ConfigHandler<SelectableLevel[], string>)(object)ConfigManager.FoggyIgnoreLevels).Value.Contains(level))
				{
					WeatherEffectOverride val2 = new WeatherEffectOverride(weather, level, val);
				}
			}
		}

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

		public static void ToggleFogExclusionZones(SelectableLevel level, bool enable = true)
		{
			Plugin.logger.LogDebug((object)"DisableFogExclusionZones called");
			List<GameObject> list = (from obj in Object.FindObjectsOfType<GameObject>()
				where ((Object)obj).name == "FogExclusionZone"
				select obj).ToList();
			foreach (GameObject item in list)
			{
				Plugin.DebugLogger.LogDebug((object)$"Setting fog exclusion zone {((Object)item).name} (parent {((Object)item.transform.parent).name}) to {enable}");
				item.SetActive(enable);
			}
		}
	}
	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)