Decompiled source of Killbind v2.0.2

baer1.KillBind.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("baer1.KillBind")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.2.0")]
[assembly: AssemblyInformationalVersion("2.0.2+d1a697f73cebb48f28c52665e1398fd54661634e")]
[assembly: AssemblyProduct("KillBind")]
[assembly: AssemblyTitle("baer1.KillBind")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace KillBind
{
	public class KeyBindings : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction KillKey { get; set; } = null;

	}
	[BepInPlugin("baer1.KillBind", "KillBind", "2.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class KillBind : BaseUnityPlugin
	{
		public enum DeathAnimation
		{
			CauseOfDeath = -2,
			None,
			Normal,
			HeadBurst,
			Spring,
			Electrocuted,
			ComedyMask,
			TragedyMask,
			Burnt,
			Sliced,
			HeadGone,
			Pieces
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		internal class UpdatePatch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Expected O, but got Unknown
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(CharacterController), "Move", (Type[])null, (Type[])null), (string)null)
				}).Advance(-2).Insert((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(OpCodes.Dup, (object)null),
					new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertySetter(typeof(KillBind), "_BodyVelocity"))
				})
					.InstructionEnumeration();
			}
		}

		internal static readonly KeyBindings keyBindings = new KeyBindings();

		private ConfigEntry<CauseOfDeath> _causeOfDeath = null;

		private ConfigEntry<DeathAnimation> _deathAnimation = null;

		public static KillBind Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		public CauseOfDeath causeOfDeath => _causeOfDeath.Value;

		public DeathAnimation? deathAnimation
		{
			get
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Expected I4, but got Unknown
				DeathAnimation value = _deathAnimation.Value;
				if (1 == 0)
				{
				}
				DeathAnimation? result;
				switch (value)
				{
				case DeathAnimation.CauseOfDeath:
				{
					CauseOfDeath val = causeOfDeath;
					if (1 == 0)
					{
					}
					DeathAnimation value2 = (((int)val == 0) ? DeathAnimation.HeadBurst : ((val - 11) switch
					{
						0 => DeathAnimation.Electrocuted, 
						2 => DeathAnimation.Burnt, 
						4 => DeathAnimation.HeadBurst, 
						6 => DeathAnimation.Sliced, 
						_ => DeathAnimation.Normal, 
					}));
					if (1 == 0)
					{
					}
					result = value2;
					break;
				}
				case DeathAnimation.None:
					result = null;
					break;
				default:
					result = _deathAnimation.Value;
					break;
				}
				if (1 == 0)
				{
				}
				return result;
			}
		}

		internal static Vector3 _BodyVelocity { get; set; } = default(Vector3);


		private void Awake()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			_causeOfDeath = ((BaseUnityPlugin)this).Config.Bind<CauseOfDeath>("General", "CauseOfDeath", (CauseOfDeath)0, "What cause of death to display for your corpse");
			_deathAnimation = ((BaseUnityPlugin)this).Config.Bind<DeathAnimation>("General", "DeathAnimation", DeathAnimation.CauseOfDeath, "What ragdoll to spawn (CauseOfDeath chooses automatically based on cause of death)");
			if (Harmony == null)
			{
				Harmony = new Harmony("baer1.KillBind");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
			keyBindings.KillKey.performed += KillBind_performed;
			Logger.LogInfo((object)"baer1.KillBind v2.0.2 has loaded!");
		}

		private static void KillBind_performed(CallbackContext ctx)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (((CallbackContext)(ref ctx)).performed && !((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && !GameNetworkManager.Instance.localPlayerController.isPlayerDead && !GameNetworkManager.Instance.localPlayerController.isTypingChat && !GameNetworkManager.Instance.localPlayerController.quickMenuManager.isMenuOpen)
			{
				DeathAnimation? deathAnimation = Instance.deathAnimation;
				GameNetworkManager.Instance.localPlayerController.KillPlayer(_BodyVelocity, deathAnimation.HasValue, Instance.causeOfDeath, Math.Clamp((int)deathAnimation.GetValueOrDefault(), 0, GameNetworkManager.Instance.localPlayerController.playersManager.playerRagdolls.Count - 1), default(Vector3));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "baer1.KillBind";

		public const string PLUGIN_NAME = "KillBind";

		public const string PLUGIN_VERSION = "2.0.2";
	}
}