Decompiled source of Kill Bind v1.1.1

Killbind/KillBind.dll

Decompiled 2 years 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 GameNetcodeStuff;
using HarmonyLib;
using KillBindNS;
using LethalCompanyInputUtils.Api;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("KillBind")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KillBind")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6dd5353c-1d70-400e-8a33-a26482141e1d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KillBind.Binds
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class KillBindPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void onPressKill(PlayerControllerB __instance)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (BasePlugin.ModEnabled.Value && BasePlugin.InputActionInstance.ExplodeKey.triggered && !__instance.isPlayerDead && !__instance.isTypingChat && !((Behaviour)HUDManager.Instance.typingIndicator).enabled && !Object.FindObjectOfType<Terminal>().terminalInUse && !__instance.inTerminalMenu && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				if (BasePlugin.DeathCause.Value > Enum.GetValues(typeof(CauseOfDeath)).Length || BasePlugin.DeathCause.Value < 0)
				{
					BasePlugin.DeathCause.Value = 0;
				}
				if (BasePlugin.HeadType.Value > 3 || BasePlugin.HeadType.Value < 0)
				{
					BasePlugin.HeadType.Value = 1;
				}
				__instance.KillPlayer(Vector3.zero, true, (CauseOfDeath)BasePlugin.DeathCause.Value, BasePlugin.HeadType.Value);
			}
		}
	}
}
namespace KillBindNS
{
	public class KillBind : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction ExplodeKey { get; set; }
	}
	[BepInPlugin("Confusified.KillBind", "Kill Bind", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BasePlugin : BaseUnityPlugin
	{
		private const string modGUID = "Confusified.KillBind";

		private const string modName = "Kill Bind";

		private const string modVersion = "1.1.1";

		private readonly Harmony _harmony = new Harmony("Confusified.KillBind");

		public ConfigFile Configuration = new ConfigFile(Utility.CombinePaths(new string[2]
		{
			Paths.ConfigPath + "\\Confusified\\",
			"Confusified.KillBind".Substring(12) + ".cfg"
		}), false);

		public static ConfigEntry<bool> ModEnabled;

		public static ConfigEntry<int> DeathCause;

		public static ConfigEntry<int> HeadType;

		internal static KillBind InputActionInstance = new KillBind();

		private void Awake()
		{
			SetModConfig();
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Kill Bind 1.1.1 has loaded");
		}

		private void SetModConfig()
		{
			ModEnabled = Configuration.Bind<bool>("Global Settings", "Enabled", true, "Toggle the mod");
			DeathCause = Configuration.Bind<int>("Mod Settings", "DeathType", 0, "Decide what cause of death you will have when pressing your kill bind.\nThere are currently 13 death causes in the game:\n(0) Unknown (Default)\n(1) Bludgeoning\n(2) Gravity\n(3) Blast\n(4) Strangulation\n(5) Suffocation\n(6) Mauling\n(7) Gunshots\n(8) Crushing\n(9) Drowning\n(10) Abandoned\n(11) Electrocution\n(12) Kicking\n\nDeath types (1)Bludgeoning, (6)Mauling and (7)Gunshots will cover the body with blood.");
			HeadType = Configuration.Bind<int>("Mod Settings", "HeadType", 1, "Decide what will happen with your head.\nThere are currently 3 head types in the game:\n(0) Default - Your head will stay on your body\n(1) Decapitate (Default) - Your head will be blown off of your body\n(2) Coilhead - Your head will be replaced with a coil");
		}
	}
}