Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TrashItem v1.0.2
TrashItem.dll
Decompiled 2 weeks agousing 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("TrashItem")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("Trash Item")] [assembly: AssemblyTitle("TrashItem")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [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 TrashItem { [BepInPlugin("TrashItem", "Trash Item", "1.0.2")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(InventoryGui), "SetupDragItem")] private static class Patch { private static void Postfix(ref ItemData item) { if (Instance.isOn()) { Instance.DragItem = item; if (item != null) { Instance.debugLog("item is selected " + item.m_shared.m_name.ToString()); } else { Instance.debugLog("item is not selected"); } } } } [HarmonyPatch(typeof(InventoryGui), "Update")] private static class Patch2 { private static void Postfix(ref InventoryGui __instance) { if (Instance.isOn() && !((Object)(object)__instance == (Object)null) && Instance.ClearDragItem) { Instance.ClearDragItem = false; __instance.SetupDragItem((ItemData)null, (Inventory)null, 1); Instance.debugLog("item is deselected"); } } } internal static Plugin Instance; internal static ManualLogSource Logger; internal static Harmony Harmony = new Harmony("TrashItem"); internal PluginConfig Enabled = null; internal PluginConfig Debug = null; internal PluginConfig Button = null; internal PluginConfig showMessages = null; internal ItemData DragItem = null; internal bool ClearDragItem = false; private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Enabled = new PluginConfig("General", "Enabled").AddStatus("Enable the plugin", defaultValue: true); Debug = new PluginConfig("General", "Debug").AddStatus("Enable debug mode"); Button = new PluginConfig("General", "Item Delete").AddTrigger("Delete drag item when enabled").AddShortcut((KeyCode)127).AddAction(DeleteItem); showMessages = new PluginConfig("General", "Show Messages").AddStatus("Show messages when item are deleted", defaultValue: true); Harmony.PatchAll(); Logger.LogInfo((object)"Plugin TrashItem is loaded!"); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); Harmony.UnpatchSelf(); Logger.LogInfo((object)"Plugin TrashItem is unloaded!"); } public bool isOn() { if (Enabled != null) { return Enabled.Status; } return false; } private void DeleteItem() { if ((Object)(object)Player.m_localPlayer == (Object)null || !InventoryGui.IsVisible()) { return; } if (DragItem == null) { if ((Object)(object)MessageHud.instance != (Object)null && showMessages.Status) { MessageHud.instance.ShowMessage((MessageType)2, "No item selected", 0, (Sprite)null, false, true); } debugLog("No item selected"); return; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); if (!inventory.ContainsItem(DragItem)) { if ((Object)(object)MessageHud.instance != (Object)null && showMessages.Status) { MessageHud.instance.ShowMessage((MessageType)2, "Item is not in player inventory", 0, (Sprite)null, false, true); } debugLog("Item is not in player inventory"); return; } ItemData itemAt = inventory.GetItemAt(DragItem.m_gridPos.x, DragItem.m_gridPos.y); if (itemAt == null) { return; } if (inventory.RemoveItem(itemAt, itemAt.m_stack)) { ClearDragItem = true; if ((Object)(object)MessageHud.instance != (Object)null && showMessages.Status) { MessageHud.instance.ShowMessage((MessageType)2, "Deleted " + itemAt.m_shared.m_name, 0, (Sprite)null, false, true); } } else if ((Object)(object)MessageHud.instance != (Object)null && showMessages.Status) { MessageHud.instance.ShowMessage((MessageType)2, "Faled to Delete " + itemAt.m_shared.m_name, 0, (Sprite)null, false, true); } } private void FixedUpdate() { if (Enabled != null) { Enabled.Update(); } if (isOn()) { if (Debug != null) { Debug.Update(); } if (Button != null) { Button.Update(); } if (showMessages != null) { showMessages.Update(); } } } public void debugLog(string message) { if (Debug != null && Debug.Status) { Logger.LogInfo((object)message); } } } public class PluginConfig { private ConfigEntry<bool> statusCE = null; private ConfigEntry<float> valueCE = null; private ConfigEntry<KeyboardShortcut> shortcutCE = null; private bool LastStatus = false; private Action onAction = null; private bool Startup = false; private bool OffOrOn = false; public string Section { get; private set; } public string Name { get; private set; } public bool IsTrigger { get; private set; } = false; public bool Status { get { if (statusCE != null) { return statusCE.Value; } return false; } set { if (statusCE != null && statusCE.Value != value) { statusCE.Value = value; } } } public float Value { get { if (valueCE != null) { return valueCE.Value; } return 0f; } set { if (valueCE != null) { valueCE.Value = value; } } } public PluginConfig(string section, string name) { Section = section; Name = name; } public PluginConfig AddStatus(string description, bool defaultValue = false) { statusCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>(Section, "Status of " + Name, defaultValue, description); return this; } public PluginConfig AddTrigger(string description, bool defaultValue = false) { IsTrigger = true; statusCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>(Section, "Trigger of " + Name, defaultValue, description); return this; } public PluginConfig AddValue(string description, float defaultValue, float minValue, float maxValue) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown valueCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>(Section, "Value of " + Name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(minValue, maxValue), Array.Empty<object>())); return this; } public PluginConfig AddShortcut(KeyCode key = (KeyCode)0, KeyCode[] modifiers = null) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) shortcutCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<KeyboardShortcut>(Section, "Shortcut of " + Name, new KeyboardShortcut(key, modifiers ?? Array.Empty<KeyCode>()), "Hotkey for on and off. Examples: Mouse 0, Mouse 1, Q, C, Shift + Q, Shift + C"); return this; } public PluginConfig AddAction(Action action) { onAction = action; if (valueCE != null) { valueCE.SettingChanged += delegate { action(); }; } return this; } public PluginConfig AddOffOrOn(bool offOrOn = false) { Startup = true; OffOrOn = offOrOn; return this; } public virtual void Update() { if (statusCE == null) { return; } if (Startup) { Status = OffOrOn; Startup = false; } if (shortcutCE != null && IskeyUp()) { Status = !Status; } if (Status != LastStatus) { string text = Section + " " + Name + " " + (IsTrigger ? "<color=green>Triggered</color>" : (Status ? "<color=green>Enabled</color>" : "<color=red>Disabled</color>")); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true); } if (onAction != null) { onAction(); } if (IsTrigger) { Status = false; } else { LastStatus = Status; } } } private bool IskeyUp() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = shortcutCE.Value; List<KeyCode> list = ((KeyboardShortcut)(ref value)).Modifiers.ToList(); foreach (KeyCode item in list) { if (!Input.GetKey(item)) { return false; } } value = shortcutCE.Value; if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey)) { return true; } return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TrashItem"; public const string PLUGIN_NAME = "Trash Item"; public const string PLUGIN_VERSION = "1.0.2"; } }