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 BlackoutHazards v1.0.2
BlackoutHazards.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BlackoutHazards")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BlackoutHazards")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("de0ddf87-f738-4090-8db2-ad18c90d4883")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace BlackoutHazards; [BepInPlugin("Toshizuno.BlackoutHazards", "Blackout Hazards", "1.0.2")] public class BlackoutHazardPlugin : BaseUnityPlugin { public static class Configuration { public static bool Apparatus; public static bool Landmines; public static bool SpikeRoofTraps; public static bool Turrets; } public static class BreakerBox { public static void SwitchBreaker(BreakerBox __instance) { if (!((NetworkBehaviour)RoundManager.Instance).IsHost || Configuration.Apparatus) { return; } Landmine[] array = Object.FindObjectsOfType<Landmine>(); SpikeRoofTrap[] array2 = Object.FindObjectsOfType<SpikeRoofTrap>(); Turret[] array3 = Object.FindObjectsOfType<Turret>(); if ((Object)(object)Instance.Breaker == (Object)null || RoundManager.Instance.powerOffPermanently || !__instance.isPowerOn) { return; } if (Configuration.Landmines) { for (int i = 0; i < array.Length; i++) { array[i].ToggleMine(true); } } if (Configuration.SpikeRoofTraps) { for (int j = 0; j < array2.Length; j++) { array2[j].ToggleSpikesEnabled(true); } } if (Configuration.Turrets) { for (int k = 0; k < array3.Length; k++) { array3[k].ToggleTurretEnabled(true); } } } } public static class Landmine { public static void Update(Landmine __instance) { if (!((NetworkBehaviour)RoundManager.Instance).IsHost) { return; } if ((Object)(object)Instance.Breaker == (Object)null) { Instance.Breaker = Object.FindObjectOfType<BreakerBox>(); } if ((Object)(object)RoundManager.Instance == (Object)null || !((NetworkBehaviour)RoundManager.Instance).IsHost || (Object)(object)Instance.Breaker == (Object)null || (Object)(object)__instance == (Object)null || !Configuration.Landmines) { return; } if (Configuration.Apparatus) { if (RoundManager.Instance.powerOffPermanently) { __instance.ToggleMine(false); } else { __instance.ToggleMine(true); } return; } if (!Instance.Breaker.isPowerOn || RoundManager.Instance.powerOffPermanently) { __instance.ToggleMine(false); } if (Instance.Breaker.isPowerOn && !RoundManager.Instance.powerOffPermanently) { __instance.ToggleMine(true); } } } public static class SpikeRoofTrap { public static void Update(SpikeRoofTrap __instance) { if (!((NetworkBehaviour)RoundManager.Instance).IsHost) { return; } if ((Object)(object)Instance.Breaker == (Object)null) { Instance.Breaker = Object.FindObjectOfType<BreakerBox>(); } if ((Object)(object)RoundManager.Instance == (Object)null || !((NetworkBehaviour)RoundManager.Instance).IsHost || (Object)(object)Instance.Breaker == (Object)null || (Object)(object)__instance == (Object)null || !Configuration.SpikeRoofTraps) { return; } if (__instance.trapActive) { if (Configuration.Apparatus) { if (RoundManager.Instance.powerOffPermanently) { __instance.ToggleSpikesEnabled(false); } } else if (!Instance.Breaker.isPowerOn || RoundManager.Instance.powerOffPermanently) { __instance.ToggleSpikesEnabled(false); } } if (__instance.trapActive) { return; } if (Configuration.Apparatus) { if (!RoundManager.Instance.powerOffPermanently) { __instance.ToggleSpikesEnabled(true); } } else if (Instance.Breaker.isPowerOn && !RoundManager.Instance.powerOffPermanently) { __instance.ToggleSpikesEnabled(true); } } } public static class Turret { public static void Update(TurretMode ___turretModeLastFrame, Turret __instance) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Invalid comparison between Unknown and I4 //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Invalid comparison between Unknown and I4 if ((Object)(object)Instance.Breaker == (Object)null) { Instance.Breaker = Object.FindObjectOfType<BreakerBox>(); } if ((Object)(object)RoundManager.Instance == (Object)null || !((NetworkBehaviour)RoundManager.Instance).IsHost || (Object)(object)Instance.Breaker == (Object)null || (Object)(object)__instance == (Object)null || !Configuration.Turrets) { return; } if (__instance.turretActive) { if (Configuration.Apparatus) { if (RoundManager.Instance.powerOffPermanently) { __instance.ToggleTurretEnabled(false); } } else if ((!Instance.Breaker.isPowerOn || RoundManager.Instance.powerOffPermanently) && (int)___turretModeLastFrame != 2 && (int)___turretModeLastFrame != 3) { __instance.ToggleTurretEnabled(false); } } else if (Configuration.Apparatus) { if (!RoundManager.Instance.powerOffPermanently) { __instance.ToggleTurretEnabled(true); } } else if (Instance.Breaker.isPowerOn && !RoundManager.Instance.powerOffPermanently) { __instance.ToggleTurretEnabled(true); } } } internal static BlackoutHazardPlugin Instance; private BreakerBox Breaker = null; private ConfigEntry<bool> Apparatus; private ConfigEntry<bool> Landmines; private ConfigEntry<bool> SpikeRoofTraps; private ConfigEntry<bool> Turrets; private readonly Harmony Patcher = new Harmony("Toshizuno.BlackoutHazards"); public static void Finalizer(Exception __exception) { if (__exception != null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)(__exception.Message + "\n" + __exception.StackTrace)); } } private void Awake() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown Instance = Instance ?? this; Apparatus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Apparatus", false, "If this config is enabled, hazards will only be disabled when the apparatus is pulled out."); Landmines = ((BaseUnityPlugin)this).Config.Bind<bool>("Hazards", "Landmines", false, "Landmines are disabled when the breaker is turned off."); SpikeRoofTraps = ((BaseUnityPlugin)this).Config.Bind<bool>("Hazards", "SpikeRoofTraps", true, "Spike Roof Traps are disabled when the breaker is turned off."); Turrets = ((BaseUnityPlugin)this).Config.Bind<bool>("Hazards", "Turrets", true, "Turrets are disabled when the breaker is turned off."); Configuration.Apparatus = Apparatus.Value; Configuration.Landmines = Landmines.Value; Configuration.SpikeRoofTraps = SpikeRoofTraps.Value; Configuration.Turrets = Turrets.Value; ((BaseUnityPlugin)this).Logger.LogWarning((object)"Postfix:Landmine::Update"); Harmony patcher = Patcher; HarmonyMethod val = new HarmonyMethod(typeof(BlackoutHazardPlugin).GetMethod("Finalizer")); patcher.Patch((MethodBase)typeof(Landmine).GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic), (HarmonyMethod)null, new HarmonyMethod(typeof(Landmine).GetMethod("Update")), (HarmonyMethod)null, val, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogWarning((object)"Postfix:SpikeRoofTrap::Update"); Harmony patcher2 = Patcher; val = new HarmonyMethod(typeof(BlackoutHazardPlugin).GetMethod("Finalizer")); patcher2.Patch((MethodBase)typeof(SpikeRoofTrap).GetMethod("Update"), (HarmonyMethod)null, new HarmonyMethod(typeof(SpikeRoofTrap).GetMethod("Update")), (HarmonyMethod)null, val, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogWarning((object)"Postfix:Turret::Update"); Harmony patcher3 = Patcher; val = new HarmonyMethod(typeof(BlackoutHazardPlugin).GetMethod("Finalizer")); patcher3.Patch((MethodBase)typeof(Turret).GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic), (HarmonyMethod)null, new HarmonyMethod(typeof(Turret).GetMethod("Update")), (HarmonyMethod)null, val, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogWarning((object)"Postfix:BreakerBox::SwitchBreaker"); Harmony patcher4 = Patcher; val = new HarmonyMethod(typeof(Patches).GetMethod("Finalizer")); patcher4.Patch((MethodBase)typeof(BreakerBox).GetMethod("SwitchBreaker"), (HarmonyMethod)null, new HarmonyMethod(typeof(BreakerBox).GetMethod("SwitchBreaker")), (HarmonyMethod)null, val, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogWarning((object)"BlackoutHazardPlugin has been patched completely and successfully."); } }