Decompiled source of HUDdleUPfix v1.0.0

plugins/HUDdleUPfix.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HUDdleUP;
using HUDdleUP.Patches;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace FluxSquido.HUDdleUPfix;

[BepInPlugin("FluxSquido.HUDdleUPfix", "HUDdleUPfix", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class HUDdleUPfixPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "FluxSquido.HUDdleUPfix";

	public const string PluginName = "HUDdleUPfix";

	public const string PluginVersion = "1.0.0";

	private const string HUDdleUPGuid = "itsschwer.HUDdleUP";

	private void Awake()
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		if (Find("HUDdleUP.Plugin", "get_Config") != null && Find("HUDdleUP.Config", "get_FullerItemDescriptions") != null && Find("HUDdleUP.Patches.FullerDescriptions", "GetCombinedDescription") != null)
		{
			ItemIcon.SetItemIndex_SetItemIndexArgs += new hook_SetItemIndex_SetItemIndexArgs(SetItemIndex);
		}
		MethodInfo methodInfo = Find("HUDdleUP.Behaviours.EquipmentCooldownPanel", "Update");
		if (methodInfo != null)
		{
			new ILHook((MethodBase)methodInfo, new Manipulator(CooldownTracksShownEquipment));
		}
	}

	private static MethodInfo Find(string type, string method)
	{
		return Type.GetType(type + ", HUDdleUP")?.GetMethod(method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
	}

	private static void SetItemIndex(orig_SetItemIndex_SetItemIndexArgs orig, ItemIcon self, SetItemIndexArgs args)
	{
		//IL_0002: 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)
		orig.Invoke(self, args);
		if (Plugin.Config.FullerItemDescriptions && Object.op_Implicit((Object)(object)self.tooltipProvider))
		{
			ItemDef itemDef = ItemCatalog.GetItemDef(self.itemIndex);
			if (Object.op_Implicit((Object)(object)itemDef))
			{
				self.tooltipProvider.overrideBodyText = FullerDescriptions.GetCombinedDescription(itemDef.descriptionToken, itemDef.pickupToken);
			}
		}
	}

	private static void CooldownTracksShownEquipment(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "get_alternateEquipmentState")
		}))
		{
			val.Remove();
			val.EmitDelegate<Func<Inventory, EquipmentState>>((Func<Inventory, EquipmentState>)AlternateEquipmentState);
		}
	}

	private static EquipmentState AlternateEquipmentState(Inventory inventory)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		if (inventory.accessibleEquipmentSetCount > 1)
		{
			return inventory.nextSetEquipmentState;
		}
		if (inventory.equipmentSlotCount > 1)
		{
			return inventory.nextSlotEquipmentState;
		}
		return EquipmentState.empty;
	}
}