Decompiled source of WeatherRegistry v0.2.9
WeatherRegistry.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; 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 HarmonyLib; using LethalLib.Modules; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using MrovLib; using MrovLib.Events; using Newtonsoft.Json; using On; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.ProBuilder; using WeatherRegistry.Definitions; using WeatherRegistry.Events; using WeatherRegistry.Modules; using WeatherRegistry.NetcodePatcher; 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.2.9.0")] [assembly: AssemblyInformationalVersion("0.2.9+ed2eb2b34af12cadf8cd2b47948a187896db2e25")] [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_FixedString<FixedString4096Bytes>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<FixedString4096Bytes>(); } } 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; } } internal abstract class ConfigHandler<T, CT> : WeatherRegistry.Definitions.ConfigHandler<T, CT> { 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) { ((ConfigHandler<T, CT>)this).ConfigEntry = ConfigManager.configFile.Bind<CT>(weather.ConfigCategory, configTitle, ((ConfigHandler<T, CT>)this).DefaultValue, configDescription); } } internal 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) { } } internal 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) { } } internal 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) { } } internal 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) { } } internal 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) { } } internal 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(); } } public class ConfigManager { [CompilerGenerated] private static class <>O { public static Event <0>__StartupActions; public static EventHandler <1>__OnConfigChange; } internal static ConfigFile configFile; public static ConfigManager Instance { get; private set; } public static ConfigEntry<bool> LogWeatherChanges { get; private set; } public static ConfigEntry<bool> LogStartup { get; private set; } public static ConfigEntry<bool> LogStartupWeights { get; private set; } public static ConfigEntry<bool> LogWeightResolving { get; private set; } public static ConfigEntry<bool> ColoredWeathers { get; private set; } public static ConfigEntry<bool> UseWeatherWeights { get; private set; } public static ConfigEntry<bool> UseScrapMultipliers { get; private set; } private static ConfigEntry<string> SunAnimatorBlacklist { get; set; } public static SelectableLevel[] SunAnimatorBlacklistLevels { get; internal set; } public 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 in 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; 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 bool EffectEnabled { get { return _effectEnabled; } set { Plugin.logger.LogDebug((object)$"Setting effect {((Object)this).name} to {value}"); GameObject effectObject = EffectObject; if (effectObject != null) { effectObject.SetActive(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 void DisableEffect(bool permament = false) { if (permament) { EffectEnabled = false; return; } GameObject effectObject = EffectObject; if (effectObject != null) { effectObject.SetActive(false); } } public ImprovedWeatherEffect(GameObject effectObject, GameObject worldObject) { EffectObject = effectObject; WorldObject = worldObject; } public ImprovedWeatherEffect(WeatherEffect weatherEffect) { EffectObject = weatherEffect.effectObject; WorldObject = weatherEffect.effectPermanentObject; } } 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] internal RegistryWeatherConfig Config = new RegistryWeatherConfig(); [JsonIgnore] internal Dictionary<SelectableLevel, WeatherEffectOverride> WeatherEffectOverrides = new Dictionary<SelectableLevel, WeatherEffectOverride>(); internal int _defaultWeight = 100; internal float _scrapAmountMultiplier = 1f; 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; set; } = new string[1] { "Gordion" }; [Obsolete("Use Weather.Config.LevelWeights instead")] public string[] DefaultLevelWeights { get; set; } = new string[1] { "MoonName@50" }; [Obsolete("Use Weather.Config.WeatherToWeatherWeights instead")] public string[] DefaultWeatherToWeatherWeights { get; set; } = new string[1] { "WeatherName@50" }; public float ScrapAmountMultiplier { get { return ((ConfigHandler<float, float>)Config.ScrapAmountMultiplier).Value; } [Obsolete("Use Weather.Config.ScrapAmountMultiplier instead")] set { _scrapAmountMultiplier = value; } } public float ScrapValueMultiplier { get { return ((ConfigHandler<float, float>)Config.ScrapValueMultiplier).Value; } [Obsolete("Use Weather.Config.ScrapValueMultiplier instead")] set { _scrapValueMultiplier = value; } } [JsonIgnore] [field: SerializeField] public FilteringOption LevelFilteringOption { get; set; } = FilteringOption.Exclude; [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 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); Object.Instantiate<Weather>(this); } internal virtual void Init() { Config.Init(this); LevelFilteringOption = ((!Config._filteringOptionConfig.Value) ? FilteringOption.Exclude : FilteringOption.Include); ((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_0050: 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); 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 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)>(); } internal class LobbyCompatibilityCompatibility { public static void Init() { Plugin.logger.LogDebug((object)"LobbyCompatibility detected, registering plugin with LobbyCompatibility."); Version version = Version.Parse("0.2.9"); PluginHelper.RegisterPlugin("mrov.WeatherRegistry", version, (CompatibilityLevel)2, (VersionStrictness)0); } } [HarmonyPatch(typeof(StartOfRound))] internal class OpeningDoorsSequencePatch { [HarmonyILManipulator] [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static void StartOfRound_openingDoorsSequence(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction instr) => ILPatternMatchingExt.MatchStfld<StartOfRound>(instr, "shipDoorsEnabled") })) { Plugin.logger.LogError((object)"Failed IL weather hook for StartOfRound.openingDoorsSequence"); return; } Plugin.debugLogger.LogInfo((object)"IL weather hook for StartOfRound.openingDoorsSequence"); val.EmitDelegate<Action>((Action)RunWeatherPatches); val.EmitDelegate<Action>((Action)SetWeatherEffects); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction instr) => ILPatternMatchingExt.MatchLdfld<SelectableLevel>(instr, "LevelDescription") })) { Plugin.logger.LogError((object)"Failed IL hook for StartOfRound.openingDoorsSequence"); return; } val.Emit(OpCodes.Ldloc_1); val.EmitDelegate<Func<string, StartOfRound, string>>((Func<string, StartOfRound, string>)delegate(string desc, StartOfRound self) { //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)self.currentLevel.currentWeather != -1) ? WeatherManager.GetCurrentWeatherName(self.currentLevel) : "Clear"); string text2 = "WEATHER: " + text; return text2 + "\n" + desc; }); } internal static void RunWeatherPatches() { TimeOfDay.Instance.nextTimeSync = 0f; } internal static void SetWeatherEffects() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; Weather currentWeather = WeatherManager.GetCurrentWeather(currentLevel); WeatherEffectOverride effectOverride = currentWeather.GetEffectOverride(currentLevel); if (effectOverride != null) { currentWeather.Effect.EffectEnabled = false; effectOverride.OverrideEffect.EffectEnabled = true; } Plugin.logger.LogDebug((object)("Landing at " + ConfigHelper.GetNumberlessName(currentLevel) + " with weather " + JsonConvert.SerializeObject((object)currentWeather, (Formatting)0, new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1 }))); try { SunAnimator.OverrideSunAnimator(currentWeather.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!"); } ((CustomEvent<(SelectableLevel, Weather)>)(object)EventManager.ShipLanding).Invoke((currentLevel, currentWeather)); } } [BepInPlugin("mrov.WeatherRegistry", "WeatherRegistry", "0.2.9")] [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 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(); } ((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 = 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); private static WeatherSelectionAlgorithm RegistryAlgorithm = new WeatherRegistryWeatherSelection(); private static WeatherSelectionAlgorithm VanillaAlgorithm = new VanillaWeatherSelection(); public static WeatherSelectionAlgorithm weatherSelectionAlgorithm { get { if (!ConfigManager.UseWeatherWeights.Value) { return VanillaAlgorithm; } return RegistryAlgorithm; } } } 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (Settings.SelectWeathers) { WeatherManager.currentWeathers.SetWeather(level, weather); level.currentWeather = weather.VanillaWeatherType; Logger.LogDebug((object)$"Changed weather for {ConfigHelper.GetNumberlessName(level)} to {weather.VanillaWeatherType}"); ((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 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> CurrentEffectTypes => (from weather in Weathers 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) { 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); } 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 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 static GameObject WeatherSyncPrefab; private static WeatherSync _instance; public static NetworkManager networkManager; private static List<GameObject> queuedNetworkPrefabs = new List<GameObject>(); public static bool networkHasStarted = false; private string LatestWeathersReceived = ""; private static readonly string DefaultValue = "{}"; public NetworkVariable<FixedString4096Bytes> WeathersSynced = new NetworkVariable<FixedString4096Bytes>(FixedString4096Bytes.op_Implicit(DefaultValue), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); 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; } set { _instance = value; } } public string Weather { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) FixedString4096Bytes value = WeathersSynced.Value; return ((object)(FixedString4096Bytes)(ref value)).ToString(); } set { //IL_0007: Unknown result type (might be due to invalid IL or missing references) WeathersSynced.Value = new FixedString4096Bytes(value); } } public override void OnNetworkSpawn() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) ((NetworkBehaviour)this).OnNetworkSpawn(); ((Object)((Component)this).gameObject).name = "WeatherSync"; Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Plugin.logger.LogDebug((object)$"WeathersSynced: {WeathersSynced.Value}"); NetworkVariable<FixedString4096Bytes> weathersSynced = WeathersSynced; weathersSynced.OnValueChanged = (OnValueChangedDelegate<FixedString4096Bytes>)(object)Delegate.Combine((Delegate?)(object)weathersSynced.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<FixedString4096Bytes>(WeathersReceived)); } public void SetNewOnHost(string weathers) { if (!((NetworkBehaviour)StartOfRound.Instance).IsHost) { Plugin.logger.LogDebug((object)"Cannot set weathers, not a host!"); return; } Plugin.logger.LogInfo((object)("Setting new weathers: " + weathers)); Plugin.logger.LogInfo((object)string.Format("Current weathers: {0} (is null? {1}) (is empty? {2})", Weather, Weather == null, Weather == "")); Weather = weathers; } public void WeathersReceived(FixedString4096Bytes oldWeathers, FixedString4096Bytes weathers) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Plugin.logger.LogDebug((object)$"Weathers received: {weathers}"); if (WeatherManager.IsSetupFinished) { ApplyReceivedWeathers(((object)(FixedString4096Bytes)(ref weathers)).ToString()); } } public void ApplyReceivedWeathers(string weathers) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Plugin.logger.LogDebug((object)("Weathers to apply: " + weathers)); if (LatestWeathersReceived == weathers) { Plugin.logger.LogDebug((object)"Weathers are the same as last ones, skipping"); return; } if (weathers == DefaultValue) { Plugin.logger.LogDebug((object)"Weathers are not set, skipping"); return; } Dictionary<string, LevelWeatherType> dictionary = JsonConvert.DeserializeObject<Dictionary<string, LevelWeatherType>>(weathers); SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { val.currentWeather = dictionary[val.PlanetName]; } LatestWeathersReceived = weathers; WeatherManager.currentWeathers.Refresh(); StartOfRound.Instance.SetMapScreenInfoToCurrentLevel(); } 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> list = new List<GameObject>(); foreach (NetworkPrefab prefab in networkManager.NetworkConfig.Prefabs.m_Prefabs) { list.Add(prefab.Prefab); } int num = 0; foreach (GameObject queuedNetworkPrefab in queuedNetworkPrefabs) { Plugin.logger.LogDebug((object)("Trying To Register Prefab: " + (object)queuedNetworkPrefab)); if (!list.Contains(queuedNetworkPrefab)) { networkManager.AddNetworkPrefab(queuedNetworkPrefab); list.Add(queuedNetworkPrefab); } else { num++; } } Plugin.logger.LogDebug((object)("Skipped Registering " + num + " NetworkObjects As They Were Already Registered.")); networkHasStarted = true; } 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); ((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.2.9"; } } namespace WeatherRegistry.Patches { [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 WeatherManager.Weathers.Select((Weather weather) => weather.Effect)) { item.DisableEffect(deactivateObjects); } ((CustomEvent)EventManager.DisableAllWeathers).Invoke(); SunAnimator.Clear(); } } [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("WeatherRegistrySyncInit"); ((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; } } [HarmonyPatch(typeof(GameNetworkManager))] internal class ResetLobbyPatch { [HarmonyPatch("ResetSavedGameValues")] [HarmonyPrefix] public static void ResetSavedGameValuesPatch() { WeatherEffect[] effects = TimeOfDay.Instance.effects; List<WeatherEffect> list = effects.ToList(); int num; try { num = WeatherManager.ModdedWeatherEnumExtension.Keys.Min(); } catch { Plugin.logger.LogWarning((object)"No modded weather effects found"); return; } Plugin.debugLogger.LogInfo((object)$"Lowest modded index: {num}"); for (int i = num; i < effects.Length; i++) { WeatherEffect val = effects[i]; if (val != null) { list.Remove(val); } } TimeOfDay.Instance.effects = list.ToArray(); } } [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."); return; } 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).text = stringBuilder.ToString(); ((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 (!ConfigManager.ColoredWeathers.Value) { 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 { Dictionary<SelectableLevel, LevelWeatherType> weathers = WeatherCalculation.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 (!ConfigManager.UseScrapMultipliers.Value) { 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); } ((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_034e: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Invalid comparison between Unknown and I4 //IL_04c3: 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.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(Terminal))] public static class TerminalStartPatch { internal static Logger Logger = new Logger("WeatherRegistry", ConfigManager.LogStartup); internal static Logger WeightsLogger = new Logger("WeatherRegistry", ConfigManager.LogStartupWeights); internal static WeatherEffect[] vanillaEffectsArray { get; private set; } = null; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] [HarmonyPriority(800)] internal static void StartOfRoundAwakePrefix(RoundManager __instance) { Logger.LogInfo((object)"StartOfRoundAwakePrefix Patch"); if (((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().IsHost) { Logger.LogDebug((object)"Host detected, spawning WeatherSync"); WeatherSync component = Object.Instantiate<GameObject>(WeatherSync.WeatherSyncPrefab).GetComponent<WeatherSync>(); ((Component)component).GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPrefix] [HarmonyPatch("Awake")] [HarmonyPriority(800)] public static bool TerminalPrefix(Terminal __instance) { if (WeatherManager.IsSetupFinished) { WeatherManager.IsSetupFinished = false; } return true; } [HarmonyPostfix] [HarmonyPatch("Start")] [HarmonyPriority(800)] public static void Postfix(Terminal __instance) { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Expected O, but got Unknown //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Expected O, but got Unknown //IL_0842: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Expected O, but got Unknown //IL_08a7: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: Expected O, but got Unknown //IL_090c: Unknown result type (might be due to invalid IL or missing references) //IL_0916: Expected O, but got Unknown Logger.LogInfo((object)"Terminal Start Patch"); WeatherManager.Reset(); WeatherEffect[] effects = TimeOfDay.Instance.effects; List<WeatherEffect> list = effects.ToList(); if (effects == null || effects.Count() == 0) { Logger.LogInfo((object)"Effects are null"); } else { Logger.LogInfo((object)$"Effects: {effects.Count()}"); } SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { List<RandomWeatherWithVariables> list2 = val.randomWeathers.ToList(); RandomWeatherWithVariables[] randomWeathers = val.randomWeathers; foreach (RandomWeatherWithVariables val2 in randomWeathers) { if (!Enum.IsDefined(typeof(LevelWeatherType), val2.weatherType)) { list2.Remove(val2); Plugin.logger.LogDebug((object)$"Removing weather {val2.weatherType} from level {((Object)val).name}"); } } if (list2.Count != val.randomWeathers.Count()) { val.randomWeathers = list2.ToArray(); } } Logger.LogInfo((object)"Creating NoneWeather type"); Weather weather4 = new Weather("None", new ImprovedWeatherEffect(null, null)); weather4.Type = WeatherType.Clear; weather4.Color = Defaults.VanillaWeatherColors[(LevelWeatherType)(-1)]; weather4.VanillaWeatherType = (LevelWeatherType)(-1); weather4.Origin = WeatherOrigin.Vanilla; weather4.Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(Defaults.VanillaWeatherToWeatherWeights.TryGetValue((LevelWeatherType)(-1), out var value) ? (string.Join(';', value) + ";") : Defaults.DefaultWeatherToWeatherWeights); Weather weather5 = weather4; WeatherManager.Weathers.Add(weather5); WeatherManager.NoneWeather = weather5; for (int k = 0; k < effects.Count(); k++) { WeatherEffect val3 = effects[k]; Logger.LogInfo((object)("Effect: " + val3.name)); LevelWeatherType val4 = (LevelWeatherType)k; bool flag = Defaults.VanillaWeathers.Contains(val4); WeatherType type = (flag ? WeatherType.Vanilla : WeatherType.Modded); Color color = (flag ? Defaults.VanillaWeatherColors[val4] : Color.blue); ImprovedWeatherEffect effect = new ImprovedWeatherEffect(val3.effectObject, val3.effectPermanentObject) { SunAnimatorBool = val3.sunAnimatorBool }; weather4 = new Weather(((object)(LevelWeatherType)(ref val4)).ToString(), effect); weather4.Type = type; weather4.Color = color; weather4.VanillaWeatherType = val4; weather4.Origin = WeatherOrigin.Vanilla; weather4.Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler(Defaults.VanillaWeatherToWeatherWeights.TryGetValue(val4, out var value2) ? (string.Join(';', value2) + ";") : Defaults.DefaultWeatherToWeatherWeights); Weather item = weather4; WeatherManager.Weathers.Add(item); } if (Plugin.IsLethalLibLoaded) { Logger.LogDebug((object)"Getting LethalLib Weathers"); List<Weather> list3 = LethalLibPatch.ConvertLLWeathers(); foreach (Weather item3 in list3) { Logger.LogDebug((object)("LethalLib Weather: " + item3.Name)); WeatherManager.RegisteredWeathers.Add(item3); } } int biggestKeyInModdedWeathersDictionary = Enum.GetValues(typeof(LevelWeatherType)).Length - 1; if (WeatherManager.ModdedWeatherEnumExtension.Count > 0) { biggestKeyInModdedWeathersDictionary = WeatherManager.ModdedWeatherEnumExtension.Keys.Max() + 1; } Logger.LogDebug((object)(WeatherManager.ModdedWeatherEnumExtension.Count > 0)); Logger.LogDebug((object)("Biggest key in modded weathers dictionary: " + biggestKeyInModdedWeathersDictionary)); WeatherManager.RegisteredWeathers.Where((Weather weather) => weather.Origin == WeatherOrigin.WeatherRegistry).ToList().ForEach(delegate(Weather weather) { int num3 = biggestKeyInModdedWeathersDictionary; weather.VanillaWeatherType = (LevelWeatherType)num3; Logger.LogInfo((object)$"Registering weather {weather.Name} under ID {num3}"); WeatherManager.ModdedWeatherEnumExtension.Add(num3, weather); biggestKeyInModdedWeathersDictionary++; }); int num = 0; foreach (KeyValuePair<int, Weather> item4 in WeatherManager.ModdedWeatherEnumExtension) { if (item4.Key > num) { num = item4.Key; } } while (list.Count <= num) { list.Add(null); } foreach (KeyValuePair<int, Weather> item5 in WeatherManager.ModdedWeatherEnumExtension) { list[item5.Key] = new WeatherEffect { name = item5.Value.Name, effectObject = item5.Value.Effect.EffectObject, effectPermanentObject = item5.Value.Effect.WorldObject, sunAnimatorBool = item5.Value.Effect.SunAnimatorBool, effectEnabled = false, lerpPosition = false, transitioning = false }; GameObject effectObject = list[item5.Key].effectObject; if (effectObject != null) { effectObject.SetActive(false); } GameObject effectPermanentObject = list[item5.Key].effectPermanentObject; if (effectPermanentObject != null) { effectPermanentObject.SetActive(false); } } TimeOfDay.Instance.effects = list.ToArray(); List<Weather> list4 = WeatherManager.RegisteredWeathers.Distinct().ToList(); list4.Sort(delegate(Weather a, Weather b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) LevelWeatherType vanillaWeatherType = a.VanillaWeatherType; return ((Enum)(LevelWeatherType)(ref vanillaWeatherType)).CompareTo((object?)b.VanillaWeatherType); }); for (int l = 0; l < list4.Count; l++) { Logger.LogInfo((object)("Registered Weather: " + list4[l].Name)); Weather item2 = list4[l]; WeatherManager.Weathers.Add(item2); } Logger.LogDebug((object)$"Weathers: {WeatherManager.Weathers.Count}"); List<SelectableLevel> list5 = StartOfRound.Instance.levels.ToList(); foreach (Weather weather3 in WeatherManager.Weathers) { Settings.ScreenMapColors.Add(weather3.Name, weather3.Color); weather3.Init(); List<SelectableLevel> list6 = new List<SelectableLevel>(); if (weather3.LevelFilteringOption == FilteringOption.Include) { list6 = weather3.LevelFilters; } else if (weather3.LevelFilteringOption == FilteringOption.Exclude) { list6 = StartOfRound.Instance.levels.ToList(); list6.RemoveAll((SelectableLevel level) => weather3.LevelFilters.Contains(level)); } Logger.LogInfo((object)("Weather " + ((Object)weather3).name + " has " + weather3.LevelFilteringOption.ToString() + " filtering option set up")); AddWeatherToLevels(weather3, list5, list6); } ConsoleTable possibleWeathersTable = new ConsoleTable(new string[2] { "Planet", "Random weathers" }); list5.Sort((SelectableLevel a, SelectableLevel b) => ConfigHelper.GetNumberlessName(a).CompareTo(ConfigHelper.GetNumberlessName(b))); list5.ForEach(delegate(SelectableLevel level) { List<LevelWeatherType> list7 = level.randomWeathers.Select((RandomWeatherWithVariables x) => x.weatherType).ToList(); list7.Sort(); string text = JsonConvert.SerializeObject((object)list7.Select((LevelWeatherType x) => ((object)(LevelWeatherType)(ref x)).ToString()).ToList()); possibleWeathersTable.AddRow(new object[2] { ConfigHelper.GetNumberlessName(level), text }); }); Logger.LogInfo((object)("Possible weathers:\n" + possibleWeathersTable.ToMinimalString())); if (ConfigManager.LogStartupWeights.Value) { string[] second = WeatherManager.Weathers.Select((Weather weather) => weather.Name).ToArray(); ConsoleTable defaultWeightsTable = new ConsoleTable(new string[2] { "Weather", "Default weight" }); WeatherManager.Weathers.ForEach(delegate(Weather weather) { defaultWeightsTable.AddRow(new object[2] { weather.Name, ((ConfigHandler<int, int>)weather.Config.DefaultWeight).Value }); }); WeightsLogger.LogInfo((object)("Default weights:\n" + defaultWeightsTable.ToMinimalString())); string[] first = new string[1] { "From \\ To" }; first = first.Concat(second).ToArray(); ConsoleTable weatherToWeatherWeightsTable = new ConsoleTable(first); WeatherManager.Weathers.ForEach(delegate(Weather weather) { List<string> row2 = new List<string> { weather.Name }; WeatherManager.Weathers.ForEach(delegate(Weather weather2) { var (flag2, num2) = weather2.GetWeatherToWeatherWeight(weather); if (flag2) { row2.Add(num2.ToString()); } else { row2.Add("X"); } }); ConsoleTable obj2 = weatherToWeatherWeightsTable; object[] array2 = row2.ToArray(); obj2.AddRow(array2); }); WeightsLogger.LogInfo((object)("Weather-weather weights:\n" + weatherToWeatherWeightsTable.ToMinimalString())); string[] first2 = new string[1] { "Level" }; first2 = first2.Concat(second).ToArray(); ConsoleTable levelWeightsTable = new ConsoleTable(first2); list5.ForEach(delegate(SelectableLevel level) { List<string> row = new List<string> { ConfigHelper.GetNumberlessName(level) }; WeatherManager.Weathers.ForEach(delegate(Weather weather) { if (weather.LevelWeights.TryGetValue(level, out var value3)) { row.Add(value3.ToString()); } else { row.Add("X"); } }); ConsoleTable obj = levelWeightsTable; object[] array = row.ToArray(); obj.AddRow(array); }); WeightsLogger.LogInfo((object)("Level weights:\n" + levelWeightsTable.ToMinimalString())); } WeatherManager.IsSetupFinished = true; StartOfRound.Instance.SetPlanetsWeather(0); StartOfRound.Instance.SetMapScreenInfoToCurrentLevel(); if (!((NetworkBehaviour)StartOfRound.Instance).IsHost) { WeatherSync.Instance.ApplyReceivedWeathers(WeatherSync.Instance.Weather); } ((CustomEvent)EventManager.SetupFinished).Invoke(); } private static void AddWeatherToLevels(Weather weather, List<SelectableLevel> levels, List<SelectableLevel> LevelsToApply) { List<LevelWeatherVariables> list = new List<LevelWeatherVariables>(); weather.WeatherVariables.Clear(); foreach (SelectableLevel level in levels) { Logger.LogDebug((object)("Level: " + ConfigHelper.GetNumberlessName(level) + ", weather: " + weather.Name)); List<RandomWeatherWithVariables> randomWeathers2 = level.randomWeathers.ToList(); LevelWeather levelWeather = new LevelWeather { Weather = weather, Level = level, Variables = new LevelWeatherVariables() }; RandomWeatherWithVariables val = null; val = ((IEnumerable<RandomWeatherWithVariables>)level.randomWeathers).FirstOrDefault((Func<RandomWeatherWithVariables, bool>)((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType == weather.VanillaWeatherType)); if (!InitializeRandomWeather(ref val, weather, level, ref randomWeathers2, LevelsToApply)) { Logger.LogDebug((object)"randomWeather is null, skipping"); continue; } levelWeather.Variables.Level = level; levelWeather.Variables.WeatherVariable1 = val?.weatherVariable ?? 1; levelWeather.Variables.WeatherVariable2 = val?.weatherVariable2 ?? 1; WeatherManager.LevelWeathers.Add(levelWeather); list.Add(levelWeather.Variables); weather.WeatherVariables.Add(level, levelWeather.Variables); } static bool InitializeRandomWeather(ref RandomWeatherWithVariables randomWeather, Weather weather, SelectableLevel level, ref List<RandomWeatherWithVariables> randomWeathers, List<SelectableLevel> LevelsToApply) { //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown if (randomWeather == null && weather.Type == WeatherType.Vanilla) { return false; } if (weather.Type == WeatherType.Clear) { randomWeathers.RemoveAll((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType == weather.VanillaWeatherType); level.randomWeathers = randomWeathers.ToArray(); return false; } if (level.PlanetName == "71 Gordion" && !LevelsToApply.Contains(level)) { Logger.LogDebug((object)("Removing weather " + weather.Name + " from the company moon")); randomWeathers.RemoveAll((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType == weather.VanillaWeatherType); level.randomWeathers = randomWeathers.ToArray(); return false; } switch (weather.Type) { case WeatherType.Vanilla: if (!LevelsToApply.Contains(level)) { Logger.LogDebug((object)("Level " + ((Object)level).name + " is not in the list of levels to apply weather to")); if (randomWeather != null) { Logger.LogDebug((object)("Removing weather " + weather.Name + " from level " + ((Object)level).name)); randomWeathers.RemoveAll((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType == weather.VanillaWeatherType); level.randomWeathers = randomWeathers.ToArray(); } return false; } return true; case WeatherType.Modded: { if (randomWeather != null) { Logger.LogDebug((object)("Removing weather " + weather.Name + " from level " + ((Object)level).name + " (added before lobby reload)")); randomWeathers.RemoveAll((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType == weather.VanillaWeatherType); } Logger.LogDebug((object)("Adding modded weather " + weather.Name)); if (!LevelsToApply.Contains(level)) { Logger.LogDebug((object)("Level " + ((Object)level).name + " is not in the list of levels to apply weather to")); return false; } Logger.LogDebug((object)$"Injecting modded weather {weather.Name} for level {((Object)level).name} (variables {weather.Effect.DefaultVariable1}/{weather.Effect.DefaultVariable2})"); RandomWeatherWithVariables item = (randomWeather = new RandomWeatherWithVariables { weatherType = weather.VanillaWeatherType, weatherVariable = weather.Effect.DefaultVariable1, weatherVariable2 = weather.Effect.DefaultVariable2 }); randomWeathers.Add(item); level.randomWeathers = randomWeathers.ToArray(); break; } } return true; } } } } namespace WeatherRegistry.Modules { public class RegistryWeatherConfig { [JsonIgnore] internal IntegerConfigHandler DefaultWeight = new IntegerConfigHandler(Defaults.DefaultWeight); [JsonIgnore] internal FloatConfigHandler ScrapAmountMultiplier = new FloatConfigHandler(Defaults.ScrapAmountMultiplier); [JsonIgnore] internal FloatConfigHandler ScrapValueMultiplier = new FloatConfigHandler(Defaults.ScrapValueMultiplier); [JsonIgnore] internal ConfigEntry<bool> _filteringOptionConfig; [JsonIgnore] internal LevelListConfigHandler LevelFilters = new LevelListConfigHandler(string.Join(';', Defaults.DefaultLevelFilters) + ";"); [JsonIgnore] internal LevelWeightsConfigHandler LevelWeights = new LevelWeightsConfigHandler(string.Join(';', Defaults.DefaultLevelWeights) + ";"); [JsonIgnore] internal WeatherWeightsConfigHandler WeatherToWeatherWeights = new WeatherWeightsConfigHandler(string.Join(';', Defaults.DefaultWeatherToWeatherWeights) + ";"); public void Init(Weather weather) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown DefaultWeight.SetConfigEntry(weather, "Default weight", new ConfigDescription("The default weight of this weather", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); ScrapAmountMultiplier.SetConfigEntry(weather, "Scrap amount multiplier", new ConfigDescription("Multiplier for the amount of scrap spawned", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); ScrapValueMultiplier.SetConfigEntry(weather, "Scrap value multiplier", new ConfigDescription("Multiplier for the value of scrap spawned", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); _filteringOptionConfig = ConfigManager.configFile.Bind<bool>(weather.ConfigCategory, "Filtering option", weather.LevelFilteringOption == FilteringOption.Include, "Whether to make the filter a whitelist (false is blacklist, true is whitelist)"); LevelFilters.SetConfigEntry(weather, "Level filter", new ConfigDescription("Semicolon-separated list of level names to filter", (AcceptableValueBase)null, Array.Empty<object>())); LevelWeights.SetConfigEntry(weather, "Level weights", new ConfigDescription("Semicolon-separated list of level weights", (AcceptableValueBase)null, Array.Empty<object>())); WeatherToWeatherWeights.SetConfigEntry(weather, "WeatherToWeather weights", new ConfigDescription("Semicolon-separated list of weather-to-weather weights - if previous day was " + weather.Name + ", next day should have weights:", (AcceptableValueBase)null, Array.Empty<object>())); } } } namespace WeatherRegistry.Events { public class WeatherRegistryEvent<T> : CustomEvent<T> { } public class WeatherRegistryEvent : CustomEvent { } } namespace WeatherRegistry.Definitions { public abstract class ConfigHandler<T, CT> : ConfigHandler<T, CT> { public ConfigDescription _configDescription; public bool _enabled = true; public bool ConfigEntryActive { get { if (((ConfigHandler<T, CT>)this).ConfigEntry != null) { return Enabled; } return false; } } public bool Enabled { get { return _enabled; } set { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown _enabled = value; if (((ConfigHandler<T, CT>)this).ConfigEntry != null) { if (!Enabled) { _configDescription = new ConfigDescription((Enabled ? "" : "**This setting has been disabled by the mod developer and won't take any effect.**\n") + _configDescription.Description, _configDescription.AcceptableValues, Array.Empty<object>()); } ConfigEntry<CT> configEntry = ((ConfigHandler<T, CT>)this).ConfigEntry; ConfigManager.configFile.Remove(((ConfigEntryBase)((ConfigHandler<T, CT>)this).ConfigEntry).Definition); ((ConfigHandler<T, CT>)this).ConfigEntry = ConfigManager.configFile.Bind<CT>(((ConfigEntryBase)configEntry).Definition.Section, ((ConfigEntryBase)configEntry).Definition.Key, ((ConfigHandler<T, CT>)this).DefaultValue, _configDescription); } } } } public class CurrentWeathers { private Dictionary<SelectableLevel, LevelWeatherType> _currentWeathers = new Dictionary<SelectableLevel, LevelWeatherType>(); public Dictionary<SelectableLevel, LevelWeatherType> Entries { get { return _currentWeathers; } internal set { _currentWeathers = value; } } public string SerializedEntries { get { Dictionary<string, LevelWeatherType> dictionary = _currentWeathers.ToDictionary((KeyValuePair<SelectableLevel, LevelWeatherType> pair) => pair.Key.PlanetName, (KeyValuePair<SelectableLevel, LevelWeatherType> pair) => pair.Value); return JsonConvert.SerializeObject((object)dictionary); } } public void Initialize() { _currentWeathers = new Dictionary<SelectableLevel, LevelWeatherType>(); } public void Refresh() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) Plugin.debugLogger.LogDebug((object)"Refreshing current weathers"); List<SelectableLevel> levels = GetLevels(); Clear(); foreach (Selectabl