Decompiled source of Loot Manager v4.0.1
Erenshor.LootManager.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Tracing; using System.Dynamic; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Numerics; using System.Numerics.Hashing; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FxResources.System.Buffers; using FxResources.System.Numerics.Vectors; using HarmonyLib; using ImGuiNET; using Lunaris; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Lunaris { public interface ILog { void Log(string message); void LogWarning(string message); void LogError(string message); } } namespace LootManager { [BepInPlugin("et508.erenshor.lootmanager", "Loot Manager", "4.0.0")] [BepInProcess("Erenshor.exe")] public class Plugin : BaseUnityPlugin { private const string PluginGuid = "et508.erenshor.lootmanager"; internal static ILog Log; internal static Plugin Instance; internal static HashSet<string> Blacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); internal static HashSet<string> Whitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); internal static HashSet<string> Banklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); internal static HashSet<string> Junklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); internal static HashSet<string> Auctionlist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); internal static HashSet<string> Editlist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static Dictionary<string, HashSet<string>> FilterList = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); public static HashSet<string> EnabledFilterCategories = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static HashSet<string> FilterAppliedToBlacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static HashSet<string> FilterAppliedToWhitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static HashSet<string> FilterAppliedToBanklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static ConfigEntry<KeyboardShortcut> _cToggleLootUIHotkey; private static ConfigEntry<KeyboardShortcut> _cToggleAutoLootHotkey; private static ConfigEntry<bool> _cAutoLootEnabled; private static ConfigEntry<float> _cAutoLootDistance; private static ConfigEntry<bool> _cAutoLootDelayEnabled; private static ConfigEntry<float> _cAutoLootDelay; private static ConfigEntry<string> _cLootMethod; private static ConfigEntry<bool> _cAuctionLootEnabled; private static ConfigEntry<bool> _cBankLootEnabled; private static ConfigEntry<string> _cBankLootMethod; private static ConfigEntry<string> _cBankLootPageMode; private static ConfigEntry<int> _cBankPageFirst; private static ConfigEntry<int> _cBankPageLast; private static ConfigEntry<bool> _cBankslotAddToList; private static ConfigEntry<bool> _cLootRare; private static ConfigEntry<bool> _cLootEquipment; private static ConfigEntry<string> _cLootEquipmentTier; private static ConfigEntry<bool> _cFishingFilterEnabled; private static ConfigEntry<bool> _cMiningFilterEnabled; private static ConfigEntry<string> _cChatOutputWindow; private static ConfigEntry<int> _cChatOutputTab; private static ConfigEntry<bool> _cChatOutputEnabled; private static ConfigEntry<bool> _cDropZonesEnabled; private static ConfigEntry<float> _cDropZonesPosX; private static ConfigEntry<float> _cDropZonesPosY; internal ImGuiRenderer _imgui; private LootManagerWindow _window; private DropZonesWindow _dropZones; private Harmony _harmony; private LootManagerRunner _runner; private bool _imguiTried; private static T Get<T>(ConfigEntry<T> e, T fallback) { if (e == null) { return fallback; } return e.Value; } private static void Set<T>(ConfigEntry<T> e, T value) { if (e != null) { e.Value = value; } } public static bool GetAutoLootEnabled() { return Get(_cAutoLootEnabled, fallback: true); } public static float GetAutoLootDistance() { return Get(_cAutoLootDistance, 20f); } public static bool GetAutoLootDelayEnabled() { return Get(_cAutoLootDelayEnabled, fallback: false); } public static float GetAutoLootDelay() { return Get(_cAutoLootDelay, 3f); } public static string GetLootMethod() { return Get(_cLootMethod, "Blacklist"); } public static bool GetAuctionLootEnabled() { return Get(_cAuctionLootEnabled, fallback: true); } public static bool GetBankLootEnabled() { return Get(_cBankLootEnabled, fallback: false); } public static string GetBankLootMethod() { return Get(_cBankLootMethod, "All"); } public static string GetBankLootPageMode() { return Get(_cBankLootPageMode, "First Empty"); } public static int GetBankPageFirst() { return Get(_cBankPageFirst, 20); } public static int GetBankPageLast() { return Get(_cBankPageLast, 20); } public static bool GetBankslotAddToList() { return Get(_cBankslotAddToList, fallback: false); } public static bool GetLootRare() { return Get(_cLootRare, fallback: false); } public static bool GetLootEquipment() { return Get(_cLootEquipment, fallback: false); } public static string GetLootEquipmentTier() { return NormalizeTier(Get(_cLootEquipmentTier, "All")); } public static bool GetFishingFilterEnabled() { return Get(_cFishingFilterEnabled, fallback: false); } public static bool GetMiningFilterEnabled() { return Get(_cMiningFilterEnabled, fallback: false); } public static string GetChatOutputWindow() { return Get(_cChatOutputWindow, "MAINCHAT"); } public static int GetChatOutputTab() { return Get(_cChatOutputTab, 0); } public static bool GetChatOutputEnabled() { return Get(_cChatOutputEnabled, fallback: true); } public static bool GetDropZonesEnabled() { return Get(_cDropZonesEnabled, fallback: true); } public static float GetDropZonesPosX() { return Get(_cDropZonesPosX, -1f); } public static float GetDropZonesPosY() { return Get(_cDropZonesPosY, -1f); } public static KeyCode GetToggleLootUIHotkey() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (_cToggleLootUIHotkey == null) { return (KeyCode)287; } KeyboardShortcut value = _cToggleLootUIHotkey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } public static KeyCode GetToggleAutoLootHotkey() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (_cToggleAutoLootHotkey == null) { return (KeyCode)291; } KeyboardShortcut value = _cToggleAutoLootHotkey.Value; return ((KeyboardShortcut)(ref value)).MainKey; } public static void SetAutoLootEnabled(bool v) { Set(_cAutoLootEnabled, v); } public static void SetAutoLootDistance(float v) { Set(_cAutoLootDistance, v); } public static void SetAutoLootDelayEnabled(bool v) { Set(_cAutoLootDelayEnabled, v); } public static void SetAutoLootDelay(float v) { Set(_cAutoLootDelay, v); } public static void SetLootMethod(string v) { Set(_cLootMethod, v); } public static void SetAuctionLootEnabled(bool v) { Set(_cAuctionLootEnabled, v); } public static void SetBankLootEnabled(bool v) { Set(_cBankLootEnabled, v); } public static void SetBankLootMethod(string v) { Set(_cBankLootMethod, v); } public static void SetBankLootPageMode(string v) { Set(_cBankLootPageMode, v); } public static void SetBankPageFirst(int v) { Set(_cBankPageFirst, v); } public static void SetBankPageLast(int v) { Set(_cBankPageLast, v); } public static void SetBankslotAddToList(bool v) { Set(_cBankslotAddToList, v); } public static void SetLootRare(bool v) { Set(_cLootRare, v); } public static void SetLootEquipment(bool v) { Set(_cLootEquipment, v); } public static void SetLootEquipmentTier(string v) { Set(_cLootEquipmentTier, v); } public static void SetFishingFilterEnabled(bool v) { Set(_cFishingFilterEnabled, v); } public static void SetMiningFilterEnabled(bool v) { Set(_cMiningFilterEnabled, v); } public static void SetChatOutputWindow(string v) { Set(_cChatOutputWindow, v); } public static void SetChatOutputTab(int v) { Set(_cChatOutputTab, v); } public static void SetChatOutputEnabled(bool v) { Set(_cChatOutputEnabled, v); } public static void SetDropZonesEnabled(bool v) { Set(_cDropZonesEnabled, v); } public static void SetToggleLootUIHotkey(KeyCode v) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_cToggleLootUIHotkey != null) { _cToggleLootUIHotkey.Value = new KeyboardShortcut(v, Array.Empty<KeyCode>()); } } public static void SetToggleAutoLootHotkey(KeyCode v) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_cToggleAutoLootHotkey != null) { _cToggleAutoLootHotkey.Value = new KeyboardShortcut(v, Array.Empty<KeyCode>()); } } public static void SetDropZonesPos(float x, float y) { Set(_cDropZonesPosX, x); Set(_cDropZonesPosY, y); } private static string NormalizeTier(string v) { if (string.IsNullOrEmpty(v)) { return "All"; } switch (v.Replace(" ", "").ToLowerInvariant()) { case "normalonly": return "Normal Only"; case "improvedonly": return "Improved Only"; case "blessedonly": return "Blessed Only"; case "ascendedonly": case "godlyonly": return "Ascended Only"; case "improvedandup": return "Improved and Up"; case "blessedandup": return "Blessed and Up"; default: return "All"; } } [DllImport("kernel32.dll", SetLastError = true)] private static extern IntPtr LoadLibrary(string path); private void Awake() { try { AwakeInner(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LootManager] Awake complete."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LootManager] Awake failed: " + ex)); } } private void AwakeInner() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown Instance = this; Log = new BepInExLog(((BaseUnityPlugin)this).Logger); BindConfig(); LootBlacklist.Load(); LootWhitelist.Load(); LootBanklist.Load(); LootJunklist.Load(); LootAuctionlist.Load(); LootFilterlist.Load(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loot Manager loaded."); _harmony = new Harmony("et508.erenshor.lootmanager"); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { if (assemblies[i].GetName().Name == "ErenshorQoL") { string text = "Brumdail.ErenshorQoLMod"; MethodInfo methodInfo = AccessTools.Method(typeof(LootWindow), "LootAll", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Character), "DoDeath", new Type[0], (Type[])null); if (methodInfo != null) { _harmony.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)1, text); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Loot Manager] Unpatched ErenshorQoL LootAll prefix."); } if (methodInfo2 != null) { _harmony.Unpatch((MethodBase)methodInfo2, (HarmonyPatchType)2, text); ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Loot Manager] Unpatched ErenshorQoL DoDeath postfix."); } break; } } _harmony.PatchAll(); LootManagerController.Initialize(); GameObject val = new GameObject("LootManager_Hotkeys"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<AutoLootHotkeyListener>(); GameObject val2 = new GameObject("LootManager_Runner"); Object.DontDestroyOnLoad((Object)(object)val2); ((Object)val2).hideFlags = (HideFlags)61; _runner = val2.AddComponent<LootManagerRunner>(); _runner.Owner = this; } private void OnEnable() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LootManager] Plugin object enabled."); } private void OnDisable() { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[LootManager] Plugin object disabled."); } private void BindConfig() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown _cToggleLootUIHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle LootUI Hotkey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Hotkey to toggle the Loot Manager UI window."); _cToggleAutoLootHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Autoloot Toggle Hotkey", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), "Hotkey to toggle auto looting on and off."); _cAutoLootEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Autoloot Settings", "Enable Autoloot", true, "Enable or disable auto looting."); _cAutoLootDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Autoloot Settings", "Autoloot Distance", 20f, "Maximum distance for auto looting."); _cAutoLootDelayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Autoloot Settings", "Enable Autoloot Delay", false, "If true, autoloot waits until fully out of combat before looting queued kills."); _cAutoLootDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Autoloot Settings", "Autoloot Delay Seconds", 3f, "Extra grace period in seconds to wait after combat ends before autolooting (0 - 10)."); _cLootMethod = ((BaseUnityPlugin)this).Config.Bind<string>("Loot Method Settings", "Loot Method", "Blacklist", "Loot method to use: Blacklist, Whitelist, or Standard."); _cAuctionLootEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Auction Settings", "Auction Loot Enabled", true, "If true, items on the auctionlist are looted and listed on the Auction House."); _cBankLootEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Bankloot Settings", "Bankloot Enabled", false, "If enabled, looted items will be deposited to bank instead of inventory."); _cBankLootMethod = ((BaseUnityPlugin)this).Config.Bind<string>("Bankloot Settings", "Bankloot Method", "All", "Method for bank looting: All or Filtered"); _cBankLootPageMode = ((BaseUnityPlugin)this).Config.Bind<string>("Bankloot Settings", "Bankloot Page Mode", "First Empty", "Mode for depositing items to bank: First Empty or Page Range"); _cBankPageFirst = ((BaseUnityPlugin)this).Config.Bind<int>("Bankloot Settings", "Bank Page First", 20, new ConfigDescription("First bank page to use when in Page Range mode.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 98), Array.Empty<object>())); _cBankPageLast = ((BaseUnityPlugin)this).Config.Bind<int>("Bankloot Settings", "Bank Page Last", 20, new ConfigDescription("Last bank page to use when in Page Range mode.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 98), Array.Empty<object>())); _cBankslotAddToList = ((BaseUnityPlugin)this).Config.Bind<bool>("Bankloot Settings", "Bankslot Add", false, "If true, items sent to the bank with the inventory Bankslot will be added to the Banklist."); _cLootRare = ((BaseUnityPlugin)this).Config.Bind<bool>("Filter Settings", "Loot Rare Equipment", false, "If true, always loot rare equipment in blacklist loot method."); _cLootEquipment = ((BaseUnityPlugin)this).Config.Bind<bool>("Filter Settings", "Loot Equipment", false, "If true, equipable items are looted regardless of blacklist status."); _cLootEquipmentTier = ((BaseUnityPlugin)this).Config.Bind<string>("Filter Settings", "Loot Equipment Tier", "All", "Which tiers of equipment to loot: All, Normal Only, Improved Only, Blessed Only, Ascended Only, Improved and Up, Blessed and Up."); _cFishingFilterEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Filter Settings", "Apply Filters to Fishing", false, "If true, loot filters (blacklist/whitelist/banklist/auctionlist) are applied to fishing catches."); _cMiningFilterEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Filter Settings", "Apply Filters to Mining", false, "If true, loot filters are applied to mining yields."); _cChatOutputWindow = ((BaseUnityPlugin)this).Config.Bind<string>("Chat Settings", "Chat Output Window", "MAINCHAT", "WindowName of the IDLog window to send Loot Manager messages to."); _cChatOutputTab = ((BaseUnityPlugin)this).Config.Bind<int>("Chat Settings", "Chat Output Tab", 0, new ConfigDescription("Tab index (0-based) within the selected chat window.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>())); _cChatOutputEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Chat Settings", "Chat Output Enabled", true, "If false, Loot Manager will not send any messages to chat."); _cDropZonesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "Show Drop Zones Window", true, "Show the Drop Zones window while the inventory is open."); _cDropZonesPosX = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Drop Zones Position X", -1f, "Saved window position (fraction of screen width). Set automatically when you drag the window; -1 = default."); _cDropZonesPosY = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Drop Zones Position Y", -1f, "Saved window position (fraction of screen height). Set automatically when you drag the window; -1 = default."); } internal void RunStart() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LootManager] Start() reached."); TryInitImGui(); } private void TryInitImGui() { if (_imguiTried) { return; } _imguiTried = true; try { InitImGuiStartup(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LootManager] ImGui startup failed: " + ex)); } } private void InitImGuiStartup() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Paths.PluginPath, "cimgui.dll"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LootManager] cimgui.dll not found at: " + text)); return; } IntPtr intPtr = LoadLibrary(text); if (intPtr == IntPtr.Zero) { ((BaseUnityPlugin)this).Logger.LogError((object)("[LootManager] Failed to pre-load cimgui.dll (Win32 error " + Marshal.GetLastWin32Error() + ")")); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[LootManager] cimgui.dll loaded at 0x" + intPtr.ToString("X"))); InitImGuiTypes(); } [MethodImpl(MethodImplOptions.NoInlining)] private void InitImGuiTypes() { float num = Mathf.Clamp((float)Screen.height / 1080f, 0.5f, 4f); _window = new LootManagerWindow(); _dropZones = new DropZonesWindow(); _imgui = new ImGuiRenderer(Log); _imgui.UiScale = num; _imgui.OnLayout = delegate { _window.Draw(); _dropZones.Draw(); }; if (!_imgui.Init()) { ((BaseUnityPlugin)this).Logger.LogError((object)"[LootManager] ImGui init failed — UI will not render."); return; } PointerOverUIPatch.Renderer = _imgui; _window.Scale = num; _dropZones.Scale = num; GameObject val = (((Object)(object)_runner != (Object)null) ? ((Component)_runner).gameObject : ((Component)this).gameObject); (val.GetComponent<ImGuiInputMute>() ?? val.AddComponent<ImGuiInputMute>()).Renderer = _imgui; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[LootManager] ImGui UI ready."); } public static void ToggleWindow() { if ((Object)(object)Instance != (Object)null && Instance._window != null) { Instance._window.Toggle(); } } internal void RunUpdate() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (!_imguiTried) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[LootManager] Start() did not run — initialising ImGui from Update()."); TryInitImGui(); } if (_window != null && !GameData.PlayerTyping && (_imgui == null || !_imgui.WantTextInput) && Input.GetKeyDown(GetToggleLootUIHotkey())) { _window.Toggle(); } } internal void RunOnGUI() { if (_imgui != null) { _imgui.OnGUI(); } } internal void RunQuit() { if (_imgui != null) { _imgui.OnApplicationQuit(); } } private void OnDestroy() { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[LootManager] Plugin object destroyed — shutting down."); if (_harmony != null) { _harmony.UnpatchSelf(); _harmony = null; } PointerOverUIPatch.Renderer = null; if ((Object)(object)_runner != (Object)null) { ImGuiInputMute component = ((Component)_runner).GetComponent<ImGuiInputMute>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Object.Destroy((Object)(object)((Component)_runner).gameObject); _runner = null; } if (_imgui != null) { _imgui.Dispose(); _imgui = null; } GameObject val = GameObject.Find("LootManager_Hotkeys"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } Instance = null; } } internal sealed class BepInExLog : ILog { private readonly ManualLogSource _src; public BepInExLog(ManualLogSource src) { _src = src; } public void Log(string message) { _src.LogInfo((object)message); } public void LogWarning(string message) { _src.LogWarning((object)message); } public void LogError(string message) { _src.LogError((object)message); } } internal sealed class LootManagerRunner : MonoBehaviour { internal Plugin Owner; private void Start() { if ((Object)(object)Owner != (Object)null) { Owner.RunStart(); } } private void Update() { if ((Object)(object)Owner != (Object)null) { Owner.RunUpdate(); } } private void OnGUI() { if ((Object)(object)Owner != (Object)null) { Owner.RunOnGUI(); } } private void OnApplicationQuit() { if ((Object)(object)Owner != (Object)null) { Owner.RunQuit(); } } } internal static class LootManagerPaths { public static string ConfigDir => Paths.ConfigPath; } public sealed class AutoLootHotkeyListener : MonoBehaviour { private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!GameData.PlayerTyping && Input.GetKeyDown(Plugin.GetToggleAutoLootHotkey())) { bool flag = !Plugin.GetAutoLootEnabled(); Plugin.SetAutoLootEnabled(flag); ChatFilterInjector.SendLootMessage(flag ? "[Loot Manager] Autoloot ON" : "[Loot Manager] Autoloot OFF", flag ? "green" : "red"); } } } internal sealed class ImGuiInputMute : MonoBehaviour { internal ImGuiRenderer Renderer; private bool _wasMuted; private static bool _haveCached; private static KeyCode _fwd; private static KeyCode _bwd; private static KeyCode _left; private static KeyCode _right; private static KeyCode _strafeL; private static KeyCode _strafeR; private static KeyCode _jump; private static KeyCode _map; private void Update() { bool flag = Renderer != null && Renderer.WantTextInput; if (flag && !_wasMuted) { Mute(); } else if (!flag && _wasMuted) { Unmute(); } } private void OnDisable() { if (_wasMuted) { Unmute(); } } private void Mute() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) _wasMuted = true; GameData.PlayerTyping = true; if ((Object)(object)GameData.PlayerControl != (Object)null) { GameData.PlayerControl.CanMove = false; GameData.PlayerControl.Autorun = false; } CacheKeysIfNeeded(); InputManager.Forward = (KeyCode)0; InputManager.Backward = (KeyCode)0; InputManager.Left = (KeyCode)0; InputManager.Right = (KeyCode)0; InputManager.StrafeL = (KeyCode)0; InputManager.StrafeR = (KeyCode)0; InputManager.Jump = (KeyCode)0; InputManager.Map = (KeyCode)0; } private void Unmute() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) _wasMuted = false; TypeText textInput = GameData.TextInput; bool? obj; if (textInput == null) { obj = null; } else { GameObject inputBox = textInput.InputBox; obj = ((inputBox != null) ? new bool?(inputBox.activeSelf) : ((bool?)null)); } bool? flag = obj; if (flag != true) { GameData.PlayerTyping = false; if ((Object)(object)GameData.PlayerControl != (Object)null) { GameData.PlayerControl.CanMove = true; } } if (_haveCached) { InputManager.Forward = _fwd; InputManager.Backward = _bwd; InputManager.Left = _left; InputManager.Right = _right; InputManager.StrafeL = _strafeL; InputManager.StrafeR = _strafeR; InputManager.Jump = _jump; InputManager.Map = _map; } } private static void CacheKeysIfNeeded() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!_haveCached) { _fwd = InputManager.Forward; _bwd = InputManager.Backward; _left = InputManager.Left; _right = InputManager.Right; _strafeL = InputManager.StrafeL; _strafeR = InputManager.StrafeR; _jump = InputManager.Jump; _map = InputManager.Map; _haveCached = true; } } } public enum EquipmentTierSetting { All, NormalOnly, ImprovedOnly, BlessedOnly, AscendedOnly, ImprovedAndUp, BlessedAndUp } [HarmonyPatch(typeof(TypeText), "CheckCommands")] public static class LootCommands { public static bool Prefix() { string text = GameData.TextInput.typed.text; if (string.IsNullOrWhiteSpace(text)) { return true; } if (text.Equals("/lootui", StringComparison.OrdinalIgnoreCase)) { Plugin.ToggleWindow(); ClearInput(); return false; } return true; } private static void ClearInput() { GameData.TextInput.typed.text = ""; GameData.TextInput.CDFrames = 10f; GameData.TextInput.InputBox.SetActive(false); GameData.PlayerTyping = false; } } public class LootManagerController : MonoBehaviour { private class Bootstrap : MonoBehaviour { internal static Bootstrap Instance; private Coroutine _waitRoutine; private bool _waiting; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; ((Object)this).name = "LootManager_Loader"; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void KickWaitForGameManager() { if (!_waiting) { if (_waitRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_waitRoutine); } _waitRoutine = ((MonoBehaviour)this).StartCoroutine(WaitForGameManagerThenSpawn()); } } private IEnumerator WaitForGameManagerThenSpawn() { _waiting = true; GameObject gm = null; while ((Object)(object)gm == (Object)null) { gm = GameObject.Find("GameManager"); if ((Object)(object)gm == (Object)null) { yield return null; } } _waiting = false; SpawnUnderGameManager(gm); } } private static bool _initialized; private static LootManagerController _instance; private const string ControllerName = "LootManager_Controller"; private const string BootstrapName = "LootManager_Loader"; private const string TargetAnchorName = "GameManager"; private const string LegacyInvName = "PlayerInv"; public static void Initialize() { if (!_initialized) { _initialized = true; EnsureBootstrapExists(); SceneManager.sceneLoaded += OnSceneLoaded_Static; SceneManager.activeSceneChanged += OnActiveSceneChanged_Static; } } private static void OnSceneLoaded_Static(Scene scene, LoadSceneMode mode) { EnsureBootstrapExists(); Bootstrap.Instance?.KickWaitForGameManager(); } private static void OnActiveSceneChanged_Static(Scene oldScene, Scene newScene) { EnsureBootstrapExists(); Bootstrap.Instance?.KickWaitForGameManager(); } private static void EnsureBootstrapExists() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if (!((Object)(object)Bootstrap.Instance != (Object)null)) { GameObject val = GameObject.Find("LootManager_Loader"); if ((Object)(object)val == (Object)null) { val = new GameObject("LootManager_Loader"); Object.DontDestroyOnLoad((Object)(object)val); } Bootstrap bootstrap = val.GetComponent<Bootstrap>(); if ((Object)(object)bootstrap == (Object)null) { bootstrap = val.AddComponent<Bootstrap>(); } bootstrap.KickWaitForGameManager(); } } private static void SpawnUnderGameManager(GameObject gameManager) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null) || !((Object)(object)((Component)_instance).gameObject != (Object)null)) { GameObject val = GameObject.Find("LootManager_Controller"); GameObject val2 = (GameObject)((!((Object)(object)val != (Object)null)) ? ((object)new GameObject("LootManager_Controller")) : ((object)val)); ((Object)val2).hideFlags = (HideFlags)0; val2.transform.SetParent(gameManager.transform, false); _instance = val2.GetComponent<LootManagerController>(); if ((Object)(object)_instance == (Object)null) { _instance = val2.AddComponent<LootManagerController>(); } } } private void OnEnable() { ((MonoBehaviour)this).StartCoroutine(WaitForInventoryAndInit()); } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } private IEnumerator WaitForInventoryAndInit() { while ((Object)(object)GameObject.Find("PlayerInv") == (Object)null) { yield return null; } int chatWaitFrames = 0; while (UpdateSocialLog.ChatWindows.Count == 0 && chatWaitFrames < 120) { yield return null; chatWaitFrames++; } ChatFilterInjector.ApplyChatMask(); } } public static class LootAuctionlist { private const string FileName = "LootAuctionlist.json"; private const string ConfigSub = "LootManager"; private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; public static void Load() { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootAuctionlist.json"); try { Directory.CreateDirectory(text); if (!File.Exists(path)) { string contents = JsonConvert.SerializeObject(new LootListData { Items = new List<string>() }, _jsonSettings); File.WriteAllText(path, contents); Plugin.Auctionlist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log("[Loot Manager] Created default LootAuctionlist.json"); } else { Plugin.Auctionlist = new HashSet<string>(from s in (JsonConvert.DeserializeObject<LootListData>(File.ReadAllText(path)) ?? new LootListData()).Items ?? new List<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log($"[Loot Manager] Loaded {Plugin.Auctionlist.Count} auctionlisted items."); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to load {0}: {1}", "LootAuctionlist.json", arg)); Plugin.Auctionlist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } } public static void SaveAuctionlist() { try { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootAuctionlist.json"); Directory.CreateDirectory(text); List<string> items = (from s in Plugin.Auctionlist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase) where !string.IsNullOrWhiteSpace(s) select s.Trim()).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList(); string contents = JsonConvert.SerializeObject(new LootListData { Items = items }, _jsonSettings); File.WriteAllText(path, contents); } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to save {0}: {1}", "LootAuctionlist.json", arg)); } } public static HashSet<string> Read() { return new HashSet<string>(Plugin.Auctionlist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); } public static void SaveAll(IEnumerable<string> items) { Plugin.Auctionlist = new HashSet<string>(from s in items ?? Enumerable.Empty<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); SaveAuctionlist(); } } [Serializable] public sealed class LootBankListData { [JsonProperty] public List<string> Items = new List<string>(); } public static class LootBanklist { private const string FileName = "LootBanklist.json"; private const string ConfigSub = "LootManager"; private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; public static void Load() { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string text2 = Path.Combine(text, "LootBanklist.json"); string text3 = Path.Combine(LootManagerPaths.ConfigDir, "LootBanklist.json"); try { Directory.CreateDirectory(text); if (!File.Exists(text2) && File.Exists(text3)) { TryMigrateLegacyFile(text3, text2); } if (!File.Exists(text2)) { string contents = JsonConvert.SerializeObject(new LootBankListData { Items = new List<string>() }, _jsonSettings); File.WriteAllText(text2, contents); Plugin.Banklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log("[Loot Manager] Created default LootBanklist.json"); } else { Plugin.Banklist = new HashSet<string>(from s in (JsonConvert.DeserializeObject<LootBankListData>(File.ReadAllText(text2)) ?? new LootBankListData()).Items ?? new List<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log($"[Loot Manager] Loaded {Plugin.Banklist.Count} banklisted items."); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to load {0}: {1}", "LootBanklist.json", arg)); Plugin.Banklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } } public static void SaveBanklist() { try { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootBanklist.json"); Directory.CreateDirectory(text); List<string> items = (from s in Plugin.Banklist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase) where !string.IsNullOrWhiteSpace(s) select s.Trim()).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList(); string contents = JsonConvert.SerializeObject(new LootBankListData { Items = items }, _jsonSettings); File.WriteAllText(path, contents); } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to save {0}: {1}", "LootBanklist.json", arg)); } } public static HashSet<string> Read() { return new HashSet<string>(Plugin.Banklist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); } public static void SaveAll(IEnumerable<string> items) { Plugin.Banklist = new HashSet<string>(from s in items ?? Enumerable.Empty<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); SaveBanklist(); } private static void TryMigrateLegacyFile(string legacyPath, string newPath) { try { if (File.Exists(newPath)) { string text = legacyPath + ".bak"; File.Copy(legacyPath, text, overwrite: true); File.Delete(legacyPath); Plugin.Log?.LogWarning("[Loot Manager] Found both legacy and new LootBanklist.json. Kept new; backed up legacy to " + text + " and removed original legacy file."); } else { File.Move(legacyPath, newPath); Plugin.Log?.Log("[Loot Manager] Migrated legacy LootBanklist.json to " + newPath); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to migrate legacy {0}: {1}", "LootBanklist.json", arg)); } } } [Serializable] public sealed class LootListData { [JsonProperty] public List<string> Items = new List<string>(); } public static class LootBlacklist { private const string FileName = "LootBlacklist.json"; private const string ConfigSub = "LootManager"; private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; public static void Load() { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string text2 = Path.Combine(text, "LootBlacklist.json"); string text3 = Path.Combine(LootManagerPaths.ConfigDir, "LootBlacklist.json"); try { Directory.CreateDirectory(text); if (!File.Exists(text2) && File.Exists(text3)) { TryMigrateLegacyFile(text3, text2); } if (!File.Exists(text2)) { string contents = JsonConvert.SerializeObject(new LootListData { Items = new List<string>() }, _jsonSettings); File.WriteAllText(text2, contents); Plugin.Blacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log("[Loot Manager] Created default LootBlacklist.json"); } else { Plugin.Blacklist = new HashSet<string>(from s in (JsonConvert.DeserializeObject<LootListData>(File.ReadAllText(text2)) ?? new LootListData()).Items ?? new List<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log($"[Loot Manager] Loaded {Plugin.Blacklist.Count} blacklisted items."); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to load {0}: {1}", "LootBlacklist.json", arg)); Plugin.Blacklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } } public static void SaveBlacklist() { try { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootBlacklist.json"); Directory.CreateDirectory(text); List<string> items = (from s in Plugin.Blacklist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase) where !string.IsNullOrWhiteSpace(s) select s.Trim()).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList(); string contents = JsonConvert.SerializeObject(new LootListData { Items = items }, _jsonSettings); File.WriteAllText(path, contents); } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to save {0}: {1}", "LootBlacklist.json", arg)); } } public static HashSet<string> Read() { return new HashSet<string>(Plugin.Blacklist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); } public static void SaveAll(IEnumerable<string> items) { Plugin.Blacklist = new HashSet<string>(from s in items ?? Enumerable.Empty<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); SaveBlacklist(); } private static void TryMigrateLegacyFile(string legacyPath, string newPath) { try { if (File.Exists(newPath)) { string text = legacyPath + ".bak"; File.Copy(legacyPath, text, overwrite: true); File.Delete(legacyPath); Plugin.Log?.LogWarning("[Loot Manager] Found both legacy and new LootBlacklist.json. Kept new; backed up legacy to " + text + " and removed original legacy file."); } else { File.Move(legacyPath, newPath); Plugin.Log?.Log("[Loot Manager] Migrated legacy LootBlacklist.json to " + newPath); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to migrate legacy {0}: {1}", "LootBlacklist.json", arg)); } } } [Serializable] public class LootFilterCategory { [JsonProperty] public bool IsEnabled = true; [JsonProperty] public bool AppliedToBlacklist; [JsonProperty] public bool AppliedToWhitelist; [JsonProperty] public bool AppliedToBanklist; [JsonProperty] public List<string> Items = new List<string>(); } public static class LootFilterlist { private const string FileName = "LootFilterlist.json"; private const string ConfigSub = "LootManager"; private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; public static void Load() { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootFilterlist.json"); try { Directory.CreateDirectory(text); if (!File.Exists(path)) { Dictionary<string, LootFilterCategory> obj = LootFilterlistDefaults.GetDefaultData() ?? new Dictionary<string, LootFilterCategory>(StringComparer.OrdinalIgnoreCase); string contents = JsonConvert.SerializeObject(obj, _jsonSettings); File.WriteAllText(path, contents); ApplyToPluginState(obj); Plugin.Log?.Log("[Loot Manager] Created default LootFilterlist.json"); } else { ApplyToPluginState(JsonConvert.DeserializeObject<Dictionary<string, LootFilterCategory>>(File.ReadAllText(path)) ?? new Dictionary<string, LootFilterCategory>(StringComparer.OrdinalIgnoreCase)); Plugin.Log?.Log($"[Loot Manager] Loaded {Plugin.FilterList.Count} filter groups."); } } catch (Exception ex) { Plugin.Log?.LogError("[Loot Manager] Failed to load LootFilterlist.json: " + ex); Plugin.FilterList = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); Plugin.EnabledFilterCategories = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } } public static void SaveFilterlist() { try { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootFilterlist.json"); Directory.CreateDirectory(text); Dictionary<string, LootFilterCategory> dictionary = new Dictionary<string, LootFilterCategory>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, HashSet<string>> item in Plugin.FilterList.OrderBy<KeyValuePair<string, HashSet<string>>, string>((KeyValuePair<string, HashSet<string>> k) => k.Key, StringComparer.OrdinalIgnoreCase)) { string key = item.Key; IEnumerable<string> source = from s in item.Value ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase) where !string.IsNullOrWhiteSpace(s) select s.Trim(); dictionary[key] = new LootFilterCategory { IsEnabled = (Plugin.EnabledFilterCategories?.Contains(key) ?? false), AppliedToBlacklist = (Plugin.FilterAppliedToBlacklist?.Contains(key) ?? false), AppliedToWhitelist = (Plugin.FilterAppliedToWhitelist?.Contains(key) ?? false), AppliedToBanklist = (Plugin.FilterAppliedToBanklist?.Contains(key) ?? false), Items = source.OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList() }; } string contents = JsonConvert.SerializeObject(dictionary, _jsonSettings); File.WriteAllText(path, contents); } catch (Exception ex) { Plugin.Log?.LogError("[Loot Manager] Failed to save LootFilterlist.json: " + ex); } } public static void ReadAll(out Dictionary<string, HashSet<string>> sections, out HashSet<string> enabled) { sections = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, HashSet<string>> filter in Plugin.FilterList) { HashSet<string> collection = ((filter.Value != null) ? filter.Value : new HashSet<string>(StringComparer.OrdinalIgnoreCase)); sections[filter.Key] = new HashSet<string>(collection, StringComparer.OrdinalIgnoreCase); } enabled = new HashSet<string>(Plugin.EnabledFilterCategories ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); } public static HashSet<string> ReadEnabled() { return new HashSet<string>(Plugin.EnabledFilterCategories ?? new HashSet<string>(), StringComparer.OrdinalIgnoreCase); } public static HashSet<string> ReadSectionItems(string sectionName) { if (string.IsNullOrWhiteSpace(sectionName)) { return new HashSet<string>(StringComparer.OrdinalIgnoreCase); } if (Plugin.FilterList.TryGetValue(sectionName, out var value) && value != null) { return new HashSet<string>(value, StringComparer.OrdinalIgnoreCase); } return new HashSet<string>(StringComparer.OrdinalIgnoreCase); } public static void SetAppliedTo(string sectionName, string listKey, bool value) { if (string.IsNullOrWhiteSpace(sectionName)) { return; } HashSet<string> hashSet = null; switch (listKey) { case "Blacklist": hashSet = Plugin.FilterAppliedToBlacklist; break; case "Whitelist": hashSet = Plugin.FilterAppliedToWhitelist; break; case "Banklist": hashSet = Plugin.FilterAppliedToBanklist; break; } if (hashSet != null) { if (value) { hashSet.Add(sectionName); } else { hashSet.Remove(sectionName); } SaveFilterlist(); } } public static void SetSectionEnabled(string sectionName, bool isEnabled) { if (!string.IsNullOrWhiteSpace(sectionName)) { if (!Plugin.FilterList.ContainsKey(sectionName)) { Plugin.FilterList[sectionName] = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } if (isEnabled) { Plugin.EnabledFilterCategories.Add(sectionName); } else { Plugin.EnabledFilterCategories.Remove(sectionName); } SaveFilterlist(); } } public static void SaveSectionItems(string sectionName, IEnumerable<string> items, bool? setEnabled = null) { if (string.IsNullOrWhiteSpace(sectionName)) { return; } HashSet<string> value = new HashSet<string>(from s in items ?? Enumerable.Empty<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); Plugin.FilterList[sectionName] = value; if (setEnabled.HasValue) { if (setEnabled.Value) { Plugin.EnabledFilterCategories.Add(sectionName); } else { Plugin.EnabledFilterCategories.Remove(sectionName); } } SaveFilterlist(); } public static void SaveAll(Dictionary<string, HashSet<string>> sections, HashSet<string> enabled) { Plugin.FilterList = sections ?? new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); Plugin.EnabledFilterCategories = enabled ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase); SaveFilterlist(); } private static void ApplyToPluginState(Dictionary<string, LootFilterCategory> input) { Dictionary<string, HashSet<string>> dictionary = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); HashSet<string> hashSet2 = new HashSet<string>(StringComparer.OrdinalIgnoreCase); HashSet<string> hashSet3 = new HashSet<string>(StringComparer.OrdinalIgnoreCase); HashSet<string> hashSet4 = new HashSet<string>(StringComparer.OrdinalIgnoreCase); if (input != null) { foreach (KeyValuePair<string, LootFilterCategory> item in input) { string text = item.Key?.Trim(); if (!string.IsNullOrEmpty(text)) { LootFilterCategory obj = item.Value ?? new LootFilterCategory(); HashSet<string> value = new HashSet<string>(from s in obj.Items ?? new List<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); dictionary[text] = value; if (obj.IsEnabled) { hashSet.Add(text); } if (obj.AppliedToBlacklist) { hashSet2.Add(text); } if (obj.AppliedToWhitelist) { hashSet3.Add(text); } if (obj.AppliedToBanklist) { hashSet4.Add(text); } } } } Plugin.FilterList = dictionary; Plugin.EnabledFilterCategories = hashSet; Plugin.FilterAppliedToBlacklist = hashSet2; Plugin.FilterAppliedToWhitelist = hashSet3; Plugin.FilterAppliedToBanklist = hashSet4; } } public static class LootFilterlistDefaults { public static Dictionary<string, LootFilterCategory> GetDefaultData() { return new Dictionary<string, LootFilterCategory>(StringComparer.OrdinalIgnoreCase) { ["Consumable"] = new LootFilterCategory { IsEnabled = true, Items = new List<string> { "Azure Mead", "Bottomless Elixir", "Brackfruit Juice", "Bread", "Elixir of Enlightenment I", "Elixir of Enlightenment II", "Elixir of Enlightenment III", "Elixir of Enlightenment IV", "Droplet of Lava", "Seafruit", "Seaspice", "Muck Ball", "Vithean Brew", "Water" } }, ["Keys"] = new LootFilterCategory { IsEnabled = true, Items = new List<string> { "Ancient Braxonian Key", "Port Azure Lighthouse Key", "Shivering Key (Halloween Event)", "Dockhouse Key", "Ghostly Key", "Intricate Key", "Key to Vitheo's Rest", "Key to Vitheo's Tomb", "Krakengard Tower Key", "Krakengard Bunk Key", "Old Church Key", "Rockshade Key", "Sableheart's Key", "Shivering Step Lighthouse Key", "Shrines Key", "Stowaway's Step Gate Key", "Stowaway's Step Lighthouse Key", "Key To Traitor's Halls" } }, ["Chess Pieces"] = new LootFilterCategory { IsEnabled = true, Items = new List<string> { "Blaze Fiend", "Ember Acolyte", "Kingsman", "Monarch of Flame", "Peon", "A Strange Figurine", "The Faceless", "The Necromancer" } }, ["Special"] = new LootFilterCategory { IsEnabled = true, Items = new List<string> { "Sivakrux", "Planar Stone", "Planar Stone Shards", "Torn Treasure Map (Bottom Left)", "Torn Treasure Map (Bottom Right)", "Torn Treasure Map (Top Left)", "Torn Treasure Map (Top Right)" } } }; } } public static class LootJunklist { private const string FileName = "LootJunklist.json"; private const string ConfigSub = "LootManager"; private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; public static void Load() { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootJunklist.json"); try { Directory.CreateDirectory(text); if (!File.Exists(path)) { string contents = JsonConvert.SerializeObject(new LootListData { Items = new List<string>() }, _jsonSettings); File.WriteAllText(path, contents); Plugin.Junklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log("[Loot Manager] Created default LootJunklist.json"); } else { Plugin.Junklist = new HashSet<string>(from s in (JsonConvert.DeserializeObject<LootListData>(File.ReadAllText(path)) ?? new LootListData()).Items ?? new List<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log($"[Loot Manager] Loaded {Plugin.Junklist.Count} junklisted items."); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to load {0}: {1}", "LootJunklist.json", arg)); Plugin.Junklist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } } public static void SaveJunklist() { try { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootJunklist.json"); Directory.CreateDirectory(text); List<string> items = (from s in Plugin.Junklist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase) where !string.IsNullOrWhiteSpace(s) select s.Trim()).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList(); string contents = JsonConvert.SerializeObject(new LootListData { Items = items }, _jsonSettings); File.WriteAllText(path, contents); } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to save {0}: {1}", "LootJunklist.json", arg)); } } public static HashSet<string> Read() { return new HashSet<string>(Plugin.Junklist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); } public static void SaveAll(IEnumerable<string> items) { Plugin.Junklist = new HashSet<string>(from s in items ?? Enumerable.Empty<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); SaveJunklist(); } } [Serializable] public sealed class LootWhiteListData { [JsonProperty] public List<string> Items = new List<string>(); } public static class LootWhitelist { private const string FileName = "LootWhitelist.json"; private const string ConfigSub = "LootManager"; private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore }; public static void Load() { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string text2 = Path.Combine(text, "LootWhitelist.json"); string text3 = Path.Combine(LootManagerPaths.ConfigDir, "LootWhitelist.json"); try { Directory.CreateDirectory(text); if (!File.Exists(text2) && File.Exists(text3)) { TryMigrateLegacyFile(text3, text2); } if (!File.Exists(text2)) { string contents = JsonConvert.SerializeObject(new LootWhiteListData { Items = new List<string>() }, _jsonSettings); File.WriteAllText(text2, contents); Plugin.Whitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log("[Loot Manager] Created default LootWhitelist.json"); } else { Plugin.Whitelist = new HashSet<string>(from s in (JsonConvert.DeserializeObject<LootWhiteListData>(File.ReadAllText(text2)) ?? new LootWhiteListData()).Items ?? new List<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); Plugin.Log?.Log($"[Loot Manager] Loaded {Plugin.Whitelist.Count} whitelisted items."); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to load {0}: {1}", "LootWhitelist.json", arg)); Plugin.Whitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase); } } public static void SaveWhitelist() { try { string text = Path.Combine(LootManagerPaths.ConfigDir, "LootManager"); string path = Path.Combine(text, "LootWhitelist.json"); Directory.CreateDirectory(text); List<string> items = (from s in Plugin.Whitelist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase) where !string.IsNullOrWhiteSpace(s) select s.Trim()).OrderBy<string, string>((string s) => s, StringComparer.OrdinalIgnoreCase).ToList(); string contents = JsonConvert.SerializeObject(new LootWhiteListData { Items = items }, _jsonSettings); File.WriteAllText(path, contents); } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to save {0}: {1}", "LootWhitelist.json", arg)); } } public static HashSet<string> Read() { return new HashSet<string>(Plugin.Whitelist ?? new HashSet<string>(StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase); } public static void SaveAll(IEnumerable<string> items) { Plugin.Whitelist = new HashSet<string>(from s in items ?? Enumerable.Empty<string>() where !string.IsNullOrWhiteSpace(s) select s.Trim(), StringComparer.OrdinalIgnoreCase); SaveWhitelist(); } private static void TryMigrateLegacyFile(string legacyPath, string newPath) { try { if (File.Exists(newPath)) { string text = legacyPath + ".bak"; File.Copy(legacyPath, text, overwrite: true); File.Delete(legacyPath); Plugin.Log?.LogWarning("[Loot Manager] Found both legacy and new LootWhitelist.json. Kept new; backed up legacy to " + text + " and removed original legacy file."); } else { File.Move(legacyPath, newPath); Plugin.Log?.Log("[Loot Manager] Migrated legacy LootWhitelist.json to " + newPath); } } catch (Exception arg) { Plugin.Log?.LogError(string.Format("[Loot Manager] Failed to migrate legacy {0}: {1}", "LootWhitelist.json", arg)); } } } public static class AuctionLoot { public static bool TryListItem(Item item, int quantity = 1) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown if ((Object)(object)item == (Object)null || (Object)(object)item == (Object)(object)GameData.PlayerInv.Empty) { return false; } if (item.FurnitureSet) { ChatFilterInjector.SendLootMessage("[Loot Manager] Cannot list \"" + item.ItemName + "\" on AH (furniture items not allowed).", "red"); return false; } if (item.ItemValue <= 0) { ChatFilterInjector.SendLootMessage("[Loot Manager] Cannot list \"" + item.ItemName + "\" on AH (no sell value).", "red"); return false; } if (item.NoTradeNoDestroy) { ChatFilterInjector.SendLootMessage("[Loot Manager] Cannot list \"" + item.ItemName + "\" on AH (no-trade item).", "red"); return false; } AuctionHouseSave val = AuctionHouse.ReadCharData(GameData.PlayerStats.MyName); if (val == null) { val = AuctionHouse.LoadCharData(GameData.PlayerStats.MyName); } if (val == null) { Plugin.Log.LogError("[Loot Manager] AuctionLoot: Failed to get player AH data."); return false; } int num = item.ItemValue * 6 - 1; val.ItemsForSale.Add(new AHItemSaveData(((BaseScriptableObject)item).Id, quantity, num)); AuctionHouse.SavePlayerAHData(val); ChatFilterInjector.SendLootMessage($"[Loot Manager] Listed \"{item.ItemName}\" on AH for {num}g.", "yellow"); return true; } } public static class BankLoot { public class LootEntry { public string Id { get; } public int Quantity { get; } public string Name { get; } public LootEntry(string id, int quantity, string name) { Id = id; Quantity = quantity; Name = name; } } public static void DepositLoot(IEnumerable<LootEntry> entries) { if (IsBankOpen()) { DepositLive(entries); } else { DepositToFile(entries); } } private static void DepositLive(IEnumerable<LootEntry> entries) { GlobalBank val = GameData.BankUI?.Bank; if ((Object)(object)val == (Object)null) { DepositToFile(entries); return; } List<Item> storedItems = val.StoredItems; List<int> quantities = val.Quantities; int count = storedItems.Count; object? obj = typeof(ItemIcon).GetField("MouseHomeSlot", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(GameData.MouseSlot); ItemIcon val2 = (ItemIcon)((obj is ItemIcon) ? obj : null); if ((Object)(object)val2 != (Object)null && val2.BankSlot) { val.DisplayBankPage(); { foreach (LootEntry entry in entries) { ChatFilterInjector.SendLootMessage("[Loot Manager] \"" + entry.Name + "\" is already in the bank.", "lightblue"); } return; } } FieldInfo field = typeof(GlobalBank).GetField("page", BindingFlags.Instance | BindingFlags.NonPublic); int num = (((!(field != null)) ? 1 : ((int)field.GetValue(val))) - 1) * 32; for (int i = num; i < num + 32 && i < count; i++) { int num2 = i - num; if (num2 >= val.BankSlots.Length) { break; } ItemIcon val3 = val.BankSlots[num2]; storedItems[i] = (((Object)(object)val3.MyItem == (Object)null || string.IsNullOrEmpty(((BaseScriptableObject)val3.MyItem).Id)) ? GameData.PlayerInv.Empty : val3.MyItem); quantities[i] = val3.Quantity; } bool flag = false; foreach (LootEntry entry2 in entries) { Item itemByID = GameData.ItemDB.GetItemByID(entry2.Id); if ((Object)(object)itemByID == (Object)null) { continue; } bool flag2 = false; if (itemByID.Stackable) { for (int j = 0; j < count; j++) { if ((Object)(object)storedItems[j] != (Object)null && (Object)(object)storedItems[j] != (Object)(object)GameData.PlayerInv.Empty && ((BaseScriptableObject)storedItems[j]).Id == entry2.Id) { quantities[j] += entry2.Quantity; flag2 = true; break; } } } if (!flag2) { for (int k = 0; k < count; k++) { if ((Object)(object)storedItems[k] == (Object)null || (Object)(object)storedItems[k] == (Object)(object)GameData.PlayerInv.Empty || string.IsNullOrEmpty(((BaseScriptableObject)storedItems[k]).Id)) { storedItems[k] = itemByID; quantities[k] = entry2.Quantity; flag2 = true; break; } } } if (flag2) { flag = true; ChatFilterInjector.SendLootMessage("[Loot Manager] Deposited \"" + entry2.Name + "\" into bank.", "lightblue"); } else { ChatFilterInjector.SendLootMessage("[Loot Manager] No bank space. Adding \"" + entry2.Name + "\" to inventory instead."); StandardLoot.LootToInv(itemByID, entry2.Quantity, entry2.Name); } } if (flag) { val.DisplayBankPage(); } } private static void DepositToFile(IEnumerable<LootEntry> entries) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_008e: Expected O, but got Unknown string text = Path.Combine(Application.persistentDataPath, "ESSaveData"); string path = Path.Combine(text, "GBDATA"); string path2 = Path.Combine(Application.persistentDataPath, "GBDATA"); BankSaveData val = (BankSaveData)(File.Exists(path) ? JsonUtility.FromJson<BankSaveData>(File.ReadAllText(path)) : ((!File.Exists(path2)) ? ((object)new BankSaveData { BankData = Enumerable.Repeat(string.Empty, 3168).ToList(), BankCount = Enumerable.Repeat(1, 3168).ToList() }) : ((object)JsonUtility.FromJson<BankSaveData>(File.ReadAllText(path2))))); int count = val.BankData.Count; int num = 32; int num2 = Mathf.CeilToInt((float)count / (float)num); string bankLootPageMode = Plugin.GetBankLootPageMode(); int num3 = Mathf.Clamp(Plugin.GetBankPageFirst(), 1, num2); int num4 = Mathf.Clamp(Plugin.GetBankPageLast(), 1, num2); int num5 = (num3 - 1) * num; int num6 = num4 * num; bool flag = false; foreach (LootEntry entry in entries) { bool flag2 = false; Item itemByID = GameData.ItemDB.GetItemByID(entry.Id); if (itemByID != null && itemByID.Stackable) { for (int i = 0; i < count; i++) { if (val.BankData[i] == entry.Id) { val.BankCount[i] += entry.Quantity; flag2 = true; break; } } } if (!flag2) { int num7 = ((bankLootPageMode == "Page Range") ? num5 : 0); int num8 = ((bankLootPageMode == "Page Range") ? Mathf.Min(num6, count) : count); for (int j = num7; j < num8; j++) { if (string.IsNullOrEmpty(val.BankData[j])) { val.BankData[j] = entry.Id; val.BankCount[j] = entry.Quantity; flag2 = true; break; } } } if (flag2) { flag = true; ChatFilterInjector.SendLootMessage("[Loot Manager] Deposited \"" + entry.Name + "\" into bank.", "lightblue"); } else { ChatFilterInjector.SendLootMessage("[Loot Manager] No bank space. Adding \"" + entry.Name + "\" to inventory instead."); StandardLoot.LootToInv(GameData.ItemDB.GetItemByID(entry.Id), entry.Quantity, entry.Name); } } if (flag) { Directory.CreateDirectory(text); File.WriteAllText(path, JsonUtility.ToJson((object)val)); } } private static bool IsBankOpen() { if ((Object)(object)GameData.BankUI != (Object)null && (Object)(object)GameData.BankUI.BankWindow != (Object)null) { return GameData.BankUI.BankWindow.activeSelf; } return false; } } public static class BlacklistLoot { public static bool ShouldLoot(Item item, int quantity) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || string.IsNullOrWhiteSpace(item.ItemName)) { return false; } if (item.NoTradeNoDestroy) { return false; } if (Plugin.GetLootEquipment() && (int)item.RequiredSlot != 0) { switch (Plugin.GetLootEquipmentTier()) { case "Normal Only": if (quantity != 1) { return false; } break; case "Improved Only": if (quantity <= 10) { return false; } break; case "Blessed Only": if (quantity != 2) { return false; } break; case "Ascended Only": if (quantity != 3) { return false; } break; case "Improved and Up": if (quantity < 2) { return false; } break; case "Blessed and Up": if (quantity < 2 || quantity > 3) { return false; } break; } } string itemName = item.ItemName; if (Plugin.Blacklist.Contains(itemName)) { return true; } foreach (KeyValuePair<string, HashSet<string>> filter in Plugin.FilterList) { if (Plugin.EnabledFilterCategories.Contains(filter.Key) && Plugin.FilterAppliedToBlacklist.Contains(filter.Key) && filter.Value.Contains(itemName)) { return true; } } return false; } } public static class StandardLoot { public static void LootToInv(Item item, int qty, string name = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)item == (Object)null)) { if (((int)item.RequiredSlot == 0) ? GameData.PlayerInv.AddItemToInv(item) : GameData.PlayerInv.AddItemToInv(item, qty)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Looted \"" + (name ?? item.ItemName) + "\" to inventory", "yellow"); } else { ChatFilterInjector.SendLootMessage("[Loot Manager] No room for \"" + (name ?? item.ItemName) + "\"", "yellow"); } } } } public static class WhitelistLoot { public static bool ShouldLoot(Item item, int quantity) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || string.IsNullOrWhiteSpace(item.ItemName)) { return false; } if (item.NoTradeNoDestroy) { return true; } if (Plugin.GetLootEquipment() && (int)item.RequiredSlot != 0) { switch (Plugin.GetLootEquipmentTier()) { case "All": return true; case "Normal Only": return quantity == 1; case "Improved Only": return quantity > 10; case "Blessed Only": return quantity == 2; case "Ascended Only": return quantity == 3; case "Improved and Up": return quantity >= 2; case "Blessed and Up": if (quantity >= 2) { return quantity <= 3; } return false; } } string itemName = item.ItemName; if (Plugin.Whitelist.Contains(itemName)) { return true; } foreach (KeyValuePair<string, HashSet<string>> filter in Plugin.FilterList) { if (Plugin.EnabledFilterCategories.Contains(filter.Key) && Plugin.FilterAppliedToWhitelist.Contains(filter.Key) && filter.Value.Contains(itemName)) { return true; } } return false; } } [HarmonyPatch(typeof(AuctionHouseUI), "UpdatePlayerSlots")] public static class AuctionHouseUIPatch { public static bool Prefix(AuctionHouseUI __instance) { foreach (ItemIcon slot in __instance.Slots) { slot.MyItem = GameData.PlayerInv.Empty; slot.UpdateSlotImage(); slot.PlayerOwned = true; ((TMP_Text)((Component)slot).GetComponent<PriceOverride>().DispPrice).text = ""; } if (__instance.CurrentSellerData == null || __instance.CurrentSellerData.SellerName != GameData.PlayerStats.MyName) { return false; } int count = __instance.Slots.Count; int num = 0; foreach (AHItemSaveData item in __instance.CurrentSellerData.ItemsForSale) { if (num >= count) { break; } if (item != null) { __instance.Slots[num].MyItem = GameData.ItemDB.GetItemByID(item.itemID); __instance.Slots[num].UpdateSlotImage(); __instance.Slots[num].Quantity = item.itemQual; ((Component)__instance.Slots[num]).GetComponent<PriceOverride>().Price = item.itemPrice; if ((Object)(object)__instance.Slots[num].MyItem != (Object)null && (Object)(object)__instance.Slots[num].MyItem != (Object)(object)GameData.PlayerInv.Empty) { ((TMP_Text)((Component)__instance.Slots[num]).GetComponent<PriceOverride>().DispPrice).text = item.itemPrice + "g"; } else { ((TMP_Text)((Component)__instance.Slots[num]).GetComponent<PriceOverride>().DispPrice).text = ""; } num++; } } return false; } } [HarmonyPatch(typeof(Character), "DoDeath")] public class Autoloot { private struct PendingLoot { public NPC Npc; public LootTable Table; } private static readonly List<PendingLoot> _pending = new List<PendingLoot>(); private static bool _pollRunning = false; private static void Postfix(Character __instance) { //IL_0078: 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) if (!Plugin.GetAutoLootEnabled() || (Object)(object)__instance == (Object)null || !__instance.isNPC || (Object)(object)__instance.MyNPC == (Object)null) { return; } NPC component = ((Component)__instance).GetComponent<NPC>(); if ((__instance.DestroyOnDeath && (Object)(object)component != (Object)null) || __instance.MyNPC.SummonedByPlayer) { return; } Character myself = GameData.PlayerControl.Myself; if ((Object)(object)myself == (Object)null || !myself.Alive) { return; } float autoLootDistance = Plugin.GetAutoLootDistance(); if (Vector3.Distance(((Component)myself).transform.position, ((Component)__instance.MyNPC).transform.position) >= autoLootDistance) { return; } LootTable component2 = ((Component)__instance.MyNPC).GetComponent<LootTable>(); if ((Object)(object)component2 == (Object)null) { return; } if (Plugin.GetAutoLootDelayEnabled()) { _pending.Add(new PendingLoot { Npc = __instance.MyNPC, Table = component2 }); if (!_pollRunning) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(PollOutOfCombat()); } } else { ChatFilterInjector.SendLootMessage("[Loot Manager] Looting NPC: " + ((Object)__instance.MyNPC).name, "yellow"); component2.LoadLootTable(); GameData.LootWindow.LootAll(); } } private static bool IsOutOfCombat() { if (GameData.AttackingPlayer != null && GameData.AttackingPlayer.Count > 0) { return false; } if (GameData.GroupMatesInCombat != null && GameData.GroupMatesInCombat.Count > 0) { return false; } return true; } private static IEnumerator PollOutOfCombat() { _pollRunning = true; while (!IsOutOfCombat()) { yield return (object)new WaitForSeconds(0.25f); } float num = Mathf.Clamp(Plugin.GetAutoLootDelay(), 0f, 10f); if (num > 0f) { yield return (object)new WaitForSeconds(num); } List<PendingLoot> list = new List<PendingLoot>(_pending); _pending.Clear(); _pollRunning = false; if (!Plugin.GetAutoLootEnabled()) { yield break; } Character val = GameData.PlayerControl?.Myself; if ((Object)(object)val == (Object)null || !val.Alive) { yield break; } foreach (PendingLoot item in list) { if (!((Object)(object)item.Npc == (Object)null) && !((Object)(object)item.Table == (Object)null) && !(Vector3.Distance(((Component)val).transform.position, ((Component)item.Npc).transform.position) >= Plugin.GetAutoLootDistance())) { ChatFilterInjector.SendLootMessage("[Loot Manager] Looting NPC: " + ((Object)item.Npc).name, "yellow"); item.Table.LoadLootTable(); GameData.LootWindow.LootAll(); } } } } public static class ChatFilterInjector { public const LogType LootManagerLogType = (LogType)8388608; private static bool _maskApplied; public static void ApplyChatMask() { if (UpdateSocialLog.ChatWindows.Count == 0) { _maskApplied = false; return; } foreach (IDLog chatWindow in UpdateSocialLog.ChatWindows) { for (int i = 0; i < chatWindow.FilterMasks.Length; i++) { ref LogType reference = ref chatWindow.FilterMasks[i]; reference = (LogType)((uint)reference & 0xFF7FFFFFu); } } IDLog targetWindow = GetTargetWindow(); if (!((Object)(object)targetWindow == (Object)null)) { int num = Mathf.Clamp(Plugin.GetChatOutputTab(), 0, targetWindow.activeTabs - 1); ref LogType reference2 = ref targetWindow.FilterMasks[num]; reference2 = (LogType)((uint)reference2 | 0x800000u); _maskApplied = true; } } public static void SendLootMessage(string message, string color = "orange") { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown if (Plugin.GetChatOutputEnabled()) { if (!_maskApplied) { ApplyChatMask(); } if (!_maskApplied) { UpdateSocialLog.LogAdd(new ChatLogLine(message, (LogType)2097152, color)); } else { UpdateSocialLog.LogAdd(new ChatLogLine(message, (LogType)8388608, color)); } } } public static IDLog GetTargetWindow() { string chatOutputWindow = Plugin.GetChatOutputWindow(); foreach (IDLog chatWindow in UpdateSocialLog.ChatWindows) { if (chatWindow.WindowName == chatOutputWindow) { return chatWindow; } } if (UpdateSocialLog.ChatWindows.Count > 0) { return UpdateSocialLog.ChatWindows[0]; } return null; } } [HarmonyPriority(800)] [HarmonyPatch(typeof(LootWindow), "LootAll")] public static class LootWindowPatch { public static bool Prefix(LootWindow __instance) { //IL_023d: Unknown result type (might be due to invalid IL or missing references) string lootMethod = Plugin.GetLootMethod(); bool bankLootEnabled = Plugin.GetBankLootEnabled(); string bankLootMethod = Plugin.GetBankLootMethod(); List<BankLoot.LootEntry> list = new List<BankLoot.LootEntry>(); foreach (ItemIcon lootSlot in __instance.LootSlots) { Item myItem = lootSlot.MyItem; int quantity = lootSlot.Quantity; if ((Object)(object)myItem == (Object)(object)GameData.PlayerInv.Empty) { continue; } string itemName = myItem.ItemName; if (lootMethod == "Blacklist" && BlacklistLoot.ShouldLoot(myItem, quantity)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Destroyed \"" + itemName + "\"", "grey"); lootSlot.MyItem = GameData.PlayerInv.Empty; lootSlot.Quantity = 1; lootSlot.UpdateSlotImage(); continue; } if (lootMethod == "Whitelist" && !WhitelistLoot.ShouldLoot(myItem, quantity)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Destroyed \"" + itemName + "\"", "grey"); lootSlot.MyItem = GameData.PlayerInv.Empty; lootSlot.Quantity = 1; lootSlot.UpdateSlotImage(); continue; } if (Plugin.GetAuctionLootEnabled() && Plugin.Auctionlist != null && Plugin.Auctionlist.Contains(itemName) && AuctionLoot.TryListItem(myItem, quantity)) { lootSlot.InformGroupOfLoot(myItem); lootSlot.MyItem = GameData.PlayerInv.Empty; lootSlot.Quantity = 1; lootSlot.UpdateSlotImage(); continue; } bool flag = false; if (bankLootEnabled) { if (bankLootMethod == "All") { flag = true; } else if (bankLootMethod == "Filtered" && Plugin.Banklist.Contains(itemName)) { flag = true; } else if (bankLootMethod == "Filtered") { foreach (KeyValuePair<string, HashSet<string>> filter in Plugin.FilterList) { if (Plugin.EnabledFilterCategories.Contains(filter.Key) && Plugin.FilterAppliedToBanklist.Contains(filter.Key) && filter.Value.Contains(itemName)) { flag = true; break; } } } } if (flag) { list.Add(new BankLoot.LootEntry(((BaseScriptableObject)myItem).Id, quantity, itemName)); } else { if (!(((int)myItem.RequiredSlot == 0) ? GameData.PlayerInv.AddItemToInv(myItem) : GameData.PlayerInv.AddItemToInv(myItem, quantity))) { ChatFilterInjector.SendLootMessage("[Loot Manager] No room for \"" + itemName + "\"", "yellow"); continue; } ChatFilterInjector.SendLootMessage("[Loot Manager] Looted \"" + itemName + "\" to inventory", "yellow"); lootSlot.InformGroupOfLoot(myItem); } lootSlot.MyItem = GameData.PlayerInv.Empty; lootSlot.Quantity = 1; lootSlot.UpdateSlotImage(); } if (list.Count > 0) { BankLoot.DepositLoot(list); } GameData.PlayerAud.PlayOneShot(((Component)GameData.GM).GetComponent<Misc>().DropItem, GameData.PlayerAud.volume / 2f * GameData.SFXVol); __instance.CloseWindow(); return false; } } [HarmonyPatch(typeof(EventSystem), "IsPointerOverGameObject", new Type[] { })] internal static class PointerOverUIPatch { internal static ImGuiRenderer Renderer; private static void Postfix(ref bool __result) { if (!__result && Renderer != null && Renderer.WantCaptureMouse) { __result = true; } } } public static class FishingPatch { [HarmonyPatch(typeof(Inventory), "AddItemToInv", new Type[] { typeof(Item) })] public static class AddItemToInv_Patch { public static bool Prefix(Item _item, ref bool __result) { try { if (!IsInFishingContext(out var caughtItem)) { return true; } if ((Object)(object)_item != (Object)(object)caughtItem) { return true; } if (_inFilter) { return true; } _inFilter = true; bool flag; try { flag = ShouldAddToInventory(_item); } finally { _inFilter = false; } if (!flag) { __result = true; return false; } } catch (Exception ex) { if (Plugin.Log != null) { Plugin.Log?.LogError("[Loot Manager] FishingPatch.AddItemToInv error: " + ex); } } return true; } } [HarmonyPatch(typeof(Inventory), "ForceItemToInv", new Type[] { typeof(Item) })] public static class ForceItemToInv_Patch { public static bool Prefix(Item _item) { try { if (!IsInFishingContext(out var caughtItem)) { return true; } if ((Object)(object)_item != (Object)(object)caughtItem) { return true; } if (_inFilter) { return true; } _inFilter = true; bool flag; try { flag = ShouldAddToInventory(_item); } finally { _inFilter = false; } if (!flag) { return false; } } catch (Exception ex) { if (Plugin.Log != null) { Plugin.Log?.LogError("[Loot Manager] FishingPatch.ForceItemToInv error: " + ex); } } return true; } } private static bool _inFilter = false; private static readonly FieldInfo _fishCaught = typeof(Fishing).GetField("fishCaught", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo _caughtItem = typeof(Fishing).GetField("caughtItem", BindingFlags.Instance | BindingFlags.NonPublic); private static bool IsInFishingContext(out Item caughtItem) { caughtItem = null; PlayerControl playerControl = GameData.PlayerControl; if ((Object)(object)playerControl == (Object)null) { return false; } Fishing component = ((Component)playerControl).GetComponent<Fishing>(); if ((Object)(object)component == (Object)null) { return false; } if (!(_fishCaught != null) || !(bool)_fishCaught.GetValue(component)) { return false; } object? obj = _caughtItem?.GetValue(component); caughtItem = (Item)((obj is Item) ? obj : null); if ((Object)(object)caughtItem != (Object)null) { return (Object)(object)caughtItem != (Object)(object)GameData.PlayerInv.Empty; } return false; } private static bool ShouldAddToInventory(Item item) { if (!Plugin.GetFishingFilterEnabled()) { return true; } string itemName = item.ItemName; string lootMethod = Plugin.GetLootMethod(); if (Plugin.GetAuctionLootEnabled() && Plugin.Auctionlist != null && Plugin.Auctionlist.Contains(itemName) && AuctionLoot.TryListItem(item)) { return false; } if (Plugin.GetBankLootEnabled() && Plugin.Banklist != null && Plugin.Banklist.Contains(itemName)) { BankLoot.DepositLoot(new BankLoot.LootEntry[1] { new BankLoot.LootEntry(((BaseScriptableObject)item).Id, 1, itemName) }); ChatFilterInjector.SendLootMessage("[Loot Manager] Fishing: banked \"" + itemName + "\".", "lightblue"); return false; } if (lootMethod == "Blacklist" && BlacklistLoot.ShouldLoot(item, 1)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Fishing: discarded \"" + itemName + "\" (blacklisted).", "grey"); return false; } if (lootMethod == "Whitelist" && !WhitelistLoot.ShouldLoot(item, 1)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Fishing: discarded \"" + itemName + "\" (not on whitelist).", "grey"); return false; } return true; } } public static class MiningPatch { [HarmonyPatch(typeof(PlayerCombat), "TryMine")] public static class TryMine_Patch { public static void Prefix() { _inMining = true; } public static void Postfix() { _inMining = false; } } [HarmonyPatch(typeof(Inventory), "AddItemToInv", new Type[] { typeof(Item) })] public static class AddItemToInv_Patch { public static bool Prefix(Item _item, ref bool __result) { try { if (!_inMining || _inFilter) { return true; } _inFilter = true; bool flag; try { flag = ShouldAddToInventory(_item); } finally { _inFilter = false; } if (!flag) { __result = true; return false; } } catch (Exception ex) { if (Plugin.Log != null) { Plugin.Log?.LogError("[Loot Manager] MiningPatch.AddItemToInv error: " + ex); } } return true; } } [HarmonyPatch(typeof(Inventory), "ForceItemToInv", new Type[] { typeof(Item) })] public static class ForceItemToInv_Patch { public static bool Prefix(Item _item) { try { if (!_inMining || _inFilter) { return true; } _inFilter = true; bool flag; try { flag = ShouldAddToInventory(_item); } finally { _inFilter = false; } if (!flag) { return false; } } catch (Exception ex) { if (Plugin.Log != null) { Plugin.Log?.LogError("[Loot Manager] MiningPatch.ForceItemToInv error: " + ex); } } return true; } } private static bool _inMining; private static bool _inFilter; private static bool ShouldAddToInventory(Item item) { if (!Plugin.GetMiningFilterEnabled()) { return true; } string itemName = item.ItemName; string lootMethod = Plugin.GetLootMethod(); if (Plugin.GetAuctionLootEnabled() && Plugin.Auctionlist != null && Plugin.Auctionlist.Contains(itemName) && AuctionLoot.TryListItem(item)) { return false; } if (Plugin.GetBankLootEnabled() && Plugin.Banklist != null && Plugin.Banklist.Contains(itemName)) { BankLoot.DepositLoot(new BankLoot.LootEntry[1] { new BankLoot.LootEntry(((BaseScriptableObject)item).Id, 1, itemName) }); ChatFilterInjector.SendLootMessage("[Loot Manager] Mining: banked \"" + itemName + "\".", "lightblue"); return false; } if (lootMethod == "Blacklist" && BlacklistLoot.ShouldLoot(item, 1)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Mining: discarded \"" + itemName + "\" (blacklisted).", "grey"); return false; } if (lootMethod == "Whitelist" && !WhitelistLoot.ShouldLoot(item, 1)) { ChatFilterInjector.SendLootMessage("[Loot Manager] Mining: discarded \"" + itemName + "\" (not on whitelist).", "grey"); return false; } return true; } } [HarmonyPatch(typeof(VendorWindow), "LoadWindow")] public static class VendorWindowPatch { private static void Postfix() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Junklist == null || Plugin.Junklist.Count == 0) { return; } Inventory playerInv = GameData.PlayerInv; if ((Object)(object)playerInv == (Object)null) { return; } int num = 0; int num2 = 0; ItemIcon[] array = playerInv.StoredSlots.ToArray(); foreach (ItemIcon val in array) { if ((Object)(object)val == (Object)null) { continue; } Item myItem = val.MyItem; if (!((Object)(object)myItem == (Object)null) && !((Object)(object)myItem == (Object)(object)playerInv.Empty) && Plugin.Junklist.Contains(myItem.ItemName) && myItem.ItemValue > 0 && !myItem.NoTradeNoDestroy) { int num3 = Mathf.RoundToInt((float)myItem.ItemValue * 0.65f) + 1; if ((int)myItem.RequiredSlot == 0 && val.Quantity > 1) { int num4 = num3 * val.Quantity; num += num4; num2++; ChatFilterInjector.SendLootMessage($"[Loot Manager] Auto-sold {val.Quantity}x {myItem.ItemName} for {num4} gold.", "yellow"); playerInv.RemoveStackFromInv(val); } else { num += num3; num2++; ChatFilterInjector.SendLootMessage($"[Loot Manager] Auto-sold {myItem.ItemName} for {num3} gold.", "yellow"); playerInv.RemoveItemFromInv(val); } } } if (num2 > 0) { playerInv.Gold += num; ((TMP_Text)playerInv.GoldTXT).text = playerInv.Gold.ToString(); GameData.PlayerAud.PlayOneShot(GameData.Misc.BuyItem, GameData.UIVolume * GameData.MasterVol); ChatFilterInjector.SendLootMessage($"[Loot Manager] Auto-sold {num2} junk item(s) for {num} gold total.", "yellow"); } } } public static class CimguiNative { public struct Vec2 { public float X; public float Y; public Vec2(float x, float y) { X = x; Y = y; } } public struct Vec4 { public float X; public float Y; public float Z; public float W; public Vec4(float x, float y, float z, float w) { X = x; Y = y; Z = z; W = w; } } private static byte[] _utf8Buf = new byte[256]; [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr igGetForegroundDrawList_Nil(); [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr igGetBackgroundDrawList_Nil(); [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr igGetWindowDrawList(); [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] public static extern void ImDrawList_AddLine(IntPtr self, Vec2 p1, Vec2 p2, uint col, float thickness); [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] public static extern void ImDrawList_AddRectFilled(IntPtr self, Vec2 pMin, Vec2 pMax, uint col, float rounding, int flags); [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern void ImDrawList_AddText_Vec2(IntPtr self, Vec2 pos, uint col, byte* textBegin, byte* textEnd); [DllImport("cimgui", CallingConvention = CallingConvention.Cdecl)] private unsafe static extern void igCalcTextSize(Vec2* pOut, byte* text, byte* textEnd, byte wrapWidth, float maxWidth); private static int WriteUtf8(string text) { int byteCount = Encoding.UTF8.GetByteCount(text); if (byteCount > _utf8Buf.Length) { _utf8Buf = new byte[byteCount * 2]; } return Encoding.UTF8.GetBytes(text, 0, text.Length, _utf8Buf, 0); } public unsafe static Vec2 CalcTextSize(string text) { if (string.IsNullOrEmpty(text)) { return new Vec2(0f, 0f); } int num = WriteUtf8(text); Vec2 result = default(Vec2); fixed (byte* utf8Buf = _utf8Buf) { byte* ptr = ((_utf8Buf == null || _utf8Buf.Length == 0) ? null : utf8Buf); igCalcTextSize(&result, ptr, ptr + num, 0, -1f); } return result; } public unsafe static void AddText(IntPtr drawList, float x, float y, uint color, string text) { if (!(drawList == IntPtr.Zero) && !string.IsNullOrEmpty(text)) { int num = WriteUtf8(text); fixed (byte* utf8Buf = _utf8Buf) { byte* ptr = ((_utf8Buf == null || _utf8Buf.Length == 0) ? null : utf8Buf); ImDrawList_AddText_Vec2(drawList, new Vec2(x, y), color, ptr, ptr + num); } } } } public sealed class ImGuiRenderer : IDisposable { private readonly ILog _log; private IntPtr _context; private bool _quitting; private Texture2D _fontTexture; private Material _material; private CommandBuffer _commandBuffer; private byte[] _unscaledStyleBackup; private float _uiScale = 1f; private float _pendingScale = -1f; private readonly Dictionary<IntPtr, Texture> _textures = new Dictionary<IntPtr, Texture>(); private readonly List<Mesh> _meshPool = new List<Mesh>(); private readonly List<Vector3> _verts = new List<Vector3>(); private readonly List<Vector2> _uvs = new List<Vector2>(); private readonly List<Color32> _colors = new List<Color32>(); private readonly List<int> _indices = new List<int>(); private readonly MaterialPropertyBlock _mpb = new MaterialPropertyBlock(); public Action OnLayout { get; set; } public ImFontPtr BoldFont { get; private set; } public bool WantCaptureMouse { get; private set; } public bool WantTextInput { get; private set; } public float UiScale { get { return _uiScale; } set { _uiScale = value; } } public float CurrentScale => _uiScale; public void SetScale(float scale) { _pendingScale = scale; } public void ClearWindowState() { IntPtr currentContext = ImGui.GetCurrentContext(); ImGui.SetCurrentContext(_context); ImGui.LoadIniSettingsFromMemory(""); ImGui.SetCurrentContext(currentContext); } public void RegisterTexture(IntPtr ptr, Texture texture) { if (ptr != IntPtr.Zero && (Object)(object)texture != (Object)null) { _textures[ptr] = texture; } } internal void ClearCaptureState() { WantCaptureMouse = false; WantTextInput = false; } public ImGuiRenderer(ILog log) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown _log = log; } public unsafe bool Init() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown if (_context != IntPtr.Zero) { _log.LogWarning("[LootManager] ImGuiRenderer.Init() called twice — ignoring."); return true; } try { _context = ImGui.CreateContext(); IntPtr currentContext = ImGui.GetCurrentContext(); ImGui.SetCurrentContext(_context); ImGuiIOPtr iO = ImGui.GetIO(); iO.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset; iO.NativePtr->IniFilename = null; ImGui.StyleColorsDark(); BuildFontAtlas(); SaveStyleBackup(); ImGui.GetStyle().ScaleAllSizes(_uiScale); CreateMaterial(); _commandBuffer = new CommandBuffer { name = "LootManager_ImGui" }; ImGui.SetCurrentContext(currentContext); _log.Log("[LootManager] ImGui initialised (isolated context)."); return true; } catch (Exception ex) { _log.LogError("[LootManager] ImGui init failed: " + ex); return false; } } public void OnGUI() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if (_context == IntPtr.Zero) { return; } Event current = Event.current; if (current == null || (int)current.type != 7) { return; } IntPtr currentContext = ImGui.GetCurrentContext(); ImGui.SetCurrentContext(_context); try { ImGuiIOPtr iO = ImGui.GetIO(); if (_pendingScale >= 0f) { ApplyScale(_pendingScale); _pendingScale = -1f; } iO.DisplaySize = new Vector2(Screen.width, Screen.height); iO.DeltaTime = ((Time.deltaTime > 0f) ? Time.deltaTime : (1f / 60f)); UpdateInput(iO); ImGui.NewFrame(); OnLayout?.Invoke(); ImGui.EndFrame(); WantCaptureMouse = iO.WantCaptureMouse; WantTextInput = iO.WantTextInput; ImGui.Render(); RenderDrawData(); } catch (Exception ex) { _log.LogError("[LootManager] ImGui render error: " + ex); } finally { ImGui.SetCurrentContext(currentContext); } } public void Dispose() { if (_context != IntPtr.Zero) { if (!_quitting) { try { IntPtr currentContext = ImGui.GetCurrentContext(); ImGui.SetCurrentContext(_context); try { ImGui.EndFrame(); } catch { } ImGui.DestroyContext(_context); if (currentContext != _context && currentContext != IntPtr.Zero) { ImGui.SetCurrentContext(currentContext); } } catch { } } _context = IntPtr.Zero; } foreach (Mesh item in _meshPool) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } _meshPool.Clear(); if ((Object)(object)_fontTexture != (Object)null) { Object.Destroy((Object)(object)_fontTexture); _fontTexture = null; } if ((Object)(object)_material != (Object)null) { Object.Destroy((Object)(object)_material); _material = null; } CommandBuffer commandBuffer = _commandBuffer; if (commandBuffer != null) { commandBuffer.Dispose(); } _commandBuffer = null; } private unsafe void BuildFontAtlas() { //IL_0168: Unknown