using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using RoR2;
using RoR2.UI;
using TMPro;
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("RiskOfRain2ItemDescriptionOnScreen")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RiskOfRain2ItemDescriptionOnScreen")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6ce16a9-ffaa-4293-ba5a-9126020df40a")]
[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")]
[BepInPlugin("com.gigahanma.PickupItemDescription", "Add Description To Pickup Item", "1.0.0")]
public class PickupItemDescriptionPlugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
val.PatchAll();
}
}
[HarmonyPatch(typeof(ContextManager))]
[HarmonyPatch("Update")]
public static class UpdateItemDescriptionPatch
{
[HarmonyPostfix]
public static void Postfix(ContextManager __instance)
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
if (!((TMP_Text)__instance.descriptionTMP).text.Contains("Get"))
{
return;
}
HUD hud = __instance.hud;
CharacterBody val = (Object.op_Implicit((Object)(object)((hud != null) ? hud.targetBodyObject : null)) ? __instance.hud.targetBodyObject.GetComponent<CharacterBody>() : null);
if (!((Object)(object)val != (Object)null))
{
return;
}
InteractionDriver component = ((Component)val).GetComponent<InteractionDriver>();
if (!((Object)(object)component != (Object)null))
{
return;
}
GameObject obj = component.FindBestInteractableObject();
IInteractable val2 = ((obj != null) ? obj.GetComponent<IInteractable>() : null);
GenericPickupController val3 = (GenericPickupController)(object)((val2 is GenericPickupController) ? val2 : null);
if (val3 == null)
{
return;
}
PickupDef pickupDef = PickupCatalog.GetPickupDef(val3.pickupIndex);
if (pickupDef != null)
{
ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
if ((Object)(object)itemDef != (Object)null)
{
string @string = Language.GetString(itemDef.descriptionToken);
TextMeshProUGUI descriptionTMP = __instance.descriptionTMP;
((TMP_Text)descriptionTMP).text = ((TMP_Text)descriptionTMP).text + " (" + @string + ")";
}
}
}
}