Decompiled source of EXPERIMENTALWeatherRegistry v1000.1.3

WeatherRegistry.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConsoleTables;
using GameNetcodeStuff;
using HarmonyLib;
using Imperium.API.Types.Networking;
using JLL.Components;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Malfunctions;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using MrovLib;
using MrovLib.Compatibility;
using MrovLib.Definitions;
using MrovLib.Events;
using Newtonsoft.Json;
using On;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Serialization;
using WeatherRegistry.Algorithms;
using WeatherRegistry.Compatibility;
using WeatherRegistry.Definitions;
using WeatherRegistry.Editor;
using WeatherRegistry.Enums;
using WeatherRegistry.Events;
using WeatherRegistry.Managers;
using WeatherRegistry.Modules;
using WeatherRegistry.NetcodePatcher;
using WeatherRegistry.Networking;
using WeatherRegistry.Patches;
using WeatherRegistry.Utils;

[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("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Malfunctions")]
[assembly: IgnoresAccessChecksTo("MrovLib")]
[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.Components")]
[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: AssemblyCompany("WeatherRegistry")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Weather API for Lethal Company.")]
[assembly: AssemblyFileVersion("0.7.6.0")]
[assembly: AssemblyInformationalVersion("0.7.6-dev.81+f5d5169ed515ba2db1408bb76ffbab858cc11544")]
[assembly: AssemblyProduct("WeatherRegistry")]
[assembly: AssemblyTitle("WeatherRegistry")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AndreyMrovol/LethalWeatherRegistry/")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 Rarity
	{
		private int _weight;

		public int Weight
		{
			get
			{
				return _weight;
			}
			set
			{
				_weight = Math.Clamp(value, 0, 10000);
			}
		}
	}
	public class NameRarity : Rarity
	{
		public string Name { get; set; }
	}
	public class LevelRarity : Rarity
	{
		public SelectableLevel Level { get; set; }
	}
	public class WeatherRarity : Rarity
	{
		public Weather Weather { get; set; }
	}
	public abstract class ConfigHandler<T, CT> : WeatherRegistry.Utils.ConfigHandler<T, CT>
	{
		public ConfigFile ConfigFile { get; set; } = ConfigManager.configFile;


		public ConfigHandler(CT value, bool enabled = true)
		{
			((ConfigHandler<T, CT>)this).DefaultValue = value;
			base.Enabled = enabled;
		}

		public void SetConfigEntry(Weather weather, string configTitle, ConfigDescription configDescription = null)
		{
			if (base.Enabled)
			{
				((ConfigHandler<T, CT>)this).ConfigEntry = ConfigFile.Bind<CT>(ConfigHelper.CleanStringForConfig(weather.ConfigCategory), ConfigHelper.CleanStringForConfig(configTitle), ((ConfigHandler<T, CT>)this).DefaultValue, configDescription);
				return;
			}
			((ConfigHandler<T, CT>)this).ConfigEntry = null;
			((Logger)Plugin.debugLogger).LogDebug("Config entry for " + weather.Name + ": " + configTitle + " is disabled");
		}

		public void SetConfigEntry(string configCategory, string configTitle, ConfigDescription configDescription = null)
		{
			if (base.Enabled)
			{
				((ConfigHandler<T, CT>)this).ConfigEntry = ConfigFile.Bind<CT>(ConfigHelper.CleanStringForConfig(configCategory), ConfigHelper.CleanStringForConfig(configTitle), ((ConfigHandler<T, CT>)this).DefaultValue, configDescription);
				return;
			}
			((ConfigHandler<T, CT>)this).ConfigEntry = null;
			((Logger)Plugin.debugLogger).LogDebug("Config entry " + configTitle + " is disabled");
		}
	}
	public class LevelListConfigHandler : ConfigHandler<SelectableLevel[], string>
	{
		public override SelectableLevel[] Value => ConfigHelper.ConvertStringToLevels(base.ConfigEntryActive ? ((ConfigHandler<SelectableLevel[], string>)this).ConfigEntry.Value : ((ConfigHandler<SelectableLevel[], string>)this).DefaultValue);

		public LevelListConfigHandler(string value, bool enabled = true)
			: base(value, enabled)
		{
		}

		public LevelListConfigHandler(string[] value, bool enabled = true)
			: base(string.Join(";", value), enabled)
		{
		}
	}
	public class LevelWeightsConfigHandler : ConfigHandler<LevelRarity[], string>
	{
		public override LevelRarity[] Value => ConfigHelper.ConvertStringToLevelRarities(base.ConfigEntryActive ? ((ConfigHandler<LevelRarity[], string>)this).ConfigEntry.Value : ((ConfigHandler<LevelRarity[], string>)this).DefaultValue);

		public LevelWeightsConfigHandler(string value, bool enabled = true)
			: base(value, enabled)
		{
		}

		public LevelWeightsConfigHandler(string[] value, bool enabled = true)
			: base(string.Join(";", value), enabled)
		{
		}
	}
	public class WeatherWeightsConfigHandler : ConfigHandler<WeatherRarity[], string>
	{
		public override WeatherRarity[] Value => ConfigHelper.ConvertStringToWeatherWeights(base.ConfigEntryActive ? ((ConfigHandler<WeatherRarity[], string>)this).ConfigEntry.Value : ((ConfigHandler<WeatherRarity[], string>)this).DefaultValue);

		public WeatherWeightsConfigHandler(string value, bool enabled = true)
			: base(value, enabled)
		{
		}

		public WeatherWeightsConfigHandler(string[] value, bool enabled = true)
			: base(string.Join(";", value), enabled)
		{
		}
	}
	public class BooleanConfigHandler : ConfigHandler<bool, bool>
	{
		public override bool Value
		{
			get
			{
				if (!base.ConfigEntryActive)
				{
					return ((ConfigHandler<bool, bool>)this).DefaultValue;
				}
				return ((ConfigHandler<bool, bool>)this).ConfigEntry.Value;
			}
		}

		public BooleanConfigHandler(bool value, bool enabled = true)
			: base(value, enabled)
		{
		}

		public BooleanConfigHandler(FilteringOption filteringOption, bool enabled = true)
			: base(filteringOption == FilteringOption.Include, enabled)
		{
		}
	}
	public class IntegerConfigHandler : ConfigHandler<int, int>
	{
		public override int Value
		{
			get
			{
				if (!base.ConfigEntryActive)
				{
					return ((ConfigHandler<int, int>)this).DefaultValue;
				}
				return ((ConfigHandler<int, int>)this).ConfigEntry.Value;
			}
		}

		public IntegerConfigHandler(int value, bool enabled = true)
			: base(value, enabled)
		{
		}
	}
	public class FloatConfigHandler : ConfigHandler<float, float>
	{
		public override float Value
		{
			get
			{
				if (!base.ConfigEntryActive)
				{
					return ((ConfigHandler<float, float>)this).DefaultValue;
				}
				return ((ConfigHandler<float, float>)this).ConfigEntry.Value;
			}
		}

		public FloatConfigHandler(float value, bool enabled = true)
			: base(value, enabled)
		{
		}
	}
	public class StringConfigHandler : ConfigHandler<string, string>
	{
		public override string Value
		{
			get
			{
				if (!base.ConfigEntryActive)
				{
					return ((ConfigHandler<string, string>)this).DefaultValue;
				}
				return ((ConfigHandler<string, string>)this).ConfigEntry.Value;
			}
		}

		public StringConfigHandler(string value, bool enabled = true)
			: base(value, enabled)
		{
		}
	}
	public class ConfigHelper
	{
		private static Logger logger = new Logger("ConfigHelper", (LoggingType)1);

		private static readonly Regex ConfigCleanerRegex = new Regex("[\\n\\t\"`\\[\\]']");

		private static Dictionary<string, Weather> _weathersDictionary = null;

		public static Dictionary<string, Weather> StringToWeather
		{
			get
			{
				if (_weathersDictionary != null)
				{
					return _weathersDictionary;
				}
				Dictionary<string, Weather> Weathers = new Dictionary<string, Weather>();
				WeatherManager.Weathers.ToList().ForEach(delegate(Weather weather)
				{
					Weathers.TryAdd(weather.Name.ToLowerInvariant(), weather);
					Weathers.TryAdd(GetAlphanumericName(weather).ToLowerInvariant(), weather);
				});
				_weathersDictionary = Weathers;
				return Weathers;
			}
			set
			{
				_weathersDictionary = value;
			}
		}

		internal static string CleanStringForConfig(string input)
		{
			return ConfigCleanerRegex.Replace(input, string.Empty).Trim();
		}

		public static Weather ResolveStringToWeather(string str)
		{
			return StringToWeather.GetValueOrDefault(str.ToLowerInvariant());
		}

		public static List<Weather> ResolveStringToWeathers(string str)
		{
			if (string.IsNullOrWhiteSpace(str))
			{
				return new List<Weather>();
			}
			string[] array = ConvertStringToArray(str);
			List<Weather> list = new List<Weather>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				Weather weather = ResolveStringToWeather(text);
				if (weather != null)
				{
					list.Add(weather);
				}
				else
				{
					((Logger)logger).LogWarning("Invalid weather name: " + text);
				}
			}
			return list;
		}

		public static string GetNumberlessName(SelectableLevel level)
		{
			return StringResolver.GetNumberlessName(level);
		}

		public static string GetAlphanumericName(SelectableLevel level)
		{
			Regex regex = new Regex("^[0-9]+|[-_/\\\\\\ ]");
			return new string(regex.Replace(level.PlanetName, ""));
		}

		public static string GetAlphanumericName(Weather weather)
		{
			Regex regex = new Regex("^[0-9]+|[-_/\\\\\\ ]");
			return new string(regex.Replace(weather.Name, ""));
		}

		public static string GetAlphanumericName(string str)
		{
			Regex regex = new Regex("^[0-9]+|[-_/\\\\\\ ]");
			return new string(regex.Replace(str, ""));
		}

		public static string[] ConvertStringToArray(string str)
		{
			return (from s in str.Split(';')
				where !string.IsNullOrWhiteSpace(s)
				select s.Trim()).ToArray();
		}

		public static SelectableLevel[] ConvertStringToLevels(string str)
		{
			return StringResolver.ResolveStringToLevels(str);
		}

		public static NameRarity[] ConvertStringToRarities(string str)
		{
			string[] array = ConvertStringToArray(str);
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split('@');
				if (array3.Length == 2 && int.TryParse(array3[1], out var result))
				{
					string key = array3[0].Trim();
					if (!dictionary.ContainsKey(key))
					{
						dictionary.Add(key, result);
					}
				}
			}
			return dictionary.Select((KeyValuePair<string, int> rarity) => new NameRarity
			{
				Name = rarity.Key,
				Weight = rarity.Value
			}).ToArray();
		}

		public static LevelRarity[] ConvertStringToLevelRarities(string str)
		{
			Dictionary<SelectableLevel, int> dictionary = new Dictionary<SelectableLevel, int>();
			NameRarity[] array = ConvertStringToRarities(str);
			NameRarity[] array2 = array;
			foreach (NameRarity nameRarity in array2)
			{
				SelectableLevel[] array3 = StringResolver.ResolveStringToLevels(nameRarity.Name);
				SelectableLevel[] array4 = array3;
				foreach (SelectableLevel val in array4)
				{
					if (!((Object)(object)val == (Object)null))
					{
						dictionary.TryAdd(val, nameRarity.Weight);
					}
				}
			}
			return dictionary.Select((KeyValuePair<SelectableLevel, int> rarity) => new LevelRarity
			{
				Level = rarity.Key,
				Weight = rarity.Value
			}).ToArray();
		}

		public static WeatherRarity[] ConvertStringToWeatherWeights(string str)
		{
			Dictionary<Weather, int> dictionary = new Dictionary<Weather, int>();
			NameRarity[] array = ConvertStringToRarities(str);
			NameRarity[] array2 = array;
			foreach (NameRarity nameRarity in array2)
			{
				Weather weather = ResolveStringToWeather(nameRarity.Name);
				if (weather != null)
				{
					dictionary.TryAdd(weather, nameRarity.Weight);
				}
			}
			return dictionary.Select((KeyValuePair<Weather, int> rarity) => new WeatherRarity
			{
				Weather = rarity.Key,
				Weight = rarity.Value
			}).ToArray();
		}
	}
	internal class ConfigManager
	{
		internal static ConfigFile configFile;

		internal static ConfigManager Instance { get; private set; }

		internal static ConfigEntry<string> BundleBlacklist { get; private set; }

		internal static List<string> BlacklistedBundles => (from s in BundleBlacklist.Value.Split(';')
			select s.Trim() into s
			where !string.IsNullOrEmpty(s)
			select s).ToList();

		internal static ConfigEntry<LoggingType> LoggingLevels { get; private set; }

		internal static ConfigEntry<WeatherAlgorithm> WeatherAlgorithm { get; private set; }

		internal static ConfigEntry<bool> FirstDayClear { get; private set; }

		internal static ConfigEntry<bool> ColoredWeathers { get; private set; }

		internal static ConfigEntry<bool> PlanetVideos { get; private set; }

		internal static ConfigEntry<bool> ShowWeatherMultipliers { get; private set; }

		internal static ConfigEntry<bool> ShowClearWeather { get; private set; }

		internal static ConfigEntry<bool> UseScrapMultipliers { get; private set; }

		internal static ConfigEntry<bool> EnableMeltdownPatch { get; private set; }

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

		private ConfigManager(ConfigFile config)
		{
			configFile = config;
			BundleBlacklist = configFile.Bind<string>("|General", "Bundle Blacklist", "", "Semicolon-separated list of asset bundle names that shouldn't be loaded.");
			LoggingLevels = configFile.Bind<LoggingType>("|Logging", "Display Log Levels", (LoggingType)0, "Select which logs to show.");
			WeatherAlgorithm = configFile.Bind<WeatherAlgorithm>("|WeatherSelection", "Weather Selection Algorithm", WeatherRegistry.Enums.WeatherAlgorithm.Registry, "Select the algorithm to use during weather selection.");
			FirstDayClear = configFile.Bind<bool>("|WeatherSelection", "First Day Clear Weather", false, "If enabled, the first day will always have clear weather, on all planets, regardless of the selected algorithm.");
			ColoredWeathers = configFile.Bind<bool>("|General", "Colored Weathers", true, "Enable colored weathers on map screen");
			PlanetVideos = configFile.Bind<bool>("|General", "Planet Videos", true, "Display planet videos on map screen");
			ShowWeatherMultipliers = configFile.Bind<bool>("|General", "Show Weather Multipliers", false, "Show weather multipliers on map screen");
			ShowClearWeather = configFile.Bind<bool>("|General", "Show Clear Weather", true, "Display 'WEATHER: CLEAR' on map screen when weather is clear");
			UseScrapMultipliers = configFile.Bind<bool>("|General", "Scrap multipliers", true, "Use Registry's scrap multipliers. Disable if you prefer to use other mod's multiplier settings.");
			EnableMeltdownPatch = configFile.Bind<bool>("|Patches", "Enable Facility Meltdown Compatibility Patch", true, "Allows you to disable FacilityMeltdown patch (for when the mod is not working correctly)");
		}

		internal void RemoveOrphanedEntries()
		{
			Plugin.logger.LogInfo((object)"Removing orphaned config entries...");
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> orphanedEntries = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
			List<KeyValuePair<ConfigDefinition, string>> list = orphanedEntries.Where((KeyValuePair<ConfigDefinition, string> entry) => entry.Key.Section.Contains("|")).ToList();
			Plugin.logger.LogWarning((object)$"Found {list.Count} orphaned config entries.");
			list.ForEach(delegate(KeyValuePair<ConfigDefinition, string> entry)
			{
				((Logger)Plugin.debugLogger).LogWarning("Removing orphaned config entry: " + entry.Key.Section + " - " + entry.Key.Key);
				orphanedEntries.Remove(entry.Key);
			});
			configFile.Save();
		}

		internal static void ReloadConfigfile()
		{
			Plugin.logger.LogInfo((object)"Reloading config file...");
			configFile.Reload();
		}

		internal static void SettingChanged(object sender, SettingChangedEventArgs args)
		{
			ConfigEntryBase changedSetting = args.ChangedSetting;
			Plugin.logger.LogInfo((object)$"Setting changed: {changedSetting.Definition.Section}/{changedSetting.Definition.Key} changed to {changedSetting.BoxedValue}");
		}
	}
	internal class Defaults
	{
		internal static List<LevelWeatherType> VanillaWeathers = Defaults.VanillaWeathers;

		internal static Dictionary<LevelWeatherType, Color> VanillaWeatherColors = new Dictionary<LevelWeatherType, Color>
		{
			{
				(LevelWeatherType)(-1),
				new Color(0.41f, 1f, 0.42f, 1f)
			},
			{
				(LevelWeatherType)0,
				new Color(0.62f, 0.4f, 0.42f, 1f)
			},
			{
				(LevelWeatherType)3,
				new Color(1f, 0.86f, 0f, 1f)
			},
			{
				(LevelWeatherType)1,
				new Color(1f, 0.86f, 0f, 1f)
			},
			{
				(LevelWeatherType)2,
				new Color(1f, 0.57f, 0f, 1f)
			},
			{
				(LevelWeatherType)4,
				new Color(1f, 0.57f, 0f, 1f)
			},
			{
				(LevelWeatherType)5,
				new Color(1f, 0f, 0f, 1f)
			}
		};

		internal static Dictionary<LevelWeatherType, string> VanillaWeatherToWeatherWeights = new Dictionary<LevelWeatherType, string>
		{
			{
				(LevelWeatherType)(-1),
				"None@160; Rainy@100; Stormy@70; Flooded@20; Foggy@40; Eclipsed@10"
			},
			{
				(LevelWeatherType)1,
				"None@100; Rainy@60; Stormy@40; Flooded@30; Foggy@50; Eclipsed@20"
			},
			{
				(LevelWeatherType)2,
				"None@160; Rainy@110; Stormy@10; Flooded@120; Foggy@20; Eclipsed@80"
			},
			{
				(LevelWeatherType)4,
				"None@160; Rainy@60; Stormy@50; Flooded@10; Foggy@60; Eclipsed@40"
			},
			{
				(LevelWeatherType)3,
				"None@200; Rainy@60; Stormy@50; Flooded@10; Foggy@30; Eclipsed@20"
			},
			{
				(LevelWeatherType)5,
				"None@300; Rainy@40; Stormy@16; Flooded@20; Foggy@60; Eclipsed@10"
			}
		};

		public static readonly string DefaultLevelFilters = "Company";

		public static readonly string DefaultLevelWeights = "MoonName@50";

		public static readonly string DefaultWeatherToWeatherWeights = "WeatherName@50";

		public static readonly int DefaultWeight = 100;

		public static readonly float ScrapAmountMultiplier = 1f;

		public static readonly float ScrapValueMultiplier = 1f;

		public static readonly FilteringOption FilteringOption = FilteringOption.Exclude;

		internal static Color LethalLibColor = new Color(0f, 0.44f, 0.76f, 1f);

		internal static readonly string WeatherSaveKey = "WeatherRegistryCurrentWeathers";
	}
	[CreateAssetMenu(fileName = "WeatherEffect", menuName = "WeatherRegistry/ImprovedWeatherEffect", order = 90)]
	public class ImprovedWeatherEffect : ScriptableObject
	{
		[JsonIgnore]
		[Tooltip("The GameObject that is visible only for the player, i.e. rain particles, sound effects etc.")]
		[SerializeField]
		public GameObject EffectObject;

		[JsonIgnore]
		[Tooltip("The GameObject that is placed in the world, i.e. floodwater, lightning bolts etc.")]
		[SerializeField]
		public GameObject WorldObject;

		private bool _effectEnabled;

		[Tooltip("The name of sun animator's bool that gets toggled when the weather effect is enabled. Vanilla uses '' for clear weather, 'overcast' for stormy/flooded, 'eclipse' for eclipsed.")]
		[field: SerializeField]
		public string SunAnimatorBool { get; set; }

		[field: SerializeField]
		public int DefaultVariable1 { get; set; }

		[field: SerializeField]
		public int DefaultVariable2 { get; set; }

		public LevelWeatherType LevelWeatherType { get; internal set; }

		public WeatherEffect VanillaWeatherEffect { get; internal set; }

		public virtual bool EffectEnabled
		{
			get
			{
				return _effectEnabled;
			}
			set
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				((Logger)WeatherEffectManager.Logger).LogDebug($"Setting effect {((Object)this).name} to {value} - is player inside? {Settings.IsPlayerInside}");
				if (!Settings.IsPlayerInside)
				{
					GameObject effectObject = EffectObject;
					if (effectObject != null)
					{
						effectObject.SetActive(value);
					}
					WeatherEffectController.SetTimeOfDayEffect(LevelWeatherType, value);
				}
				GameObject worldObject = WorldObject;
				if (worldObject != null)
				{
					worldObject.SetActive(value);
				}
				_effectEnabled = value;
			}
		}

		public bool EffectActive
		{
			get
			{
				GameObject effectObject = EffectObject;
				if (effectObject == null)
				{
					return false;
				}
				return effectObject.activeSelf;
			}
		}

		public virtual void DisableEffect(bool permament = false)
		{
			if (permament)
			{
				EffectEnabled = false;
				return;
			}
			GameObject effectObject = EffectObject;
			if (effectObject != null)
			{
				effectObject.SetActive(false);
			}
		}

		public ImprovedWeatherEffect(GameObject effectObject, GameObject worldObject)
		{
			EffectObject = effectObject;
			WorldObject = worldObject;
			GameObject effectObject2 = EffectObject;
			if (effectObject2 != null)
			{
				effectObject2.SetActive(false);
			}
			GameObject worldObject2 = WorldObject;
			if (worldObject2 != null)
			{
				worldObject2.SetActive(false);
			}
		}

		public ImprovedWeatherEffect(WeatherEffect weatherEffect)
		{
			EffectObject = weatherEffect.effectObject;
			WorldObject = weatherEffect.effectPermanentObject;
			VanillaWeatherEffect = weatherEffect;
			GameObject effectObject = EffectObject;
			if (effectObject != null)
			{
				effectObject.SetActive(false);
			}
			GameObject worldObject = WorldObject;
			if (worldObject != null)
			{
				worldObject.SetActive(false);
			}
		}
	}
	public class EventManager
	{
		public static WeatherRegistryEvent DisableAllWeathers = new WeatherRegistryEvent();

		public static WeatherRegistryEvent BeforeSetupStart = new WeatherRegistryEvent();

		public static WeatherRegistryEvent SetupFinished = new WeatherRegistryEvent();

		public static WeatherRegistryEvent<int> DayChanged = new WeatherRegistryEvent<int>();

		public static WeatherRegistryEvent<(SelectableLevel level, Weather weather, string screenText)> MapScreenUpdated = new WeatherRegistryEvent<(SelectableLevel, Weather, string)>();

		public static WeatherRegistryEvent<(SelectableLevel level, Weather weather)> WeatherChanged = new WeatherRegistryEvent<(SelectableLevel, Weather)>();

		public static WeatherRegistryEvent<(SelectableLevel level, Weather weather)> ShipLanding = new WeatherRegistryEvent<(SelectableLevel, Weather)>();
	}
	public class Logger : Logger
	{
		public override ManualLogSource LogSource { get; set; }

		public Logger(string SourceName, LoggingType defaultLoggingType = 1)
			: base(SourceName, defaultLoggingType)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((Logger)this).ModName = SourceName;
			((Logger)this).LogSource = Logger.CreateLogSource("WeatherRegistry");
			((Logger)this)._name = SourceName;
		}

		public override bool ShouldLog(LoggingType type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return ConfigManager.LoggingLevels.Value >= type;
		}
	}
	[BepInPlugin("mrov.WeatherRegistry", "WeatherRegistry", "1000.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("Ozzymops.DisableStormyWeather")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static EventHandler<SettingChangedEventArgs> <>9__13_2;

			public static Event <>9__13_1;

			internal void <Awake>b__13_2(object sender, SettingChangedEventArgs args)
			{
				ConfigManager.SettingChanged(sender, args);
			}

			internal void <Awake>b__13_1()
			{
				TerminalNodeManager.Init();
			}
		}

		[Obsolete("Use PluginInfo.PLUGIN_GUID instead")]
		public const string GUID = "mrov.WeatherRegistry";

		internal static ManualLogSource logger;

		internal static Logger debugLogger = new Logger("Debug", (LoggingType)1);

		internal static Harmony harmony = new Harmony("mrov.WeatherRegistry");

		internal static AssetBundleManager AssetBundleManager;

		internal static bool IsLethalLibLoaded = false;

		internal static JLLCompat JLLCompat;

		internal static LobbyControlCompat LobbyControlCompat;

		internal static FacilityMeltdownCompat FacilityMeltdownCompat;

		internal static OrbitsCompat OrbitsCompat;

		internal static ImperiumCompat ImperiumCompat;

		internal static MalfunctionsCompat MalfunctionsCompat;

		internal static Hook WeatherTypeEnumHook;

		private void Awake()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_007d: 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_0088: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			WeatherRegistry.Patches.NetcodePatcher.PatchNetcodeMethods();
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			AssetBundleManager assetBundleManager = new AssetBundleManager();
			((AssetBundleLoaderManager)assetBundleManager).BundleBlacklist = ConfigManager.BlacklistedBundles;
			AssetBundleManager = assetBundleManager;
			((AssetBundleLoaderManager)AssetBundleManager).LoadAllBundles();
			((AssetBundleLoaderManager)AssetBundleManager).ConvertLoadedAssets();
			EventManager.MainMenuLoaded.AddListener((Event)delegate
			{
				MainMenuInit();
				ConfigManager.Instance.RemoveOrphanedEntries();
				ConfigManager.configFile.SettingChanged += delegate(object sender, SettingChangedEventArgs args)
				{
					ConfigManager.SettingChanged(sender, args);
				};
			});
			WeatherRegistryEvent setupFinished = EventManager.SetupFinished;
			object obj = <>c.<>9__13_1;
			if (obj == null)
			{
				Event val = delegate
				{
					TerminalNodeManager.Init();
				};
				<>c.<>9__13_1 = val;
				obj = (object)val;
			}
			((CustomEvent)setupFinished).AddListener((Event)obj);
			if (Chainloader.PluginInfos.ContainsKey("evaisa.lethallib"))
			{
				IsLethalLibLoaded = true;
				LethalLibPatch.Init();
			}
			else
			{
				logger.LogDebug((object)"LethalLib not detected!");
			}
			WeatherTypeEnumHook = new Hook((MethodBase)typeof(Enum).GetMethod("ToString", Array.Empty<Type>()), typeof(EnumPatches).GetMethod("LevelWeatherTypeEnumToStringHook"));
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LobbyCompatibilityCompatibility.Init();
			}
			JLLCompat = new JLLCompat("JacobG5.JLL");
			LobbyControlCompat = new LobbyControlCompat("mattymatty.LobbyControl");
			LobbyControlCompat.Init();
			FacilityMeltdownCompat = new FacilityMeltdownCompat("me.loaforc.facilitymeltdown");
			OrbitsCompat = new OrbitsCompat("com.fiufki.orbits");
			OrbitsCompat.Init();
			ImperiumCompat = new ImperiumCompat("giosuel.Imperium");
			MalfunctionsCompat = new MalfunctionsCompat("com.zealsprince.malfunctions");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin mrov.WeatherRegistry is loaded!");
		}

		private void MainMenuInit()
		{
			ImperiumCompat.Init();
		}
	}
	public class Settings
	{
		public static Dictionary<string, TMP_ColorGradient> ScreenMapColors = new Dictionary<string, TMP_ColorGradient>();

		public static bool SetupFinished => WeatherManager.IsSetupFinished;

		public static WeatherSelectionAlgorithm WeatherSelectionAlgorithm => WeatherCalculation.WeatherSelectionAlgorithm;

		public static bool IsGameStarted { get; internal set; } = false;


		public static bool IsPlayerInside { get; set; } = false;


		public static bool SelectWeathers { get; set; } = true;


		public static bool ScrapMultipliers { get; set; } = ConfigManager.UseScrapMultipliers.Value;


		public static bool ColoredWeathers { get; set; } = ConfigManager.ColoredWeathers.Value;


		public static bool WeatherOverrideNames { get; set; } = true;


		public static bool PlanetVideos { get; set; } = ConfigManager.PlanetVideos.Value;


		public static bool MapScreenOverride { get; set; } = true;

	}
	public static class WeatherController
	{
		private static Logger Logger = new Logger("WeatherController", (LoggingType)0);

		public static void ChangeCurrentWeather(Weather weather)
		{
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			ChangeWeather(currentLevel, weather);
		}

		public static void ChangeCurrentWeather(LevelWeatherType weatherType)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			ChangeWeather(currentLevel, weatherType);
		}

		public static void ChangeWeather(SelectableLevel level, LevelWeatherType weatherType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Weather weather = WeatherManager.GetWeather(weatherType);
			ChangeWeather(level, weather);
		}

		public static void ChangeWeather(SelectableLevel level, Weather weather)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.SelectWeathers)
			{
				return;
			}
			if (weather == null)
			{
				((Logger)Logger).LogWarning("Weather is null, cannot change weather");
				return;
			}
			level.currentWeather = weather.VanillaWeatherType;
			if ((Object)(object)StartOfRound.Instance.currentLevel == (Object)(object)level)
			{
				TimeOfDay.Instance.currentLevelWeather = weather.VanillaWeatherType;
			}
			((Logger)Logger).LogDebug($"Changed weather for {ConfigHelper.GetNumberlessName(level)} to {weather.VanillaWeatherType}");
			if (!StartOfRound.Instance.inShipPhase)
			{
				if ((Object)(object)StartOfRound.Instance.currentLevel == (Object)(object)level)
				{
					((Logger)Logger).LogDebug("Ship has already landed, changing weather effects");
					SetWeatherEffects(weather);
					return;
				}
				((Logger)Logger).LogDebug("Ship has already landed - cannot change weather effect on other level!");
			}
			WeatherManager.CurrentWeathers.SetWeather(level, weather);
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.WeatherChanged).Invoke((level, weather));
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}

		public static void SetRandomWeathers(SelectableLevel level, List<RandomWeatherWithVariables> randomWeathers)
		{
			SetRandomWeathers(level, randomWeathers.ToArray());
		}

		public static void SetRandomWeathers(SelectableLevel level, RandomWeatherWithVariables[] randomWeathers)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			level.randomWeathers = randomWeathers.ToArray();
			string alphanumericName = ConfigHelper.GetAlphanumericName(level);
			foreach (RandomWeatherWithVariables val in randomWeathers)
			{
				((Logger)Logger).LogWarning($"Adding random weather {val.weatherType} to {alphanumericName}");
			}
		}

		public static void AddRandomWeather(SelectableLevel level, RandomWeatherWithVariables randomWeather)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			List<RandomWeatherWithVariables> list = level.randomWeathers.ToList();
			if ((int)randomWeather.weatherType == -1)
			{
				((Logger)Logger).LogInfo("Cannot add None weather to random weathers, skipping");
				return;
			}
			list.Add(randomWeather);
			level.randomWeathers = list.Distinct().ToArray();
			Plugin.logger.LogInfo((object)$"Adding random weather {randomWeather.weatherType} to {ConfigHelper.GetAlphanumericName(level)}");
		}

		public static void RemoveRandomWeather(SelectableLevel level, RandomWeatherWithVariables randomWeather)
		{
			List<RandomWeatherWithVariables> list = level.randomWeathers.ToList();
			list.Remove(randomWeather);
			level.randomWeathers = list.ToArray();
		}

		public static void RemoveRandomWeather(SelectableLevel level, 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)
			List<RandomWeatherWithVariables> list = level.randomWeathers.Where((RandomWeatherWithVariables rw) => rw.weatherType == weatherType).ToList();
			foreach (RandomWeatherWithVariables item in list)
			{
				RemoveRandomWeather(level, item);
			}
		}

		public static void SetWeatherEffects(LevelWeatherType weatherType)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			WeatherSync.Instance.SetWeatherEffectOnHost(weatherType);
		}

		public static void SetWeatherEffects(Weather weather)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SetWeatherEffects(weather.VanillaWeatherType);
		}

		public static void AddWeatherEffect(LevelWeatherType weatherType)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)$"Adding weather effect {weatherType}");
			List<LevelWeatherType> list = WeatherSync.Instance.Effects.Effects.ToList();
			list.Add(weatherType);
			WeatherSync.Instance.SetWeatherEffectsOnHost(list.ToArray());
		}

		public static void AddWeatherEffect(Weather weather)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			AddWeatherEffect(weather.VanillaWeatherType);
		}

		public static void RemoveWeatherEffect(LevelWeatherType weatherType)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)$"Removing weather effect {weatherType}");
			List<LevelWeatherType> list = WeatherSync.Instance.Effects.Effects.ToList();
			list.Remove(weatherType);
			WeatherSync.Instance.SetWeatherEffectsOnHost(list.ToArray());
		}
	}
	public static class WeatherEffectController
	{
		internal static void SetTimeOfDayEffect(LevelWeatherType weatherType, bool enabled)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if ((int)weatherType != -1)
			{
				if (Settings.IsPlayerInside)
				{
					Plugin.logger.LogWarning((object)"Player is inside, not setting time of day effect");
				}
				else if (TimeOfDay.Instance.effects[weatherType] != null)
				{
					((Logger)Plugin.debugLogger).LogDebug($"Setting time of day effect {weatherType} to {enabled}");
					TimeOfDay.Instance.effects[weatherType].effectEnabled = enabled;
				}
			}
		}

		[Obsolete("Use SetWeatherEffects(Weather[]) instead")]
		public static void SetWeatherEffects(Weather weather)
		{
			SetWeatherEffects(new Weather[1] { weather });
		}

		public static void SetWeatherEffects(Weather[] weathers)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			DisableWeatherEffects(weathers);
			foreach (Weather weather2 in weathers)
			{
				if (weather2 == null)
				{
					continue;
				}
				if ((int)weather2.VanillaWeatherType != 4)
				{
					PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
					localPlayerController.isUnderwater = false;
					localPlayerController.sourcesCausingSinking = Mathf.Clamp(localPlayerController.sourcesCausingSinking - 1, 0, 100);
					localPlayerController.isMovementHindered = Mathf.Clamp(localPlayerController.isMovementHindered - 1, 0, 100);
					localPlayerController.hinderedMultiplier = 1f;
				}
				if ((int)weather2.VanillaWeatherType == -1)
				{
					SunAnimator.OverrideSunAnimator(weather2.VanillaWeatherType);
					continue;
				}
				if (((CompatibilityBase)Plugin.JLLCompat).IsModPresent)
				{
					var (flag, val) = Plugin.JLLCompat.GetJLLData();
					if (flag)
					{
						Plugin.logger.LogInfo((object)"Enabling JLL WeatherEffect");
						val.effectEnabled = true;
						GameObject effectObject = val.effectObject;
						if (effectObject != null)
						{
							effectObject.SetActive(true);
						}
						continue;
					}
				}
				WeatherEffectOverride effectOverride = weather2.GetEffectOverride(currentLevel);
				if (effectOverride == null)
				{
					weather2.Effect.EffectEnabled = true;
					SetTimeOfDayEffect(weather2.VanillaWeatherType, enabled: true);
				}
				else
				{
					weather2.Effect.EffectEnabled = false;
					effectOverride.OverrideEffect.EffectEnabled = true;
				}
			}
			try
			{
				SunAnimator.OverrideSunAnimator(weathers.Any((Weather weather) => Defaults.VanillaWeathers.Contains(weather.VanillaWeatherType)) ? weathers.Where((Weather weather) => Defaults.VanillaWeathers.Contains(weather.VanillaWeatherType)).Max((Weather weather) => weather.VanillaWeatherType) : weathers.Max((Weather weather) => weather.VanillaWeatherType));
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)("SunAnimator exception: " + ex.Message));
				Plugin.logger.LogWarning((object)"PLEASE report this issue to the mod developer with your modpack code and this log!");
			}
		}

		public static void SetWeatherEffects(LevelWeatherType[] weatherTypes)
		{
			Weather[] weatherEffects = weatherTypes.Select(WeatherManager.GetWeather).ToArray();
			SetWeatherEffects(weatherEffects);
		}

		public static void DisableWeatherEffects(Weather[] newWeathers)
		{
			foreach (WeatherEffectOverride weatherEffectOverride in OverridesManager.WeatherEffectOverrides)
			{
				if (!newWeathers.Contains(weatherEffectOverride.Weather))
				{
					weatherEffectOverride.OverrideEffect.DisableEffect(permament: true);
				}
			}
			foreach (Weather weather in WeatherManager.Weathers)
			{
				if (!newWeathers.Contains(weather))
				{
					weather.Effect.DisableEffect(permament: true);
				}
			}
			if (!((CompatibilityBase)Plugin.JLLCompat).IsModPresent)
			{
				return;
			}
			var (flag, val) = Plugin.JLLCompat.GetJLLData();
			if (flag)
			{
				Plugin.logger.LogInfo((object)"Disabling JLL WeatherEffect");
				val.effectEnabled = false;
				GameObject effectObject = val.effectObject;
				if (effectObject != null)
				{
					effectObject.SetActive(false);
				}
			}
		}

		public static void EnableCurrentWeatherEffects()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (((CompatibilityBase)Plugin.JLLCompat).IsModPresent)
			{
				var (flag, val) = Plugin.JLLCompat.GetJLLData();
				if (flag)
				{
					Plugin.logger.LogInfo((object)"Enabling JLL WeatherEffect");
					val.effectEnabled = true;
					GameObject effectObject = val.effectObject;
					if (effectObject != null)
					{
						effectObject.SetActive(true);
					}
				}
			}
			foreach (LevelWeatherType currentEffectType in WeatherManager.CurrentEffectTypes)
			{
				Weather weather = WeatherManager.GetWeather(currentEffectType);
				weather.Effect.EffectEnabled = true;
				SetTimeOfDayEffect(weather.VanillaWeatherType, enabled: true);
			}
		}

		public static void HandleJLLOverride(LevelWeatherType weatherType, bool enable)
		{
			if (Plugin.JLLCompat.IsJLLDoingWeatherOverride())
			{
				Plugin.logger.LogInfo((object)"Detected JLL WeatherOverride");
			}
		}
	}
	public static class WeatherManager
	{
		internal static bool IsSetupFinished = false;

		public static Dictionary<int, Weather> ModdedWeatherEnumExtension = new Dictionary<int, Weather>();

		public static CurrentWeathers CurrentWeathers = new CurrentWeathers();

		public static List<Weather> RegisteredWeathers { get; internal set; } = new List<Weather>();


		public static List<Weather> Weathers => WeathersDictionary.Values.ToList();

		public static Dictionary<LevelWeatherType, Weather> WeathersDictionary { get; internal set; } = new Dictionary<LevelWeatherType, Weather>();


		public static Weather NoneWeather { get; internal set; }

		public static List<LevelWeatherType> LevelWeatherTypes => Weathers.Select((Weather weather) => weather.VanillaWeatherType).ToList();

		public static List<LevelWeatherType> CurrentEffectTypes => (from weather in Weathers
			where (Object)(object)weather.Effect != (Object)null
			where weather.Effect.EffectEnabled
			select weather.VanillaWeatherType).ToList();

		[Obsolete("Use OverridesManager.WeatherEffectOverrides instead")]
		public static List<WeatherEffectOverride> WeatherEffectOverrides => OverridesManager.WeatherEffectOverrides;

		public static void RegisterWeather(Weather weather)
		{
			RegisteredWeathers.Add(weather);
		}

		public static Weather GetWeather(LevelWeatherType levelWeatherType)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			if (WeathersDictionary.ContainsKey(levelWeatherType))
			{
				return WeathersDictionary[levelWeatherType];
			}
			Plugin.logger.LogWarning((object)$"Weather {levelWeatherType} not found in dictionary");
			return null;
		}

		public static List<Weather> GetWeathers()
		{
			return Weathers;
		}

		internal static void Reset()
		{
			IsSetupFinished = false;
			Weathers.ForEach(delegate(Weather weather)
			{
				if (weather.Origin != WeatherOrigin.WeatherRegistry && weather.Origin != WeatherOrigin.WeatherTweaks)
				{
					Object.Destroy((Object)(object)weather.Effect);
				}
			});
			Weathers.Clear();
			WeathersDictionary.Clear();
			ModdedWeatherEnumExtension.Clear();
			CurrentWeathers.Clear();
			OverridesManager.WeatherEffectOverrides.Clear();
			Settings.ScreenMapColors.Clear();
			ConfigHelper.StringToWeather = null;
			RegisteredWeathers.RemoveAll((Weather weather) => weather.Origin != WeatherOrigin.WeatherRegistry && weather.Origin != WeatherOrigin.WeatherTweaks);
			WeatherLevelData.LatestWeathersReceived = Array.Empty<WeatherSyncData>();
		}

		public static string WeatherDisplayOverride(SelectableLevel level)
		{
			return string.Empty;
		}

		internal static List<LevelWeatherType> GetPlanetPossibleWeathers(SelectableLevel level)
		{
			return WeightsManager.GetPlanetPossibleWeathers(level);
		}

		public static WeightHandler<Weather, WeatherWeightType> GetPlanetWeightedList(SelectableLevel level)
		{
			return WeightsManager.GetPlanetWeightedList(level);
		}

		public static (int weight, WeatherWeightType type) GetWeatherWeightForLevel(SelectableLevel level, Weather weather)
		{
			return WeightsManager.GetWeatherWeightForLevel(level, weather);
		}

		[Obsolete("Use OverridesManager.GetCurrentWeatherOverride instead")]
		public static WeatherEffectOverride GetCurrentWeatherOverride(SelectableLevel level, Weather weather)
		{
			return OverridesManager.GetCurrentWeatherOverride(level, weather);
		}

		public static Weather GetCurrentWeather(SelectableLevel level)
		{
			if (!Settings.SetupFinished)
			{
				Plugin.logger.LogWarning((object)"Something is trying to get the current weather before setup is finished!");
				return null;
			}
			return CurrentWeathers.GetLevelWeather(level);
		}

		public static Weather GetCurrentLevelWeather()
		{
			return GetCurrentWeather(StartOfRound.Instance.currentLevel);
		}

		public static string GetCurrentWeatherName(SelectableLevel level, bool ignoreOverride = false)
		{
			string text = WeatherDisplayOverride(level);
			if (text != string.Empty && !ignoreOverride)
			{
				return text;
			}
			return GetCurrentWeather(level).Name;
		}

		public static string GetWeatherList()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			List<WeatherListData> list = new List<WeatherListData>();
			foreach (Weather weather in Weathers)
			{
				list.Add(new WeatherListData
				{
					WeatherID = FixedString64Bytes.op_Implicit(((int)weather.VanillaWeatherType).ToString()),
					WeatherName = FixedString64Bytes.op_Implicit(weather.Name)
				});
			}
			return JsonConvert.SerializeObject((object)list, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			});
		}
	}
	public class WeatherResolvable
	{
		public virtual string WeatherName { get; }

		public virtual LevelWeatherType WeatherType { get; }

		public override string ToString()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected I4, but got Unknown
			return $"{WeatherName} ({(int)WeatherType})";
		}
	}
	public class WeatherNameResolvable : WeatherResolvable
	{
		[CompilerGenerated]
		private string <weatherName>P;

		public override string WeatherName => <weatherName>P;

		public override LevelWeatherType WeatherType
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if (WeatherManager.IsSetupFinished)
				{
					return (LevelWeatherType)(((??)ConfigHelper.ResolveStringToWeather(<weatherName>P)?.VanillaWeatherType) ?? (-1));
				}
				((Logger)Plugin.debugLogger).LogDebug("Tried to resolve weather name " + <weatherName>P + " before setup finished");
				return (LevelWeatherType)(-1);
			}
		}

		public WeatherNameResolvable(string weatherName)
		{
			<weatherName>P = weatherName;
			base..ctor();
		}
	}
	public class WeatherTypeResolvable : WeatherResolvable
	{
		[CompilerGenerated]
		private LevelWeatherType <weatherType>P;

		public override LevelWeatherType WeatherType => <weatherType>P;

		public override string WeatherName
		{
			get
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				if (WeatherManager.IsSetupFinished)
				{
					return WeatherManager.GetWeather(<weatherType>P).Name;
				}
				return "";
			}
		}

		public WeatherTypeResolvable(LevelWeatherType weatherType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			<weatherType>P = weatherType;
			base..ctor();
		}
	}
	internal class WeatherSync : NetworkBehaviour
	{
		private static Logger Logger = new Logger("WeatherSync", (LoggingType)1);

		public NetworkVariable<WeatherSyncDataWrapper> WeathersSynced = new NetworkVariable<WeatherSyncDataWrapper>(new WeatherSyncDataWrapper
		{
			Weathers = Array.Empty<WeatherSyncData>()
		}, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<WeatherEffectDataWrapper> EffectsSynced = new NetworkVariable<WeatherEffectDataWrapper>(new WeatherEffectDataWrapper
		{
			Effects = (LevelWeatherType[])(object)new LevelWeatherType[1] { (LevelWeatherType)(-1) }
		}, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<FixedString4096Bytes> WeatherData = new NetworkVariable<FixedString4096Bytes>(default(FixedString4096Bytes), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public static GameObject WeatherSyncPrefab;

		public static NetworkManager networkManager;

		public static bool networkHasStarted = false;

		private static WeatherSync _instance;

		private static List<GameObject> queuedNetworkPrefabs = new List<GameObject>();

		public WeatherSyncData[] Weather
		{
			get
			{
				return WeathersSynced.Value.Weathers;
			}
			set
			{
				WeathersSynced.Value = new WeatherSyncDataWrapper
				{
					Weathers = value
				};
			}
		}

		public WeatherEffectDataWrapper Effects
		{
			get
			{
				return EffectsSynced.Value;
			}
			set
			{
				EffectsSynced.Value = new WeatherEffectDataWrapper
				{
					Effects = value.Effects
				};
			}
		}

		public FixedString4096Bytes WeatherList
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return WeatherData.Value;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				WeatherData.Value = value;
			}
		}

		public static WeatherSync Instance
		{
			get
			{
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = Object.FindObjectOfType<WeatherSync>();
					if ((Object)(object)_instance == (Object)null)
					{
						((Logger)Logger).LogError("WeatherSync instance is null");
					}
				}
				return _instance;
			}
			private set
			{
				_instance = value;
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			InitializeInstance();
			NetworkVariable<WeatherSyncDataWrapper> weathersSynced = WeathersSynced;
			weathersSynced.OnValueChanged = (OnValueChangedDelegate<WeatherSyncDataWrapper>)(object)Delegate.Combine((Delegate?)(object)weathersSynced.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<WeatherSyncDataWrapper>(WeatherLevelData.WeathersReceived));
			NetworkVariable<WeatherEffectDataWrapper> effectsSynced = EffectsSynced;
			effectsSynced.OnValueChanged = (OnValueChangedDelegate<WeatherEffectDataWrapper>)(object)Delegate.Combine((Delegate?)(object)effectsSynced.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<WeatherEffectDataWrapper>(WeatherEffectData.EffectsReceived));
		}

		public void SetNewOnHost(Dictionary<string, LevelWeatherType> weathers)
		{
			if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				((Logger)Logger).LogDebug("Cannot set weathers, not a host!");
				return;
			}
			WeatherSyncData[] weather = weathers.Select(delegate(KeyValuePair<string, LevelWeatherType> kvp)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				WeatherSyncData result = default(WeatherSyncData);
				result.Weather = kvp.Value;
				result.LevelName = new FixedString64Bytes(kvp.Key);
				return result;
			}).ToArray();
			Weather = weather;
		}

		public void SetWeatherEffectOnHost(LevelWeatherType weatherType)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected I4, but got Unknown
			SetWeatherEffectsOnHost((LevelWeatherType[])(object)new LevelWeatherType[1] { (LevelWeatherType)(int)weatherType });
		}

		public void SetWeatherEffectsOnHost(LevelWeatherType[] weatherTypes)
		{
			if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				((Logger)Logger).LogDebug("Cannot set effects, not a host!");
				return;
			}
			((Logger)Logger).LogDebug("Setting effects: [" + string.Join("; ", weatherTypes) + "]");
			Effects = new WeatherEffectDataWrapper
			{
				Effects = weatherTypes
			};
		}

		public static void RegisterNetworkPrefab(GameObject prefab)
		{
			if (!networkHasStarted)
			{
				((Logger)Logger).LogDebug("Registering NetworkPrefab: " + (object)prefab);
				queuedNetworkPrefabs.Add(prefab);
			}
			else
			{
				((Logger)Logger).LogWarning("Attempted To Register NetworkPrefab: " + ((object)prefab)?.ToString() + " After GameNetworkManager Has Started!");
			}
		}

		internal static void RegisterPrefabs(NetworkManager networkManager)
		{
			((Logger)Logger).LogDebug("Registering NetworkPrefabs in NetworkManager");
			List<GameObject> existingPrefabs = GetExistingPrefabs(networkManager);
			RegisterQueuedPrefabs(networkManager, existingPrefabs);
			networkHasStarted = true;
		}

		private void InitializeInstance()
		{
			((Object)((Component)this).gameObject).name = "WeatherSync";
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Logger)Logger).LogDebug($"WeathersSynced: {WeathersSynced.Value}");
		}

		private static List<GameObject> GetExistingPrefabs(NetworkManager networkManager)
		{
			List<GameObject> list = new List<GameObject>();
			foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs)
			{
				list.Add(prefab.Prefab);
			}
			return list;
		}

		private static void RegisterQueuedPrefabs(NetworkManager networkManager, List<GameObject> addedNetworkPrefabs)
		{
			int num = 0;
			foreach (GameObject queuedNetworkPrefab in queuedNetworkPrefabs)
			{
				((Logger)Logger).LogDebug("Trying To Register Prefab: " + (object)queuedNetworkPrefab);
				if (!addedNetworkPrefabs.Contains(queuedNetworkPrefab))
				{
					networkManager.AddNetworkPrefab(queuedNetworkPrefab);
					addedNetworkPrefabs.Add(queuedNetworkPrefab);
				}
				else
				{
					num++;
				}
			}
			((Logger)Logger).LogDebug("Skipped Registering " + num + " NetworkObjects As They Were Already Registered.");
		}

		protected override void __initializeVariables()
		{
			if (WeathersSynced == null)
			{
				throw new Exception("WeatherSync.WeathersSynced cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)WeathersSynced).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)WeathersSynced, "WeathersSynced");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)WeathersSynced);
			if (EffectsSynced == null)
			{
				throw new Exception("WeatherSync.EffectsSynced cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)EffectsSynced).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)EffectsSynced, "EffectsSynced");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)EffectsSynced);
			if (WeatherData == null)
			{
				throw new Exception("WeatherSync.WeatherData cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)WeatherData).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)WeatherData, "WeatherData");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)WeatherData);
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((NetworkBehaviour)this).__initializeRpcs();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "WeatherSync";
		}
	}
	public class Weather
	{
		public ImprovedWeatherEffect Effect;

		public RegistryWeatherConfig Config = new RegistryWeatherConfig();

		internal Dictionary<SelectableLevel, WeatherEffectOverride> WeatherEffectOverrides = new Dictionary<SelectableLevel, WeatherEffectOverride>();

		public string Name { get; set; }

		public virtual string NameShort
		{
			get
			{
				if (Name.Length > 5)
				{
					return Name.Substring(0, 5);
				}
				return Name;
			}
		}

		[Obsolete("Use Weather.Name instead")]
		public string name => Name;

		public LevelWeatherType VanillaWeatherType { get; internal set; } = (LevelWeatherType)(-1);


		internal WeatherOrigin Origin { get; set; } = WeatherOrigin.WeatherRegistry;


		public WeatherType Type { get; internal set; } = WeatherType.Modded;


		public TMP_ColorGradient ColorGradient { get; set; } = ColorConverter.ToTMPColorGradient(Color.cyan);


		public Color Color
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return ColorGradient.topLeft;
			}
			[Obsolete("Use Weather.ColorGradient instead")]
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				ColorGradient = ColorConverter.ToTMPColorGradient(value);
			}
		}

		public int DefaultWeight => ((ConfigHandler<int, int>)Config.DefaultWeight).Value;

		[Obsolete("Use Weather.Config.LevelFilters instead")]
		public string[] DefaultLevelFilters => ((ConfigHandler<SelectableLevel[], string>)Config.LevelFilters).DefaultValue.Split(";");

		[Obsolete("Use Weather.Config.LevelWeights instead")]
		public string[] DefaultLevelWeights => ((ConfigHandler<LevelRarity[], string>)Config.LevelWeights).DefaultValue.Split(";");

		[Obsolete("Use Weather.Config.WeatherToWeatherWeights instead")]
		public string[] DefaultWeatherToWeatherWeights => ((ConfigHandler<WeatherRarity[], string>)Config.WeatherToWeatherWeights).DefaultValue.Split(";");

		public float ScrapAmountMultiplier => ((ConfigHandler<float, float>)Config.ScrapAmountMultiplier).Value;

		public float ScrapValueMultiplier => ((ConfigHandler<float, float>)Config.ScrapValueMultiplier).Value;

		[SerializeField]
		public FilteringOption LevelFilteringOption
		{
			get
			{
				if (!((ConfigHandler<bool, bool>)Config.FilteringOption).Value)
				{
					return FilteringOption.Exclude;
				}
				return FilteringOption.Include;
			}
			[Obsolete("Use Weather.Config.FilteringOption instead")]
			set
			{
				Config.FilteringOption = new BooleanConfigHandler(value == FilteringOption.Include);
			}
		}

		public List<SelectableLevel> LevelFilters => ((ConfigHandler<SelectableLevel[], string>)Config.LevelFilters).Value.ToList();

		public Dictionary<LevelWeatherType, int> WeatherWeights => ((ConfigHandler<WeatherRarity[], string>)Config.WeatherToWeatherWeights).Value.ToDictionary((WeatherRarity rarity) => rarity.Weather.VanillaWeatherType, (WeatherRarity rarity) => rarity.Weight);

		public Dictionary<SelectableLevel, int> LevelWeights => ((ConfigHandler<LevelRarity[], string>)Config.LevelWeights).Value.ToDictionary((LevelRarity rarity) => rarity.Level, (LevelRarity rarity) => rarity.Weight);

		public virtual string ConfigCategory => ((Type == WeatherType.Vanilla || Type == WeatherType.Clear) ? "Vanilla" : "Modded") + " Weather: " + Name.Replace(" ", "") + ((Origin != WeatherOrigin.WeatherRegistry && Origin != 0) ? $" ({Origin})" : "");

		public Weather(string name = "None", ImprovedWeatherEffect effect = null)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Regex regex = new Regex("<.*?>");
			Name = regex.Replace(name, "");
			Effect = effect;
			if ((Object)(object)effect != (Object)null)
			{
				((Object)Effect).name = Name;
			}
		}

		public virtual void Init()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Config.Init(this);
			if ((Object)(object)Effect != (Object)null)
			{
				Effect.LevelWeatherType = VanillaWeatherType;
			}
			else
			{
				Plugin.logger.LogError((object)("Weather " + Name + " has no effect assigned!"));
			}
			if ((Object)(object)ColorGradient != (Object)null)
			{
				((Object)ColorGradient).name = "Weather" + GetAlphanumericName();
			}
		}

		public List<RandomWeatherWithVariables> GetRandomWeathers(SelectableLevel level)
		{
			return level.randomWeathers.Where((RandomWeatherWithVariables rw) => rw.weatherType == VanillaWeatherType).ToList();
		}

		public override string ToString()
		{
			return Name;
		}

		public void RemoveFromMoon(string moonNames)
		{
			ConfigHelper.ConvertStringToLevels(moonNames).ToList().ForEach(delegate(SelectableLevel level)
			{
				LevelFilters.Remove(level);
			});
		}

		public void RemoveFromMoon(SelectableLevel moon)
		{
			LevelFilters.Remove(moon);
		}

		public (int weight, WeatherWeightType type) GetWeightWithOrigin(SelectableLevel level)
		{
			//IL_0010: 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)
			Logger logger = WeatherCalculation.Logger;
			int item = DefaultWeight;
			WeatherWeightType weatherWeightType = WeatherWeightType.Default;
			Weather weather = WeatherManager.GetWeather(level.currentWeather);
			if (weather == null)
			{
				((Logger)logger).LogError("Previous weather is null for " + ((Object)level).name);
			}
			int value2;
			if (LevelWeights.TryGetValue(level, out var value))
			{
				weatherWeightType = WeatherWeightType.Level;
				item = value;
			}
			else if (weather.WeatherWeights.TryGetValue(VanillaWeatherType, out value2) && StartOfRound.Instance.gameStats.daysSpent != 0)
			{
				weatherWeightType = WeatherWeightType.WeatherToWeather;
				item = value2;
			}
			else
			{
				weatherWeightType = WeatherWeightType.Default;
			}
			return (item, weatherWeightType);
		}

		public int GetWeight(SelectableLevel level)
		{
			return GetWeightWithOrigin(level).weight;
		}

		public string GetAlphanumericName()
		{
			return ConfigHelper.GetAlphanumericName(this);
		}

		public (bool isWTW, int weight) GetWeatherToWeatherWeight(Weather previousWeather)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (previousWeather.WeatherWeights.TryGetValue(VanillaWeatherType, out var value))
			{
				return (true, value);
			}
			return (false, DefaultWeight);
		}

		public WeatherEffectOverride GetEffectOverride(SelectableLevel level)
		{
			if (WeatherEffectOverrides.ContainsKey(level))
			{
				return WeatherEffectOverrides[level];
			}
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "mrov.WeatherRegistry";

		public const string PLUGIN_NAME = "WeatherRegistry";

		public const string PLUGIN_VERSION = "1000.1.3";
	}
}
namespace WeatherRegistry.Utils
{
	public static class ColorConverter
	{
		public static TMP_ColorGradient ToTMPColorGradient(Color color)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			color.a = 1f;
			TMP_ColorGradient val = ScriptableObject.CreateInstance<TMP_ColorGradient>();
			val.colorMode = (ColorMode)0;
			val.topLeft = color;
			val.topRight = color;
			val.bottomLeft = color;
			val.bottomRight = color;
			return val;
		}

