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 Weather Gains2 v1.1.0
joleman11.weathergains.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using WeatherGains.Types; [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("joleman11.weathergains")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3363c048ef052345a0a5302b975ea2b10088e6dc")] [assembly: AssemblyProduct("WeatherGains")] [assembly: AssemblyTitle("joleman11.weathergains")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.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; } } [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 WeatherGains { [Serializable] public class ModConfiguration : SyncedInstance<ModConfiguration> { public ConfigEntry<bool> ValueMultiEnabled; public ConfigEntry<bool> AmountMultiEnabled; public ConfigEntry<bool> LungValueMultiEnabled; public ConfigEntry<float> FogValueMultiplier; public ConfigEntry<float> FogAmountMultiplier; public ConfigEntry<float> RainValueMultiplier; public ConfigEntry<float> RainAmountMultiplier; public ConfigEntry<float> ClearValueMultiplier; public ConfigEntry<float> ClearAmountMultiplier; public ConfigEntry<float> StormValueMultiplier; public ConfigEntry<float> StormAmountMultiplier; public ConfigEntry<float> FloodValueMultiplier; public ConfigEntry<float> FloodAmountMultiplier; public ConfigEntry<float> EclipsedValueMultiplier; public ConfigEntry<float> EclipsedAmountMultiplier; public readonly Dictionary<LevelWeatherType, MultiValueGroup> Multipliers; public ConfigFile ApplyConfig(ConfigFile cfg) { ValueMultiEnabled = cfg.Bind<bool>("General", "Value Multiplier Enabled", true, "Whether the scrap value multiplier is enabled."); AmountMultiEnabled = cfg.Bind<bool>("General", "Amount Multiplier Enabled", true, "Whether the scrap amount multiplier is enabled."); LungValueMultiEnabled = cfg.Bind<bool>("General", "Apparatus Multiplier Enabled", true, "Whether the Apparatus value multiplier is enabled."); FogValueMultiplier = cfg.Bind<float>("Multipliers", "FogValueMultiplier", 1.2f, "Scrap value multiplier during foggy weather on a moon. Set to 1 for no change."); FogAmountMultiplier = cfg.Bind<float>("Multipliers", "FogAmountMultiplier", 1.1f, "Scrap amount multiplier during foggy weather on a moon. Set to 1 for no change."); RainValueMultiplier = cfg.Bind<float>("Multipliers", "RainValueMultiplier", 1.2f, "Scrap value multiplier during rain weather on a moon. Set to 1 for no change."); RainAmountMultiplier = cfg.Bind<float>("Multipliers", "RainAmountMultiplier", 1.1f, "Scrap amount multiplier during rain weather on a moon. Set to 1 for no change."); ClearValueMultiplier = cfg.Bind<float>("Multipliers", "ClearValueMultiplier", 1f, "Scrap value multiplier during clear/no weather on a moon. Set to 1 for no change."); ClearAmountMultiplier = cfg.Bind<float>("Multipliers", "ClearAmountMultiplier", 1f, "Scrap amount multiplier during clear/no weather on a moon. Set to 1 for no change."); FloodValueMultiplier = cfg.Bind<float>("Multipliers", "FloodValueMultiplier", 1.5f, "Scrap value multiplier during floods on a moon. Set to 1 for no change."); FloodAmountMultiplier = cfg.Bind<float>("Multipliers", "FloodAmountMultiplier", 1.25f, "Scrap amount multiplier during floods on a moon. Set to 1 for no change."); StormValueMultiplier = cfg.Bind<float>("Multipliers", "StormValueMultiplier", 1.55f, "Scrap value multiplier during storms on a moon. Set to 1 for no change."); StormAmountMultiplier = cfg.Bind<float>("Multipliers", "StormAmountMultiplier", 1.3f, "Scrap amount multiplier during storms on a moon. Set to 1 for no change."); EclipsedValueMultiplier = cfg.Bind<float>("Multipliers", "EclipsedValueMultiplier", 2.1f, "Scrap value multiplier during eclipsed weather on a moon. Set to 1 for no change."); EclipsedAmountMultiplier = cfg.Bind<float>("Multipliers", "EclipsedAmountMultiplier", 1.4f, "Scrap amount multiplier during eclipsed weather on a moon. Set to 1 for no change."); return cfg; } public ModConfiguration(ConfigFile cfg) { InitInstance(this); cfg.SaveOnConfigSet = false; cfg = ApplyConfig(cfg); Multipliers = new Dictionary<LevelWeatherType, MultiValueGroup> { { (LevelWeatherType)3, new MultiValueGroup { ValueMultiplier = FogValueMultiplier, AmountMultiplier = FogAmountMultiplier } }, { (LevelWeatherType)1, new MultiValueGroup { ValueMultiplier = RainValueMultiplier, AmountMultiplier = RainAmountMultiplier } }, { (LevelWeatherType)(-1), new MultiValueGroup { ValueMultiplier = ClearValueMultiplier, AmountMultiplier = ClearAmountMultiplier } }, { (LevelWeatherType)2, new MultiValueGroup { ValueMultiplier = StormValueMultiplier, AmountMultiplier = StormAmountMultiplier } }, { (LevelWeatherType)4, new MultiValueGroup { ValueMultiplier = FloodValueMultiplier, AmountMultiplier = FloodAmountMultiplier } }, { (LevelWeatherType)5, new MultiValueGroup { ValueMultiplier = EclipsedValueMultiplier, AmountMultiplier = EclipsedAmountMultiplier } } }; ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile cfg) { ((Dictionary<ConfigDefinition, string>)AccessTools.Property(typeof(ConfigFile), "OrphanedEntries").GetValue(cfg)).Clear(); } } [Serializable] public class SyncedInstance<T> { [NonSerialized] protected static int IntSize = 4; internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager; internal static bool IsClient => NetworkManager.Singleton.IsClient; internal static bool IsHost => NetworkManager.Singleton.IsHost; public static T Default { get; private set; } public static T Instance { get; private set; } public static bool Synced { get; internal set; } protected void InitInstance(T instance) { Default = instance; Instance = instance; IntSize = 4; } internal static void SyncInstance(byte[] data) { Instance = DeserializeFromBytes(data); Synced = true; } internal static void RevertSync() { Instance = Default; Synced = false; } public static byte[] SerializeToBytes(T val) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream memoryStream = new MemoryStream(); try { binaryFormatter.Serialize(memoryStream, val); return memoryStream.ToArray(); } catch (Exception arg) { WeatherGains.Logger.LogError((object)$"Error serializing instance: {arg}"); return null; } } public static T DeserializeFromBytes(byte[] data) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream serializationStream = new MemoryStream(data); try { return (T)binaryFormatter.Deserialize(serializationStream); } catch (Exception arg) { WeatherGains.Logger.LogError((object)$"Error deserializing instance: {arg}"); return default(T); } } } [BepInPlugin("joleman11.weathergains", "WeatherGains", "1.0.0")] public class WeatherGains : BaseUnityPlugin { internal static ModConfiguration BoundConfig { get; private set; } public static WeatherGains Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Logger.LogInfo((object)"joleman11.weathergains v1.0.0 is loading..."); BoundConfig = new ModConfiguration(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)"joleman11.weathergains v1.0.0 has loaded!"); } internal static void Patch() { //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_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("joleman11.weathergains"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "joleman11.weathergains"; public const string PLUGIN_NAME = "WeatherGains"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace WeatherGains.Types { public class MultiValueGroup { public ConfigEntry<float> ValueMultiplier { get; set; } public ConfigEntry<float> AmountMultiplier { get; set; } } } namespace WeatherGains.Patches { [HarmonyPatch(typeof(LungProp))] public class LungPropPatch { [HarmonyPatch("DisconnectFromMachinery")] [HarmonyPrefix] private static void DisconnectFromMachineryPatch(LungProp __instance) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (WeatherGains.BoundConfig.LungValueMultiEnabled.Value) { ((GrabbableObject)__instance).SetScrapValue((int)((float)((GrabbableObject)__instance).scrapValue * WeatherGains.BoundConfig.Multipliers[TimeOfDay.Instance.currentLevelWeather].ValueMultiplier.Value)); } } } [HarmonyPatch(typeof(Terminal))] public class GetEnemies { public static SpawnableMapObject Landmine; public static SpawnableMapObject Turret; public static SpawnableMapObject SpikeTrap; public static SpawnableMapObject Seamine; public static SpawnableMapObject BigBertha; [HarmonyPatch("Start")] [HarmonyPostfix] public static void GetEnemy(Terminal __instance) { WeatherGains.Logger.LogInfo((object)"Start GetEnemy"); SelectableLevel val = null; SelectableLevel[] moonsCatalogueList = __instance.moonsCatalogueList; foreach (SelectableLevel val2 in moonsCatalogueList) { if (!(((Object)val2).name == "OffenseLevel")) { continue; } val = val2; WeatherGains.Logger.LogInfo((object)"FOUND OFFENSE!"); SpawnableMapObject[] spawnableMapObjects = val2.spawnableMapObjects; foreach (SpawnableMapObject val3 in spawnableMapObjects) { if (((Object)val3.prefabToSpawn).name == "Landmine" && Landmine == null) { Landmine = val3; } else if (((Object)val3.prefabToSpawn).name == "TurretContainer" && Turret == null) { Turret = val3; } else if (((Object)val3.prefabToSpawn).name == "SpikeRoofTrapHazard" && SpikeTrap == null) { SpikeTrap = val3; } else if (((Object)val3.prefabToSpawn).name == "Seamine" && Seamine == null) { Seamine = val3; } else if (((Object)val3.prefabToSpawn).name == "Bertha" && BigBertha == null) { BigBertha = val3; } } break; } if ((Object)(object)val == (Object)null) { return; } SelectableLevel[] moonsCatalogueList2 = __instance.moonsCatalogueList; foreach (SelectableLevel val4 in moonsCatalogueList2) { if (((Object)val4).name == "ExperimentationLevel" || ((Object)val4).name == "AssuranceLevel" || ((Object)val4).name == "VowLevel") { SpawnableMapObject val5 = ((IEnumerable<SpawnableMapObject>)val4.spawnableMapObjects).FirstOrDefault((Func<SpawnableMapObject, bool>)delegate(SpawnableMapObject spawnableMapObject) { GameObject prefabToSpawn = spawnableMapObject.prefabToSpawn; return ((prefabToSpawn != null) ? ((Object)prefabToSpawn).name : null) == "SpikeRoofTrapHazard"; }); if (val5 == null) { List<SpawnableMapObject> list = val4.spawnableMapObjects.ToList(); list.Add(SpikeTrap); val4.spawnableMapObjects = list.ToArray(); WeatherGains.Logger.LogInfo((object)"added SpikeRoofTrapHazard"); } val4.factorySizeMultiplier = val.factorySizeMultiplier; val4.minScrap = val.minScrap; val4.maxScrap = val.maxScrap; val4.minTotalScrapValue = val.minTotalScrapValue; val4.maxTotalScrapValue = val.maxTotalScrapValue; val4.maxEnemyPowerCount = val.maxEnemyPowerCount; val4.maxDaytimeEnemyPowerCount = val.maxDaytimeEnemyPowerCount; val4.maxOutsideEnemyPowerCount = val.maxOutsideEnemyPowerCount; val4.daytimeEnemiesProbabilityRange = val.daytimeEnemiesProbabilityRange; val4.daytimeEnemySpawnChanceThroughDay = val.daytimeEnemySpawnChanceThroughDay; val4.enemySpawnChanceThroughoutDay = val.enemySpawnChanceThroughoutDay; val4.outsideEnemySpawnChanceThroughDay = val.outsideEnemySpawnChanceThroughDay; val4.spawnProbabilityRange = val.spawnProbabilityRange; } } } } [HarmonyPatch(typeof(RoundManager))] public class RoundManagerPatch { [HarmonyPatch("SpawnScrapInLevel")] [HarmonyPrefix] private static void SpawnScrapInLevelPrefix() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) if (WeatherGains.BoundConfig.ValueMultiEnabled.Value) { RoundManager instance = RoundManager.Instance; instance.scrapValueMultiplier *= WeatherGains.BoundConfig.Multipliers[TimeOfDay.Instance.currentLevelWeather].ValueMultiplier.Value; } if (WeatherGains.BoundConfig.AmountMultiEnabled.Value) { RoundManager instance2 = RoundManager.Instance; instance2.scrapAmountMultiplier *= WeatherGains.BoundConfig.Multipliers[TimeOfDay.Instance.currentLevelWeather].AmountMultiplier.Value; } WeatherGains.Logger.LogInfo((object)($"Successfully modified the scrap generation values for weather type {TimeOfDay.Instance.currentLevelWeather} on moon (level) {TimeOfDay.Instance.currentLevel}!\n\n" + $"Modded Value Multiplier: {RoundManager.Instance.scrapValueMultiplier}\n" + $"Modded Amount Multiplier: {RoundManager.Instance.scrapAmountMultiplier}")); } [HarmonyPatch("SpawnScrapInLevel")] [HarmonyPostfix] private static void SpawnScrapInLevelPostfix() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) if (WeatherGains.BoundConfig.ValueMultiEnabled.Value) { RoundManager instance = RoundManager.Instance; instance.scrapValueMultiplier /= WeatherGains.BoundConfig.Multipliers[TimeOfDay.Instance.currentLevelWeather].ValueMultiplier.Value; } if (WeatherGains.BoundConfig.AmountMultiEnabled.Value) { RoundManager instance2 = RoundManager.Instance; instance2.scrapAmountMultiplier /= WeatherGains.BoundConfig.Multipliers[TimeOfDay.Instance.currentLevelWeather].AmountMultiplier.Value; } WeatherGains.Logger.LogInfo((object)($"Successfully reverted the scrap generation values for weather type {TimeOfDay.Instance.currentLevelWeather} on moon (level) {TimeOfDay.Instance.currentLevel}!\n\n" + $"Reverted Value Multiplier: {RoundManager.Instance.scrapValueMultiplier}\n" + $"Reverted Amount Multiplier: {RoundManager.Instance.scrapAmountMultiplier}\n\n" + "This is intended functionality... the mod isn't breaking!")); } } }