Decompiled source of WeatherRegistry v0.3.11

WeatherRegistry.dll

Decompiled a day 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 JLL.Components;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using MrovLib;
using MrovLib.Compatibility;
using MrovLib.Events;
using Newtonsoft.Json;
using On;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.ProBuilder;
using WeatherRegistry.Compatibility;
using WeatherRegistry.Definitions;
using WeatherRegistry.Events;
using WeatherRegistry.Modules;
using WeatherRegistry.NetcodePatcher;
using WeatherRegistry.Networking;
using WeatherRegistry.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("WeatherRegistry")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Weather API for Lethal Company.")]
[assembly: AssemblyFileVersion("0.3.11.0")]
[assembly: AssemblyInformationalVersion("0.3.11+a22f190d46f5e8135ca9976c46cf9d72d10d7857")]
[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]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<WeatherSyncDataWrapper>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<WeatherSyncDataWrapper>();
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<WeatherEffectSyncData>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<WeatherEffectSyncData>();
	}
}
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.Definitions.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>(weather.ConfigCategory, configTitle, ((ConfigHandler<T, CT>)this).DefaultValue, configDescription);
				return;
			}
			((ConfigHandler<T, CT>)this).ConfigEntry = null;
			Plugin.debugLogger.LogDebug((object)("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>(configCategory, configTitle, ((ConfigHandler<T, CT>)this).DefaultValue, configDescription);
				return;
			}
			((ConfigHandler<T, CT>)this).ConfigEntry = null;
			Plugin.debugLogger.LogDebug((object)("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)
		{
		}
	}
	internal class ConfigHelper
	{
		private static Logger logger = new Logger("WeatherRegistry", ConfigManager.LogWeightResolving);

		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(((Object)weather).name.ToLowerInvariant(), weather);
					Weathers.TryAdd(weather.Name.ToLowerInvariant(), weather);
					Weathers.TryAdd(GetAlphanumericName(weather).ToLowerInvariant(), weather);
				});
				_weathersDictionary = Weathers;
				return Weathers;
			}
			set
			{
				_weathersDictionary = value;
			}
		}

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

		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[] 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);
			List<NameRarity> list = new List<NameRarity>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(':');
				if (array3.Length == 2 && int.TryParse(array3[1], out var result))
				{
					list.Add(new NameRarity
					{
						Name = array3[0],
						Weight = result
					});
				}
			}
			return list.ToArray();
		}

		public static LevelRarity[] ConvertStringToLevelRarities(string str)
		{
			string[] array = ConvertStringToArray(str);
			List<LevelRarity> list = new List<LevelRarity>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split('@');
				if (array3.Length != 2 || !int.TryParse(array3[1], out var result))
				{
					continue;
				}
				SelectableLevel[] array4 = StringResolver.ResolveStringToLevels(array3[0]);
				SelectableLevel[] array5 = array4;
				foreach (SelectableLevel val in array5)
				{
					if (!((Object)(object)val == (Object)null))
					{
						list.Add(new LevelRarity
						{
							Level = val,
							Weight = result
						});
					}
				}
			}
			return list.ToArray();
		}

		public static WeatherRarity[] ConvertStringToWeatherWeights(string str)
		{
			string[] array = ConvertStringToArray(str);
			List<WeatherRarity> list = new List<WeatherRarity>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split('@');
				if (array3.Length == 2 && int.TryParse(array3[1], out var result))
				{
					Weather weather = ResolveStringToWeather(array3[0]);
					if (!((Object)(object)weather == (Object)null))
					{
						list.Add(new WeatherRarity
						{
							Weather = weather,
							Weight = result
						});
					}
				}
			}
			return list.ToArray();
		}
	}
	internal class ConfigManager
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Event <0>__StartupActions;

			public static EventHandler <1>__OnConfigChange;
		}

		internal static ConfigFile configFile;

		internal static ConfigManager Instance { get; private set; }

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

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

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

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

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

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

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

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

		internal static ConfigEntry<string> SunAnimatorBlacklist { get; set; }

		internal static SelectableLevel[] SunAnimatorBlacklistLevels { get; set; }

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

		private ConfigManager(ConfigFile config)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			configFile = config;
			WeatherRegistryEvent setupFinished = EventManager.SetupFinished;
			object obj = <>O.<0>__StartupActions;
			if (obj == null)
			{
				Event val = StartupActions;
				<>O.<0>__StartupActions = val;
				obj = (object)val;
			}
			((CustomEvent)setupFinished).AddListener((Event)obj);
			LogWeatherChanges = configFile.Bind<bool>("|Debugging", "Log Weather Changes", true, "Log weather changes to console");
			LogStartup = configFile.Bind<bool>("|Debugging", "Log Startup", true, "Log startup information to console");
			LogStartupWeights = configFile.Bind<bool>("|Debugging", "Log Startup Weights", true, "Log all defined weights during startup");
			LogWeightResolving = configFile.Bind<bool>("|Debugging", "Log Weight Resolving", true, "Log weight resolving to console");
			ColoredWeathers = configFile.Bind<bool>("|General", "Colored Weathers", true, "Enable colored weathers on map screen");
			PlanetVideos = configFile.Bind<bool>("|General", "Planet Videos", false, "Display planet videos on map screen");
			UseWeatherWeights = configFile.Bind<bool>("|General", "Weather weights", true, "Use weights for selecting weathers. Disable if you want to use vanilla algorithm.");
			UseScrapMultipliers = configFile.Bind<bool>("|General", "Scrap multipliers", true, "Use Registry's scrap multipliers. Disable if you prefer to use other mod's multiplier settings.");
			SunAnimatorBlacklist = configFile.Bind<string>("|SunAnimator", "Blacklist", "Asteroid-13;", "Semicolon-separated list of level names to blacklist from being patched by sun animator");
		}

		private static void OnConfigChange(object sender, EventArgs eventArgs)
		{
			SunAnimatorBlacklistLevels = ConfigHelper.ConvertStringToLevels(SunAnimatorBlacklist.Value);
		}

		internal static void StartupActions()
		{
			SunAnimatorBlacklistLevels = ConfigHelper.ConvertStringToLevels(SunAnimatorBlacklist.Value);
			SunAnimatorBlacklist.SettingChanged += OnConfigChange;
		}
	}
	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.41f, 1f, 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 = "Gordion";

		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/WeatherEffect", order = 10)]
	public class ImprovedWeatherEffect : ScriptableObject
	{
		[JsonIgnore]
		public GameObject EffectObject;

		[JsonIgnore]
		public GameObject WorldObject;

		private bool _effectEnabled;

		[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; set; } = (LevelWeatherType)(-1);


		public virtual bool EffectEnabled
		{
			get
			{
				return _effectEnabled;
			}
			set
			{
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				Plugin.logger.LogDebug((object)$"Setting effect {((Object)this).name} to {value}");
				Plugin.logger.LogDebug((object)$"Is player inside? {EntranceTeleportPatch.isPlayerInside}");
				if (!EntranceTeleportPatch.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)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			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)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			EffectObject = weatherEffect.effectObject;
			WorldObject = weatherEffect.effectPermanentObject;
			GameObject effectObject = EffectObject;
			if (effectObject != null)
			{
				effectObject.SetActive(false);
			}
			GameObject worldObject = WorldObject;
			if (worldObject != null)
			{
				worldObject.SetActive(false);
			}
		}
	}
	public enum WeatherType
	{
		Clear,
		Vanilla,
		Modded
	}
	public enum WeatherOrigin
	{
		Vanilla,
		WeatherRegistry,
		LethalLib,
		LethalLevelLoader,
		WeatherTweaks
	}
	public enum FilteringOption
	{
		Include,
		Exclude
	}
	[JsonObject(/*Could not decode attribute arguments.*/)]
	[CreateAssetMenu(fileName = "Weather", menuName = "WeatherRegistry/WeatherDefinition", order = 5)]
	public class Weather : ScriptableObject
	{
		[JsonProperty]
		public string Name;

		[JsonIgnore]
		public ImprovedWeatherEffect Effect;

		[JsonIgnore]
		public Dictionary<SelectableLevel, LevelWeatherVariables> WeatherVariables = new Dictionary<SelectableLevel, LevelWeatherVariables>();

		[JsonIgnore]
		public AnimationClip AnimationClip;

		[JsonIgnore]
		public RegistryWeatherConfig Config = new RegistryWeatherConfig();

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

		[Obsolete("Use Weather.Config.DefaultWeight instead")]
		internal int _defaultWeight = 100;

		[Obsolete("Use Weather.Config.ScrapAmountMultiplier instead")]
		internal float _scrapAmountMultiplier = 1f;

		[Obsolete("Use Weather.Config.ScrapValueMultiplier instead")]
		internal float _scrapValueMultiplier = 1f;

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


		[JsonIgnore]
		internal WeatherOrigin Origin { get; set; } = WeatherOrigin.WeatherRegistry;


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


		[field: SerializeField]
		public Color Color { get; set; } = Color.cyan;


		[SerializeField]
		public int DefaultWeight
		{
			get
			{
				return ((ConfigHandler<int, int>)Config.DefaultWeight).Value;
			}
			[Obsolete("Use Weather.Config.DefaultWeight instead")]
			set
			{
				_defaultWeight = value;
			}
		}

		[Obsolete("Use Weather.Config.LevelFilters instead")]
		public string[] DefaultLevelFilters
		{
			get
			{
				return ((ConfigHandler<SelectableLevel[], string>)Config.LevelFilters).DefaultValue.Split(";");
			}
			set
			{
				Config.LevelFilters = new LevelListConfigHandler(value);
			}
		}

		[Obsolete("Use Weather.Config.LevelWeights instead")]
		public string[] DefaultLevelWeights
		{
			get
			{
				return ((ConfigHandler<LevelRarity[], string>)Config.LevelWeights).DefaultValue.Split(";");
			}
			set
			{
				Config.LevelWeights = new LevelWeightsConfigHandler(value);
			}
		}

		[Obsolete("Use Weather.Config.WeatherToWeatherWeights instead")]
		public string[] DefaultWeatherToWeatherWeights
		{
			get
			{
				return ((ConfigHandler<WeatherRarity[], string>)Config.WeatherToWeatherWeights).DefaultValue.Split(";");
			}
			set
			{
				Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(value);
			}
		}

		public float ScrapAmountMultiplier
		{
			get
			{
				return ((ConfigHandler<float, float>)Config.ScrapAmountMultiplier).Value;
			}
			[Obsolete("Use Weather.Config.ScrapAmountMultiplier instead")]
			set
			{
				Config.ScrapAmountMultiplier = new FloatConfigHandler(value);
			}
		}

		public float ScrapValueMultiplier
		{
			get
			{
				return ((ConfigHandler<float, float>)Config.ScrapValueMultiplier).Value;
			}
			[Obsolete("Use Weather.Config.ScrapValueMultiplier instead")]
			set
			{
				Config.ScrapValueMultiplier = new FloatConfigHandler(value);
			}
		}

		[SerializeField]
		[JsonIgnore]
		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);
			}
		}

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

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

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

		internal virtual string ConfigCategory => ((Type == WeatherType.Vanilla || Type == WeatherType.Clear) ? "Vanilla" : "Modded") + " Weather: " + ((Object)this).name + ((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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)("Called Weather constructor for weather " + name));
			Regex regex = new Regex("<.*?>");
			Name = regex.Replace(name, "");
			((Object)this).name = regex.Replace(name, "");
			Effect = effect;
			if ((Object)(object)effect != (Object)null)
			{
				((Object)Effect).name = name;
			}
			Object.DontDestroyOnLoad((Object)(object)this);
		}

		internal 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;
			}
			((Object)this).hideFlags = (HideFlags)61;
		}

		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 GetWeight(SelectableLevel level)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Logger logger = WeatherCalculation.Logger;
			int num = DefaultWeight;
			Weather weather = WeatherManager.GetWeather(level.currentWeather);
			if ((Object)(object)weather == (Object)null)
			{
				logger.LogError((object)("Previous weather is null for " + ((Object)level).name));
			}
			int value2;
			if (LevelWeights.TryGetValue(level, out var value))
			{
				logger.LogDebug((object)$"{Name} has level weight {value}");
				num = value;
			}
			else if (weather.WeatherWeights.TryGetValue(VanillaWeatherType, out value2) && StartOfRound.Instance.gameStats.daysSpent != 0)
			{
				logger.LogDebug((object)$"{Name} has weather>weather weight {value2}");
				num = value2;
			}
			else
			{
				logger.LogDebug((object)$"{Name} has default weight {num}");
			}
			return num;
		}

		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 class LevelWeatherVariables
	{
		public SelectableLevel Level;

		public int WeatherVariable1;

		public int WeatherVariable2;
	}
	public class LevelWeather : LevelWeatherVariables
	{
		public Weather Weather;

		public LevelWeatherVariables Variables;
	}
	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)>();
	}
	[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 result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Expected O, but got Unknown
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Expected O, but got Unknown
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Expected O, but got Unknown
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Expected O, but got Unknown
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			CodeMatcher val2 = val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[19]
			{
				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.Ldloc_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StartOfRound), "currentLevel"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SelectableLevel), "currentWeather"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldelem_Ref, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Stloc_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_2, (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),
				new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(WeatherEffect), "effectPermanentObject"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Object), "op_Inequality", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldloc_2, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(WeatherEffect), "effectPermanentObject"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null)
			});
			val2.RemoveInstructions(19);
			CodeMatcher val3 = val2.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)
			});
			val3.RemoveInstructions(7);
			val3.Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(OpeningDoorsSequencePatch), "RunWeatherPatches", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(OpeningDoorsSequencePatch), "SetWeatherEffects", (Type[])null, (Type[])null))
			});
			val3.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(StartOfRound), "currentLevel"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SelectableLevel), "LevelDescription"), (string)null)
			}).Advance(3).Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(OpeningDoorsSequencePatch), "ModifyDescription", (Type[])null, (Type[])null))
			});
			return val.InstructionEnumeration();
		}

		private static string ModifyDescription(string description, StartOfRound instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			string text = (((int)instance.currentLevel.currentWeather != -1) ? WeatherManager.GetCurrentWeatherName(instance.currentLevel) : "Clear");
			string text2 = "WEATHER: " + text;
			Plugin.logger.LogDebug((object)text2);
			return text2 + "\n" + description;
		}

		internal static void RunWeatherPatches()
		{
			TimeOfDay.Instance.nextTimeSync = 0f;
		}

		internal static void SetWeatherEffects()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			Weather currentWeather = WeatherManager.GetCurrentWeather(currentLevel);
			if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				WeatherSync.Instance.SetWeatherEffectOnHost(currentWeather.VanillaWeatherType);
			}
			Plugin.logger.LogDebug((object)("Landing at " + ConfigHelper.GetNumberlessName(currentLevel) + " with weather " + JsonConvert.SerializeObject((object)currentWeather, (Formatting)0, new JsonSerializerSettings
			{
				ReferenceLoopHandling = (ReferenceLoopHandling)1
			})));
			((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).Invoke((currentLevel, currentWeather));
		}
	}
	[BepInPlugin("mrov.WeatherRegistry", "WeatherRegistry", "0.3.11")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "mrov.WeatherRegistry";

		internal static ManualLogSource logger;

		internal static Logger debugLogger = new Logger("mrov.WeatherRegistry", (ConfigEntry<bool>)null);

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

		internal static bool IsLethalLibLoaded = false;

		internal static JLLCompat JLLCompat;

		internal static LobbyControlCompat LobbyControlCompat;

		internal static Hook WeatherTypeEnumHook;

		private void Awake()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			ConfigManager.Init(((BaseUnityPlugin)this).Config);
			SunAnimator.Init();
			if (Chainloader.PluginInfos.ContainsKey("evaisa.lethallib"))
			{
				IsLethalLibLoaded = true;
				LethalLibPatch.Init();
			}
			else
			{
				logger.LogInfo((object)"LethalLib not detected!");
			}
			WeatherTypeEnumHook = new Hook((MethodBase)typeof(Enum).GetMethod("ToString", Array.Empty<Type>()), typeof(WeatherManager).GetMethod("LevelWeatherTypeEnumHook"));
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LobbyCompatibilityCompatibility.Init();
			}
			JLLCompat = new JLLCompat("JacobG5.JLL");
			LobbyControlCompat = new LobbyControlCompat("mattymatty.LobbyControl");
			LobbyControlCompat.Init();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin mrov.WeatherRegistry is loaded!");
		}
	}
	public class Settings
	{
		public static Dictionary<string, Color> ScreenMapColors = new Dictionary<string, Color>();

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


		public static WeatherSelectionAlgorithm WeatherSelectionAlgorithm { get; set; } = ConfigManager.UseWeatherWeights.Value ? WeatherCalculation.RegistryAlgorithm : WeatherCalculation.VanillaAlgorithm;


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


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


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


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

	}
	public class WeatherCalculation
	{
		internal class WeatherRegistryWeatherSelection : WeatherSelectionAlgorithm
		{
			public override Dictionary<SelectableLevel, LevelWeatherType> SelectWeathers(int connectedPlayersOnServer, StartOfRound startOfRound)
			{
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: 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_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				if (!((NetworkBehaviour)startOfRound).IsHost)
				{
					Logger.LogInfo((object)"Not a host, cannot generate weathers!");
					return null;
				}
				previousDayWeather.Clear();
				Dictionary<SelectableLevel, LevelWeatherType> dictionary = new Dictionary<SelectableLevel, LevelWeatherType>();
				Random random = GetRandom(startOfRound);
				List<SelectableLevel> list = startOfRound.levels.ToList();
				Logger.LogDebug((object)("Levels: " + string.Join(';', list.Select((SelectableLevel level) => level.PlanetName))));
				foreach (SelectableLevel item in list)
				{
					previousDayWeather[item.PlanetName] = item.currentWeather;
					Logger.LogMessage((object)"-------------");
					Logger.LogMessage((object)(item.PlanetName ?? ""));
					Logger.LogDebug((object)$"previousDayWeather: {previousDayWeather[item.PlanetName]}");
					if (item.overrideWeather)
					{
						Logger.LogMessage((object)$"Override weather present, changing weather to {item.overrideWeatherType}");
						Weather weather = WeatherManager.GetWeather(item.overrideWeatherType);
						dictionary[item] = weather.VanillaWeatherType;
						((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.WeatherChanged).Invoke((item, weather));
					}
					else
					{
						dictionary[item] = (LevelWeatherType)(-1);
						WeightHandler<Weather> planetWeightedList = WeatherManager.GetPlanetWeightedList(item);
						Weather weather2 = planetWeightedList.Random();
						dictionary[item] = weather2.VanillaWeatherType;
						((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.WeatherChanged).Invoke((item, weather2));
						Logger.LogMessage((object)("Selected weather: " + weather2.Name));
						Logger.LogMessage((object)$"Chance for that was {planetWeightedList.Get(weather2)} / {planetWeightedList.Sum} ({(float)planetWeightedList.Get(weather2) / (float)planetWeightedList.Sum * 100f}%)");
					}
				}
				Logger.LogMessage((object)"-------------");
				return dictionary;
			}
		}

		internal class VanillaWeatherSelection : WeatherSelectionAlgorithm
		{
			public override Dictionary<SelectableLevel, LevelWeatherType> SelectWeathers(int connectedPlayersOnServer, StartOfRound startOfRound)
			{
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<SelectableLevel, LevelWeatherType> vanillaSelectedWeather = new Dictionary<SelectableLevel, LevelWeatherType>();
				Random random = GetRandom(startOfRound);
				List<SelectableLevel> list = startOfRound.levels.ToList();
				float num = 1f;
				if (connectedPlayersOnServer + 1 > 1 && startOfRound.daysPlayersSurvivedInARow > 2 && startOfRound.daysPlayersSurvivedInARow % 3 == 0)
				{
					num = (float)random.Next(15, 25) / 10f;
				}
				int num2 = Mathf.Clamp((int)((double)Mathf.Clamp(startOfRound.planetsWeatherRandomCurve.Evaluate((float)random.NextDouble()) * num, 0f, 1f) * (double)startOfRound.levels.Length), 0, startOfRound.levels.Length);
				list.ForEach(delegate(SelectableLevel level)
				{
					vanillaSelectedWeather[level] = (LevelWeatherType)(-1);
				});
				Logger.LogMessage((object)"Selected vanilla algorithm - weights are not being used!");
				Logger.LogMessage((object)$"Picking weathers for {num2} moons:");
				Logger.LogMessage((object)"-------------");
				for (int i = 0; i < num2; i++)
				{
					SelectableLevel val = list[random.Next(0, list.Count)];
					if (val.randomWeathers != null && val.randomWeathers.Length != 0)
					{
						vanillaSelectedWeather[val] = val.randomWeathers[random.Next(0, val.randomWeathers.Length)].weatherType;
						Logger logger = Logger;
						string planetName = val.PlanetName;
						LevelWeatherType val2 = vanillaSelectedWeather[val];
						logger.LogMessage((object)("Selected weather for " + planetName + ": " + ((object)(LevelWeatherType)(ref val2)).ToString()));
					}
					else
					{
						Logger.LogDebug((object)("Cannot pick weather for " + val.PlanetName));
					}
					list.Remove(val);
				}
				Logger.LogMessage((object)"-------------");
				return vanillaSelectedWeather;
			}
		}

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

		public static Logger Logger = new Logger("WeatherRegistry", ConfigManager.LogWeatherChanges);

		internal static WeatherSelectionAlgorithm RegistryAlgorithm = new WeatherRegistryWeatherSelection();

		internal static WeatherSelectionAlgorithm VanillaAlgorithm = new VanillaWeatherSelection();

		[Obsolete("Use Settings.WeatherSelectionAlgorithm instead")]
		public static WeatherSelectionAlgorithm WeatherSelectionAlgorithm
		{
			get
			{
				return Settings.WeatherSelectionAlgorithm;
			}
			set
			{
				Settings.WeatherSelectionAlgorithm = value;
			}
		}
	}
	public static class WeatherController
	{
		private static ManualLogSource Logger = new ManualLogSource("WeatherController");

		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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.SelectWeathers)
			{
				level.currentWeather = weather.VanillaWeatherType;
				Logger.LogDebug((object)$"Changed weather for {ConfigHelper.GetNumberlessName(level)} to {weather.VanillaWeatherType}");
				if (!StartOfRound.Instance.inShipPhase)
				{
					Logger.LogDebug((object)"Ship has already landed, only changing weather effects");
					SetWeatherEffects(weather);
				}
				else
				{
					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)
			//IL_003e: 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.LogWarning((object)$"Adding random weather {val.weatherType} to {alphanumericName}");
				WeatherManager.GetWeather(val.weatherType).WeatherVariables[level] = new LevelWeatherVariables
				{
					Level = level,
					WeatherVariable1 = val.weatherVariable,
					WeatherVariable2 = val.weatherVariable2
				};
			}
		}

		public static void AddRandomWeather(SelectableLevel level, RandomWeatherWithVariables randomWeather)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			List<RandomWeatherWithVariables> list = level.randomWeathers.ToList();
			list.Add(randomWeather);
			level.randomWeathers = list.ToArray();
			WeatherManager.GetWeather(randomWeather.weatherType).WeatherVariables[level] = new LevelWeatherVariables
			{
				Level = level,
				WeatherVariable1 = randomWeather.weatherVariable,
				WeatherVariable2 = randomWeather.weatherVariable2
			};
		}

		public static void RemoveRandomWeather(SelectableLevel level, RandomWeatherWithVariables randomWeather)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			List<RandomWeatherWithVariables> list = level.randomWeathers.ToList();
			list.Remove(randomWeather);
			level.randomWeathers = list.ToArray();
			WeatherManager.GetWeather(randomWeather.weatherType).WeatherVariables.Remove(level);
		}

		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 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 (EntranceTeleportPatch.isPlayerInside)
				{
					Plugin.logger.LogWarning((object)"Player is inside, not setting time of day effect");
				}
				else if (TimeOfDay.Instance.effects[weatherType] != null)
				{
					Plugin.debugLogger.LogDebug((object)$"Setting time of day effect {weatherType} to {enabled}");
					TimeOfDay.Instance.effects[weatherType].effectEnabled = enabled;
				}
			}
		}

		public static void SetWeatherEffects(Weather weather)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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)
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			DisableWeatherEffects();
			if ((Object)(object)weather == (Object)null)
			{
				return;
			}
			if ((int)weather.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)weather.VanillaWeatherType == -1)
			{
				SunAnimator.OverrideSunAnimator(weather.VanillaWeatherType);
				return;
			}
			if (((CompatibilityBase)Plugin.JLLCompat).IsModPresent)
			{
				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);
					}
					return;
				}
			}
			WeatherEffectOverride effectOverride = weather.GetEffectOverride(currentLevel);
			if (effectOverride == null)
			{
				weather.Effect.EffectEnabled = true;
				SetTimeOfDayEffect(weather.VanillaWeatherType, enabled: true);
			}
			else
			{
				weather.Effect.EffectEnabled = false;
				effectOverride.OverrideEffect.EffectEnabled = true;
			}
			try
			{
				SunAnimator.OverrideSunAnimator(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 weatherType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Weather weather = WeatherManager.GetWeather(weatherType);
			SetWeatherEffects(weather);
		}

		public static void DisableWeatherEffects()
		{
			foreach (WeatherEffectOverride weatherEffectOverride in WeatherManager.WeatherEffectOverrides)
			{
				weatherEffectOverride.OverrideEffect.DisableEffect(permament: true);
			}
			foreach (ImprovedWeatherEffect item in WeatherManager.Weathers.Select((Weather weather) => weather.Effect))
			{
				item.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<LevelWeather> LevelWeathers { get; internal set; } = new List<LevelWeather>();


		public static List<WeatherEffectOverride> WeatherEffectOverrides { get; internal set; } = new List<WeatherEffectOverride>();


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


		public static Weather NoneWeather { get; internal set; }

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

		[Obsolete("Use WeatherManager.CurrentWeathers instead")]
		public static CurrentWeathers currentWeathers => CurrentWeathers;

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

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

		public static Weather GetWeather(LevelWeatherType levelWeatherType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Weathers.Find((Weather weather) => weather.VanillaWeatherType == levelWeatherType);
		}

		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);
					Object.Destroy((Object)(object)weather);
				}
			});
			LevelWeathers.Clear();
			Weathers.Clear();
			ModdedWeatherEnumExtension.Clear();
			WeatherEffectOverrides.Clear();
			CurrentWeathers.Clear();
			Settings.ScreenMapColors.Clear();
			ConfigHelper.StringToWeather = null;
			RegisteredWeathers.RemoveAll((Weather weather) => weather.Origin != WeatherOrigin.WeatherRegistry && weather.Origin != WeatherOrigin.WeatherTweaks);
		}

		public static string LevelWeatherTypeEnumHook(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) && ModdedWeatherEnumExtension.ContainsKey((int)(LevelWeatherType)(object)self))
			{
				return ((Object)ModdedWeatherEnumExtension[(int)(LevelWeatherType)(object)self]).name;
			}
			return orig(self);
		}

		internal static List<LevelWeatherType> GetPlanetPossibleWeathers(SelectableLevel level)
		{
			List<LevelWeatherType> list = (from randomWeather in level.randomWeathers
				where (int)randomWeather.weatherType != -1
				select randomWeather into x
				select x.weatherType).Distinct().ToList();
			list.Insert(0, (LevelWeatherType)(-1));
			Plugin.logger.LogDebug((object)("Possible weathers: " + string.Join("; ", list.Select((LevelWeatherType x) => ((object)(LevelWeatherType)(ref x)).ToString()))));
			if (list == null || list.Count() == 0)
			{
				Plugin.logger.LogError((object)"Level's random weathers are null");
				return new List<LevelWeatherType>();
			}
			return list;
		}

		public static WeightHandler<Weather> GetPlanetWeightedList(SelectableLevel level)
		{
			//IL_003a: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			WeightHandler<Weather> val = new WeightHandler<Weather>();
			Logger logger = WeatherCalculation.Logger;
			List<LevelWeatherType> planetPossibleWeathers = GetPlanetPossibleWeathers(level);
			if (planetPossibleWeathers == null || planetPossibleWeathers.Count() == 0)
			{
				Plugin.logger.LogError((object)"Level's random weathers are null");
				return val;
			}
			foreach (LevelWeatherType item in planetPossibleWeathers)
			{
				Weather weather = GetWeather(item);
				int weight = weather.GetWeight(level);
				val.Add(weather, weight);
			}
			return val;
		}

		public static Weather GetCurrentWeather(SelectableLevel level)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (CurrentWeathers.Contains(level))
			{
				return CurrentWeathers.GetLevelWeather(level);
			}
			return GetWeather(level.currentWeather);
		}

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

		public static string GetCurrentWeatherName(SelectableLevel level)
		{
			return GetCurrentWeather(level).Name;
		}

		internal static AnimationClip GetWeatherAnimationClip(LevelWeatherType weatherType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return GetWeather(weatherType).AnimationClip;
		}

		public static WeatherEffectOverride GetCurrentWeatherOverride(SelectableLevel level, Weather weather)
		{
			weather.WeatherEffectOverrides.TryGetValue(level, out var value);
			return value;
		}
	}
	internal class WeatherSync : NetworkBehaviour
	{
		public NetworkVariable<WeatherSyncDataWrapper> WeathersSynced = new NetworkVariable<WeatherSyncDataWrapper>(new WeatherSyncDataWrapper
		{
			Weathers = Array.Empty<WeatherSyncData>()
		}, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		public NetworkVariable<WeatherEffectSyncData> EffectsSynced = new NetworkVariable<WeatherEffectSyncData>(new WeatherEffectSyncData
		{
			WeatherType = (LevelWeatherType)(-1)
		}, (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 WeatherEffectSyncData Effects
		{
			get
			{
				return EffectsSynced.Value;
			}
			set
			{
				//IL_0011: 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)
				EffectsSynced.Value = new WeatherEffectSyncData
				{
					WeatherType = value.WeatherType
				};
			}
		}

		public static WeatherSync Instance
		{
			get
			{
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = Object.FindObjectOfType<WeatherSync>();
					if ((Object)(object)_instance == (Object)null)
					{
						Plugin.logger.LogError((object)"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<WeatherEffectSyncData> effectsSynced = EffectsSynced;
			effectsSynced.OnValueChanged = (OnValueChangedDelegate<WeatherEffectSyncData>)(object)Delegate.Combine((Delegate?)(object)effectsSynced.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<WeatherEffectSyncData>(WeatherEffectData.EffectsReceived));
		}

		public void SetNewOnHost(Dictionary<string, LevelWeatherType> weathers)
		{
			if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				Plugin.logger.LogDebug((object)"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_0027: 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)
			if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				Plugin.logger.LogDebug((object)"Cannot set effects, not a host!");
				return;
			}
			Effects = new WeatherEffectSyncData
			{
				WeatherType = weatherType
			};
		}

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

		internal static void RegisterPrefabs(NetworkManager networkManager)
		{
			Plugin.logger.LogDebug((object)"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);
			Plugin.logger.LogDebug((object)$"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)
			{
				Plugin.logger.LogDebug((object)("Trying To Register Prefab: " + (object)queuedNetworkPrefab));
				if (!addedNetworkPrefabs.Contains(queuedNetworkPrefab))
				{
					networkManager.AddNetworkPrefab(queuedNetworkPrefab);
					addedNetworkPrefabs.Add(queuedNetworkPrefab);
				}
				else
				{
					num++;
				}
			}
			Plugin.logger.LogDebug((object)("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);
			((NetworkBehaviour)this).__initializeVariables();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "WeatherSync";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WeatherRegistry";

		public const string PLUGIN_NAME = "WeatherRegistry";

		public const string PLUGIN_VERSION = "0.3.11";
	}
}
namespace WeatherRegistry.Patches
{
	[HarmonyPatch(typeof(AudioReverbTrigger))]
	public class AudioReverbTriggerPatches
	{
		[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
			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);
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(EntranceTeleport))]
	internal class EntranceTeleportPatch
	{
		internal static Logger logger = new Logger("EntranceTeleport", (ConfigEntry<bool>)null);

		internal static bool isPlayerInside = false;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")]
		private static void TeleportPlayerPatch(EntranceTeleport __instance)
		{
			logger.LogDebug((object)("TeleportPlayerPatch called with " + ((Object)__instance).name));
			isPlayerInside = __instance.isEntranceToBuilding;
			if (isPlayerInside)
			{
				logger.LogDebug((object)"Player is inside");
				return;
			}
			logger.LogDebug((object)"Player is outside");
			WeatherEffectController.EnableCurrentWeatherEffects();
		}
	}
	[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>());
			Plugin.logger.LogDebug((object)"WeatherSync initialized in GameNetworkManager.Start");
		}
	}
	public class LethalLibPatch
	{
		public static Dictionary<int, CustomWeather> GetLethalLibWeathers()
		{
			return Weathers.customWeathers;
		}

		public static List<Weather> ConvertLLWeathers()
		{
			//IL_00a4: 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)
				{
					VanillaWeatherType = (LevelWeatherType)item.Key,
					Origin = WeatherOrigin.LethalLib,
					Color = Defaults.LethalLibColor,
					Config = 
					{
						DefaultWeight = new IntegerConfigHandler(50)
					}
				};
				list.Add(weather);
				WeatherManager.ModdedWeatherEnumExtension.Add(item.Key, weather);
			}
			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("0.3.11");
			PluginHelper.RegisterPlugin("mrov.WeatherRegistry", version, (CompatibilityLevel)2, (VersionStrictness)0);
		}
	}
	[HarmonyPatch(typeof(LungProp))]
	internal static class LungPropPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("DisconnectFromMachinery")]
		public static void DisconnectFromMachineryPatch(LungProp __instance)
		{
			if (((NetworkBehaviour)__instance).IsHost)
			{
				Weather currentLevelWeather = WeatherManager.GetCurrentLevelWeather();
				((GrabbableObject)__instance).SetScrapValue((int)((float)((GrabbableObject)__instance).scrapValue * currentLevelWeather.ScrapValueMultiplier));
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class ResetLobbyPatch
	{
		[HarmonyPatch("ResetSavedGameValues")]
		[HarmonyPrefix]
		public static void ResetSavedGameValuesPatch()
		{
			Plugin.logger.LogDebug((object)"Removing all save entries made by WeatherRegistry");
			WeatherManager.CurrentWeathers.Clear();
			for (int i = 0; i <= 100; i++)
			{
				string text = $"{Defaults.WeatherSaveKey}-{i}";
				if (ES3.KeyExists(text, GameNetworkManager.Instance.currentSaveFileName))
				{
					ES3.DeleteKey(text, GameNetworkManager.Instance.currentSaveFileName);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class SetMapScreenInfoToCurrentLevelPatch
	{
		[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		internal static void GameMethodPatch(ref TextMeshProUGUI ___screenLevelDescription, ref SelectableLevel ___currentLevel, StartOfRound __instance)
		{
			if (!WeatherManager.IsSetupFinished)
			{
				Plugin.logger.LogWarning((object)"WeatherManager is not set up yet.");
			}
			else if (Settings.MapScreenOverride)
			{
				Regex regex = new Regex("\\n{2,}");
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("ORBITING: " + ___currentLevel.PlanetName + "\n");
				stringBuilder.Append("WEATHER: " + GetColoredString(___currentLevel) + "\n");
				stringBuilder.Append(regex.Replace(___currentLevel.LevelDescription, "\n") ?? "");
				((TMP_Text)___screenLevelDescription).fontWeight = (FontWeight)700;
				((TMP_Text)___screenLevelDescription).SetText(stringBuilder.ToString(), true);
				if (!Settings.PlanetVideos)
				{
					((Behaviour)__instance.screenLevelVideoReel).enabled = false;
				}
				((CustomEvent<(SelectableLevel, Weather, string)>)(object)EventManager.MapScreenUpdated).Invoke((___currentLevel, WeatherManager.GetCurrentWeather(___currentLevel), stringBuilder.ToString()));
			}
		}

		private static string GetDisplayWeatherString(SelectableLevel level, Weather weather)
		{
			return weather.Name;
		}

		private static string GetColoredString(SelectableLevel level)
		{
			Weather currentWeather = WeatherManager.GetCurrentWeather(level);
			string displayWeatherString = GetDisplayWeatherString(level, currentWeather);
			if (!Settings.ColoredWeathers)
			{
				return displayWeatherString;
			}
			string outputString = "";
			Regex regex = new Regex("(\\/)|(\\?)|(>)|(\\+)");
			regex.Split(displayWeatherString).ToList().ForEach(delegate(string word)
			{
				//IL_001d: 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)
				string text = word.Trim();
				Color value;
				string text2 = ColorUtility.ToHtmlStringRGB(Settings.ScreenMapColors.TryGetValue(text, out value) ? value : Color.black);
				outputString += ((text2 != "000000") ? ("<color=#" + text2 + ">" + word + "</color>") : (text ?? ""));
			});
			return outputString;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class SetPlanetsWeatherPatch
	{
		[HarmonyPatch("SetPlanetsWeather")]
		[HarmonyPrefix]
		public static bool GameMethodPatch(int connectedPlayersOnServer, StartOfRound __instance)
		{
			Plugin.logger.LogDebug((object)"SetPlanetsWeather called.");
			if (!WeatherManager.IsSetupFinished)
			{
				Plugin.logger.LogWarning((object)"WeatherManager is not set up yet.");
				return false;
			}
			if (!Settings.SelectWeathers)
			{
				Plugin.logger.LogDebug((object)"Weather selection is disabled.");
				return true;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				Plugin.logger.LogWarning((object)"Instance is null");
				return true;
			}
			Plugin.logger.LogInfo((object)$"Picking weathers on day {StartOfRound.Instance.gameStats.daysSpent}, file {GameNetworkManager.Instance.currentSaveFileName}");
			if (((NetworkBehaviour)__instance).IsHost)
			{
				string text = $"{Defaults.WeatherSaveKey}-{StartOfRound.Instance.gameStats.daysSpent}";
				bool flag = ES3.KeyExists(text, GameNetworkManager.Instance.currentSaveFileName);
				Plugin.logger.LogInfo((object)$"Save file has weather data: {flag}");
				if (flag)
				{
					Plugin.logger.LogInfo((object)$"Loading picked weathers from save: day {StartOfRound.Instance.gameStats.daysSpent}, file {GameNetworkManager.Instance.currentSaveFileName}");
					Plugin.logger.LogDebug((object)("Weathers: " + ES3.Load<string>(text, GameNetworkManager.Instance.currentSaveFileName)));
					WeatherManager.CurrentWeathers.SetWeathersFromStringDictionary(ES3.Load<string>(text, GameNetworkManager.Instance.currentSaveFileName));
				}
				else
				{
					Plugin.debugLogger.LogDebug((object)("Weather selection algorithm: " + Settings.WeatherSelectionAlgorithm.GetType().Name));
					Dictionary<SelectableLevel, LevelWeatherType> weathers = Settings.WeatherSelectionAlgorithm.SelectWeathers(connectedPlayersOnServer, __instance);
					WeatherManager.CurrentWeathers.SetWeathers(weathers);
				}
				ES3.Save<string>(text, WeatherManager.CurrentWeathers.SerializedEntries, GameNetworkManager.Instance.currentSaveFileName);
				Plugin.logger.LogDebug((object)$"Saved picked weathers: day {StartOfRound.Instance.gameStats.daysSpent}, file {GameNetworkManager.Instance.currentSaveFileName}");
			}
			((CustomEvent<int>)EventManager.DayChanged).Invoke(__instance.gameStats.daysSpent);
			return false;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class SpawnScrapInLevelPatches
	{
		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyAfter(new string[] { "com.github.fredolx.meteomultiplier", "DarthLilo.WeatherBonuses" })]
		[HarmonyPriority(0)]
		[HarmonyPrefix]
		private static void ChangeMultipliers(RoundManager __instance)
		{
			if (!Settings.ScrapMultipliers)
			{
				Plugin.logger.LogDebug((object)"Skipped using WeatherRegistry's scrap multipliers.");
				return;
			}
			Weather currentWeather = WeatherManager.GetCurrentWeather(__instance.currentLevel);
			__instance.scrapValueMultiplier = currentWeather.ScrapValueMultiplier * 0.4f;
			__instance.scrapAmountMultiplier = currentWeather.ScrapAmountMultiplier;
		}

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyPostfix]
		[HarmonyPriority(800)]
		private static void LogMultipliers(RoundManager __instance)
		{
			Plugin.logger.LogInfo((object)$"Spawned scrap in level with multipliers: {__instance.scrapValueMultiplier} (value), {__instance.scrapAmountMultiplier} (amount)");
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("OnDisable")]
		[HarmonyPrefix]
		public static void DisableWeathersPatch()
		{
			foreach (Weather weather in WeatherManager.Weathers)
			{
				weather.Effect.DisableEffect(permament: true);
			}
			HUDManager.Instance.increaseHelmetCondensation = false;
			HUDManager.Instance.HelmetCondensationDrops();
			((CustomEvent)EventManager.DisableAllWeathers).Invoke();
		}
	}
	internal class SunAnimator
	{
		public class AnimationClipOverrides : List<KeyValuePair<AnimationClip, AnimationClip>>
		{
			public AnimationClip this[string name]
			{
				get
				{
					return Find((KeyValuePair<AnimationClip, AnimationClip> x) => ((Object)x.Key).name.Equals(name)).Value;
				}
				set
				{
					int num = FindIndex((KeyValuePair<AnimationClip, AnimationClip> x) => ((Object)x.Key).name.Equals(name));
					if (num != -1)
					{
						base[num] = new KeyValuePair<AnimationClip, AnimationClip>(base[num].Key, value);
					}
				}
			}

			public AnimationClipOverrides(int capacity)
				: base(capacity)
			{
			}
		}

		internal static ManualLogSource logger = Logger.CreateLogSource("WeatherRegistry SunAnimator");

		internal static Dictionary<string, LevelWeatherType> vanillaBools = new Dictionary<string, LevelWeatherType>
		{
			{
				"",
				(LevelWeatherType)(-1)
			},
			{
				"overcast",
				(LevelWeatherType)2
			},
			{
				"eclipse",
				(LevelWeatherType)5
			}
		};

		internal static Dictionary<LevelWeatherType, string> clipNames = new Dictionary<LevelWeatherType, string>
		{
			{
				(LevelWeatherType)(-1),
				""
			},
			{
				(LevelWeatherType)2,
				"Stormy"
			},
			{
				(LevelWeatherType)5,
				"Eclipse"
			}
		};

		internal static List<string> animatorControllerBlacklist = new List<string>(1) { "SunAnimContainerCompanyLevel" };

		internal static AnimatorOverrideController animatorOverrideController;

		public static void Init()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			Harmony val = new Harmony("WeatherRegistry.SunAnimator");
			val.Patch((MethodBase)AccessTools.Method(typeof(Animator), "SetBool", new Type[2]
			{
				typeof(string),
				typeof(bool)
			}, (Type[])null), new HarmonyMethod(typeof(SunAnimator), "SetBoolStringPatch", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			logger.LogDebug((object)"Patching Animator.SetBool(string, bool)");
		}

		public static bool SetBoolPatch(Animator __instance, object nameOrId, bool value)
		{
			return true;
		}

		public static bool SetBoolStringPatch(Animator __instance, string name, bool value)
		{
			return SetBoolPatch(__instance, name, value);
		}

		public static void OverrideSunAnimator(LevelWeatherType weatherType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Invalid comparison between Unknown and I4
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			Plugin.logger.LogDebug((object)"OverrideSunAnimator called");
			if (ConfigManager.SunAnimatorBlacklistLevels.Contains(StartOfRound.Instance.currentLevel))
			{
				logger.LogDebug((object)$"Current level {StartOfRound.Instance.currentLevel} is blacklisted");
			}
			if ((Object)(object)TimeOfDay.Instance.sunAnimator == (Object)null)
			{
				logger.LogDebug((object)"sunAnimator is null, skipping");
				return;
			}
			AnimatorClipInfo[] currentAnimatorClipInfo = TimeOfDay.Instance.sunAnimator.GetCurrentAnimatorClipInfo(0);
			if (currentAnimatorClipInfo.Length == 0)
			{
				logger.LogDebug((object)"There are no SunAnimator clips, skipping");
				return;
			}
			logger.LogInfo((object)("Current clip: " + ((Object)((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip).name));
			string name = ((Object)TimeOfDay.Instance.sunAnimator.runtimeAnimatorController).name;
			logger.LogInfo((object)$"animatorControllerName: {name}, weatherType: {weatherType}");
			if (animatorControllerBlacklist.Contains(name))
			{
				logger.LogDebug((object)("TimeOfDay.Instance.sunAnimator controller " + name + " is blacklisted"));
				return;
			}
			if ((Object)(object)animatorOverrideController == (Object)null)
			{
				animatorOverrideController = new AnimatorOverrideController(TimeOfDay.Instance.sunAnimator.runtimeAnimatorController)
				{
					name = name + "override"
				};
			}
			AnimationClipOverrides clipOverrides = new AnimationClipOverrides(animatorOverrideController.overridesCount);
			logger.LogDebug((object)$"Overrides: {animatorOverrideController.overridesCount}");
			animatorOverrideController.GetOverrides((List<KeyValuePair<AnimationClip, AnimationClip>>)clipOverrides);
			List<AnimationClip> list = animatorOverrideController.runtimeAnimatorController.animationClips.ToList();
			Dictionary<LevelWeatherType, AnimationClip> clips = new Dictionary<LevelWeatherType, AnimationClip>();
			Weather weather = WeatherManager.GetWeather(weatherType);
			try
			{
				AnimationClip val = list.Find((AnimationClip clip) => ((Object)clip).name.Contains(clipNames[(LevelWeatherType)5]));
				AnimationClip val2 = list.Find((AnimationClip clip) => ((Object)clip).name.Contains(clipNames[(LevelWeatherType)2]));
				AnimationClip val3 = list.Find((AnimationClip clip) => !((Object)clip).name.Contains(clipNames[(LevelWeatherType)2]) && !((Object)clip).name.Contains(clipNames[(LevelWeatherType)5]));
				clips = new Dictionary<LevelWeatherType, AnimationClip>
				{
					{
						(LevelWeatherType)5,
						val
					},
					{
						(LevelWeatherType)2,
						val2
					},
					{
						(LevelWeatherType)4,
						val2
					},
					{
						(LevelWeatherType)3,
						val2
					},
					{
						(LevelWeatherType)1,
						val2
					},
					{
						(LevelWeatherType)(-1),
						val3
					}
				};
				if ((Object)(object)WeatherManager.GetWeatherAnimationClip(weatherType) != (Object)null)
				{
					AnimationClip weatherAnimationClip = WeatherManager.GetWeatherAnimationClip(weatherType);
					ArrayUtility.Add<AnimationClip>(TimeOfDay.Instance.sunAnimator.runtimeAnimatorController.animationClips, weatherAnimationClip);
					list.Add(weatherAnimationClip);
					clips[weatherType] = weatherAnimationClip;
					logger.LogInfo((object)$"Added animation clip for weather type {weatherType}");
					TimeOfDay.Instance.sunAnimator.runtimeAnimatorController.animationClips.ToList().ForEach(delegate(AnimationClip clip)
					{
						logger.LogInfo((object)("clip: " + ((Object)clip).name));
					});
				}
				else if (weather.Type == WeatherType.Clear)
				{
					logger.LogDebug((object)("Weather is " + weather.Name + ", setting clip to None"));
					clips[weatherType] = val3;
				}
				else if (weather.Type != WeatherType.Vanilla)
				{
					logger.LogDebug((object)$"No custom animation clip found for weather type {weatherType}");
					logger.LogDebug((object)"Trying to apply vanilla animator bool");
					if (!vanillaBools.TryGetValue(weather.Effect.SunAnimatorBool, out var _))
					{
						logger.LogInfo((object)$"No vanilla bool found for weather type {weatherType}");
						return;
					}
					clips[weatherType] = clips[vanillaBools[weather.Effect.SunAnimatorBool]];
				}
				if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
				{
					return;
				}
			}
			catch (Exception ex)
			{
				logger.LogWarning((object)("Detected a null clip: " + ex.Message));
				return;
			}
			logger.LogDebug((object)$"Clips: {clips.Count}");
			if (clips.Keys.Select((LevelWeatherType key) => key == weatherType).Count() == 0)
			{
				logger.LogDebug((object)$"No animation clip found for weather type {weatherType}");
				return;
			}
			AnimationClip value2;
			string text = (clips.TryGetValue(weatherType, out value2) ? ((Object)value2).name : null);
			if (text == null)
			{
				logger.LogDebug((object)$"No animation clip found for weather type {weatherType}");
				return;
			}
			clips.ToList().ForEach(delegate(KeyValuePair<LevelWeatherType, AnimationClip> clipPair)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				if (clipPair.Key != weatherType)
				{
					clipOverrides[((Object)clipPair.Value).name] = clips[weatherType];
					logger.LogDebug((object)("Setting override from " + ((Object)clipPair.Value).name + " to " + ((Object)clips[weatherType]).name));
				}
				else
				{
					clipOverrides[((Object)clipPair.Value).name] = null;
					logger.LogDebug((object)("Setting override from " + ((Object)clipPair.Value).name + " to null"));
				}
			});
			logger.LogDebug((object)string.Format("Current bools: {0} {1}", TimeOfDay.Instance.sunAnimator.GetBool("overcast"), TimeOfDay.Instance.sunAnimator.GetBool("eclipsed")));
			if ((int)weatherType != -1)
			{
				animatorOverrideController.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)clipOverrides);
				TimeOfDay.Instance.sunAnimator.runtimeAnimatorController = (RuntimeAnimatorController)(object)animatorOverrideController;
			}
			else
			{
				TimeOfDay.Instance.sunAnimator.runtimeAnimatorController = animatorOverrideController.runtimeAnimatorController;
			}
			logger.LogInfo((object)("Current clip: " + ((Object)((AnimatorClipInfo)(ref TimeOfDay.Instance.sunAnimator.GetCurrentAnimatorClipInfo(0)[0])).clip).name));
		}

		internal static void LogOverrides(AnimationClipOverrides clipOverrides)
		{
			logger.LogDebug((object)$"Overrides: {clipOverrides.Count}");
			clipOverrides.ToList().ForEach(delegate(KeyValuePair<AnimationClip, AnimationClip> clip)
			{
				logger.LogInfo((object)("overrideclip " + (Object.op_Implicit((Object)(object)clip.Key) ? ((Object)clip.Key).name : "null") + " : " + (Object.op_Implicit((Object)(object)clip.Value) ? ((Object)clip.Value).name : "null")));
			});
		}

		internal static void Clear()
		{
			animatorOverrideController = null;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	public static class TimeOfDayPatch
	{
		internal static ManualLogSource logger = Logger.CreateLogSource("WeatherRegistry TimeOfDay");

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TimeOfDay), "DisableAllWeather")]
		private static void DisableAllWeatherPatch(TimeOfDay __instance, bool deactivateObjects)
		{
			logger.LogDebug((object)"Disabling all weather");
			if (!deactivateObjects)
			{
				return;
			}
			logger.LogDebug((object)"DecativateObjects is true");
			foreach (ImprovedWeatherEffect item in from weather in WeatherManager.Weathers
				where (Object)(object)weather.Effect != (Object)null
				select weather.Effect)
			{
				item.DisableEffect(deactivateObjects);
			}
			((CustomEvent)EventManager.DisableAllWeathers).Invoke();
			SunAnimator.Clear();
			EntranceTeleportPatch.isPlayerInside = false;
			WeatherSync.Instance.SetWeatherEffectOnHost((LevelWeatherType)(-1));
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public static class TerminalStartPatch
	{
		internal static Logger Logger = new Logger("WeatherRegistry", ConfigManager.LogStartup);

		internal static Logger WeightsLogger