Decompiled source of ArtifactOfCommand ItemDescriptions v1.0.0

plugins\CommandItemDescriptions\CommandItemDescriptions.dll

Decompiled 13 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CommandItemDescriptions")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CommandItemDescriptions")]
[assembly: AssemblyTitle("CommandItemDescriptions")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 CommandItemDescriptions
{
	[HarmonyPatch(typeof(PickupPickerPanel), "SetPickupOptions")]
	internal static class CommandPickerPatch
	{
		private static void Postfix(PickupPickerPanel __instance, Option[] options, UIElementAllocator<MPButton> ___buttonAllocator)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)((Component)__instance).gameObject).name.StartsWith("CommandPickerPanel"))
			{
				return;
			}
			int num = Mathf.Min(options.Length, ___buttonAllocator.elements.Count);
			for (int i = 0; i < num; i++)
			{
				MPButton val = ___buttonAllocator.elements[i];
				Graphic val2 = ((Selectable)val).targetGraphic;
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = ((Component)val).GetComponentInChildren<Graphic>(true);
				}
				if (!((Object)(object)val2 == (Object)null))
				{
					val2.raycastTarget = true;
					TooltipProvider val3 = ((Component)val).GetComponent<TooltipProvider>();
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = ((Component)val).gameObject.AddComponent<TooltipProvider>();
					}
					ConfigureTooltip(val3, options[i].pickup.pickupIndex);
				}
			}
		}

		private static void ConfigureTooltip(TooltipProvider tooltip, PickupIndex pickupIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			if (pickupDef == null)
			{
				((Behaviour)tooltip).enabled = false;
				return;
			}
			ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
			string nameToken;
			string descriptionToken;
			if ((Object)(object)itemDef != (Object)null)
			{
				nameToken = itemDef.nameToken;
				descriptionToken = itemDef.descriptionToken;
			}
			else
			{
				if (!((Object)(object)equipmentDef != (Object)null))
				{
					((Behaviour)tooltip).enabled = false;
					return;
				}
				nameToken = equipmentDef.nameToken;
				descriptionToken = equipmentDef.descriptionToken;
			}
			((Behaviour)tooltip).enabled = true;
			tooltip.AllowTooltipOnNavigationSelect = true;
			tooltip.SetContent(new TooltipContent
			{
				titleToken = nameToken,
				titleColor = pickupDef.darkColor,
				bodyToken = descriptionToken,
				bodyColor = Color.white,
				overrideTitleText = null,
				overrideBodyText = null,
				disableTitleRichText = false,
				disableBodyRichText = false
			});
		}
	}
	[BepInPlugin("com.lebofly.artifactofcommanditemdescriptions", "Artifact of Command Item Descriptions", "1.0.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.lebofly.artifactofcommanditemdescriptions";

		public const string PluginName = "Artifact of Command Item Descriptions";

		public const string PluginVersion = "1.0.0";

		private Harmony harmony;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			harmony = new Harmony("com.lebofly.artifactofcommanditemdescriptions");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Artifact of Command Item Descriptions 1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
}