Decompiled source of Toggle Hazards v1.0.0

HazardToggle.dll

Decompiled 3 months ago
using 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 BepInEx.Logging;
using HarmonyLib;
using HazardToggle.Patches;
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("HazardToggle")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HazardToggle")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("88d17c9c-8741-42f9-9e18-655ef30d1225")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HazardToggle
{
	[BepInPlugin("SpiralMods.HazardToggle", "Toggle Hazards", "1.0.0")]
	public class HazardToggleBase : BaseUnityPlugin
	{
		private const string modGUID = "SpiralMods.HazardToggle";

		private const string modName = "Toggle Hazards";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("SpiralMods.HazardToggle");

		private static HazardToggleBase Instance;

		internal ManualLogSource mls;

		public static ConfigEntry<bool> RemoveSpikes;

		public static ConfigEntry<bool> RemoveFog;

		public static ConfigEntry<bool> RemoveLandmine;

		public static ConfigEntry<bool> RemoveTurret;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SpiralMods.HazardToggle");
			mls.LogInfo((object)"Toggle Hazards has loaded (ModVersion: 1.0.0, ModGUID: SpiralMods.HazardToggle)!");
			SetBindings();
			harmony.PatchAll(typeof(SpikeHazard));
			harmony.PatchAll(typeof(FogHazard));
			harmony.PatchAll(typeof(LandmineHazard));
			harmony.PatchAll(typeof(TurretHazard));
		}

		private void SetBindings()
		{
			RemoveSpikes = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable spikes", false, "If true, removes spike traps!");
			RemoveFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable fog valves", false, "If true, removes fog valves!");
			RemoveLandmine = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable landmines", false, "If true, removes landmines!");
			RemoveTurret = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable turrets", false, "If true, removes turrets!");
		}
	}
}
namespace HazardToggle.Patches
{
	[HarmonyPatch(typeof(Turret))]
	internal class TurretHazard
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate()
		{
			if (HazardToggleBase.RemoveTurret.Value && GameNetworkManager.Instance.isHostingGame)
			{
				Turret val = Object.FindObjectOfType<Turret>();
				Console.Write("A turret has been deleted.");
				Object.DestroyImmediate((Object)(object)val);
				Object.DestroyImmediate((Object)(object)val);
			}
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandmineHazard
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate()
		{
			if (HazardToggleBase.RemoveLandmine.Value && GameNetworkManager.Instance.isHostingGame)
			{
				Landmine val = Object.FindObjectOfType<Landmine>();
				Console.Write("A landmine has been deleted.");
				Object.DestroyImmediate((Object)(object)val);
				Object.DestroyImmediate((Object)(object)val);
			}
		}
	}
	[HarmonyPatch(typeof(SpikeRoofTrap))]
	internal class FogHazard
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate()
		{
			if (HazardToggleBase.RemoveFog.Value && GameNetworkManager.Instance.isHostingGame)
			{
				SpikeRoofTrap val = Object.FindObjectOfType<SpikeRoofTrap>();
				Console.Write("A fog valve has been deleted.");
				Object.DestroyImmediate((Object)(object)val);
				Object.DestroyImmediate((Object)(object)val);
			}
		}
	}
	[HarmonyPatch(typeof(SteamValveHazard))]
	internal class SpikeHazard
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void patchUpdate()
		{
			if (HazardToggleBase.RemoveSpikes.Value && GameNetworkManager.Instance.isHostingGame)
			{
				SteamValveHazard val = Object.FindObjectOfType<SteamValveHazard>();
				Console.Write("A spike trap has been deleted.");
				Object.DestroyImmediate((Object)(object)val);
				Object.DestroyImmediate((Object)(object)val);
			}
		}
	}
}