Decompiled source of ExtraSlots MultipleHotkeyUsage v1.0.0

ExtraSlots_MultipleHotkeyUsage.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ExtraSlots;
using ExtraSlots.HotBars;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ExtraSlots_MultipleHotkeyUsage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExtraSlots_MultipleHotkeyUsage")]
[assembly: AssemblyTitle("ExtraSlots_MultipleHotkeyUsage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExtraSlots_MultipleHotkeyUsage
{
	[BepInPlugin("kabooma.ExtraSlots_MultipleHotkeyUsage", "ExtraSlots_MultipleHotkeyUsage", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ExtraSlots_MultipleHotkeyUsage : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(QuickBars), "UpdateItemUse")]
		public static class QuickBarsPatch
		{
			public static bool Prefix()
			{
				if (((Character)Player.m_localPlayer).TakeInput())
				{
					List<ItemData> itemsToUse = GetItemsToUse();
					if (itemsToUse.Count == 0)
					{
						return false;
					}
					foreach (ItemData item in itemsToUse)
					{
						((Humanoid)Player.m_localPlayer).UseItem(Slots.PlayerInventory, item, false);
					}
				}
				return false;
			}
		}

		public const string PLUGIN_GUID = "kabooma.ExtraSlots_MultipleHotkeyUsage";

		public const string DEPENDENCY_GUID = "shudnal.ExtraSlots";

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("ExtraSlots_MultipleHotkeyUsage");
			val.PatchAll();
		}

		public static List<Slot> GetSlotsWithShortcutDown()
		{
			List<Slot> first = FoodSlotsHotBar.hotBarSlots.Where((Slot s) => s.IsShortcutDown()).ToList();
			List<Slot> second = QuickSlotsHotBar.hotBarSlots.Where((Slot s) => s.IsShortcutDown()).ToList();
			return first.Concat(second).ToList();
		}

		public static List<ItemData> GetItemsToUse()
		{
			List<Slot> slotsWithShortcutDown = GetSlotsWithShortcutDown();
			return slotsWithShortcutDown.Select((Slot s) => s.Item).ToList();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ExtraSlots_MultipleHotkeyUsage";

		public const string PLUGIN_NAME = "ExtraSlots_MultipleHotkeyUsage";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}