		public static string ToHex(Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGB(color);
		}
	}
	public abstract class ConfigHandler<T, CT> : ConfigHandler<T, CT>
	{
		public ConfigDescription _configDescription;

		public bool _enabled = true;

		public bool ConfigEntryActive
		{
			get
			{
				if (((ConfigHandler<T, CT>)this).ConfigEntry != null)
				{
					return Enabled;
				}
				return false;
			}
		}

		public bool Enabled { get; set; }
	}
	public class DynamicGradientApplier
	{
		private class GradientInfo
		{
			public string content;

			public int originalPosition;

			public TMP_ColorGradient gradient;

			public int tagLength;
		}

		public TextMeshProUGUI textComponent;

		public DynamicGradientApplier(TextMeshProUGUI textComponent)
		{
			this.textComponent = textComponent;
			base..ctor();
		}

		public void ApplyGradientsFromTags(string text)
		{
			string pattern = "<gradient=\"?([^\">]+)\"?>(.*?)</gradient>";
			MatchCollection matchCollection = Regex.Matches(text, pattern);
			if (matchCollection.Count == 0)
			{
				((TMP_Text)textComponent).text = text;
				return;
			}
			List<GradientInfo> list = new List<GradientInfo>();
			foreach (Match item in matchCollection)
			{
				string value = item.Groups[1].Value;
				string value2 = item.Groups[2].Value;
				int index = item.Index;
				TMP_ColorGradient coloredString = GetColoredString(value);
				if ((Object)(object)coloredString != (Object)null)
				{
					list.Add(new GradientInfo
					{
						content = value2,
						originalPosition = index,
						gradient = coloredString,
						tagLength = item.Length
					});
				}
			}
			string text2 = Regex.Replace(text, pattern, "$2");
			((TMP_Text)textComponent).text = text2;
			((TMP_Text)textComponent).ForceMeshUpdate(false, false);
			int num = 0;
			foreach (GradientInfo item2 in list)
			{
				int num2 = item2.originalPosition - num;
				int endChar = num2 + item2.content.Length - 1;
				ApplyGradient(num2, endChar, item2.gradient);
				int num3 = item2.tagLength - item2.content.Length;
				num += num3;
			}
		}

		private TMP_ColorGradient GetColoredString(string text)
		{
			//IL_000f: 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)
			//IL_0023: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			TMP_ColorGradient value;
			TMP_ColorGradient val = (TMP_ColorGradient)(Settings.ScreenMapColors.TryGetValue(text, out value) ? ((object)value) : ((object)new TMP_ColorGradient()));
			if ((Object)(object)val != (Object)new TMP_ColorGradient())
			{
				Color topLeft = default(Color);
				((Color)(ref topLeft))..ctor(val.topLeft.r, val.topLeft.g * 1.1f, val.topLeft.b, val.topLeft.a);
				Color topRight = default(Color);
				((Color)(ref topRight))..ctor(val.topRight.r, val.topRight.g * 1.1f, val.topRight.b, val.topRight.a);
				Color bottomLeft = default(Color);
				((Color)(ref bottomLeft))..ctor(val.bottomLeft.r, val.bottomLeft.g * 1.1f, val.bottomLeft.b, val.bottomLeft.a);
				Color bottomRight = default(Color);
				((Color)(ref bottomRight))..ctor(val.bottomRight.r, val.bottomRight.g * 1.1f, val.bottomRight.b, val.bottomRight.a);
				val = new TMP_ColorGradient
				{
					topLeft = topLeft,
					topRight = topRight,
					bottomLeft = bottomLeft,
					bottomRight = bottomRight,
					colorMode = val.colorMode,
					name = ((Object)val).name
				};
			}
			((Logger)Plugin.debugLogger).LogDebug("Picked gradient for '" + text + "': " + ((Object)val).name);
			return val;
		}

		private void ApplyGradient(int startChar, int endChar, TMP_ColorGradient gradient)
		{
			//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)
			//IL_0014: 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)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0057: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//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)
			TMP_TextInfo textInfo = ((TMP_Text)textComponent).textInfo;
			Color topLeft = gradient.topLeft;
			Color val = gradient.topRight;
			Color val2 = gradient.bottomLeft;
			Color val3 = gradient.bottomRight;
			if ((int)gradient.colorMode == 0)
			{
				topLeft = gradient.topLeft;
				val = gradient.topLeft;
				val2 = gradient.topLeft;
				val3 = gradient.topLeft;
			}
			else if ((int)gradient.colorMode == 1)
			{
				val2 = topLeft;
				val3 = val;
			}
			else if ((int)gradient.colorMode == 2)
			{
				val = topLeft;
				val3 = val2;
			}
			for (int i = startChar; i <= endChar && i < textInfo.characterCount; i++)
			{
				if (textInfo.characterInfo[i].isVisible)
				{
					int materialReferenceIndex = textInfo.characterInfo[i].materialReferenceIndex;
					int vertexIndex = textInfo.characterInfo[i].vertexIndex;
					Color32[] colors = textInfo.meshInfo[materialReferenceIndex].colors32;
					colors[vertexIndex] = Color32.op_Implicit(val2);
					colors[vertexIndex + 1] = Color32.op_Implicit(topLeft);
					colors[vertexIndex + 2] = Color32.op_Implicit(val);
					colors[vertexIndex + 3] = Color32.op_Implicit(val3);
				}
			}
			((TMP_Text)textComponent).UpdateVertexData((TMP_VertexDataUpdateFlags)16);
		}
	}
	public class WeightHandler<T, OT> : WeightHandler<T>
	{
		private Dictionary<T, OT> originDict = new Dictionary<T, OT>();

		public OT GetOrigin(T item)
		{
			if (!originDict.ContainsKey(item))
			{
				return default(OT);
			}
			return originDict[item];
		}
	}
}
namespace WeatherRegistry.Patches
{
	[HarmonyPatch(typeof(AudioReverbTrigger))]
	public class AudioReverbTriggerPatches
	{
		private static Logger logger = new Logger("AudioReverbTrigger", (LoggingType)2);

