Please disclose if any significant portion of your mod was created 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 UnreliableWeatherReports v1.0.1
UnreliableWeatherReports.dll
Decompiled 2 years agousing 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.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; [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: AssemblyCompany("UnreliableWeatherReports")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Makes weather reports incorrect or unavailable")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("UnreliableWeatherReports")] [assembly: AssemblyTitle("UnreliableWeatherReports")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 UnreliableWeatherReports { public class Config { public static ConfigEntry<double> unknownWeatherChance; public static ConfigEntry<double> unknownDayChance; public static ConfigEntry<double> incorrectWeatherChance; public Config(ConfigFile cfg) { unknownWeatherChance = cfg.Bind<double>("General", "UnknownWeatherChance", 35.0, "Chance of unknown weather per moon"); incorrectWeatherChance = cfg.Bind<double>("General", "IncorrectWeatherChance", 20.0, "Chance of incorrect weather report per moon (if not unknown)"); unknownDayChance = cfg.Bind<double>("General", "UnknownDayChance", 10.0, "Chance of unknown weather everywhere for an entire day"); } } public static class Globals { public static List<bool> unknownWeatherMoons = new List<bool>(); public static List<bool> incorrectWeatherMoons = new List<bool>(); public static List<LevelWeatherType> incorrectWeatherReports = new List<LevelWeatherType>(); } [BepInPlugin("UnreliableWeatherReports", "UnreliableWeatherReports", "1.0.1")] public class Plugin : BaseUnityPlugin { public static Config MyConfig { get; internal set; } private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown MyConfig = new Config(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("UnreliableWeatherReports"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin UnreliableWeatherReports is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "UnreliableWeatherReports"; public const string PLUGIN_NAME = "UnreliableWeatherReports"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace UnreliableWeatherReports.Patches { [HarmonyPatch(typeof(StartOfRound), "SetMapScreenInfoToCurrentLevel")] public class SetMapScreenInfoToCurrentLevel { private static bool Prefix(StartOfRound __instance) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Invalid comparison between Unknown and I4 //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) ((Behaviour)__instance.screenLevelVideoReel).enabled = false; ((Component)__instance.screenLevelVideoReel).gameObject.SetActive(false); __instance.screenLevelVideoReel.clip = __instance.currentLevel.videoReel; TimeOfDay val = Object.FindObjectOfType<TimeOfDay>(); if (val.totalTime == 0f) { val.totalTime = (float)val.numberOfHours * val.lengthOfHours; } string text = (((int)__instance.currentLevel.currentWeather == -1) ? "" : ("Weather: " + ((object)(LevelWeatherType)(ref __instance.currentLevel.currentWeather)).ToString())); if (Globals.incorrectWeatherMoons.Count != 0) { object obj; if ((int)Globals.incorrectWeatherReports[__instance.currentLevel.levelID] != -1) { LevelWeatherType val2 = Globals.incorrectWeatherReports[__instance.currentLevel.levelID]; obj = "Weather: " + ((object)(LevelWeatherType)(ref val2)).ToString(); } else { obj = ""; } string text2 = (string)obj; string text3 = ((Globals.unknownWeatherMoons[__instance.currentLevel.levelID] && __instance.currentLevel.levelID != 3) ? "Weather: Unknown" : ((Globals.incorrectWeatherMoons[__instance.currentLevel.levelID] && __instance.currentLevel.levelID != 3) ? text2 : text)); string levelDescription = __instance.currentLevel.LevelDescription; ((TMP_Text)__instance.screenLevelDescription).SetText("Orbiting: " + __instance.currentLevel.PlanetName + "\n" + levelDescription + "\n" + text3, true); } __instance.mapScreen.overrideCameraForOtherUse = true; ((Component)__instance.mapScreen.cam).transform.position = new Vector3(0f, 100f, 0f); ((Behaviour)__instance.screenLevelDescription).enabled = true; if ((Object)(object)__instance.currentLevel.videoReel != (Object)null) { ((Behaviour)__instance.screenLevelVideoReel).enabled = true; ((Component)__instance.screenLevelVideoReel).gameObject.SetActive(true); __instance.screenLevelVideoReel.Play(); } return false; } } [HarmonyPatch(typeof(StartOfRound), "SetPlanetsWeather")] public class SetPlanetsWeather { private static void Postfix(StartOfRound __instance) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Invalid comparison between Unknown and I4 //IL_016a: Unknown result type (might be due to invalid IL or missing references) Globals.unknownWeatherMoons.Clear(); Globals.incorrectWeatherMoons.Clear(); Globals.incorrectWeatherReports.Clear(); Random random = new Random(__instance.randomMapSeed); double num = random.NextDouble(); for (int i = 0; i < 128; i++) { double num2 = random.NextDouble(); bool flag = (num < Config.unknownDayChance.Value / 100.0 || num2 < Config.unknownWeatherChance.Value / 100.0) && i != 3; Globals.unknownWeatherMoons.Add(flag); if (flag) { Globals.incorrectWeatherMoons.Add(item: false); Globals.incorrectWeatherReports.Add((LevelWeatherType)(-1)); continue; } double num3 = random.NextDouble(); bool flag2 = num3 < Config.incorrectWeatherChance.Value / 100.0 && i != 3; Globals.incorrectWeatherMoons.Add(flag2); if (!flag2) { Globals.incorrectWeatherReports.Add((LevelWeatherType)(-1)); continue; } List<LevelWeatherType> list = Enum.GetValues(typeof(LevelWeatherType)).OfType<LevelWeatherType>().ToList(); int index; do { index = random.Next(list.Count); } while (list[index] == __instance.levels[i].currentWeather || (int)list[index] == 0); Globals.incorrectWeatherReports.Add(list[index]); } } } [HarmonyPatch(typeof(Terminal), "TextPostProcess")] public class TextPostProcess { private static bool Prefix(Terminal __instance, ref string modifiedDisplayText, ref TerminalNode node) { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Invalid comparison between Unknown and I4 //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Invalid comparison between Unknown and I4 //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_0045: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Invalid comparison between Unknown and I4 //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) int num = modifiedDisplayText.Split("[planetTime]").Length - 1; LevelWeatherType val; if (num > 0) { Regex regex = new Regex(Regex.Escape("[planetTime]")); for (int i = 0; i < num && __instance.moonsCatalogueList.Length > i; i++) { string text = (((int)__instance.moonsCatalogueList[i].currentWeather == -1) ? "" : ("(" + ((object)(LevelWeatherType)(ref __instance.moonsCatalogueList[i].currentWeather)).ToString() + ")")); object obj; if ((int)Globals.incorrectWeatherReports[__instance.moonsCatalogueList[i].levelID] != -1) { val = Globals.incorrectWeatherReports[__instance.moonsCatalogueList[i].levelID]; obj = "(" + ((object)(LevelWeatherType)(ref val)).ToString() + ")"; } else { obj = ""; } string text2 = (string)obj; string replacement = ((GameNetworkManager.Instance.isDemo && __instance.moonsCatalogueList[i].lockedForDemo) ? "(Locked)" : (Globals.unknownWeatherMoons[__instance.moonsCatalogueList[i].levelID] ? "(Unknown)" : (Globals.incorrectWeatherMoons[__instance.moonsCatalogueList[i].levelID] ? text2 : text))); modifiedDisplayText = regex.Replace(modifiedDisplayText, replacement, 1); } } if (node.displayPlanetInfo != -1) { string text3 = (((int)StartOfRound.Instance.levels[node.displayPlanetInfo].currentWeather != -1) ? (((object)(LevelWeatherType)(ref StartOfRound.Instance.levels[node.displayPlanetInfo].currentWeather)).ToString().ToLower() ?? "") : "mild weather"); object obj2; if ((int)Globals.incorrectWeatherReports[StartOfRound.Instance.levels[node.displayPlanetInfo].levelID] == -1) { obj2 = "mild weather"; } else { val = Globals.incorrectWeatherReports[StartOfRound.Instance.levels[node.displayPlanetInfo].levelID]; obj2 = ((object)(LevelWeatherType)(ref val)).ToString().ToLower() ?? ""; } string text4 = (string)obj2; string newValue = (Globals.unknownWeatherMoons[StartOfRound.Instance.levels[node.displayPlanetInfo].levelID] ? "????" : (Globals.incorrectWeatherMoons[StartOfRound.Instance.levels[node.displayPlanetInfo].levelID] ? text4 : text3)); modifiedDisplayText = modifiedDisplayText.Replace("[currentPlanetTime]", newValue); } return true; } } }