Decompiled source of LandMineUponDeath v1.0.0

Kaboom.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Kaboom.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("Kaboom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Kaboom")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7780de8c-278d-4c24-a697-39c05de7178d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Kaboom
{
	[BepInPlugin("com.kaboom.plugin", "Kaboom", "1.0.0")]
	public class AddMineUnderPlayer : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.kaboom.plugin");

		private static AddMineUnderPlayer instance;

		internal static void Log(string message)
		{
			Logger.CreateLogSource("Kaboom").LogInfo((object)message);
		}

		private void Awake()
		{
			if ((Object)(object)instance != (Object)null)
			{
				instance = this;
			}
			Log("\n---------------------------\nKaboom loaded\n---------------------------\n");
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(AddMineUnderPlayer));
		}
	}
}
namespace Kaboom.Patches
{
	internal class PlayerControllerBPatch : WhoopieCushionItem
	{
		private static ArrayList landmines = new ArrayList();

		internal static void Log(string message)
		{
			Logger.CreateLogSource("Kaboom").LogInfo((object)message);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_168339603")]
		[HarmonyPostfix]
		private static void patch(ref Vector3 ___placeOfDeath)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Log("\n---------------------------\nPLACE OF DEATH: " + ((object)(Vector3)(ref ___placeOfDeath)).ToString() + "\n---------------------------\n");
			GameObject val = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((GameObject x) => ((Object)x).name == "Landmine"));
			Log("\n---------------------------\nLANDMINE PREFAB: " + ((object)val).ToString() + "\n---------------------------\n");
			val.transform.rotation = Quaternion.Euler(-90f, 0f, 0f);
			if ((Object)(object)val != (Object)null)
			{
				landmines.Add(Object.Instantiate<GameObject>(val, ___placeOfDeath, val.transform.rotation));
			}
			Vector3 position = val.transform.position;
			string? text = ((object)(Vector3)(ref position)).ToString();
			Quaternion rotation = val.transform.rotation;
			Log(text + " " + ((object)(Quaternion)(ref rotation)).ToString());
			Log("\n---------------------------\nAAAAAAAAAAAAAAAAAAAAAAAAAA\n\n\n\n---------------------------\n");
		}

		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPostfix]
		private static void patch2()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			Log("\n---------------------------\nREMOVING LANDMINES\n---------------------------\n");
			foreach (GameObject landmine in landmines)
			{
				GameObject val = landmine;
				Object.Destroy((Object)(object)val);
			}
			Log("\n---------------------------\nAAAAAAAAAAAAAAAAAAAAAAAAAA\n\n\n\n---------------------------\n");
		}
	}
}