Decompiled source of MasterKey v1.0.0

BepInEx/plugins/MasterKey.dll

Decompiled 11 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MasterKey.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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MasterKey")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MasterKey")]
[assembly: AssemblyTitle("MasterKey")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MasterKey
{
	[BepInPlugin("LCMOD.MasterKey", "MasterKey", "1.0.0")]
	public class MasterKeyBase : BaseUnityPlugin
	{
		public const string MODGUID = "LCMOD.MasterKey";

		public const string MODNAME = "MasterKey";

		public const string MODVERSION = "1.0.0";

		private readonly Harmony harmony = new Harmony("LCMOD.MasterKey");

		public static MasterKeyBase Instance;

		public static ManualLogSource logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod LCMOD.MasterKey is loaded!");
			harmony.PatchAll(typeof(MasterKeyBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace MasterKey.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("DespawnHeldObject")]
		[HarmonyPrefix]
		private static bool DontDespawnKey()
		{
			if (((object)GameNetworkManager.Instance.localPlayerController.ItemSlots[GameNetworkManager.Instance.localPlayerController.currentItemSlot]).GetType() == typeof(KeyItem))
			{
				return false;
			}
			return true;
		}
	}
}