// Consolidated decompiled source — Azumatt-ClickToDestroy v1.0.1 // Generated by Hexium's decompiled-source browser. Best-effort concatenation of every type in this // version's manifest — decompiler output isn't guaranteed to compile as-is. using System; using System.Runtime.CompilerServices; using System.IO; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; // ---- ClickToDestroy.dll :: Microsoft.CodeAnalysis.EmbeddedAttribute ---- namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } // ---- ClickToDestroy.dll :: ClickToDestroy.ClickToDestroyPlugin ---- namespace ClickToDestroy { [BepInPlugin("Azumatt.ClickToDestroy", "ClickToDestroy", "1.0.1")] public class ClickToDestroyPlugin : BaseUnityPlugin { internal const string ModName = "ClickToDestroy"; internal const string ModVersion = "1.0.1"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.ClickToDestroy"; private static string ConfigFileName = "Azumatt.ClickToDestroy.cfg"; private static string ConfigFileFullPath; private readonly Harmony _harmony = new Harmony("Azumatt.ClickToDestroy"); public static readonly ManualLogSource ClickToDestroyLogger; private static ConfigEntry modifierKey; private void Awake() { modifierKey = base.Config.Bind("1 - General", "Modifier Key", KeyCode.LeftControl, "The key that must be held down to destroy items"); _harmony.PatchAll(); SetupWatcher(); } private void OnDestroy() { base.Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { ClickToDestroyLogger.LogDebug("ReadConfigValues called"); base.Config.Reload(); } catch { ClickToDestroyLogger.LogError("There was an issue loading your " + ConfigFileName); ClickToDestroyLogger.LogError("Please check your config entries for spelling and format!"); } } static ClickToDestroyPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ClickToDestroyLogger = BepInEx.Logging.Logger.CreateLogSource("ClickToDestroy"); modifierKey = null; } } } // ---- ClickToDestroy.dll :: ClickToDestroy.UIInventoryRightClickOnBackpackSlotPatch ---- namespace ClickToDestroy { [HarmonyPatch(typeof(UISlotInventoryStorage), "OnPointerRightClick")] internal static class UIInventoryRightClickOnBackpackSlotPatch { private static bool Prefix(UISlotInventoryStorage __instance, PointerEventData eventData) { if (!Input.GetKey(KeyCode.LeftControl)) { return true; } if (__instance.Item == (Item)null) { return true; } ClickToDestroyPlugin.ClickToDestroyLogger.LogInfo("Destroying item"); __instance.Item.StorageBelongTo.RemoveItem(__instance.Item); Global.code.uiInventory.Refresh(); return false; } } }