Decompiled source of Quick Drop v1.0.1

QuickDrop.dll

Decompiled a year ago
using System.Diagnostics;
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 QuickDrop.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("QuickDrop")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("QuickDrop")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("afd7a42f-ed64-41bc-84d5-180365c052a3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace QuickDrop
{
	[BepInPlugin("Nases.QuickDrop", "Quick Drop", "1.0.0.0")]
	public class QuickDropMod : BaseUnityPlugin
	{
		private const string modGUID = "Nases.QuickDrop";

		private const string modName = "Quick Drop";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Nases.QuickDrop");

		private static QuickDropMod instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Nases.QuickDrop");
			mls.LogInfo((object)"Quick Drop Mod is active");
			harmony.PatchAll(typeof(QuickDropMod));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace QuickDrop.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Discard_performed")]
		[HarmonyPrefix]
		private static void quickDropItemsPatch(PlayerControllerB __instance, ref bool ___isHoldingObject, ref GrabbableObject[] ___ItemSlots)
		{
			if (___isHoldingObject)
			{
				return;
			}
			MethodInfo method = typeof(PlayerControllerB).GetMethod("NextItemSlot", BindingFlags.Instance | BindingFlags.NonPublic);
			MethodInfo method2 = typeof(PlayerControllerB).GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!(method != null) || !(method2 != null))
			{
				return;
			}
			int currentItemSlot = __instance.currentItemSlot;
			object[] parameters = new object[1] { true };
			for (int num = (int)method.Invoke(__instance, parameters); num != currentItemSlot; num = (num + 1) % ___ItemSlots.Length)
			{
				if ((Object)(object)___ItemSlots[num] != (Object)null)
				{
					method2.Invoke(__instance, new object[2] { num, null });
					break;
				}
			}
		}
	}
}