Decompiled source of GoOutWithABang v1.0.1

GoOutWithABang.dll

Decompiled a year ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using GoOutWithABang.Patches;
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("GoOutWithABang")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GoOutWithABang")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0535b7f0-8a10-494c-8f5b-e28692a0449c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GoOutWithABang
{
	[BepInPlugin("Chrigi.GoOutWithABangMod", "Go Out With A Bang Mod", "1.0.1")]
	public class GoOutWithABangModBase : BaseUnityPlugin
	{
		private const string modGUID = "Chrigi.GoOutWithABangMod";

		private const string modName = "Go Out With A Bang Mod";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("Chrigi.GoOutWithABangMod");

		private static GoOutWithABangModBase Instance;

		internal static ConfigEntry<bool> SuffocationSetting;

		internal static ConfigEntry<bool> BlastSetting;

		internal static ConfigEntry<bool> UnknownSetting;

		internal static ConfigEntry<bool> StrangulationSetting;

		internal static ConfigEntry<bool> MaulingSetting;

		internal static ConfigEntry<bool> BludgeoningSetting;

		internal static ConfigEntry<bool> GravitySetting;

		internal static ConfigEntry<bool> GunshotsSetting;

		internal static ConfigEntry<bool> CrushingSetting;

		internal static ConfigEntry<bool> DrowningSetting;

		internal static ConfigEntry<bool> AbandonedSetting;

		internal static ConfigEntry<bool> ElectrocutionSetting;

		internal static ConfigEntry<bool> KickingSetting;

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Chrigi.GoOutWithABangMod");
			mls.LogInfo((object)"Time to go out with a bang!");
			SuffocationSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Suffocation", true, "Enable Explosion on Suffocation");
			BlastSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Blast", false, "Enable Explosion on Blast");
			UnknownSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Unknown", false, "Enable Explosion on Unknown");
			StrangulationSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Strangulation", true, "Enable Explosion on Strangulation");
			MaulingSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Mauling", true, "Enable Explosion on Mauling");
			BludgeoningSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Bludgeoning", true, "Enable Explosion on Bludgeoning");
			GravitySetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Gravity", true, "Enable Explosion on Gravity");
			GunshotsSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Gunshots", true, "Enable Explosion on Gunshots");
			CrushingSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Crushing", true, "Enable Explosion on Crushing");
			DrowningSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Drowning", true, "Enable Explosion on Drowning");
			AbandonedSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Abandoned", true, "Enable Explosion on Abandoned");
			ElectrocutionSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Electrocution", true, "Enable Explosion on Electrocution");
			KickingSetting = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Kicking", true, "Enable Explosion on Kicking");
			harmony.PatchAll(typeof(LandMinePatch));
			harmony.PatchAll(typeof(GoOutWithABangModBase));
		}
	}
}
namespace GoOutWithABang.Patches
{
	internal class LandMinePatch
	{
		private static ManualLogSource logger = GoOutWithABangModBase.mls;

		private static bool ded;

		private static RoundManager currentRound;

		private static bool server = false;

		private static bool isLevelLoaded = false;

		private static bool deathMineSpawned = false;

		private static int mine = 0;

		private static bool suff;

		private static bool blast;

		private static bool unknown;

		private static bool strang;

		private static bool maul;

		private static bool bludg;

		private static bool grav;

		private static bool gun;

		private static bool crush;

		private static bool drown;

		private static bool aban;

		private static bool electro;

		private static bool kick;

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static void LoadNewLevelPatch()
		{
			server = false;
			isLevelLoaded = false;
			currentRound = RoundManager.Instance;
			if (((NetworkBehaviour)currentRound).IsServer)
			{
				server = true;
			}
			ded = false;
			suff = GoOutWithABangModBase.SuffocationSetting.Value;
			blast = GoOutWithABangModBase.BlastSetting.Value;
			unknown = GoOutWithABangModBase.UnknownSetting.Value;
			strang = GoOutWithABangModBase.StrangulationSetting.Value;
			maul = GoOutWithABangModBase.MaulingSetting.Value;
			bludg = GoOutWithABangModBase.BludgeoningSetting.Value;
			grav = GoOutWithABangModBase.GravitySetting.Value;
			gun = GoOutWithABangModBase.GunshotsSetting.Value;
			crush = GoOutWithABangModBase.CrushingSetting.Value;
			drown = GoOutWithABangModBase.DrowningSetting.Value;
			aban = GoOutWithABangModBase.AbandonedSetting.Value;
			electro = GoOutWithABangModBase.ElectrocutionSetting.Value;
			kick = GoOutWithABangModBase.KickingSetting.Value;
		}

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void FinishGeneratingNewLevelClientRpcPatch()
		{
			isLevelLoaded = true;
			logger.LogInfo((object)"Level Loaded, any new mine spawned will blow up instantly");
			int num = currentRound.currentLevel.spawnableMapObjects.Count();
			for (int i = 0; i < num; i++)
			{
				if (((Object)currentRound.currentLevel.spawnableMapObjects[i].prefabToSpawn).name == "Landmine")
				{
					logger.LogInfo((object)("Found Mine Index: " + i));
					mine = i;
					break;
				}
			}
		}

		[HarmonyPatch(typeof(Landmine), "Start")]
		[HarmonyPrefix]
		private static void LandminePatch(ref Landmine __instance)
		{
			logger.LogInfo((object)"Landmine Spawned");
			if (isLevelLoaded && deathMineSpawned)
			{
				logger.LogInfo((object)"Forcing mine explosion");
				__instance.ExplodeMineServerRpc();
				deathMineSpawned = false;
				logger.LogInfo((object)"Mine forcefully activated");
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB))]
		[HarmonyPatch("KillPlayerServerRpc")]
		[HarmonyPostfix]
		private static void PlayerControllerBPatch(PlayerControllerB __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Invalid comparison between Unknown and I4
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Invalid comparison between Unknown and I4
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Invalid comparison between Unknown and I4
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Invalid comparison between Unknown and I4
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Invalid comparison between Unknown and I4
			if (server && __instance.isPlayerDead && (!((NetworkBehaviour)__instance).IsOwnedByServer || !ded) && ((int)__instance.causeOfDeath != 5 || suff) && ((int)__instance.causeOfDeath != 6 || maul) && ((int)__instance.causeOfDeath != 1 || bludg) && ((int)__instance.causeOfDeath != 2 || grav) && ((int)__instance.causeOfDeath != 7 || gun) && ((int)__instance.causeOfDeath != 8 || crush) && ((int)__instance.causeOfDeath != 9 || drown) && ((int)__instance.causeOfDeath != 10 || aban) && ((int)__instance.causeOfDeath != 11 || electro) && ((int)__instance.causeOfDeath != 12 || kick) && ((int)__instance.causeOfDeath != 4 || strang) && ((int)__instance.causeOfDeath != 0 || unknown) && ((int)__instance.causeOfDeath != 3 || blast))
			{
				if (((NetworkBehaviour)__instance).IsOwnedByServer)
				{
					ded = true;
				}
				logger.LogInfo((object)"Spawning mine on dead player");
				deathMineSpawned = true;
				GameObject val = Object.Instantiate<GameObject>(currentRound.currentLevel.spawnableMapObjects[mine].prefabToSpawn, __instance.placeOfDeath, Quaternion.identity, currentRound.mapPropsContainer.transform);
				val.GetComponent<NetworkObject>().Spawn(true);
			}
		}
	}
}