		[HarmonyTranspiler]
		[HarmonyPatch("ChangeAudioReverbForPlayer")]
		internal static IEnumerable<CodeInstruction> ChangeAudioReverbForPlayerPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			CodeMatcher val2 = val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[7]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "get_Instance", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "effects"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "get_Instance", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "currentLevelWeather"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldelem_Ref, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(WeatherEffect), "effectEnabled"), (string)null)
			});
			val2.RemoveInstructions(7);
			val2.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AudioReverbTriggerPatches), "ChangeReverbRegistryCheck", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		public static void ChangeReverbRegistryCheck(AudioReverbTrigger audioReverbTrigger)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			((Logger)logger).LogWarning("---CheckIfShouldEnable Ran!---");
			if (!((Object)(object)audioReverbTrigger == (Object)null) && audioReverbTrigger.enableCurrentLevelWeather && (int)TimeOfDay.Instance.currentLevelWeather != -1)
			{
				((Logger)logger).LogDebug($"AudioReverbTrigger: {audioReverbTrigger}");
				((Logger)logger).LogDebug($"EnableCurrentLevelWeather: {audioReverbTrigger.enableCurrentLevelWeather}");
				((Logger)logger).LogDebug($"CurrentLevelWeather: {TimeOfDay.Instance.currentLevelWeather}");
				((Logger)logger).LogWarning("Currently enabled effects: " + string.Join(", ", WeatherManager.CurrentEffectTypes));
				WeatherEffectController.EnableCurrentWeatherEffects();
			}
		}
	}
	[HarmonyPatch(typeof(EntranceTeleport))]
	internal class EntranceTeleportPatch
	{
		private static Logger logger = new Logger("EntranceTeleport", (LoggingType)2);

		[Obsolete("Use Settings.IsPlayerInside instead")]
		internal static bool isPlayerInside => Settings.IsPlayerInside;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")]
		private static void TeleportPlayerPatch(EntranceTeleport __instance)
		{
			((Logger)logger).LogDebug("TeleportPlayerPatch called with " + ((Object)__instance).name);
			Settings.IsPlayerInside = __instance.isEntranceToBuilding;
			if (Settings.IsPlayerInside)
			{
				((Logger)logger).LogDebug("Player is inside");
				return;
			}
			((Logger)logger).LogDebug("Player is outside");
			WeatherEffectController.EnableCurrentWeatherEffects();
		}
	}
	public static class EnumPatches
	{
		public static string LevelWeatherTypeEnumToStringHook(Func<Enum, string> orig, Enum self)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected I4, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected I4, but got Unknown
			if (self.GetType() == typeof(LevelWeatherType) && WeatherManager.ModdedWeatherEnumExtension.ContainsKey((int)(LevelWeatherType)(object)self))
			{
				return WeatherManager.ModdedWeatherEnumExtension[(int)(LevelWeatherType)(object)self].Name;
			}
			return orig(self);
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "Start")]
	internal class GameNetworkManagerStartPatch
	{
		[HarmonyPrefix]
		public static void GameMethodPatch(GameNetworkManager __instance)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			WeatherSync.networkManager = ((Component)__instance).GetComponent<NetworkManager>();
			GameObject val = new GameObject("WeatherRegistrySyncInnit");
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<NetworkObject>();
			byte[] value = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("weatherregistryweathersync"));
			val.GetComponent<NetworkObject>().GlobalObjectIdHash = BitConverter.ToUInt32(value, 0);
			val.AddComponent<WeatherSync>();
			val.GetComponent<NetworkObject>().DontDestroyWithOwner = true;
			val.GetComponent<NetworkObject>().SceneMigrationSynchronization = true;
			val.GetComponent<NetworkObject>().DestroyWithScene = false;
			Object.DontDestroyOnLoad((Object)(object)val);
			WeatherSync.WeatherSyncPrefab = val;
			WeatherSync.RegisterNetworkPrefab(val);
			WeatherSync.RegisterPrefabs(((Component)__instance).GetComponent<NetworkManager>());
			((Logger)Plugin.debugLogger).LogDebug("WeatherSync initialized in GameNetworkManager.Start");
		}
	}
	[HarmonyPatch(typeof(GiantKiwiAI))]
	public static class GiantKiwiAISpawnPatch
	{
		[HarmonyPatch("SpawnNestEggs")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> SpawnNestEggsTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null)
			});
			if (val.IsInvalid)
			{
				Plugin.logger.LogError((object)"Failed to find SpawnEggsClientRpc call in SpawnNestEggs!");
				return instructions;
			}
			val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldloc_2, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GiantKiwiAISpawnPatch), "AdjustEggValuesForWeather", (Type[])null, (Type[])null))
			});
			Plugin.logger.LogInfo((object)"Successfully patched SpawnNestEggs with weather multiplier adjustment!");
			return val.InstructionEnumeration();
		}

		private static void AdjustEggValuesForWeather(int[] eggScrapValues)
		{
			Weather currentLevelWeather = WeatherManager.GetCurrentLevelWeather();
			Plugin.logger.LogDebug((object)$"Adjusting {eggScrapValues.Length} eggs with weather multiplier {currentLevelWeather.ScrapValueMultiplier}");
			for (int i = 0; i < eggScrapValues.Length; i++)
			{
				int num = eggScrapValues[i];
				eggScrapValues[i] = Mathf.CeilToInt((float)eggScrapValues[i] * currentLevelWeather.ScrapValueMultiplier);
				Plugin.logger.LogDebug((object)$"Egg {i}: {num} -> {eggScrapValues[i]}");
			}
		}
	}
	public static class ImperiumPatches
	{
		public static class ImperiumMoonManagerPatches
		{
			public static bool RefreshWeatherEffectsPrefixPatch()
			{
				return false;
			}
		}

		public static class ImperiumPlayerManagerPatch
		{
			public static void TeleportPlayerPrefixPatch(TeleportPlayerRequest request)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				((Logger)Plugin.debugLogger).LogDebug($"TeleportPlayer called with playerId: {((TeleportPlayerRequest)(ref request)).PlayerId} and destination: {((TeleportPlayerRequest)(ref request)).Destination}");
				((Logger)Plugin.debugLogger).LogDebug($"Is player script inside? {StartOfRound.Instance.allPlayerScripts[((TeleportPlayerRequest)(ref request)).PlayerId].isInsideFactory}");
			}

			public static IEnumerable<CodeInstruction> TeleportPlayerTranspilerPatch(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Expected O, but got Unknown
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "get_Instance", (Type[])null, (Type[])null), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(TimeOfDay), "DisableAllWeather", (Type[])null, (Type[])null), (string)null)
				});
				val.RemoveInstructions(3);
				return val.InstructionEnumeration();
			}

			public static void TeleportPlayerPostfixPatch(TeleportPlayerRequest request)
			{
				((Logger)Plugin.debugLogger).LogDebug($"Postfix: Is player script inside? {StartOfRound.Instance.allPlayerScripts[((TeleportPlayerRequest)(ref request)).PlayerId].isInsideFactory}");
				Settings.IsPlayerInside = StartOfRound.Instance.allPlayerScripts[((TeleportPlayerRequest)(ref request)).PlayerId].isInsideFactory;
				if (Settings.IsPlayerInside)
				{
					((Logger)Plugin.debugLogger).LogDebug("Player is inside, disabling all weather effects.");
					TimeOfDay.Instance.DisableAllWeather(false);
				}
				else
				{
					((Logger)Plugin.debugLogger).LogDebug("Player is outside, enabling all weather effects.");
					WeatherEffectController.EnableCurrentWeatherEffects();
				}
			}
		}
	}
	public class LethalLibPatch
	{
		public static Dictionary<int, CustomWeather> GetLethalLibWeathers()
		{
			return Weathers.customWeathers;
		}

		public static List<Weather> ConvertLLWeathers()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, CustomWeather> lethalLibWeathers = GetLethalLibWeathers();
			List<Weather> list = new List<Weather>();
			foreach (KeyValuePair<int, CustomWeather> item in lethalLibWeathers)
			{
				CustomWeather value = item.Value;
				ImprovedWeatherEffect improvedWeatherEffect = new ImprovedWeatherEffect(value.weatherEffect.effectObject, value.weatherEffect.effectPermanentObject);
				((Object)improvedWeatherEffect).name = value.name;
				improvedWeatherEffect.SunAnimatorBool = value.weatherEffect.sunAnimatorBool;
				improvedWeatherEffect.DefaultVariable1 = value.weatherVariable1;
				improvedWeatherEffect.DefaultVariable2 = value.weatherVariable2;
				ImprovedWeatherEffect effect = improvedWeatherEffect;
				Weather weather = new Weather(value.name, effect);
				weather.VanillaWeatherType = (LevelWeatherType)item.Key;
				weather.Origin = WeatherOrigin.LethalLib;
				weather.ColorGradient = ColorConverter.ToTMPColorGradient(Defaults.LethalLibColor);
				weather.Config.DefaultWeight = new IntegerConfigHandler(50);
				weather.Config.FilteringOption = new BooleanConfigHandler(FilteringOption.Include);
				weather.Config.LevelFilters = new LevelListConfigHandler(string.Join(";", value.levels));
				Weather weather2 = weather;
				list.Add(weather2);
				WeatherManager.ModdedWeatherEnumExtension.Add(item.Key, weather2);
			}
			return list;
		}

		public static void Init()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			Plugin.logger.LogDebug((object)"Disabling LethalLib injections");
			FieldInfo field = typeof(Weathers).GetField("weatherEnumHook", BindingFlags.Static | BindingFlags.NonPublic);
			Hook val = (Hook)field.GetValue(null);
			val.Undo();
			Plugin.harmony.Patch((MethodBase)AccessTools.Method(typeof(Weathers), "RegisterLevelWeathers_StartOfRound_Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(LethalLibPatch), "StartOfRoundAwakePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Plugin.harmony.Patch((MethodBase)AccessTools.Method(typeof(Weathers), "TimeOfDay_Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(LethalLibPatch), "TimeOfDayAwakePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		internal static bool StartOfRoundAwakePrefix(orig_Awake orig, StartOfRound self)
		{
			Plugin.logger.LogDebug((object)"Skipping LethalLib StartOfRound method");
			orig.Invoke(self);
			return false;
		}

		internal static bool TimeOfDayAwakePrefix(orig_Awake orig, TimeOfDay self)
		{
			Plugin.logger.LogDebug((object)"Skipping LethalLib TimeOfDay method");
			orig.Invoke(self);
			return false;
		}
	}
	internal class LobbyCompatibilityCompatibility
	{
		public static void Init()
		{
			Plugin.logger.LogDebug((object)"LobbyCompatibility detected, registering plugin with LobbyCompatibility.");
			Version version = Version.Parse("1000.1.3");
			PluginHelper.RegisterPlugin("mrov.WeatherRegistry", version, (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	[HarmonyPatch(typeof(LungProp))]
	internal static class LungPropPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		public static bool StartPatch(LungProp __instance)
		{
			if (((CompatibilityBase)Plugin.FacilityMeltdownCompat).IsModPresent && ConfigManager.EnableMeltdownPatch.Value)
			{
				Plugin.logger.LogInfo((object)"FacilityMeltdown is present - WeatherRegistry will not run its apparatus patch.");
				return true;
			}
			if (!Settings.ScrapMultipliers)
			{
				Plugin.logger.LogInfo((object)"Skipped using WeatherRegistry's scrap multipliers.");
				return true;
			}
			UpdateScanNode(__instance);
			if (!Settings.IsGameStarted)
			{
				Plugin.logger.LogInfo((object)"Game has not been started yet, skipping WeatherRegistry's apparatus patch.");
				return true;
			}
			try
			{
				((Logger)Plugin.debugLogger).LogInfo($"ApparatusSpawnBefore: {((GrabbableObject)__instance).scrapValue}");
				Weather currentLevelWeather = WeatherManager.GetCurrentLevelWeather();
				((Logger)Plugin.debugLogger).LogInfo($"Scrap multiplier: {currentLevelWeather.ScrapValueMultiplier}");
				((GrabbableObject)__instance).SetScrapValue((int)((float)((GrabbableObject)__instance).scrapValue * currentLevelWeather.ScrapValueMultiplier));
				UpdateScanNode(__instance);
				((Logger)Plugin.debugLogger).LogInfo($"ApparatusSpawnAfter: {((GrabbableObject)__instance).scrapValue}");
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)ex.Message);
				return true;
			}
			return true;
		}

		private static void UpdateScanNode(LungProp lungProp)
		{
			ScanNodeProperties componentInChildren = ((Component)lungProp).gameObject.GetComponentInChildren<ScanNodeProperties>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.subText = "Value: $???";
			}
		}
	}
	public class NetcodePatcher
	{
		internal static void PatchNetcodeMethods()
		{
			Type[] array;
			try
			{
				array = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				List<Type> list = new List<Type>();
				foreach (Type item in ex.Types.Where((Type type) => type != null))
				{
					list.Add(item);
				}
				array = list.ToArray();
			}
			Type[] array2 = array;
			foreach (Type type2 in array2)
			{
				MethodInfo[] methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class OpeningDoorsSequencePatch
	{
		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		internal static IEnumerable<CodeInstruction> StartOfRound_openingDoorsSequence(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Expected O, but got Unknown
			//IL_030d: Unknown res