using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DestroyItemMenuOption")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DestroyItemMenuOption")]
[assembly: AssemblyTitle("DestroyItemMenuOption")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DestroyItemMenuOptionMod;
[BepInPlugin("com.iancuio.destroyitemmenuoptionmod", "Destroy Item Menu Option Mod", "1.0.0")]
public class DestroyItemPlugin : BaseUnityPlugin
{
internal void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.iancuio.destroyitemmenuoptionmod").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Destroy Item Menu Option Mod loaded successfully!");
}
}
[HarmonyPatch(typeof(ItemDisplayOptionPanel), "GetActiveActions")]
public class ItemDisplayOptionPanel_GetActiveActions_Patch
{
private const int DestroyActionID = 631;
[HarmonyPostfix]
public static void Postfix(ref List<int> __result)
{
if (__result != null)
{
__result.Add(631);
}
}
}
[HarmonyPatch(typeof(ItemDisplayOptionPanel), "GetActionText")]
public class ItemDisplayOptionPanel_GetActionText_Patch
{
private const int DestroyActionID = 631;
[HarmonyPrefix]
public static bool Prefix(int _actionID, ref string __result)
{
if (_actionID == 631)
{
__result = "Destroy Item";
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ItemDisplayOptionPanel), "ActionHasBeenPressed")]
public class ItemDisplayOptionPanel_ActionHasBeenPressed_Patch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__1_1;
internal void <Prefix>b__1_1()
{
}
}
private const int DestroyActionID = 631;
[HarmonyPrefix]
public static bool Prefix(ItemDisplayOptionPanel __instance, int _actionID)
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
if (_actionID != 631)
{
return true;
}
Item targetItem = Traverse.Create((object)__instance).Field("m_pendingItem").GetValue<Item>();
CharacterUI characterUI = Traverse.Create((object)__instance).Field("m_characterUI").GetValue<CharacterUI>();
if ((Object)(object)targetItem == (Object)null || (Object)(object)characterUI == (Object)null)
{
return false;
}
((UIElement)characterUI.ContextMenu).Hide();
MessagePanel messagePanel = characterUI.MessagePanel;
string text = "Are you sure you want to destroy \"" + targetItem.Name + "\"? This action is permanent.";
UnityAction val = delegate
{
if ((Object)(object)targetItem != (Object)null && !string.IsNullOrEmpty(targetItem.UID))
{
ItemManager.Instance.DestroyItem(targetItem.UID);
((UIElement)characterUI.ContextMenu).Hide();
}
};
object obj = <>c.<>9__1_1;
if (obj == null)
{
UnityAction val2 = delegate
{
};
<>c.<>9__1_1 = val2;
obj = (object)val2;
}
messagePanel.Show(text, "Destroy Item", val, (UnityAction)obj, true, -1f, (UnityAction)null);
return false;
}
}