Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Combined Weathers Toolkit v1.1.1
CombinedWeathersToolkit.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CombinedWeathersToolkit.Toolkit; using CombinedWeathersToolkit.Toolkit.Core; using CombinedWeathersToolkit.Utils; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using TMPro; using Unity.Netcode; using UnityEngine; using WeatherRegistry; using WeatherRegistry.Definitions; using WeatherRegistry.Managers; using WeatherRegistry.Modules; using WeatherRegistry.Patches; using WeatherRegistry.Utils; using WeatherTweaks; using WeatherTweaks.Definitions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: IgnoresAccessChecksTo("WeatherTweaks")] [assembly: AssemblyCompany("CombinedWeathersToolkit")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9ac909c1ccc0d75ad5a60c7dcb4739e0f9894898")] [assembly: AssemblyProduct("CombinedWeathersToolkit")] [assembly: AssemblyTitle("CombinedWeathersToolkit")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace CombinedWeathersToolkit { internal class Config { public readonly ConfigEntry<bool> AllowConfigRegistery; public readonly ConfigEntry<bool> AllowJsonRegistery; public readonly ConfigEntry<bool> RegisterPredefinedWeathers; public readonly ConfigEntry<float> PredefinedWeathersWeightModifier; public readonly ConfigEntry<string> WeatherConfigCreatorString; public readonly ConfigEntry<string> WeatherConfigCreatorExample; public readonly ConfigEntry<bool> DebugLogsEnabled; public readonly ConfigEntry<bool> DebugCommandsEnabled; public readonly ConfigEntry<string> UniqueWeatherAlgorithm; public readonly List<string> WeatherConfigCreatorList = new List<string>(); public Config(ConfigFile cfg) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown cfg.SaveOnConfigSet = false; AllowConfigRegistery = cfg.Bind<bool>("General", "Allow config registery", true, "Allow the mod to register any combined weather effects that are created in the config."); AllowJsonRegistery = cfg.Bind<bool>("General", "Allow json registery", true, "Allow the mod to register any combined weather effects that are created with .json files."); RegisterPredefinedWeathers = cfg.Bind<bool>("Predefined weathers", "Register predefined combined weathers", true, "If true, some predefined combined weather effects will be registered by this mod without the need of manually creating them."); PredefinedWeathersWeightModifier = cfg.Bind<float>("Predefined weathers", "Global weight modifier", 0.2f, new ConfigDescription("If 'Register predefined combined weathers' is true, this config will dynamically update the weight of all predefined combined weathers based on this value which will act as a multiplier.\nIf you want all predefined weathers to spawn more often then enter a bigger value here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); DebugLogsEnabled = cfg.Bind<bool>("Debug", "Debug logs", false, "Enable more explicit logs in the console (for debug reasons)."); DebugCommandsEnabled = cfg.Bind<bool>("Debug", "Debug commands", false, "Enable debug commands in the game's chat (for debug reasons)."); UniqueWeatherAlgorithm = cfg.Bind<string>("Misc", "Unique weather Algorithm", "", "When filled by a valid weather name, this config will override the WeatherTweaks weather algorithm to force spawn the selected weather every day on every moons."); WeatherConfigCreatorString = cfg.Bind<string>("Config weathers", "Weather Config creator", "", "Comma separated list of combined/progressing weather effects that will be used to register new weathers from the config."); WeatherConfigCreatorExample = cfg.Bind<string>("Config weathers", "Example", "Eclipsed + Foggy : Eclipsed : Foggy,Solar Storm: color(#ff0000) : solarflare : stormy,Enemies infestation: color(red) : Eclipsed : forsaken : blood moon : type(progressing)", "This is an example config that explains how to register new combined weathers with the 'Weather Config creator' config.\nFollow the format in the example to write your own weather in 'Weather Config creator'."); cfg.Save(); cfg.SaveOnConfigSet = true; } public void SetupCustomConfigs() { Compatibility.CheckInstalledPlugins(); if (!Compatibility.WeatherRegisteryInstalled) { Plugin.logger.LogError((object)"WeatherRegistery is not installed! Please install WeatherRegistery before using this mod."); } if (!Compatibility.WeatherTweaksInstalled) { Plugin.logger.LogError((object)"WeatherTweaks is not installed! Please install WeatherTweaks before using this mod."); } if (AllowConfigRegistery.Value) { PopulateWeatherConfigCreatorList(); } } private void PopulateWeatherConfigCreatorList() { if (string.IsNullOrWhiteSpace(WeatherConfigCreatorString.Value)) { return; } foreach (string item in from s in WeatherConfigCreatorString.Value.Split(',') select s.Trim()) { WeatherConfigCreatorList.Add(item); } } } [BepInPlugin("zigzag.combinedweatherstoolkit", "Combined_Weathers_Toolkit", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private const string GUID = "zigzag.combinedweatherstoolkit"; private const string NAME = "Combined_Weathers_Toolkit"; private const string VERSION = "1.1.1"; public static Plugin instance; public static ManualLogSource logger; private readonly Harmony harmony = new Harmony("zigzag.combinedweatherstoolkit"); internal static List<string> installedWeathers = new List<string>(); internal static Config config { get; private set; } = null; internal static void DebugLog(object message) { if (config.DebugLogsEnabled.Value) { logger.LogWarning(message); } } private void Awake() { instance = this; logger = ((BaseUnityPlugin)this).Logger; config = new Config(((BaseUnityPlugin)this).Config); config.SetupCustomConfigs(); harmony.PatchAll(); logger.LogInfo((object)"Combined_Weathers_Toolkit is loaded !"); } } } namespace CombinedWeathersToolkit.Utils { internal class Compatibility { public static bool WeatherRegisteryInstalled; public static bool WeatherTweaksInstalled; public static void CheckInstalledPlugins() { WeatherRegisteryInstalled = IsPluginInstalled("mrov.WeatherRegistry"); WeatherTweaksInstalled = IsPluginInstalled("WeatherTweaks"); } private static bool IsPluginInstalled(string pluginGUID, string? pluginVersion = null) { return Chainloader.PluginInfos.ContainsKey(pluginGUID) && (pluginVersion == null || new Version(pluginVersion).CompareTo(Chainloader.PluginInfos[pluginGUID].Metadata.Version) <= 0); } } internal class Effects { public static void ChangeWeather(string weatherNameResolvable) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ChangeWeather(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType); } public static void ChangeWeather(LevelWeatherType weather) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) StartOfRound.Instance.currentLevel.currentWeather = weather; if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost) { WeatherController.SetWeatherEffects(weather); } } public static void AddCombinedWeather(string weatherNameResolvable) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) string text = weatherNameResolvable.ToLower(); if (1 == 0) { } LevelWeatherType val = (LevelWeatherType)(text switch { "rainy" => 1, "stormy" => 2, "foggy" => 3, "flooded" => 4, "dustclouds" => 0, "eclipsed" => 5, _ => ((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType, }); if (1 == 0) { } LevelWeatherType weather = val; AddCombinedWeather(weather); } public static void AddCombinedWeather(LevelWeatherType weather) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) WeatherController.AddWeatherEffect(weather); } public static bool IsWeatherEffectPresent(string weatherNameResolvable) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return IsWeatherEffectPresent(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType); } public static bool IsWeatherEffectPresent(LevelWeatherType weatherType) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < WeatherManager.CurrentEffectTypes.Count; i++) { if (WeatherManager.CurrentEffectTypes[i] == weatherType) { return true; } } return false; } public static void RemoveWeather(string weatherNameResolvable) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) RemoveWeather(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType); } public static void RemoveWeather(LevelWeatherType weatherType) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (WeatherManager.CurrentEffectTypes.Contains(weatherType)) { WeatherManager.GetWeather(weatherType).Effect.DisableEffect(true); } } public static void RemoveLastWeather() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (WeatherManager.CurrentEffectTypes.Count > 0) { List<LevelWeatherType> currentEffectTypes = WeatherManager.CurrentEffectTypes; RemoveWeather(currentEffectTypes[currentEffectTypes.Count - 1]); } } public static string GetListOfCurrentWeathers() { //IL_002c: 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 (WeatherManager.CurrentEffectTypes.Count == 0) { return "None"; } string text = ""; for (int i = 0; i < WeatherManager.CurrentEffectTypes.Count; i++) { string text2 = text; LevelWeatherType val = WeatherManager.CurrentEffectTypes[i]; text = text2 + ((object)(LevelWeatherType)(ref val)).ToString(); if (i < WeatherManager.CurrentEffectTypes.Count - 1) { text += ", "; } } return text; } public static Weather? GetWeather(string weatherNameResolvable) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return GetWeather(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType); } public static Weather? GetWeather(LevelWeatherType weatherType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return WeatherManager.GetWeather(weatherType); } public static void ForceSetWeatherAlgorithm(string weatherName) { Plugin.config.UniqueWeatherAlgorithm.Value = weatherName; } public static void Message(string title, string bottom, bool warning = false) { HUDManager.Instance.DisplayTip(title, bottom, warning, false, "LC_Tip1"); } public static void MessageComputer(params string[] messages) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown DialogueSegment[] array = (DialogueSegment[])(object)new DialogueSegment[messages.Length]; for (int i = 0; i < messages.Length; i++) { array[i] = new DialogueSegment { speakerText = "PILOT COMPUTER", bodyText = messages[i] }; } HUDManager.Instance.ReadDialogue(array); } } } namespace CombinedWeathersToolkit.Toolkit { internal class ConfigRegistery { internal static void LoadAllConfigValues() { if (Plugin.config.WeatherConfigCreatorList.Count == 0) { return; } int num = 0; Plugin.DebugLog("[ConfigRegistery] Found values in config file, now loading Weather Config creator"); foreach (string weatherConfigCreator in Plugin.config.WeatherConfigCreatorList) { ToolkitWeather toolkitWeather = new ToolkitWeather(); if (string.IsNullOrWhiteSpace(weatherConfigCreator)) { return; } int num2 = 0; foreach (string item in from s in weatherConfigCreator.Split(':') select s.Trim()) { if (string.IsNullOrWhiteSpace(item)) { Plugin.logger.LogError((object)"[ConfigRegistery] One of the field in Weather Config creator is empty or null, this could result in an unwanted behavior"); continue; } string text = string.Concat(item.Where((char c) => !char.IsWhiteSpace(c))).ToLower(); if (num2 == 0) { toolkitWeather.Name = item; } else if (text.StartsWith("color(") && text.EndsWith(')')) { string text2 = text; toolkitWeather.SetColorFromString(text2.Substring(6, text2.Length - 1 - 6)); } else if (text.StartsWith("type(") && text.EndsWith(')')) { string text2 = text; toolkitWeather.SetTypeFromString(text2.Substring(5, text2.Length - 1 - 5)); } else { toolkitWeather.AddWeather(text, isNameAlreadyConcat: true); } num2++; } if (toolkitWeather.Register()) { num++; Plugin.DebugLog("[ConfigRegistery] Registered weather: " + toolkitWeather.Name); } else { Plugin.DebugLog("[ConfigRegistery] The '" + weatherConfigCreator + "' value is not valid and could not register a weather ; this can happen if the name of the weather was not set or if one of the added weathers is a modded weather and the mod it's from it not installed"); } } Plugin.logger.LogInfo((object)$"[ConfigRegistery] Loaded {num} custom weathers from Weather Config creator"); } } internal class JsonRegistery { internal static void LoadAllJsonFiles() { string[] files = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "*.cwt.json", SearchOption.AllDirectories); string[] array = files; foreach (string text in array) { string fileName = Path.GetFileName(text); Plugin.DebugLog("[JsonRegistery] Found json file, now loading: " + fileName); int num = RegisterWeathersFromJson(text); Plugin.logger.LogInfo((object)$"[JsonRegistery] Loaded {num} custom weathers from json file: {fileName}"); } } private static int RegisterWeathersFromJson(string filePath) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 //IL_008d: Unknown result type (might be due to invalid IL or missing references) string text = File.ReadAllText(filePath); if (text == null || text.Length <= 0) { Plugin.logger.LogError((object)"[JsonRegistery] The file is empty or null"); return 0; } int num = 0; JObject val = JObject.Parse(text); foreach (JProperty item in val.Properties()) { string name = item.Name; JToken value = item.Value; ToolkitWeather toolkitWeather = new ToolkitWeather(); if ((int)value.Type == 1) { foreach (JProperty item2 in ((JObject)value).Properties()) { switch (item2.Name.ToLower()) { case "type": toolkitWeather.SetTypeFromString(ExtractJsonProperty<string>(item2)); break; case "name": toolkitWeather.Name = ExtractJsonProperty<string>(item2); break; case "color": toolkitWeather.SetColorFromString(ExtractJsonProperty<string>(item2)); break; case "weight": toolkitWeather.Weight = ExtractJsonProperty<int>(item2); break; case "scrap_amount": toolkitWeather.ScrapAmountMultiplier = ExtractJsonProperty<float>(item2); break; case "scrap_value": toolkitWeather.ScrapValueMultiplier = ExtractJsonProperty<float>(item2); break; case "filtering": toolkitWeather.Filtering = ExtractJsonProperty<bool>(item2); break; case "level_filter": toolkitWeather.LevelFilter = ExtractJsonProperty<string>(item2); break; case "level_weights": toolkitWeather.LevelWeights = ExtractJsonProperty<string>(item2); break; case "weather_to_weather_weights": toolkitWeather.WeatherToWeatherWeights = ExtractJsonProperty<string>(item2); break; case "progressing_times": toolkitWeather.AddProgressingValues(ExtractJsonProperty<float[]>(item2), areTimesValues: true); break; case "progressing_chances": toolkitWeather.AddProgressingValues(ExtractJsonProperty<float[]>(item2), areTimesValues: false); break; case "weathers": toolkitWeather.AddWeathers(ExtractJsonProperty<string[]>(item2)); break; } } } else { Plugin.logger.LogError((object)("[JsonRegistery] The '" + name + "' property is not an Object, skipping...")); } if (toolkitWeather.Register()) { num++; Plugin.DebugLog("[JsonRegistery] Registered weather: " + toolkitWeather.Name); } else { Plugin.DebugLog("[JsonRegistery] The '" + name + "' property is not valid and could not register a weather ; this can happen if the property has no 'name' field or if one of the added weathers is a modded weather and the mod it's from it not installed"); } } return num; } private static T ExtractJsonProperty<T>(JProperty property) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Invalid comparison between Unknown and I4 //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Invalid comparison between Unknown and I4 //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Invalid comparison between Unknown and I4 //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Invalid comparison between Unknown and I4 //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Invalid comparison between Unknown and I4 //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Invalid comparison between Unknown and I4 JToken value = property.Value; if (typeof(T) == typeof(string)) { return (T)(object)((object)value).ToString(); } if (typeof(T) == typeof(int)) { if ((int)value.Type == 6 || (int)value.Type == 7) { return (T)(object)Extensions.Value<int>((IEnumerable<JToken>)value); } if (int.TryParse(((object)value).ToString(), out var result)) { return (T)(object)result; } } else if (typeof(T) == typeof(float)) { if ((int)value.Type == 7 || (int)value.Type == 6) { return (T)(object)Extensions.Value<float>((IEnumerable<JToken>)value); } string s = ((object)value).ToString(); if (float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result2) || float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out result2)) { return (T)(object)result2; } } else if (typeof(T) == typeof(bool)) { if ((int)value.Type == 9) { return (T)(object)Extensions.Value<bool>((IEnumerable<JToken>)value); } if (bool.TryParse(((object)value).ToString(), out var result3)) { return (T)(object)result3; } } else if (typeof(T) == typeof(float[])) { List<float> list = new List<float>(); if ((int)value.Type == 2) { foreach (JToken item in (JArray)value) { if ((int)item.Type == 7 || (int)item.Type == 6) { list.Add(Extensions.Value<float>((IEnumerable<JToken>)item)); continue; } string s2 = ((object)item).ToString(); if (float.TryParse(s2, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result4) || float.TryParse(s2, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out result4)) { list.Add(result4); } } return (T)(object)list.ToArray(); } } else if (typeof(T) == typeof(string[])) { if ((int)value.Type == 2) { return (T)(object)((IEnumerable<JToken>)(JArray)value).Select((JToken x) => ((object)x).ToString()).ToArray(); } return (T)(object)new string[1] { ((object)value).ToString() }; } return default(T); } } internal class PredefinedRegistery { internal static void LoadAllPredefinedWeathers() { Plugin.DebugLog("[PredefinedRegistery] Predefined weathers are enabled, now loading everything"); RegisterWeather("Rainy + Majora Moon", "rainy", "majoramoon"); RegisterWeather("Majora Eclipsed", Col("#ff0000/#ff59ff/#f2006d/#ff59ff"), "eclipsed", "majoramoon"); RegisterWeather("Majora Chaos", Col("#aa0000/#aa0000/#f2006d/#f2006d"), "rainy", "stormy", "eclipsed", "majoramoon"); RegisterWeather("Snowfall + Majora Moon", "snowfall", "majoramoon"); RegisterWeather("Celestial Borealis", Col("#ff80ff/#80ffff/#f2006d/#80ffff"), "solarflare", "majoramoon"); RegisterWeather("Tornado + Majora Moon", "tornado", "majoramoon"); RegisterWeather("Cosmic Crash", Col("#82ffd7/red/red/red"), "meteorshower", "majoramoon"); RegisterWeather("Hallowed + Majora Moon", "hallowed", "majoramoon"); RegisterWeather("Dark Majora Moon", Col("black/magenta/magenta/black"), "blackfog", "majoramoon"); RegisterWeather("The Crimson Flood", Col("#ff4580"), "flooded", "bloodmoon"); RegisterWeather("Snowfall + Blood Moon", "snowfall", "bloodmoon"); RegisterWeather("Toxic Smog + Blood Moon", Col("#ff4580/#ff4580/#00b000/#00b000"), "toxicsmog", "bloodmoon"); RegisterWeather("Meteor Shower + Blood Moon", Col("#ff4580/#ff4580/#4d0011/#4d0011"), "meteorshower", "bloodmoon"); RegisterWeather("Forsaken + Blood Moon", "forsaken", "bloodmoon"); RegisterWeather("Dark Blood Moon", Col("#ff4580/#ff4580/#ff4580/black"), "blackfog", "bloodmoon"); RegisterWeather("Majora Supermoon", Col("#ff0095/magenta/#ff0095/#ff0095"), "majoramoon", "bloodmoon"); RegisterWeather("Climate Anomaly", Col("yellow"), "snowfall", "heatwave", "solarflare"); RegisterWeather("Heatwave + Blizzard", "heatwave", "blizzard"); RegisterWeather("Nuclear Winter", Col("#04aca4/#069983/#0eb157/white"), "toxicsmog", "blizzard"); RegisterWeather("Hallowed Smog", Col("#fc7714/#0abc63/#fc7714/#0abc63"), "toxicsmog", "hallowed"); RegisterWeather("Toxic Winds", Col("#008042"), "toxicsmog", "tornado"); RegisterWeather("Black Fog + Heatwave", "blackfog", "heatwave"); RegisterWeather("Black Fog + Snowfall", Col("#99ffce"), "blackfog", "snowfall"); RegisterWeather("Black Winter", Col("#6ba6fe/#1b7deb/#307cb6/black"), "blackfog", "blizzard"); RegisterWeather("Ashen Mist", Col("#4f2d6e"), "foggy", "toxicsmog"); RegisterWeatherProgressing("Thermal Shift", Col("#874a00"), "blizzard", "snowfall", "none", "solarflare", "heatwave"); RegisterWeatherProgressing("Gravitational Freeze", Col("#006887"), "heatwave", "solarflare", "none", "snowfall", "blizzard"); RegisterWeather("Foggy + Meteor Shower", Col("red"), "foggy", "meteorshower"); RegisterWeather("Meteor Tempest", Col("red/yellow/#ff5300/yellow"), "stormy", "tornado", "meteorshower"); RegisterWeather("Gravity Anomaly", Col("cyan/#ff5300/yellow/red"), "meteorshower", "eclipsed", "solarflare"); RegisterWeather("Superstorm", Col("magenta"), "stormy", "flooded", "tornado", "hurricane"); RegisterWeather("Void Cyclone", Col("white/white/#800000/#800000"), "blackout", "tornado"); RegisterWeather("Flooded + Hallowed", "flooded", "hallowed"); RegisterWeather("Hallowed Eclipse", Col("red"), "hallowed", "eclipsed"); RegisterWeather("Forsaken Storm", Col("#ff0080/#94294b/#ffb164/#ffb164"), "stormy", "forsaken"); RegisterWeather("Rainy + Earthquakes + Solar Flare", "rainy", "earthquakes", "solarflare"); RegisterWeatherProgressing("Impending Storm", Col("#c4c156"), "none", "rainy", "cloudy", "stormy", "hurricane"); RegisterWeather("Haunted", Col("#ffb164/#ffb164/#8000ff/#d3a70c"), "blackout", "hallowed", "blackfog"); RegisterWeather("Nocturne Frost", Col("#2431a6"), "blackout", "blizzard"); RegisterWeather("Darkness", Col("black/black/white/white"), "blackfog", "blackout"); RegisterWeather("Total Darkness", Col("#9680ff/white/#050066/#ba8df5"), "blackfog", "blackout", "foggy"); RegisterWeather("Blue Fog", Col("#0714e3"), "blue", "blackfog"); RegisterWeather("Dark Blue Moon", Col("#ff0080/black/#4553f8/#4553f8"), "blue", "bloodmoon"); RegisterWeather("Blue Requiem", Col("#0080c0/#0080c0/#ff00ff/#ff00ff"), "blue", "majoramoon"); RegisterWeather("Eternal Darkness", Col("black/cyan/black/blue"), "blackfog", "blackout", "foggy", "heatwave", "evilblue"); RegisterWeather("Bloodlight Omen", Col("#ff0080/#ff0080/#ffb164/#ffcc00"), "bloodmoon", "orange", "rapture"); RegisterWeather("The Pharaoh's Curse", Col("#ffcc00/#ffcc00/red/#ffcc00"), "dustclouds", "earthquakes", "heatwave", "rapture"); RegisterWeather("Orange Dream", Col("#ffb164"), "orange", "snowfall", "solarflare"); RegisterWeather("Majora Tempest", Col("#18e7cd/#91ff7d/#efa4ff/#00849b"), "gusty", "hurricane", "majoramoon"); RegisterWeather("Howling Winds", Col("#b0ff66"), "cloudy", "gusty", "earthquakes"); RegisterWeather("Gusty + Forsaken + Orange", "forsaken", "orange", "gusty"); RegisterWeatherProgressing("Striking Gust", Col("#3ffe9e/#707be9/#3ffe9e/#707be9"), "gusty", "hurricane"); RegisterWeather("The Great Flood", Col("#2b79ff"), "flooded", "rainy"); string[] source = new string[7] { "blizzard", "cloudy", "blackout", "blue", "evilblue", "nightshift", "orange" }; List<string> list = new List<string> { "rainy", "stormy", "eclipsed" }; foreach (string weather in Plugin.installedWeathers) { if (!source.Any((string x) => x == weather)) { list.Add(weather); } } RegisterWeather("The End of the World", Col("magenta/red/#ffb164/cyan"), list.ToArray()); Plugin.logger.LogInfo((object)"[PredefinedRegistery] All predefined weathers are loaded"); } private static void RegisterWeather(string name, params string[] weathers) { ToolkitWeather toolkit = new ToolkitWeather { Name = name }; RegisterWeather(toolkit, (CustomWeatherType)1, weathers); } private static void RegisterWeather(string name, TMP_ColorGradient color, params string[] weathers) { ToolkitWeather toolkit = new ToolkitWeather { Name = name, NameColor = color }; RegisterWeather(toolkit, (CustomWeatherType)1, weathers); } private static void RegisterWeatherProgressing(string name, params string[] weathers) { ToolkitWeather toolkit = new ToolkitWeather { Name = name }; RegisterWeather(toolkit, (CustomWeatherType)2, weathers); } private static void RegisterWeatherProgressing(string name, TMP_ColorGradient color, params string[] weathers) { ToolkitWeather toolkit = new ToolkitWeather { Name = name, NameColor = color }; RegisterWeather(toolkit, (CustomWeatherType)2, weathers); } private static void RegisterWeather(ToolkitWeather toolkit, CustomWeatherType type, params string[] weathers) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) toolkit.Type = type; toolkit.WeightModifier = Plugin.config.PredefinedWeathersWeightModifier.Value; toolkit.AddWeathers(weathers); if (toolkit.Register()) { Plugin.DebugLog("[PredefinedRegistery] Registered weather: " + toolkit.Name); } } private static TMP_ColorGradient Col(string colorStr) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) TMP_ColorGradient colorGradientFromString = ToolkitHelper.GetColorGradientFromString(colorStr); if ((Object)(object)colorGradientFromString != (Object)null) { return colorGradientFromString; } return ColorConverter.ToTMPColorGradient(Color.cyan); } } } namespace CombinedWeathersToolkit.Toolkit.Core { internal class ToolkitCombinedWeatherType : CombinedWeatherType { internal ToolkitWeather ToolkitWeather; public override string ConfigCategory => ToolkitHelper.GetConfigCategory(ToolkitWeather); internal ToolkitCombinedWeatherType(ToolkitWeather toolkit) : base(toolkit.Name, toolkit.Weathers, toolkit.WeightModifier.GetValueOrDefault(0.2f)) { ToolkitWeather = toolkit; ToolkitHelper.SetColor(toolkit, (Weather)(object)this); } public override void Init() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown ToolkitHelper.SetConfig(ToolkitWeather, (WeatherTweaksWeather)(object)this); if (ToolkitWeather.Weight.HasValue) { ((RegistryWeatherConfig)((CombinedWeatherType)this).Config).DefaultWeight = new IntegerConfigHandler(ToolkitWeather.Weight.Value, true); IntPtr functionPointer = typeof(WeatherTweaksWeather).GetMethod("Init").MethodHandle.GetFunctionPointer(); ((Action)Activator.CreateInstance(typeof(Action), this, functionPointer))(); } else { ((CombinedWeatherType)this).Init(); } } public override (float valueMultiplier, float amountMultiplier) GetDefaultMultiplierData() { if (!ToolkitWeather.ScrapValueMultiplier.HasValue && !ToolkitWeather.ScrapAmountMultiplier.HasValue) { (float, float) defaultMultiplierData = ((CombinedWeatherType)this).GetDefaultMultiplierData(); if (ToolkitHelper.ShouldResetAmountData(ToolkitWeather)) { defaultMultiplierData.Item2 = 1f; } return defaultMultiplierData; } return ToolkitHelper.GetMultipliers(ToolkitWeather); } } internal class ToolkitHelper { internal static string GetConfigCategory(ToolkitWeather toolkit) { return "WeatherToolkit Weather: " + toolkit.Name; } internal static void SetColor(ToolkitWeather toolkit, Weather weather) { if ((Object)(object)toolkit.NameColor != (Object)null) { weather.ColorGradient = toolkit.NameColor; } } internal static void SetConfig(ToolkitWeather toolkit, WeatherTweaksWeather weather) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown ((Weather)weather).Config.FilteringOption = new BooleanConfigHandler(toolkit.Filtering.GetValueOrDefault(), true); ((Weather)weather).Config.LevelFilters = new LevelListConfigHandler((!string.IsNullOrEmpty(toolkit.LevelFilter)) ? toolkit.LevelFilter : "Company", true); ((Weather)weather).Config.LevelWeights = new LevelWeightsConfigHandler((!string.IsNullOrEmpty(toolkit.LevelWeights)) ? toolkit.LevelWeights : "", true); ((Weather)weather).Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler((!string.IsNullOrEmpty(toolkit.WeatherToWeatherWeights)) ? toolkit.WeatherToWeatherWeights : "", true); } internal static (float valueMultiplier, float amountMultiplier) GetMultipliers(ToolkitWeather toolkit) { float item = 1f; float item2 = 1f; if (toolkit.ScrapValueMultiplier.HasValue) { item2 = toolkit.ScrapValueMultiplier.Value; } if (toolkit.ScrapAmountMultiplier.HasValue) { item = toolkit.ScrapAmountMultiplier.Value; } return (item2, item); } internal static bool ShouldResetAmountData(ToolkitWeather toolkit) { return toolkit.Name == "The End of the World"; } public static ToolkitWeather? GetToolkitFromWeatherTweaksWeather(WeatherTweaksWeather? weather) { if (weather == null || !((Weather)weather).ConfigCategory.StartsWith("WeatherToolkit")) { return null; } ToolkitWeather result = null; if (weather is ToolkitCombinedWeatherType toolkitCombinedWeatherType) { result = toolkitCombinedWeatherType.ToolkitWeather; } else if (weather is ToolkitProgressingWeatherType toolkitProgressingWeatherType) { result = toolkitProgressingWeatherType.ToolkitWeather; } return result; } public static Color[] GetColorsFromString(string colorString) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) string[] array = (from s in colorString.ToLower().Split('/') select s.Trim()).ToArray(); Color[] array2 = (Color[])(object)new Color[array.Length]; Color val = default(Color); for (int i = 0; i < array.Length; i++) { string text = array[i]; Color val2; if (text[0] == '#') { val2 = ((!ColorUtility.TryParseHtmlString(text, ref val)) ? Color.cyan : val); } else { string text2 = text.ToLower(); if (1 == 0) { } Color val3 = (Color)(text2 switch { "red" => Color.red, "green" => Color.green, "blue" => Color.blue, "yellow" => Color.yellow, "cyan" => Color.cyan, "magenta" => Color.magenta, "black" => Color.black, "white" => Color.white, "gray" => Color.gray, "grey" => Color.grey, "clear" => Color.clear, _ => Color.cyan, }); if (1 == 0) { } val2 = val3; } array2[i] = val2; } return array2; } public static TMP_ColorGradient? GetColorGradientFromString(string colorString) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Color[] colorsFromString = GetColorsFromString(colorString); int num = colorsFromString.Length; if (1 == 0) { } TMP_ColorGradient result = (TMP_ColorGradient)(num switch { 1 => ColorConverter.ToTMPColorGradient(colorsFromString[0]), 2 => GetGradientFull(colorsFromString[0], colorsFromString[1], colorsFromString[0], colorsFromString[1]), 3 => GetGradientFull(colorsFromString[0], colorsFromString[1], colorsFromString[2], colorsFromString[2]), 4 => GetGradientFull(colorsFromString[0], colorsFromString[1], colorsFromString[2], colorsFromString[3]), _ => null, }); if (1 == 0) { } return result; } public static TMP_ColorGradient GetGradientFull(Color color0, Color color1, Color color2, Color color3) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) TMP_ColorGradient gradientInstance = GetGradientInstance(); gradientInstance.colorMode = (ColorMode)3; gradientInstance.topLeft = color0; gradientInstance.topRight = color1; gradientInstance.bottomLeft = color2; gradientInstance.bottomRight = color3; return gradientInstance; } public static TMP_ColorGradient GetGradientInstance() { return ScriptableObject.CreateInstance<TMP_ColorGradient>(); } } internal class ToolkitProgressingWeatherType : ProgressingWeatherType { internal ToolkitWeather ToolkitWeather; public override string ConfigCategory => ToolkitHelper.GetConfigCategory(ToolkitWeather); internal ToolkitProgressingWeatherType(ToolkitWeather toolkit) : base(toolkit.Name, toolkit.Weathers[0], toolkit.GetProgressingWeatherEntries(), toolkit.WeightModifier.GetValueOrDefault(0.2f) + 0.1f) { ToolkitWeather = toolkit; ToolkitHelper.SetColor(toolkit, (Weather)(object)this); } public override void Init() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown ToolkitHelper.SetConfig(ToolkitWeather, (WeatherTweaksWeather)(object)this); if (ToolkitWeather.Weight.HasValue) { ((RegistryWeatherConfig)((ProgressingWeatherType)this).Config).DefaultWeight = new IntegerConfigHandler(ToolkitWeather.Weight.Value, true); IntPtr functionPointer = typeof(WeatherTweaksWeather).GetMethod("Init").MethodHandle.GetFunctionPointer(); ((Action)Activator.CreateInstance(typeof(Action), this, functionPointer))(); } else { ((ProgressingWeatherType)this).Init(); } } public override (float valueMultiplier, float amountMultiplier) GetDefaultMultiplierData() { if (!ToolkitWeather.ScrapValueMultiplier.HasValue && !ToolkitWeather.ScrapAmountMultiplier.HasValue) { return ((ProgressingWeatherType)this).GetDefaultMultiplierData(); } return ToolkitHelper.GetMultipliers(ToolkitWeather); } } public class ToolkitWeather { public CustomWeatherType? Type; public string? Name; public TMP_ColorGradient? NameColor; public int? Weight; public float? ScrapAmountMultiplier; public float? ScrapValueMultiplier; public bool? Filtering; public string? LevelFilter; public string? LevelWeights; public string? WeatherToWeatherWeights; public float? WeightModifier; public List<float> ProgressingTimes = new List<float>(); public List<float> ProgressingChances = new List<float>(); public List<WeatherResolvable> Weathers = new List<WeatherResolvable>(); public void SetTypeFromString(string typeString) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) string text = typeString.ToLower(); if (1 == 0) { } CustomWeatherType value = (CustomWeatherType)(text switch { "combined" => 1, "combo" => 1, "progressing" => 2, "progressive" => 2, _ => 0, }); if (1 == 0) { } Type = value; } public void SetColorFromString(string colorString) { NameColor = ToolkitHelper.GetColorGradientFromString(colorString); } public void AddProgressingValues(float[] values, bool areTimesValues) { foreach (float num in values) { if (!(num < 0f)) { if (areTimesValues) { ProgressingTimes.Add(num); } else { ProgressingChances.Add(num); } } } } public void AddWeather(string weatherName, bool isNameAlreadyConcat = false) { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown if (!string.IsNullOrEmpty(weatherName)) { string text = (isNameAlreadyConcat ? weatherName : string.Concat(weatherName.Where((char c) => !char.IsWhiteSpace(c))).ToLower()); if (1 == 0) { } WeatherResolvable val = (WeatherResolvable)(text switch { "none" => (object)new WeatherTypeResolvable((LevelWeatherType)(-1)), "dustclouds" => (object)new WeatherTypeResolvable((LevelWeatherType)0), "rainy" => (object)new WeatherTypeResolvable((LevelWeatherType)1), "stormy" => (object)new WeatherTypeResolvable((LevelWeatherType)2), "foggy" => (object)new WeatherTypeResolvable((LevelWeatherType)3), "flooded" => (object)new WeatherTypeResolvable((LevelWeatherType)4), "eclipsed" => (object)new WeatherTypeResolvable((LevelWeatherType)5), _ => (object)new WeatherNameResolvable(text), }); if (1 == 0) { } WeatherResolvable item = val; Weathers.Add(item); } } public void AddWeathers(string[] weatherNames) { foreach (string weatherName in weatherNames) { AddWeather(weatherName); } } public List<ProgressingWeatherEntry> GetProgressingWeatherEntries() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown List<ProgressingWeatherEntry> list = new List<ProgressingWeatherEntry>(); for (int i = 1; i < Weathers.Count; i++) { list.Add(new ProgressingWeatherEntry { DayTime = ProgressingTimes[i - 1], Chance = ProgressingChances[i - 1], Weather = Weathers[i] }); } return list; } public bool AreWeathersInstalled() { foreach (WeatherResolvable weather in Weathers) { if (weather.WeatherName != "" && !Plugin.installedWeathers.Any((string w) => w == weather.WeatherName)) { return false; } } return true; } public bool IsValid() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Invalid comparison between Unknown and I4 if (!Type.HasValue || Type == (CustomWeatherType?)0) { Type = (CustomWeatherType)1; } if (string.IsNullOrEmpty(Name)) { return false; } if (!AreWeathersInstalled()) { return false; } if ((int)Type.GetValueOrDefault() == 1) { return Weathers.Count >= 1; } if ((int)Type.GetValueOrDefault() == 2) { if (Weathers.Count <= 1) { return false; } if (Weathers.Count - 1 == ProgressingTimes.Count && Weathers.Count - 1 == ProgressingChances.Count) { return true; } if (ProgressingTimes.Count != 0 && ProgressingChances.Count != 0) { return false; } if ((ProgressingTimes.Count == 0 && ProgressingChances.Count == 0) || (ProgressingTimes.Count == 0 && ProgressingChances.Count == Weathers.Count - 1) || (ProgressingChances.Count == 0 && ProgressingTimes.Count == Weathers.Count - 1)) { if (ProgressingTimes.Count == 0) { float num = 1f / (float)Weathers.Count; for (int i = 0; i < Weathers.Count - 1; i++) { ProgressingTimes.Add(num * (float)(i + 1)); } } if (ProgressingChances.Count == 0) { ProgressingChances.AddRange(Weathers.Select((WeatherResolvable x) => 1f)); } return true; } return false; } return false; } public bool Register() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 if (!IsValid()) { return false; } CustomWeatherType? type = Type; CustomWeatherType? val = type; if (val.HasValue) { CustomWeatherType valueOrDefault = val.GetValueOrDefault(); if ((int)valueOrDefault == 1) { new ToolkitCombinedWeatherType(this); return true; } if ((int)valueOrDefault == 2) { new ToolkitProgressingWeatherType(this); return true; } } return false; } } } namespace CombinedWeathersToolkit.Patches { [HarmonyPatch(typeof(StartupManager))] internal class ScreenMapColorsArrowFixer { [HarmonyPostfix] [HarmonyPatch("Init")] public static void AddArrowDataToScreenMapColors() { foreach (Weather weather in WeatherManager.Weathers) { if (weather.Name.Contains('>')) { ToolkitWeather toolkitFromWeatherTweaksWeather = ToolkitHelper.GetToolkitFromWeatherTweaksWeather((WeatherTweaksWeather?)(object)((weather is WeatherTweaksWeather) ? weather : null)); if (toolkitFromWeatherTweaksWeather != null && !((Object)(object)toolkitFromWeatherTweaksWeather.NameColor == (Object)null)) { Settings.ScreenMapColors.Add(weather.Name.Replace(">", Defaults.SpecialSymbolMap[">"]), weather.ColorGradient); Plugin.DebugLog(weather.Name + " was added to ScreenMapColors by CWT using SpecialSymbolMap"); } } } } } [HarmonyPatch(typeof(SetMapScreenInfoToCurrentLevelPatch))] internal class CustomToolkitScreenColor { [HarmonyPostfix] [HarmonyPatch("GetColoredString")] public static void GetColoredStringToolkit(SelectableLevel level, ref string __result) { if (!Settings.ColoredWeathers) { return; } Weather currentWeather = WeatherManager.GetCurrentWeather(level); ToolkitWeather toolkitFromWeatherTweaksWeather = ToolkitHelper.GetToolkitFromWeatherTweaksWeather((WeatherTweaksWeather?)(object)((currentWeather is WeatherTweaksWeather) ? currentWeather : null)); if (toolkitFromWeatherTweaksWeather != null && !((Object)(object)toolkitFromWeatherTweaksWeather.NameColor == (Object)null)) { Plugin.DebugLog(toolkitFromWeatherTweaksWeather.Name + " weather was spawned using CWT with a defined color"); string text = SetMapScreenInfoToCurrentLevelPatch.GetDisplayWeatherString(level, currentWeather); string text2 = text; if (text.Contains('>')) { text = text.Replace(">", Defaults.SpecialSymbolMap[">"]); } TMP_ColorGradient value; TMP_ColorGradient val = (Settings.ScreenMapColors.TryGetValue(text, out value) ? value : null); if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)ToolkitHelper.GetGradientInstance()) { __result = "<gradient=" + text + ">" + text2 + "</gradient>"; } else { __result = text ?? ""; } } } } [HarmonyPatch(typeof(HUDManager))] internal class DebugCommandsManager { [HarmonyPostfix] [HarmonyPatch("AddChatMessage")] public static void AddChatMessageDebugCommand(string chatMessage) { if (Plugin.config.DebugCommandsEnabled.Value && !((Object)(object)StartOfRound.Instance == (Object)null) && !StartOfRound.Instance.inShipPhase && StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.shipIsLeaving && chatMessage.StartsWith("/cwt")) { string[] array = chatMessage.Split(' '); if (array.Length > 1) { ExecuteCommand(array); } } } private static void ExecuteCommand(string[] command) { switch (command[1]) { case "clear": Effects.ChangeWeather((LevelWeatherType)(-1)); Effects.Message("Debug CWT", "Removed all weathers from current level"); break; case "list": Effects.Message("Debug CWT", "Current weathers: " + Effects.GetListOfCurrentWeathers()); break; case "algo": { string text = ((command.Length > 2) ? string.Join(" ", command.Skip(2)) : ""); Effects.ForceSetWeatherAlgorithm(text); if (text != "") { Effects.Message("Debug CWT", "Forced weather algorithm to " + text); } else { Effects.Message("Debug CWT", "Reseted weather algorithm to normal behavior"); } break; } default: Effects.AddCombinedWeather(command[1]); Effects.Message("Debug CWT", "Spawned " + command[1] + " combined weather"); break; } } } [HarmonyPatch(typeof(TimeOfDay))] internal class GreatFloodWaterRisingManager { public static RandomWeatherWithVariables? floodEffect; public static bool searchForEffect = true; public static readonly List<(string message, bool hasHappened)> tidesWarnings = new List<(string, bool)> { ("High tide approaching! Water level will rise at its peak very soon. Seek higher ground immediately!", false), ("Low tide is coming! Water level will start to drop, take this chance to meet the quota!", false), ("High tide detected! The flood water level is unstable. Please take refuge in a higher location!", false), ("Low tide is coming! The flood water level is now droping. Stay safe!", false), ("High tide is expected! Water level is starting to rise again, be careful!", false) }; [HarmonyPostfix] [HarmonyPatch("MoveTimeOfDay")] public static void OverrideGreatFloodWaterLevel() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) if (!(WeatherManager.GetCurrentLevelWeather().Name == "The Great Flood") || !GreatFloodSetupManager.originalMinWaterLevel.HasValue || !GreatFloodSetupManager.originalMaxWaterLevel.HasValue) { return; } if (searchForEffect) { floodEffect = ((IEnumerable<RandomWeatherWithVariables>)StartOfRound.Instance.currentLevel.randomWeathers).FirstOrDefault((Func<RandomWeatherWithVariables, bool>)((RandomWeatherWithVariables x) => (int)x.weatherType == 4)); searchForEffect = false; } else if (floodEffect != null) { if ((TimeOfDay.Instance.currentDayTime >= 360f && TimeOfDay.Instance.currentDayTime < 450f) || (TimeOfDay.Instance.currentDayTime >= 690f && TimeOfDay.Instance.currentDayTime < 780f)) { floodEffect.weatherVariable = (floodEffect.weatherVariable2 = (int)((Component)StartOfRound.Instance.middleOfShipNode).transform.position.y + 7); } else if ((TimeOfDay.Instance.currentDayTime >= 450f && TimeOfDay.Instance.currentDayTime < 690f) || (TimeOfDay.Instance.currentDayTime >= 780f && TimeOfDay.Instance.currentDayTime < 982f)) { floodEffect.weatherVariable = GreatFloodSetupManager.originalMinWaterLevel.Value; floodEffect.weatherVariable2 = GreatFloodSetupManager.originalMaxWaterLevel.Value; } else if (TimeOfDay.Instance.currentDayTime >= 982f) { floodEffect.weatherVariable = (floodEffect.weatherVariable2 = (int)((Component)StartOfRound.Instance.middleOfShipNode).transform.position.y); } if (TimeOfDay.Instance.currentDayTime >= 350f && !tidesWarnings[0].hasHappened) { Effects.MessageComputer(tidesWarnings[0].message); tidesWarnings[0] = (tidesWarnings[0].message, true); } else if (TimeOfDay.Instance.currentDayTime >= 440f && !tidesWarnings[1].hasHappened) { Effects.MessageComputer(tidesWarnings[1].message); tidesWarnings[1] = (tidesWarnings[1].message, true); } else if (TimeOfDay.Instance.currentDayTime >= 680f && !tidesWarnings[2].hasHappened) { Effects.MessageComputer(tidesWarnings[2].message); tidesWarnings[2] = (tidesWarnings[2].message, true); } else if (TimeOfDay.Instance.currentDayTime >= 770f && !tidesWarnings[3].hasHappened) { Effects.MessageComputer(tidesWarnings[3].message); tidesWarnings[3] = (tidesWarnings[3].message, true); } else if (TimeOfDay.Instance.currentDayTime >= 962f && !tidesWarnings[4].hasHappened) { Effects.MessageComputer(tidesWarnings[4].message); tidesWarnings[4] = (tidesWarnings[4].message, true); } } } } [HarmonyPatch(typeof(StartOfRound))] internal class GreatFloodSetupManager { internal static bool originalEffectExist = true; internal static int? originalMinWaterLevel = null; internal static int? originalMaxWaterLevel = null; [HarmonyPostfix] [HarmonyPatch("OnShipLandedMiscEvents")] public static void SaveGreatFloodOriginalWaterLevel() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown if (WeatherManager.GetCurrentLevelWeather().Name == "The Great Flood") { int num = (int)RoundManager.Instance.outsideAINodes.Min((GameObject node) => node.transform.position.y); int num2 = num + 3; RandomWeatherWithVariables val = ((IEnumerable<RandomWeatherWithVariables>)StartOfRound.Instance.currentLevel.randomWeathers).FirstOrDefault((Func<RandomWeatherWithVariables, bool>)((RandomWeatherWithVariables x) => (int)x.weatherType == 4)); if (val == null) { StartOfRound.Instance.currentLevel.randomWeathers = StartOfRound.Instance.currentLevel.randomWeathers.Append((RandomWeatherWithVariables)new ImprovedRandomWeatherWithVariables { weatherType = (LevelWeatherType)4, weatherVariable = num, weatherVariable2 = num2 }).ToArray(); originalEffectExist = false; originalMinWaterLevel = num; originalMaxWaterLevel = num2; } else { originalMinWaterLevel = val.weatherVariable; originalMaxWaterLevel = val.weatherVariable2; } } } [HarmonyPrefix] [HarmonyPatch("SetShipReadyToLand")] public static void ResetGreatFloodWaterLevel() { if (!originalMinWaterLevel.HasValue || !originalMaxWaterLevel.HasValue) { return; } if (!originalEffectExist) { StartOfRound.Instance.currentLevel.randomWeathers = StartOfRound.Instance.currentLevel.randomWeathers.Where((RandomWeatherWithVariables x) => (int)x.weatherType != 4).ToArray(); } else { RandomWeatherWithVariables val = ((IEnumerable<RandomWeatherWithVariables>)StartOfRound.Instance.currentLevel.randomWeathers).FirstOrDefault((Func<RandomWeatherWithVariables, bool>)((RandomWeatherWithVariables x) => (int)x.weatherType == 4)); val.weatherVariable = originalMinWaterLevel.Value; val.weatherVariable2 = originalMaxWaterLevel.Value; } originalMinWaterLevel = null; originalMaxWaterLevel = null; originalEffectExist = true; GreatFloodWaterRisingManager.searchForEffect = true; GreatFloodWaterRisingManager.floodEffect = null; for (int i = 0; i < GreatFloodWaterRisingManager.tidesWarnings.Count; i++) { GreatFloodWaterRisingManager.tidesWarnings[i] = (GreatFloodWaterRisingManager.tidesWarnings[i].message, false); } } } [HarmonyPatch(typeof(Plugin))] internal class InitToolkitWeatherRegistery { [HarmonyPrefix] [HarmonyPatch("MainMenuInit")] public static void InitToolkitWeathers() { Plugin.installedWeathers.AddRange(from w in WeatherManager.RegisteredWeathers where (int)w.Type == 2 && (int)w.Origin != 2 select string.Concat(w.Name.Where((char c) => !char.IsWhiteSpace(c))).ToLower()); if (Plugin.config.RegisterPredefinedWeathers.Value) { PredefinedRegistery.LoadAllPredefinedWeathers(); } if (Plugin.config.AllowConfigRegistery.Value) { ConfigRegistery.LoadAllConfigValues(); } if (Plugin.config.AllowJsonRegistery.Value) { JsonRegistery.LoadAllJsonFiles(); } } } [HarmonyPatch(typeof(WeatherTweaksWeather))] internal class OverrideToolkitScrapMultipliers { [HarmonyPrefix] [HarmonyPatch("Init")] public static bool InitToolkit(WeatherTweaksWeather __instance) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || (int)((Weather)__instance).Origin != 2) { return true; } ToolkitWeather toolkitFromWeatherTweaksWeather = ToolkitHelper.GetToolkitFromWeatherTweaksWeather(__instance); if (toolkitFromWeatherTweaksWeather == null) { return true; } var (num, num2) = __instance.GetDefaultMultiplierData(); ((Weather)__instance).Config.ScrapValueMultiplier = new FloatConfigHandler(num, true); ((Weather)__instance).Config.ScrapAmountMultiplier = new FloatConfigHandler(num2, true); ((Weather)__instance).Effect.SunAnimatorBool = WeatherManager.GetWeather(__instance.WeatherTypes.Last().WeatherType).Effect.SunAnimatorBool; IntPtr functionPointer = typeof(Weather).GetMethod("Init", BindingFlags.Instance | BindingFlags.Public).MethodHandle.GetFunctionPointer(); ((Action)Activator.CreateInstance(typeof(Action), __instance, functionPointer))(); return false; } } [HarmonyPatch(typeof(WeatherTweaksWeatherAlgorithm))] internal class SingleWeatherManager { [HarmonyPrefix] [HarmonyPatch("SelectWeathers")] public static bool OverrideCalculatedWeather(ref WeatherTweaksWeatherAlgorithm __instance, ref Dictionary<SelectableLevel, LevelWeatherType> __result, StartOfRound startOfRound) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(Plugin.config.UniqueWeatherAlgorithm.Value) || !((NetworkBehaviour)StartOfRound.Instance).IsHost) { return true; } WeatherCalculation.previousDayWeather.Clear(); if (startOfRound.gameStats.daysSpent == 0 && ConfigManager.FirstDaySpecial.Value) { return true; } Dictionary<SelectableLevel, Weather> dictionary = new Dictionary<SelectableLevel, Weather>(); List<SelectableLevel> gameLevels = Variables.GetGameLevels(); foreach (SelectableLevel item in gameLevels) { WeatherCalculation.previousDayWeather[item.PlanetName] = item.currentWeather; Weather weather = Effects.GetWeather(Plugin.config.UniqueWeatherAlgorithm.Value); if (weather == null) { Plugin.logger.LogError((object)"The weather in the UniqueWeatherAlgorithm config is not valid, reverting to WeatherTweaks algorithm"); return true; } dictionary[item] = weather; } Dictionary<SelectableLevel, LevelWeatherType> dictionary2 = new Dictionary<SelectableLevel, LevelWeatherType>(); foreach (KeyValuePair<SelectableLevel, Weather> item2 in dictionary) { dictionary2[item2.Key] = item2.Value.VanillaWeatherType; } __result = dictionary2; return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }