Decompiled source of SpellBrigadeStatEditor v0.1.46
BepInEx\plugins\SpellBrigadeStatEditorBepInEx\SpellBrigadeStatEditorBepInEx.dll
Decompiled 6 hours 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.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("SpellBrigadeStatEditorBepInEx")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Stat editor and scroll tools for The Spell Brigade")] [assembly: AssemblyFileVersion("0.1.46.0")] [assembly: AssemblyInformationalVersion("0.1.46")] [assembly: AssemblyProduct("Spell Brigade Stat Editor")] [assembly: AssemblyTitle("SpellBrigadeStatEditorBepInEx")] [assembly: AssemblyVersion("0.1.46.0")] namespace SpellBrigadeStatEditorBepInEx; [BepInPlugin("local.spellbrigade.stat-editor-bepinex", "Spell Brigade Stat Editor - BepInEx", "0.1.46")] public sealed class Plugin : BasePlugin { internal static ManualLogSource Logger; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> KeepBonuses; internal static ConfigEntry<float> WindowX; internal static ConfigEntry<float> WindowY; internal static ConfigEntry<float> WindowWidth; internal static ConfigEntry<float> WindowHeight; internal static ConfigEntry<float> XpMultiplier; internal static ConfigEntry<float> GoldMultiplier; internal static ConfigEntry<bool> TestF10Enabled; internal static ConfigEntry<float> TestF10Cooldown; internal static ConfigEntry<bool> TestAutoReload; internal static ConfigEntry<bool> TestVerboseLog; internal static ConfigEntry<bool> TestScrollOnlyArmed; internal static ConfigEntry<bool> TestF10AllDebugArtifacts; internal static ConfigEntry<float> TestAutoFilterSettleDelay; internal static ConfigEntry<bool> TestChestOnlyMode; internal static ConfigEntry<bool> TestChestMultiplayer; internal static ConfigEntry<bool> MultiplayerSafeMode; private static bool? _multiplayerSession; private static float _nextMultiplayerCheck = -1f; private static float _lastMultiplayerManagerLookup = -999f; private static Type _multiplayerManagerType; private static object _multiplayerManager; private static bool _restoreSavedBonusesPending; internal static string ChestFilterStatus = "Off. Enable CHEST-ONLY MODE in F11 to test."; private static bool _chestWasOpen; private static bool _chestFilterAttempted; private static bool _chestFilterPending; private static float _chestFilterDue; private static float _nextChestScan; private static string _chestStoreId = ""; private static int _chestFilteredCount; private static Type _chestCachedManagerType; private static object _chestCachedManager; private static float _chestLastManagerRefresh = -999f; private static ConfigFile _liveConfig; private static DateTime _lastConfigWriteUtc; private static float _nextConfigPoll; internal static int TestF10Accepted; internal static string TestLastEvent = "No test run yet"; internal static readonly Dictionary<string, ConfigEntry<float>> Saved = new Dictionary<string, ConfigEntry<float>>(); internal static readonly List<StatRow> Rows = new List<StatRow>(); internal static readonly Dictionary<string, object> GameStats = new Dictionary<string, object>(); private static MethodInfo _gameStatsMethod; private static MethodInfo _cachedStatConverter; private static bool _cachedStatConverterSearched; private static bool _cachedStatConverterBroken; private static float _nextGameStatScan; private static float _lastDiagnostics = -999f; private static readonly Dictionary<string, string> SpellDisplays = new Dictionary<string, string>(); private static float _nextSpellRead; private static object _spellReadPlayer; private static string _spellReadStatus = "not scanned"; internal static readonly List<string> EquippedSpells = new List<string>(); private static readonly HashSet<string> UnreadableSpellLists = new HashSet<string>(StringComparer.Ordinal); internal static readonly Dictionary<string, Dictionary<string, string>> PerSpellDisplays = new Dictionary<string, Dictionary<string, string>>(StringComparer.Ordinal); internal static readonly Dictionary<string, float> PerSpellBonuses = new Dictionary<string, float>(StringComparer.Ordinal); internal static string SelectedSpell = null; internal static readonly string[] SpellStatNames = new string[12] { "Damage", "FireRate", "Size", "Speed", "Range", "LifeTime", "Projectiles", "CriticalChance", "CriticalDamage", "DamageTickRate", "ElementStrengthMultiplier", "HitboxSizeMultiplier" }; internal static readonly List<string> ScrollCatalogPreview = new List<string>(); internal static string ScrollCatalogStatus = "Not scanned. Press SCAN CATALOG in F11 Test Lab."; internal static string ScrollCatalogSource = "none"; private static float _lastCatalogProbe = -999f; internal static bool ScrollOnlyRequested; internal static bool ScrollOnlyReady; internal static bool ScrollOnlySelectionCompleted; internal static string ScrollOnlyStatus = "Not opened. Arm and click SCROLL-ONLY TEST in F11."; internal static readonly List<object> ScrollOnlyItems = new List<object>(); internal static readonly List<string> ScrollOnlyTitles = new List<string>(); private static float _nextScrollOnlyPoll; private static float _scrollOnlyStart; private static int _queuedScrollOnlyIndex = -1; internal static bool NativeDebugFilterApplied = false; private static bool _autoNativeFilterPending; private static bool _scrollOnlyAutoMode; private static float _autoNativeFilterDue; internal static readonly List<object> PendingPlayers = new List<object>(); internal static object LocalPlayer; internal static Harmony HooksHarmony; internal static string Status = "Checking game API..."; internal static bool PlayerHookOk; internal static bool XpHookOk; internal static bool GoldHookOk; internal static Type PlayerStatsType; internal static MethodInfo ReadValueMethod; internal static MethodInfo ApplyBonusMethod; internal static Type StatEnum; internal static Type ModifierEnum; internal static object ModifierStatic; private static float _nextDiscovery; private static float _nextScan; private static float _nextScanWarning; private static readonly HashSet<string> _readWarnings = new HashSet<string>(); private static float _lastScrollApiProbe = -999f; private static float _lastNativeScrollHotkey = -999f; private static bool _f10OwnsStore; private static bool _f10ShopSeen; private static bool _f10CloseRequested; private static bool _f10DebugStore; private static float _f10StoreRequestAt; private static float _f10LastCloseAt; private static float _f10NextObserve; private static string _f10OwnedStoreId = ""; private static object _f10OwnedManager; private static float _lastDebugStoreAttempt = -999f; internal static bool SafetyBlocksChanges { get { if (MultiplayerSafeMode != null && MultiplayerSafeMode.Value) { return _multiplayerSession != false; } return false; } } internal static string SafetyModeDescription { get { if (MultiplayerSafeMode != null && MultiplayerSafeMode.Value) { if (_multiplayerSession != true) { if (_multiplayerSession != false) { return "MODE UNKNOWN: MODIFIED GAMEPLAY BLOCKED"; } return "SOLO: NORMAL MOD FEATURES AVAILABLE"; } return "MULTIPLAYER: MODIFIED GAMEPLAY BLOCKED"; } return "OFF (multiplayer edits allowed; experimental)"; } } internal static bool HasQueuedScrollOnlyChoice => false; internal static void InvalidatePlayerMode() { _multiplayerSession = null; _nextMultiplayerCheck = -1f; _lastMultiplayerManagerLookup = -999f; _multiplayerManager = null; _multiplayerManagerType = null; } internal static void RefreshMultiplayerMode(float now, bool force = false) { if (LocalPlayer == null) { if (_multiplayerSession.HasValue || _multiplayerManager != null) { InvalidatePlayerMode(); } } else { if (!force && now < _nextMultiplayerCheck) { return; } _nextMultiplayerCheck = now + 0.65f; bool? flag = null; try { if (_multiplayerManagerType == null) { _multiplayerManagerType = FindType("Il2Cpp.StoreManager"); } if (_multiplayerManagerType != null) { if (_multiplayerManager == null || now - _lastMultiplayerManagerLookup > 8f) { _lastMultiplayerManagerLookup = now; _multiplayerManager = FindStoreManagerSingleton(_multiplayerManagerType); } if (_multiplayerManager != null) { MethodInfo methodInfo = FindMethod(_multiplayerManagerType, "IsMultiplayer", 0); if (methodInfo != null) { flag = Convert.ToBoolean(methodInfo.Invoke(_multiplayerManager, null)); } } } } catch (Exception ex) { flag = null; _multiplayerManager = null; if (_multiplayerSession.HasValue) { Logger.LogWarning((object)("MP SAFE: mode check became unavailable; defaulting to protected: " + ex.GetBaseException().Message)); } } if (flag != _multiplayerSession) { _multiplayerSession = flag; Logger.LogInfo((object)("MP SAFE: player mode " + ((flag == true) ? "MULTIPLAYER" : ((flag == false) ? "SOLO" : "UNKNOWN")) + "; safeguard " + ((MultiplayerSafeMode != null && MultiplayerSafeMode.Value) ? "ON" : "OFF"))); } if (!_restoreSavedBonusesPending || SafetyBlocksChanges || LocalPlayer == null) { return; } _restoreSavedBonusesPending = false; if (KeepBonuses == null || !KeepBonuses.Value) { return; } foreach (StatRow row in Rows) { if (Saved.TryGetValue(row.Name, out var value) && value.Value > 0f) { Apply(row, value.Value); } } } } public override void Load() { //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; Enabled = ((BasePlugin)this).Config.Bind<bool>("Settings", "Enabled", true, "Master switch"); KeepBonuses = ((BasePlugin)this).Config.Bind<bool>("Settings", "KeepBonusesBetweenRuns", false, "Remember stat bonuses for next run"); WindowX = ((BasePlugin)this).Config.Bind<float>("Overlay", "PositionX", -1f, "Saved window position in screen pixels; -1 uses centered position"); WindowY = ((BasePlugin)this).Config.Bind<float>("Overlay", "PositionY", -1f, "Saved window position in screen pixels; -1 uses centered position"); WindowWidth = ((BasePlugin)this).Config.Bind<float>("Overlay", "Width", 1840f, "Saved resizable overlay width in virtual pixels"); WindowHeight = ((BasePlugin)this).Config.Bind<float>("Overlay", "Height", 1020f, "Saved resizable overlay height in virtual pixels"); XpMultiplier = ((BasePlugin)this).Config.Bind<float>("Settings", "XpMultiplier", 1f, "Solo / host XP multiplier"); GoldMultiplier = ((BasePlugin)this).Config.Bind<float>("Settings", "GoldMultiplier", 1f, "End-of-run gold multiplier"); TestF10Enabled = ((BasePlugin)this).Config.Bind<bool>("TestLab", "F10ScrollShortcutEnabled", true, "Enable the working F10 native artifact/scroll shop shortcut in solo runs."); TestF10Cooldown = ((BasePlugin)this).Config.Bind<float>("TestLab", "F10CooldownSeconds", 2.5f, "Runtime F10 anti-double-trigger cooldown. UI clamps to 1-10 seconds."); TestAutoReload = ((BasePlugin)this).Config.Bind<bool>("TestLab", "AutoReloadConfig", true, "Watch this plugin's config file and apply external edits while the game is running."); TestVerboseLog = ((BasePlugin)this).Config.Bind<bool>("TestLab", "VerboseTestLogs", false, "Extra Test Lab messages in BepInEx/LogOutput.log."); TestScrollOnlyArmed = ((BasePlugin)this).Config.Bind<bool>("TestLab", "ExperimentalScrollOnlyArmed", false, "Allow opt-in scroll-only overlay on the game's DEBUG store. DEBUG items may include normally unavailable artifacts. SOLO ONLY."); TestF10AllDebugArtifacts = ((BasePlugin)this).Config.Bind<bool>("TestLab", "F10UseAllDebugArtifacts", false, "Opt-in: F10 opens the DEBUG store, then automatically redraws native cards to show only artifacts. This may include locked or normally unavailable artifacts. SOLO ONLY. Turn OFF to restore native 3-choice F10."); TestAutoFilterSettleDelay = ((BasePlugin)this).Config.Bind<float>("TestLab", "AutoFilterSettleDelaySeconds", 0.25f, "Wait after artifact reward offers are fully available before filtering the native card UI. Live adjustable in F11; range 0.15-1.5 seconds."); TestChestOnlyMode = ((BasePlugin)this).Config.Bind<bool>("TestLab", "ChestOnlyNativeScrollPicker", false, "EXPERIMENT: Do NOT open extra shops; automatically redraw existing artifact reward selection when a genuine chest/shop appears. F10 is blocked in this mode. NOT guaranteed to work with multiplayer/server validation. OFF by default."); TestChestMultiplayer = ((BasePlugin)this).Config.Bind<bool>("TestLab", "AllowExperimentalChestPickerInMultiplayer", false, "EXPERIMENTAL and UNVERIFIED: allow local native card redraw in multiplayer ONLY IF MultiplayerSafeMode is OFF. This is not server-validated. OFF by default."); MultiplayerSafeMode = ((BasePlugin)this).Config.Bind<bool>("Settings", "MultiplayerSafeMode", true, "ON (recommended): when multiplayer is detected OR cannot be verified, prevent mod stat edits, XP/gold multiplication, extra scroll menus, and chest-card redraws. To test multiplayer chest filtering, turn this OFF AND explicitly arm its separate experimental option."); _liveConfig = ((BasePlugin)this).Config; try { _lastConfigWriteUtc = File.GetLastWriteTimeUtc(((BasePlugin)this).Config.ConfigFilePath); } catch (Exception ex) { ((BasePlugin)this).Log.LogWarning((object)("Test Lab: initial config timestamp unavailable: " + ex.Message)); } foreach (StatRow definition in StatRow.Definitions) { Saved[definition.Name] = ((BasePlugin)this).Config.Bind<float>("SavedBonuses", definition.Name, 0f, "Bonus for " + definition.Label); } HooksHarmony = new Harmony("local.spellbrigade.stat-editor-bepinex.hooks"); ((BasePlugin)this).Log.LogInfo((object)"Stat Editor 0.1.46: plugin Load() started. 1440p layout enabled. No hard dependency on Il2CppNetworking.Shared."); try { StatEditorOverlay statEditorOverlay = ((BasePlugin)this).AddComponent<StatEditorOverlay>(); ((BasePlugin)this).Log.LogInfo((object)("Stat Editor overlay created: " + ((Object)(object)statEditorOverlay != (Object)null) + ". Press F8, even in the main menu.")); } catch (Exception ex2) { ((BasePlugin)this).Log.LogError((object)("Failed to create F8 overlay: " + ex2)); } } internal static string ReloadTestSettings() { if (_liveConfig == null) { return "Test Lab config not ready"; } try { _liveConfig.Reload(); _lastConfigWriteUtc = File.GetLastWriteTimeUtc(_liveConfig.ConfigFilePath); string text = (TestLastEvent = "Settings reloaded LIVE from " + Path.GetFileName(_liveConfig.ConfigFilePath)); Logger.LogInfo((object)("TEST LAB: " + text)); return text; } catch (Exception ex) { string text2 = "Config reload failed: " + ex.GetBaseException().Message; Logger.LogWarning((object)("TEST LAB: " + text2)); return text2; } } internal static bool PollLiveSettings(float now) { if (_liveConfig == null || TestAutoReload == null || !TestAutoReload.Value || now < _nextConfigPoll) { return false; } _nextConfigPoll = now + 1.5f; try { DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(_liveConfig.ConfigFilePath); if (lastWriteTimeUtc == DateTime.MinValue || lastWriteTimeUtc <= _lastConfigWriteUtc) { return false; } ReloadTestSettings(); return true; } catch (Exception ex) { Logger.LogWarning((object)("TEST LAB: config polling unavailable: " + ex.GetBaseException().Message)); _nextConfigPoll = now + 20f; return false; } } internal static string TestLabStatus() { return "F10 " + (TestF10Enabled.Value ? "ON" : "OFF") + " | cooldown " + Math.Max(1f, Math.Min(10f, TestF10Cooldown.Value)).ToString("0.0") + "s | live config " + (TestAutoReload.Value ? "ON" : "OFF") + " | F10 choice mode: " + ((TestChestOnlyMode != null && TestChestOnlyMode.Value) ? "BLOCKED / CHEST-ONLY" : ((TestF10AllDebugArtifacts != null && TestF10AllDebugArtifacts.Value) ? "ALL DEBUG ARTIFACTS" : "VANILLA 3")) + " | multiplayer safety: " + SafetyModeDescription + " | multiplayer chest experiment: " + ((TestChestMultiplayer != null && TestChestMultiplayer.Value) ? "ARMED" : "OFF"); } internal static void Discover(float now) { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown if (PlayerHookOk || now < _nextDiscovery) { return; } _nextDiscovery = now + 15f; try { Type type = FindType("Il2Cpp.PlayerStats", "PlayerStats"); if (type == null) { Status = "Can't resolve PlayerStats from game assemblies; see log"; Logger.LogWarning((object)Status); return; } MethodInfo methodInfo = FindMethod(type, "GetCharacterValue", 1); MethodInfo methodInfo2 = FindMethod(type, "AddCharacterImprovement", 3); if (methodInfo == null || methodInfo2 == null) { Status = "PlayerStats found, but its stat methods were unavailable"; Logger.LogWarning((object)Status); return; } Type parameterType = methodInfo.GetParameters()[0].ParameterType; Type parameterType2 = methodInfo2.GetParameters()[2].ParameterType; if (!parameterType.IsEnum || !parameterType2.IsEnum) { Status = "Unexpected game stat API; see log"; Logger.LogWarning((object)Status); return; } object modifierStatic = Enum.Parse(parameterType2, "Static", ignoreCase: true); MethodInfo methodInfo3 = FindMethod(type, "Awake", 0); if (methodInfo3 == null) { throw new MissingMethodException("PlayerStats.Awake"); } HarmonyMethod val = new HarmonyMethod(typeof(GameHooks).GetMethod("PlayerAwake", BindingFlags.Static | BindingFlags.Public)); HooksHarmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); PlayerStatsType = type; ReadValueMethod = methodInfo; ApplyBonusMethod = methodInfo2; StatEnum = parameterType; ModifierEnum = parameterType2; ModifierStatic = modifierStatic; PlayerHookOk = true; Status = "Player stat hook installed; start a run"; Logger.LogInfo((object)Status); TryOtherHooks(); } catch (Exception ex) { Status = "Stat API incompatible: " + ex.GetType().Name + "; see log"; Logger.LogWarning((object)("Stat API hook unavailable; F8 menu still works: " + ex)); } } private static void TryOtherHooks() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown try { Type type = FindType("Il2Cpp.PartyLevelManager", "PartyLevelManager"); MethodInfo methodInfo = ((type == null) ? null : FindMethod(type, "TryAddExperience", -1)); if (methodInfo != null) { HooksHarmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(GameHooks).GetMethod("XpPrefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); XpHookOk = true; } Logger.LogInfo((object)("XP hook: " + XpHookOk)); } catch (Exception ex) { Logger.LogWarning((object)("XP hook unavailable: " + ex.Message)); } try { Type type2 = FindType("Il2Cpp.RunGoldCalculator", "RunGoldCalculator"); MethodInfo methodInfo2 = ((type2 == null) ? null : FindMethod(type2, "Calculate", -1)); if (methodInfo2 != null) { HooksHarmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(GameHooks).GetMethod("GoldPostfix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); GoldHookOk = true; } Logger.LogInfo((object)("Gold hook: " + GoldHookOk)); } catch (Exception ex2) { Logger.LogWarning((object)("Gold hook unavailable: " + ex2.Message)); } } private static Type FindType(params string[] names) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { foreach (string name in names) { try { Type type = assembly.GetType(name, throwOnError: false, ignoreCase: false); if (type != null) { return type; } } catch (Exception) { } } } return null; } private static MethodInfo FindMethod(Type type, string name, int parameters) { if (type == null) { return null; } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == name && (parameters < 0 || methodInfo.GetParameters().Length == parameters)) { return methodInfo; } } return null; } private static bool? Flag(object target, string property) { if (target == null) { return null; } Type type = target.GetType(); PropertyInfo property2 = type.GetProperty(property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property2 != null) { return Convert.ToBoolean(property2.GetValue(target)); } FieldInfo field = type.GetField(property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null)) { return Convert.ToBoolean(field.GetValue(target)); } return null; } internal static void DumpScrollApiDiagnostics() { if (Time.unscaledTime - _lastScrollApiProbe < 0.8f) { return; } _lastScrollApiProbe = Time.unscaledTime; Logger.LogInfo((object)"========== v0.1.46 F10 SCROLL / HOTKEY API INSPECTION =========="); Logger.LogInfo((object)"Shift+F10 diagnostic is READ ONLY. The normal F10 hotkey uses OfferStoreToAllPlayers only."); Logger.LogInfo((object)("F10: player-ready=" + (LocalPlayer != null) + ", stat-hook=" + PlayerHookOk)); string[] array = new string[11] { "Il2Cpp.StoreManager", "Il2Cpp.StoreType", "Il2Cpp.StoreGenerationType", "Il2Cpp.StoreInventoryGeneratorFactory", "Il2Cpp.ArtifactInventoryGenerator", "Il2Cpp.StoreInventoryGenerator", "Il2Cpp.StorePanel", "Il2Cpp.ArtifactChestWithPickup", "Il2Cpp.ArtifactInventoryGeneratorData", "Il2Cpp.StoreItem", "Il2Cpp.StoreItemDatabase" }; foreach (string text in array) { try { Type type = FindType(text); if (type == null) { Logger.LogInfo((object)("F10 TYPE NOT FOUND " + text)); continue; } Logger.LogInfo((object)("F10 TYPE " + type.FullName + " base=" + ((type.BaseType == null) ? "none" : type.BaseType.FullName))); if (type.IsEnum) { try { Logger.LogInfo((object)("F10 ENUM " + type.Name + " = " + string.Join(",", Enum.GetNames(type)))); } catch (Exception ex) { Logger.LogWarning((object)("F10 ENUM error " + ex.GetBaseException().Message)); } continue; } try { int num = 0; MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!methodInfo.IsSpecialName && (type.Name == "StoreManager" || type.Name == "ArtifactInventoryGenerator" || type.Name == "StoreInventoryGeneratorFactory" || type.Name == "ArtifactChestWithPickup" || ContainsAny(methodInfo.Name, "Enter", "Store", "Generate", "Open", "Spawn", "Show", "Item")) && num++ < 90) { Logger.LogInfo((object)("F10 METHOD " + type.Name + ": " + methodInfo)); } } Logger.LogInfo((object)("F10 METHOD COUNT " + type.Name + " " + num)); } catch (Exception ex2) { Logger.LogWarning((object)("F10 METHODS " + type.Name + ": " + ex2.GetBaseException().Message)); } try { int num2 = 0; PropertyInfo[] properties = type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (num2++ < 75) { Logger.LogInfo((object)("F10 PROPERTY " + type.Name + ": " + propertyInfo.PropertyType.FullName + " " + propertyInfo.Name + " get=" + propertyInfo.CanRead + " set=" + propertyInfo.CanWrite + " static=" + ((propertyInfo.GetMethod ?? propertyInfo.SetMethod)?.IsStatic ?? false))); continue; } break; } } catch (Exception ex3) { Logger.LogWarning((object)("F10 PROPERTIES " + type.Name + ": " + ex3.GetBaseException().Message)); } try { int num3 = 0; FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (num3++ < 45) { Logger.LogInfo((object)("F10 FIELD " + type.Name + ": " + fieldInfo.FieldType.FullName + " " + fieldInfo.Name + " static=" + fieldInfo.IsStatic)); continue; } break; } } catch (Exception ex4) { Logger.LogWarning((object)("F10 FIELDS " + type.Name + ": " + ex4.GetBaseException().Message)); } } catch (Exception ex5) { Logger.LogWarning((object)("F10 TYPE ERROR " + text + ": " + ex5.GetBaseException().Message)); } } Logger.LogInfo((object)"Shift+F10 COMPLETE. Send the F10 sections of LogOutput.log; do not wait for a chest."); Logger.LogInfo((object)"========== END F10 SCROLL / HOTKEY API INSPECTION =========="); } internal static string TryOpenNativeScrollStore() { float unscaledTime = Time.unscaledTime; if (TestF10Enabled != null && !TestF10Enabled.Value) { TestLastEvent = "F10 disabled in F11 Scroll Options"; return TestLastEvent; } float num = ((TestF10Cooldown == null) ? 2.5f : Math.Max(1f, Math.Min(10f, TestF10Cooldown.Value))); if (unscaledTime - _lastNativeScrollHotkey < num) { return "F10: cooldown (" + num.ToString("0.0") + "s)"; } _lastNativeScrollHotkey = unscaledTime; Logger.LogInfo((object)"F10 NATIVE SCROLL TEST: requested (no generator hooks installed)"); if (LocalPlayer == null || !PlayerHookOk) { return NativeScrollDenied("No active local wizard; start a solo run first"); } try { Type type = FindType("Il2Cpp.StoreManager"); if (type == null) { return NativeScrollDenied("StoreManager type not found"); } Type type2 = FindType("Il2Cpp.StoreType"); if (type2 == null || !type2.IsEnum) { return NativeScrollDenied("StoreType enum unavailable; nothing was opened"); } string[] names = Enum.GetNames(type2); Logger.LogInfo((object)("F10 StoreType entries: " + string.Join(", ", names))); string text = null; string[] array = names; foreach (string text2 in array) { if (string.Equals(text2, "Artifact", StringComparison.OrdinalIgnoreCase) || string.Equals(text2, "Artifacts", StringComparison.OrdinalIgnoreCase) || string.Equals(text2, "ArtifactChest", StringComparison.OrdinalIgnoreCase) || string.Equals(text2, "Scroll", StringComparison.OrdinalIgnoreCase) || string.Equals(text2, "ScrollChest", StringComparison.OrdinalIgnoreCase)) { text = text2; break; } } if (text == null) { array = names; foreach (string text3 in array) { if (text3.IndexOf("Artifact", StringComparison.OrdinalIgnoreCase) >= 0 || text3.IndexOf("Scroll", StringComparison.OrdinalIgnoreCase) >= 0) { if (text != null) { return NativeScrollDenied("Several artifact/scroll StoreType values; refused to guess"); } text = text3; } } } if (text == null) { return NativeScrollDenied("No artifact/scroll StoreType; read F10 StoreType entries in log"); } object obj = Enum.Parse(type2, text, ignoreCase: true); Logger.LogInfo((object)("F10: StoreType selected=" + text)); object obj2 = FindStoreManagerSingleton(type); if (obj2 == null) { return NativeScrollDenied("Could not locate the live StoreManager singleton; no store opened"); } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null) { return NativeScrollDenied("Cannot verify solo mode; refused to open store"); } if (Convert.ToBoolean(methodInfo.Invoke(obj2, null))) { return NativeScrollDenied("Multiplayer detected; F10 is solo-only"); } if (Flag(obj2, "IsShopPanelActive") == true) { return NativeScrollDenied("A reward selection is already open"); } if (Flag(obj2, "IsExitingStore") == true) { return NativeScrollDenied("A reward selection is closing"); } MethodInfo methodInfo2 = FindMethod(type, "OfferStoreToAllPlayers", 1); if (methodInfo2 == null) { return NativeScrollDenied("OfferStoreToAllPlayers method unavailable"); } methodInfo2.Invoke(obj2, new object[1] { obj }); Logger.LogInfo((object)("F10 NATIVE SCROLL TEST: OfferStoreToAllPlayers(" + text + ") returned normally")); TestF10Accepted++; TestLastEvent = "F10 native scroll opened (requested #" + TestF10Accepted + ")"; if (TestVerboseLog != null && TestVerboseLog.Value) { Logger.LogInfo((object)("TEST LAB TRACE: " + TestLabStatus() + "; calls accepted=" + TestF10Accepted)); } return "F10: requested game's normal artifact selection (check screen)"; } catch (Exception ex) { Logger.LogWarning((object)("F10 NATIVE SCROLL TEST FAILED safely: " + ex)); return "F10: store call failed; see LogOutput.log (normal chests unchanged)"; } } private static void ClearF10Ownership(string reason) { if (_f10OwnsStore) { Logger.LogInfo((object)("F10 TOGGLE: cleared owned-store tracking: " + reason)); } _f10OwnsStore = false; _f10ShopSeen = false; _f10CloseRequested = false; _f10DebugStore = false; _f10OwnedManager = null; _f10OwnedStoreId = ""; } private static void TrackF10Store(bool debug) { try { Type type = FindType("Il2Cpp.StoreManager"); object obj = ((type == null) ? null : FindStoreManagerSingleton(type)); if (obj == null) { Logger.LogWarning((object)"F10 TOGGLE: store requested, but no manager for safe close tracking"); return; } _f10OwnedManager = obj; _f10OwnsStore = true; _f10DebugStore = debug; _f10ShopSeen = false; _f10CloseRequested = false; _f10OwnedStoreId = ""; _f10StoreRequestAt = Time.unscaledTime; _f10NextObserve = 0f; Logger.LogInfo((object)("F10 TOGGLE: tracking a " + (debug ? "DEBUG" : "ARTIFACT") + " shop requested by F10")); } catch (Exception ex) { Logger.LogWarning((object)("F10 TOGGLE: tracking unavailable: " + ex.GetBaseException().Message)); ClearF10Ownership("tracking error"); } } internal static void PollF10ShopOwnership(float now, bool force = false) { if (!_f10OwnsStore || (!force && now < _f10NextObserve)) { return; } _f10NextObserve = now + 0.18f; try { if (_f10OwnedManager == null || (now - _f10StoreRequestAt > 25f && !_f10ShopSeen)) { ClearF10Ownership("store never became active / changed scene"); return; } bool? flag = Flag(_f10OwnedManager, "IsShopPanelActive"); if (flag == false) { if (_f10ShopSeen) { ClearF10Ownership("native reward panel closed"); } } else { if (flag != true) { return; } if (!_f10DebugStore && !string.Equals(Convert.ToString(ReadPropertyOrField(_f10OwnedManager, "CurrentStoreType")), "Artifact", StringComparison.OrdinalIgnoreCase)) { ClearF10Ownership("another type of shop is active"); return; } string text = Convert.ToString(ReadPropertyOrField(_f10OwnedManager, "currentStoreId")) ?? ""; if (_f10ShopSeen && !string.IsNullOrEmpty(_f10OwnedStoreId) && !string.IsNullOrEmpty(text) && !string.Equals(_f10OwnedStoreId, text, StringComparison.Ordinal)) { ClearF10Ownership("another store replaced the F10 shop"); } else if (!_f10ShopSeen) { _f10ShopSeen = true; _f10OwnedStoreId = text; Logger.LogInfo((object)"F10 TOGGLE: native F10 shop is active; press F10 again to request close"); } } } catch (Exception ex) { Logger.LogWarning((object)("F10 TOGGLE: ownership poll failed: " + ex.GetBaseException().Message)); ClearF10Ownership("manager no longer accessible"); } } private static string TryCloseF10OpenedStore() { if (!_f10OwnsStore) { return null; } float unscaledTime = Time.unscaledTime; PollF10ShopOwnership(unscaledTime, force: true); if (!_f10OwnsStore) { return null; } if (!_f10ShopSeen) { return "F10: previous shop is still opening; press again after its cards appear"; } if (_f10CloseRequested) { return "F10: native close was already requested. If still open, use a native card or revert."; } if (Flag(_f10OwnedManager, "IsShopPanelActive") != true) { ClearF10Ownership("already closed"); return null; } if (Flag(_f10OwnedManager, "IsExitingStore") != false) { return "F10: shop is already exiting"; } try { Type type = FindType("Il2Cpp.StoreManager"); if (type == null) { return "F10: close unavailable (StoreManager missing)"; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(_f10OwnedManager, null))) { return "F10: closing shops is disabled in multiplayer"; } MethodInfo methodInfo2 = FindMethod(type, "CloseStoreRpc", 0); if (methodInfo2 == null) { return "F10: native CloseStoreRpc unavailable; use a native reward card"; } Logger.LogWarning((object)"F10 TOGGLE: invoking native CloseStoreRpc() only on F10-created solo shop; no reward chosen"); if (_f10DebugStore) { CancelScrollOnlyPicker(); } _f10CloseRequested = true; _f10LastCloseAt = unscaledTime; methodInfo2.Invoke(_f10OwnedManager, null); Logger.LogInfo((object)"F10 TOGGLE: CloseStoreRpc returned; waiting for native shop to finish closing"); return "F10: requested native shop close (no item selected). Check that gameplay resumes."; } catch (Exception ex) { _f10CloseRequested = false; Logger.LogWarning((object)("F10 TOGGLE: close failed; no other exit APIs attempted: " + ex)); return "F10: close failed: " + ex.GetBaseException().Message + "; choose native card instead"; } } internal static string TryOpenConfiguredF10() { string text = TryCloseF10OpenedStore(); if (text != null) { return text; } if (SafetyBlocksChanges) { return "F10 disabled by multiplayer-safe mode: " + SafetyModeDescription; } if (TestChestOnlyMode != null && TestChestOnlyMode.Value) { return "F10 disabled in CHEST-ONLY MODE: collect a real scroll chest to earn exactly one reward"; } if (TestF10Enabled == null || !TestF10Enabled.Value) { return "F10 disabled in Test Lab"; } string text2; if (TestF10AllDebugArtifacts != null && TestF10AllDebugArtifacts.Value) { Logger.LogInfo((object)"F10 ALL DEBUG ARTIFACTS mode: opening native Debug store for automatic card filtering"); text2 = TryOpenScrollOnlyDebug(autoFilter: true); if (text2.StartsWith("F10 ALL: waiting", StringComparison.Ordinal)) { TrackF10Store(debug: true); } } else { text2 = TryOpenNativeScrollStore(); if (text2.StartsWith("F10: requested game's normal", StringComparison.Ordinal)) { TrackF10Store(debug: false); } } return text2; } internal static string TryOpenNativeDebugStore() { if (TestChestOnlyMode != null && TestChestOnlyMode.Value) { return "DEBUG STORE shortcut blocked in CHEST-ONLY MODE (no extra reward shops)"; } float unscaledTime = Time.unscaledTime; if (unscaledTime - _lastDebugStoreAttempt < 5f) { return "DEBUG STORE: 5-second cooldown"; } _lastDebugStoreAttempt = unscaledTime; Logger.LogInfo((object)"========== v0.1.46 OPTIONAL NATIVE DEBUG STORE TEST =========="); Logger.LogWarning((object)"DEBUG STORE: EXPERIMENTAL, SOLO ONLY. The game decides which debug items it offers."); if (LocalPlayer == null || !PlayerHookOk) { return "DEBUG STORE: start a solo run first"; } try { Type type = FindType("Il2Cpp.StoreManager"); Type type2 = FindType("Il2Cpp.StoreType"); if (type == null || type2 == null || !type2.IsEnum) { return "DEBUG STORE: StoreManager or StoreType unavailable"; } string text = null; string[] names = Enum.GetNames(type2); foreach (string text2 in names) { if (string.Equals(text2, "Debug", StringComparison.OrdinalIgnoreCase)) { text = text2; } } if (text == null) { return "DEBUG STORE: no named Debug StoreType in this game"; } object obj = FindStoreManagerSingleton(type); if (obj == null) { return "DEBUG STORE: no live StoreManager"; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(obj, null))) { return "DEBUG STORE: refused (not verifiably solo)"; } if (Flag(obj, "IsShopPanelActive") != false || Flag(obj, "IsExitingStore") != false) { return "DEBUG STORE: close other reward screens first"; } MethodInfo methodInfo2 = FindMethod(type, "OfferStoreToAllPlayers", 1); if (methodInfo2 == null) { return "DEBUG STORE: native store opener missing"; } object obj2 = Enum.Parse(type2, text, ignoreCase: true); Logger.LogInfo((object)"DEBUG STORE STEP: native entry = OfferStoreToAllPlayers(Debug) (no generator cast)"); methodInfo2.Invoke(obj, new object[1] { obj2 }); Logger.LogInfo((object)"DEBUG STORE STEP: OfferStoreToAllPlayers(Debug) returned normally"); TestLastEvent = "Experimental DEBUG store requested in solo run"; return "DEBUG STORE: requested native Debug shop; close F11 to inspect"; } catch (Exception ex) { Logger.LogWarning((object)("DEBUG STORE FAILED: " + ex)); return "DEBUG STORE: call failed: " + ex.GetBaseException().Message; } finally { Logger.LogInfo((object)"========== END v0.1.46 DEBUG STORE TEST =========="); } } internal static string TryOpenScrollOnlyDebug(bool autoFilter = false) { bool num = TestScrollOnlyArmed != null && TestScrollOnlyArmed.Value; bool flag = autoFilter && TestF10AllDebugArtifacts != null && TestF10AllDebugArtifacts.Value; if (!num && !flag) { return "SCROLL-ONLY: arm the manual test or enable F10 ALL DEBUG ARTIFACTS mode first"; } if (ScrollOnlyRequested) { return "SCROLL-ONLY: already awaiting/displaying a debug store"; } string text = TryOpenNativeDebugStore(); if (!text.StartsWith("DEBUG STORE: requested", StringComparison.Ordinal)) { return "SCROLL-ONLY: " + text; } ScrollOnlyRequested = true; ScrollOnlyReady = false; _scrollOnlyAutoMode = autoFilter; _autoNativeFilterPending = autoFilter; _autoNativeFilterDue = float.MaxValue; ScrollOnlySelectionCompleted = false; NativeDebugFilterApplied = false; ScrollOnlyItems.Clear(); ScrollOnlyTitles.Clear(); _queuedScrollOnlyIndex = -1; _nextScrollOnlyPoll = 0f; _scrollOnlyStart = Time.unscaledTime; ScrollOnlyStatus = "Waiting for native DEBUG store. The original store remains usable behind this panel."; Logger.LogWarning((object)("SCROLL-ONLY v0.1.46: opt-in debug store opened; only live ArtifactItems will be shown. NOT normal-run eligibility filtered. AutoFilter=" + autoFilter)); if (!autoFilter) { return "SCROLL-ONLY: waiting to read native debug store; then try FILTER NATIVE CARDS"; } return "F10 ALL: waiting for native debug offers; will filter cards automatically"; } internal static void CancelScrollOnlyPicker() { ScrollOnlyRequested = false; ScrollOnlyReady = false; _autoNativeFilterPending = false; _scrollOnlyAutoMode = false; ScrollOnlyItems.Clear(); ScrollOnlyTitles.Clear(); _queuedScrollOnlyIndex = -1; ScrollOnlyStatus = "Picker overlay dismissed. Any open native debug shop remains usable."; } internal static void RefreshScrollOnlyPicker(float now) { if (!ScrollOnlyRequested || ScrollOnlyReady || now < _nextScrollOnlyPoll) { return; } _nextScrollOnlyPoll = now + 0.12f; if (_queuedScrollOnlyIndex >= 0) { return; } try { Type type = FindType("Il2Cpp.StoreManager"); if (type == null) { ScrollOnlyStatus = "StoreManager not found"; return; } object obj = FindStoreManagerSingleton(type); if (obj == null) { ScrollOnlyStatus = "No StoreManager"; return; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(obj, null))) { CancelScrollOnlyPicker(); ScrollOnlyStatus = "Stopped: multiplayer or mode unknown"; return; } if (Flag(obj, "IsShopPanelActive") != true) { if (ScrollOnlyReady) { CancelScrollOnlyPicker(); ScrollOnlyStatus = "Native reward screen closed"; } else if (now - _scrollOnlyStart > 14f) { CancelScrollOnlyPicker(); ScrollOnlyStatus = "Timed out waiting for debug shop; use normal F10"; } return; } object obj2 = ReadPropertyOrField(obj, "itemsCurrentlyInStore"); if (obj2 == null) { ScrollOnlyStatus = "Waiting for live reward list"; return; } List<object> list = new List<object>(); if (!TryReadCachedSpellItemsDirect(obj2, list, out var problem)) { ScrollOnlyStatus = "Cannot read live cards: " + problem; } else if (list.Count < 40) { ScrollOnlyStatus = "Waiting for full DEBUG offers (seen " + list.Count + ")"; } else { if (ScrollOnlyReady) { return; } Type type2 = FindType("Il2Cpp.ArtifactItem"); if (type2 == null) { ScrollOnlyStatus = "Native ArtifactItem type unavailable"; return; } MethodInfo checkedArtifactCast = GetCheckedArtifactCast(list.Find((object i) => i != null), type2); if (checkedArtifactCast == null) { ScrollOnlyStatus = "Safe ArtifactItem type-check unavailable"; return; } List<object> list2 = new List<object>(); List<string> list3 = new List<string>(); foreach (object item in list) { if (item != null && checkedArtifactCast.Invoke(item, null) != null) { list2.Add(item); list3.Add(SafeStoreItemTitle(item)); if (list2.Count >= 32) { break; } } } if (list2.Count < 1) { ScrollOnlyStatus = "No verified artifact cards in active DEBUG store"; return; } ScrollOnlyItems.Clear(); ScrollOnlyItems.AddRange(list2); ScrollOnlyTitles.Clear(); ScrollOnlyTitles.AddRange(list3); ScrollOnlyReady = true; if (_autoNativeFilterPending) { float num = Mathf.Clamp((TestAutoFilterSettleDelay == null) ? 0.25f : TestAutoFilterSettleDelay.Value, 0.15f, 1.5f); _autoNativeFilterDue = now + num; Logger.LogInfo((object)("F10 ALL: " + list3.Count + " artifact cards ready; scheduling native filter in " + num.ToString("0.00", CultureInfo.InvariantCulture) + "s")); } ScrollOnlyStatus = "Found " + list3.Count + " LIVE debug artifacts (not normal-run eligibility filtered)."; Logger.LogInfo((object)("SCROLL-ONLY READY: " + ScrollOnlyStatus)); for (int num2 = 0; num2 < list3.Count; num2++) { Logger.LogInfo((object)("SCROLL-ONLY LIVE ARTIFACT " + (num2 + 1).ToString("00") + ": " + list3[num2])); } } } catch (Exception ex) { Logger.LogWarning((object)("SCROLL-ONLY live-card scan failed harmlessly: " + ex)); CancelScrollOnlyPicker(); ScrollOnlyStatus = "Failed reading debug items: " + ex.GetBaseException().Message; } } internal static string PollAutoNativeFilter(float now) { if (!_autoNativeFilterPending || !ScrollOnlyRequested || !ScrollOnlyReady || now < _autoNativeFilterDue) { return null; } _autoNativeFilterPending = false; Logger.LogInfo((object)"F10 ALL: applying native ArtifactItem-only card filter"); string text = TryFilterNativeDebugCards(); Logger.LogInfo((object)("F10 ALL: automatic filter result: " + text)); if (!NativeDebugFilterApplied) { _scrollOnlyAutoMode = false; Logger.LogWarning((object)"F10 ALL: automatic filter unsuccessful; native debug store left untouched"); } return text; } internal static string TryFilterNativeDebugCards() { NativeDebugFilterApplied = false; if ((TestScrollOnlyArmed == null || !TestScrollOnlyArmed.Value) && !_scrollOnlyAutoMode) { return "NATIVE FILTER: disarmed"; } if (!ScrollOnlyRequested || !ScrollOnlyReady || ScrollOnlyItems.Count < 1) { return "NATIVE FILTER: open the scroll-only debug picker first"; } try { Logger.LogInfo((object)"NATIVE FILTER v0.1.46 STEP: validate active DEBUG store"); Type type = FindType("Il2Cpp.StoreManager"); object obj = ((type == null) ? null : FindStoreManagerSingleton(type)); if (obj == null || Flag(obj, "IsShopPanelActive") != true || Flag(obj, "IsExitingStore") != false) { return "NATIVE FILTER: shop has closed or is exiting"; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(obj, null))) { return "NATIVE FILTER: refused - solo only"; } object obj2 = ReadPropertyOrField(obj, "itemsCurrentlyInStore"); List<object> list = new List<object>(); if (obj2 == null) { return "NATIVE FILTER: game did not provide any active offers"; } if (!TryReadCachedSpellItemsDirect(obj2, list, out var problem) || list.Count < 40) { return "NATIVE FILTER: debug offers no longer active; " + problem; } Logger.LogInfo((object)("NATIVE FILTER STEP: current native debug offers=" + list.Count)); Type type2 = FindType("Il2Cpp.ArtifactItem"); MethodInfo methodInfo2 = ((type2 == null) ? null : GetCheckedArtifactCast(list.Find((object x) => x != null), type2)); if (methodInfo2 == null) { return "NATIVE FILTER: native ArtifactItem type check unavailable"; } object obj3 = ReadPropertyOrField(obj, "storePanel"); if (obj3 == null) { return "NATIVE FILTER: native StorePanel unavailable; original shop untouched"; } MethodInfo methodInfo3 = FindMethod(obj3.GetType(), "SetDebugOptions", 1); if (methodInfo3 == null) { return "NATIVE FILTER: StorePanel.SetDebugOptions unavailable; original shop untouched"; } Logger.LogInfo((object)"NATIVE FILTER STEP: StorePanel.SetDebugOptions method found"); Type type3 = obj2.GetType(); object obj4 = Activator.CreateInstance(type3); if (obj4 == null) { return "NATIVE FILTER: could not create native list; original shop untouched"; } MethodInfo methodInfo4 = FindMethod(type3, "Add", 1); if (methodInfo4 == null) { return "NATIVE FILTER: native list Add unavailable; original shop untouched"; } int num = 0; HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (object item in list) { if (item != null && methodInfo2.Invoke(item, null) != null) { string text = Convert.ToString(ReadPropertyOrField(item, "Pointer"), CultureInfo.InvariantCulture); if (!string.IsNullOrEmpty(text) && hashSet.Add(text)) { methodInfo4.Invoke(obj4, new object[1] { item }); num++; } } } if (num < 1 || num > 32 || num != ScrollOnlyItems.Count) { return "NATIVE FILTER: artifact list changed; original debug cards preserved"; } Logger.LogInfo((object)("NATIVE FILTER STEP: prepared " + num + " verified original live artifacts; calling game's SetDebugOptions")); methodInfo3.Invoke(obj3, new object[1] { obj4 }); NativeDebugFilterApplied = true; ScrollOnlyStatus = "Native debug cards filtered to " + num + " artifacts. Use ORIGINAL card clicks to select."; Logger.LogInfo((object)("NATIVE FILTER SUCCESS: " + ScrollOnlyStatus)); CancelScrollOnlyPicker(); return "NATIVE FILTER: " + num + " cards requested; choose from the game's own orange cards"; } catch (Exception ex) { Logger.LogWarning((object)("NATIVE FILTER FAILED: original game shop can be used instead. " + ex)); return "NATIVE FILTER: failed - " + ex.GetBaseException().Message + "; use native orange cards"; } } private static void ResetChestObservation(string message) { _chestWasOpen = false; _chestFilterPending = false; _chestFilterAttempted = false; _chestStoreId = ""; if (!string.IsNullOrWhiteSpace(message)) { ChestFilterStatus = message; } } internal static void PollChestOnlyArtifactShop(float now) { if (TestChestOnlyMode == null || !TestChestOnlyMode.Value) { if (_chestWasOpen || _chestFilterPending || _chestFilterAttempted) { ResetChestObservation("Chest-only mode disabled; original reward UI is unchanged next chest"); } _chestCachedManager = null; } else { if (now < _nextChestScan) { return; } _nextChestScan = now + 0.12f; if (LocalPlayer == null || !PlayerHookOk) { return; } try { Type type = _chestCachedManagerType ?? FindType("Il2Cpp.StoreManager"); if (type == null) { ChestFilterStatus = "StoreManager unavailable"; return; } _chestCachedManagerType = type; object obj = _chestCachedManager; if (now - _chestLastManagerRefresh >= 12f) { _chestLastManagerRefresh = now; object obj2 = FindStoreManagerSingleton(type); if (obj2 != null) { obj = obj2; _chestCachedManager = obj2; } else { _chestCachedManager = null; obj = null; } } if (obj == null) { return; } int num; object obj3; if (Flag(obj, "IsShopPanelActive") == true) { num = ((Flag(obj, "IsExitingStore") == false) ? 1 : 0); if (num != 0) { obj3 = ReadPropertyOrField(obj, "CurrentStoreType"); goto IL_0128; } } else { num = 0; } obj3 = null; goto IL_0128; IL_0128: object obj4 = obj3; bool flag = obj4 != null && string.Equals(Convert.ToString(obj4), "Artifact", StringComparison.OrdinalIgnoreCase); if (num == 0 || !flag) { if (_chestWasOpen) { ResetChestObservation("Chest selection closed; waiting for the next real scroll chest"); } return; } string text = Convert.ToString(ReadPropertyOrField(obj, "currentStoreId")) ?? ""; if (!_chestWasOpen || (!string.IsNullOrWhiteSpace(text) && text != _chestStoreId)) { _chestWasOpen = true; _chestFilterPending = false; _chestFilterAttempted = false; _chestStoreId = text; _chestFilteredCount = 0; ChestFilterStatus = "Artifact shop detected; checking genuine reward context"; Logger.LogInfo((object)("CHEST ONLY: real Artifact shop detected; store id=" + ((text.Length > 48) ? text.Substring(0, 48) : text))); } if (_chestFilterAttempted) { return; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null) { _chestFilterAttempted = true; ChestFilterStatus = "Could not verify player mode; vanilla cards preserved"; return; } bool flag2 = Convert.ToBoolean(methodInfo.Invoke(obj, null)); if (flag2 && MultiplayerSafeMode != null && MultiplayerSafeMode.Value) { _chestFilterAttempted = true; ChestFilterStatus = "MP SAFE ON: genuine chest keeps ORIGINAL offers (no local redraw)"; Logger.LogInfo((object)"MP SAFE: stopped multiplayer chest card redraw"); return; } if (flag2 && (TestChestMultiplayer == null || !TestChestMultiplayer.Value)) { _chestFilterAttempted = true; ChestFilterStatus = "Multiplayer safe default: VANILLA cards. Enable separate MP opt-in after solo testing."; Logger.LogWarning((object)"CHEST ONLY: multiplayer detected; filtered cards blocked unless explicitly armed"); return; } object obj5 = ReadPropertyOrField(obj, "itemsCurrentlyInStore"); if (obj5 == null) { return; } List<object> list = new List<object>(); if (!TryReadCachedSpellItemsDirect(obj5, list, out var problem)) { _chestFilterAttempted = true; ChestFilterStatus = "Cannot read native chest offers: " + problem; } else if (list.Count >= 1) { if (list.Count > 6) { _chestFilterAttempted = true; ChestFilterStatus = "Not a 1-6-card Artifact chest; vanilla cards preserved"; } else if (!_chestFilterPending) { _chestFilterPending = true; _chestFilterDue = now + Mathf.Clamp((TestAutoFilterSettleDelay == null) ? 0.25f : TestAutoFilterSettleDelay.Value, 0.15f, 1.5f); Logger.LogInfo((object)("CHEST ONLY: " + list.Count + " native Artifact offers found. Filtering AFTER native panel settles; multiplayer=" + flag2)); ChestFilterStatus = "Detected actual scroll selection (" + list.Count + " choices). Preparing expanded native cards."; } else if (!(now < _chestFilterDue)) { _chestFilterPending = false; _chestFilterAttempted = true; string text2 = (ChestFilterStatus = TryFilterExistingChestCards(obj, type, obj5, list, flag2)); Logger.LogInfo((object)("CHEST ONLY RESULT: " + text2)); } } } catch (Exception ex) { _chestFilterAttempted = true; _chestFilterPending = false; ChestFilterStatus = "Chest filter failed; use original cards: " + ex.GetBaseException().Message; Logger.LogWarning((object)("CHEST ONLY: caught error, no extra store created: " + ex)); _chestCachedManager = null; _nextChestScan = now + 1f; } } } private static string TryFilterExistingChestCards(object manager, Type managerType, object currentNativeOffers, List<object> currentOffers, bool multiplayer) { try { if (Flag(manager, "IsShopPanelActive") != true || Flag(manager, "IsExitingStore") != false || !string.Equals(Convert.ToString(ReadPropertyOrField(manager, "CurrentStoreType")), "Artifact", StringComparison.OrdinalIgnoreCase)) { return "Chest closed before filter; nothing changed"; } if (multiplayer && MultiplayerSafeMode != null && MultiplayerSafeMode.Value) { return "Multiplayer safe mode ON; original offers kept"; } if (multiplayer && (TestChestMultiplayer == null || !TestChestMultiplayer.Value)) { return "Multiplayer opt-in switched off; vanilla offers kept"; } MethodInfo methodInfo = FindMethod(managerType, "GetDebugStoreItems", 0); if (methodInfo == null) { return "GetDebugStoreItems unavailable; original cards kept"; } Logger.LogInfo((object)"CHEST ONLY: reading debug catalog (no new reward shop will open)"); object obj = methodInfo.Invoke(manager, null); if (obj == null) { return "Empty debug catalog; original cards kept"; } List<object> list = new List<object>(); if (!TryReadCachedSpellItemsDirect(obj, list, out var problem)) { return "Debug catalog unreadable: " + problem + "; original cards kept"; } Type type = FindType("Il2Cpp.ArtifactItem"); MethodInfo methodInfo2 = ((type == null) ? null : GetCheckedArtifactCast(list.Find((object x) => x != null), type)); if (methodInfo2 == null) { return "Artifact type verification unavailable; original cards kept"; } object obj2 = ReadPropertyOrField(manager, "storePanel"); if (obj2 == null) { return "Native StorePanel missing; original cards kept"; } MethodInfo methodInfo3 = FindMethod(obj2.GetType(), "SetDebugOptions", 1); if (methodInfo3 == null) { return "SetDebugOptions unavailable; original cards kept"; } object obj3 = Activator.CreateInstance(currentNativeOffers.GetType()); MethodInfo methodInfo4 = FindMethod(currentNativeOffers.GetType(), "Add", 1); if (obj3 == null || methodInfo4 == null) { return "Native list constructor unavailable; original cards kept"; } int num = 0; HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (object item in list) { if (item == null || methodInfo2.Invoke(item, null) == null) { continue; } string text = Convert.ToString(ReadPropertyOrField(item, "Pointer"), CultureInfo.InvariantCulture); if (!string.IsNullOrWhiteSpace(text) && hashSet.Add(text)) { methodInfo4.Invoke(obj3, new object[1] { item }); if (++num >= 32) { break; } } } if (num < 2) { return "Fewer than two verified artifact options; original cards kept"; } Logger.LogWarning((object)("CHEST ONLY: REDRAWING existing Artifact shop from " + currentOffers.Count + " offered cards to " + num + " debug artifact cards; multiplayer=" + multiplayer)); methodInfo3.Invoke(obj2, new object[1] { obj3 }); _chestFilteredCount = num; return "Displayed " + num + " orange cards in existing chest. Click a NATIVE card once. (MP server validation unverified)"; } catch (Exception ex) { Logger.LogWarning((object)("CHEST ONLY: local redraw failed: " + ex)); return "Native redraw failed: " + ex.GetBaseException().Message + "; original chest may remain usable"; } } private static string NativeScrollDenied(string reason) { Logger.LogWarning((object)("F10 NATIVE SCROLL TEST SKIPPED: " + reason)); return "F10: " + reason; } private static object FindStoreManagerSingleton(Type managerType) { Type type = managerType; while (type != null) { try { PropertyInfo[] properties = type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { MethodInfo getMethod = propertyInfo.GetGetMethod(nonPublic: true); if (getMethod == null || !getMethod.IsStatic || propertyInfo.GetIndexParameters().Length != 0 || (!managerType.IsAssignableFrom(propertyInfo.PropertyType) && !string.Equals(propertyInfo.Name, "Instance", StringComparison.OrdinalIgnoreCase) && !string.Equals(propertyInfo.Name, "Singleton", StringComparison.OrdinalIgnoreCase))) { continue; } try { object value = propertyInfo.GetValue(null); if (value != null && managerType.IsInstanceOfType(value)) { Logger.LogInfo((object)("F10: StoreManager singleton from " + type.Name + "." + propertyInfo.Name)); return value; } } catch (Exception ex) { Logger.LogWarning((object)("F10 singleton property " + propertyInfo.Name + ": " + ex.GetBaseException().Message)); } } } catch (Exception ex2) { Logger.LogWarning((object)("F10 singleton property scan " + type.Name + ": " + ex2.GetBaseException().Message)); } try { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!fieldInfo.IsStatic || !managerType.IsAssignableFrom(fieldInfo.FieldType)) { continue; } try { object value2 = fieldInfo.GetValue(null); if (value2 != null && managerType.IsInstanceOfType(value2)) { Logger.LogInfo((object)("F10: StoreManager singleton from " + type.Name + "." + fieldInfo.Name)); return value2; } } catch (Exception ex3) { Logger.LogWarning((object)("F10 singleton field " + fieldInfo.Name + ": " + ex3.GetBaseException().Message)); } } } catch (Exception ex4) { Logger.LogWarning((object)("F10 singleton field scan " + type.Name + ": " + ex4.GetBaseException().Message)); } type = type.BaseType; } return null; } internal static string SnapshotCurrentScrollOffers() { ScrollCatalogPreview.Clear(); ScrollCatalogSource = "StoreManager.itemsCurrentlyInStore (READ ONLY)"; Logger.LogInfo((object)"========== v0.1.46 LIVE SCROLL OFFERS BEGIN =========="); if (LocalPlayer == null || !PlayerHookOk) { return ScrollCatalogStatus = "Start a solo run first"; } try { Type type = FindType("Il2Cpp.StoreManager"); if (type == null) { return ScrollCatalogStatus = "StoreManager unavailable"; } object obj = FindStoreManagerSingleton(type); if (obj == null) { return ScrollCatalogStatus = "Live StoreManager unavailable"; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(obj, null))) { return ScrollCatalogStatus = "Solo only: cannot verify solo mode"; } Logger.LogInfo((object)"LIVE CATALOG STEP: reading StoreManager.itemsCurrentlyInStore"); object obj2 = ReadPropertyOrField(obj, "itemsCurrentlyInStore"); Logger.LogInfo((object)("LIVE CATALOG STEP: value " + ((obj2 == null) ? "NULL" : obj2.GetType().FullName))); if (obj2 == null) { return ScrollCatalogStatus = "No current store items. Open F10 first."; } List<object> list = new List<object>(); string problem; bool flag = TryReadCachedSpellItemsDirect(obj2, list, out problem); Logger.LogInfo((object)("LIVE CATALOG STEP: enumerated=" + flag + " count=" + list.Count + " reason=" + problem)); if (!flag) { return ScrollCatalogStatus = "Can't read live offers: " + problem; } int num = 0; foreach (object item in list) { if (item != null) { num++; string text = SafeStoreItemTitle(item); string text2 = num.ToString("00") + ". " + text; ScrollCatalogPreview.Add(text2); Logger.LogInfo((object)("LIVE CATALOG ITEM " + text2)); } } Logger.LogInfo((object)("LIVE CATALOG COMPLETE: " + num + " reward cards captured")); return ScrollCatalogStatus = "Observed " + num + " current reward items. READ ONLY; no selection available."; } catch (Exception ex) { Logger.LogWarning((object)("LIVE CATALOG failed: " + ex)); return ScrollCatalogStatus = "Live snapshot unavailable: " + ex.GetBaseException().Message; } finally { Logger.LogInfo((object)"========== v0.1.46 LIVE SCROLL OFFERS END =========="); } } private static string SafeStoreItemTitle(object item) { if (item == null) { return "(null)"; } string[] array = new string[3] { "TitleEntry", "_TitleEntry_k__BackingField", "DescriptionEntry" }; foreach (string name in array) { try { string text = Convert.ToString(ReadPropertyOrField(item, name)); if (!string.IsNullOrWhiteSpace(text)) { text = text.Replace('\r', ' ').Replace('\n', ' ').Trim(); return (text.Length > 135) ? (text.Substring(0, 132) + "...") : text; } } catch (Exception) { } } return item.GetType().Name + " (title unavailable)"; } private static MethodInfo GetCheckedArtifactCast(object item, Type artifactType) { if (item == null || artifactType == null) { return null; } for (Type type = item.GetType(); type != null; type = type.BaseType) { MethodInfo[] methods; try { methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch (Exception) { continue; } MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { if (!(methodInfo.Name != "TryCast") && methodInfo.IsGenericMethodDefinition && methodInfo.GetGenericArguments().Length == 1 && methodInfo.GetParameters().Length == 0) { try { return methodInfo.MakeGenericMethod(artifactType); } catch (Exception) { } } } } return null; } internal static string ScanScrollCatalog(bool artifactsOnly = false) { if (Time.unscaledTime - _lastCatalogProbe < 1.5f) { return "Catalog scan cooldown (1.5 seconds)"; } _lastCatalogProbe = Time.unscaledTime; ScrollCatalogPreview.Clear(); ScrollCatalogSource = (artifactsOnly ? "GetDebugStoreItems + checked ArtifactItem native cast (READ ONLY)" : "StoreManager.GetDebugStoreItems (READ ONLY)"); Logger.LogInfo((object)"========== v0.1.46 SCROLL CATALOG BEGIN =========="); Logger.LogInfo((object)("CATALOG: opt-in debug list; artifactsOnly=" + artifactsOnly + "; no reward modifiers, static generator settings or selection calls")); if (LocalPlayer == null || !PlayerHookOk) { return ScrollCatalogStatus = "No active wizard. Start a solo run."; } try { Type type = FindType("Il2Cpp.StoreManager"); if (type == null) { return ScrollCatalogStatus = "StoreManager unavailable"; } object obj = FindStoreManagerSingleton(type); if (obj == null) { return ScrollCatalogStatus = "Live StoreManager unavailable"; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(obj, null))) { return ScrollCatalogStatus = "Solo only: cannot verify a solo run"; } MethodInfo methodInfo2 = FindMethod(type, "GetDebugStoreItems", 0); if (methodInfo2 == null) { return ScrollCatalogStatus = "GetDebugStoreItems not present"; } Logger.LogInfo((object)"CATALOG STEP: invoking StoreManager.GetDebugStoreItems() (debug list, not filtered eligibility)"); object obj2 = methodInfo2.Invoke(obj, null); Logger.LogInfo((object)("CATALOG STEP: debug list object " + ((obj2 == null) ? "NULL" : obj2.GetType().FullName))); if (obj2 == null) { return ScrollCatalogStatus = "Game returned no debug items"; } List<object> list = new List<object>(); string problem; bool flag = TryReadCachedSpellItemsDirect(obj2, list, out problem); Logger.LogInfo((object)("CATALOG STEP: list enumerated=" + flag + ", count=" + list.Count + ", message=" + problem)); if (!flag) { return ScrollCatalogStatus = "Could not read item list: " + problem; } Type type2 = null; MethodInfo methodInfo3 = null; if (artifactsOnly) { type2 = FindType("Il2Cpp.ArtifactItem"); if (type2 == null) { return ScrollCatalogStatus = "Native ArtifactItem type unavailable (no mutations made)"; } methodInfo3 = GetCheckedArtifactCast(list.Find((object x) => x != null), type2); if (methodInfo3 == null) { return ScrollCatalogStatus = "Verified native TryCast<ArtifactItem> unavailable (no mutations made)"; } Logger.LogInfo((object)("ARTIFACT FILTER: native type=" + type2.FullName + ", checked cast=" + methodInfo3.DeclaringType.FullName + "." + methodInfo3.Name)); } int num = 0; int num2 = 0; foreach (object item in list) { if (item == null) { continue; } num2++; if (artifactsOnly) { object obj3; try { obj3 = methodInfo3.Invoke(item, null); } catch (Exception ex) { string message = ex.GetBaseException().Message; Logger.LogWarning((object)("ARTIFACT FILTER: checked cast unavailable at item " + num2 + ": " + message)); ScrollCatalogPreview.Clear(); return ScrollCatalogStatus = "Artifact type-check failed: " + message + ". No rewards changed."; } if (obj3 == null) { continue; } } num++; string text = SafeStoreItemTitle(item); string text2 = num.ToString("00") + ". " + text; ScrollCatalogPreview.Add(text2); if (num <= 128) { Logger.LogInfo((object)("CATALOG ITEM " + text2 + (artifactsOnly ? " [verified ArtifactItem]" : " [DEBUG ITEM; type unverified]"))); } if (num != 1) { continue; } try { int num3 = 0; PropertyInfo[] properties = item.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { if (num3++ < 35) { Logger.LogInfo((object)("CATALOG ITEM PROPERTY " + propertyInfo.Name + " : " + propertyInfo.PropertyType.Name)); continue; } break; } } catch (Exception ex2) { Logger.LogWarning((object)("CATALOG property metadata failed: " + ex2.GetBaseException().Message)); } } ScrollCatalogStatus = (artifactsOnly ? ("Verified " + num + " artifact-type DEBUG items of " + num2 + ". Eligibility NOT checked. Selection DISABLED.") : ("Read " + num + " DEBUG items with title keys; includes non-artifacts. Selection DISABLED.")); Logger.LogInfo((object)("CATALOG COMPLETE: " + ScrollCatalogStatus)); return ScrollCatalogStatus; } catch (Exception ex3) { Logger.LogWarning((object)("CATALOG SCAN failed (no game rewards altered): " + ex3)); return ScrollCatalogStatus = "Catalog scan unavailable: " + ex3.GetBaseException().Message; } finally { Logger.LogInfo((object)"========== v0.1.46 SCROLL CATALOG END =========="); } } internal static string ScanActiveRunArtifacts(bool checkNativeAvailability) { float unscaledTime = Time.unscaledTime; if (unscaledTime - _lastCatalogProbe < 1.5f) { return "Scan cooldown (1.5 sec)"; } _lastCatalogProbe = unscaledTime; ScrollCatalogPreview.Clear(); ScrollCatalogSource = (checkNativeAvailability ? "ACTIVE ArtifactInventoryGenerator: candidates + mode/availability checks (read-only)" : "ACTIVE ArtifactInventoryGenerator.GetAllPossibleArtifacts (read-only)"); Logger.LogInfo((object)"========== v0.1.46 RUN ARTIFACT SCAN BEGIN =========="); Logger.LogInfo((object)("RUN SCAN: checkNativeAvailability=" + checkNativeAvailability + "; no generator hooks, no static settings, no selection or reward mutations")); try { if (LocalPlayer == null || !PlayerHookOk) { return ScrollCatalogStatus = "Start a solo run first"; } Type type = FindType("Il2Cpp.StoreManager"); if (type == null) { return ScrollCatalogStatus = "StoreManager unavailable"; } object obj = FindStoreManagerSingleton(type); if (obj == null) { return ScrollCatalogStatus = "StoreManager instance unavailable"; } MethodInfo methodInfo = FindMethod(type, "IsMultiplayer", 0); if (methodInfo == null || Convert.ToBoolean(methodInfo.Invoke(obj, null))) { return ScrollCatalogStatus = "Solo-only run scan: cannot verify solo mode"; } bool? flag = Flag(obj, "IsShopPanelActive"); Logger.LogInfo((object)("RUN SCAN STEP: IsShopPanelActive=" + (flag.HasValue ? flag.Value.ToString() : "unknown"))); if (flag != true) { return ScrollCatalogStatus = "Open F10 artifact selection FIRST, then scan while cards are visible"; } object obj2 = ReadPropertyOrField(obj, "CurrentStoreType"); Logger.LogInfo((object)("RUN SCAN STEP: CurrentStoreType=" + ((obj2 == null) ? "(null)" : obj2.ToString()))); if (obj2 == null || obj2.ToString().IndexOf("Artifact", StringComparison.OrdinalIgnoreCase) < 0) { return ScrollCatalogStatus = "Current store is not an Artifact store"; } Logger.LogInfo((object)"RUN SCAN STEP: reading currentStoreInventoryGenerator (existing instance only)"); object obj3 = ReadPropertyOrField(obj, "currentStoreInventoryGenerator"); Logger.LogInfo((object)("RUN SCAN STEP: generator wrapper=" + ((obj3 == null) ? "NULL" : obj3.GetType().FullName))); if (obj3 == null) { return ScrollCatalogStatus = "Active artifact generator unavailable. No changes made."; } Type type2 = FindType("Il2Cpp.ArtifactInventoryGenerator"); if (type2 == null) { return ScrollCatalogStatus = "ArtifactInventoryGenerator type not available"; } object obj4 = null; if (type2.IsInstanceOfType(obj3)) { obj4 = obj3; } else { MethodInfo checkedArtifactCast = GetCheckedArtifactCast(obj3, type2); if (checkedArtifactCast == null) { return ScrollCatalogStatus = "No checked cast for live generator; refused unsafe conversion"; } Logger.LogInfo((object)"RUN SCAN STEP: verifying required networking interop assembly BEFORE native cast"); bool flag2 = false; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { if (string.Equals(assemblies[i].GetName().Name, "Il2CppNetworking.Shared", StringComparison.OrdinalIgnoreCase)) { flag2 = true; break; } } } catch (Exception) { } if (!flag2) { Logger.LogWarning((object)"RUN SCAN BLOCKED: Il2CppNetworking.Shared is not loaded. Skipping cast and its known exception."); return ScrollCatalogStatus = "Native run scan unavailable: missing Il2CppNetworking.Shared; use ARTIFACTS ONLY or try DEBUG STORE. No changes made."; } Logger.LogInfo((object)"RUN SCAN STEP: trying checked native generator cast"); obj4 = checkedArtifactCast.Invoke(obj3, null); } Logger.LogInfo((object)("RUN SCAN STEP: typed generator=" + ((obj4 == null) ? "NULL" : obj4.GetType().FullName))); if (obj4 == null) { return ScrollCatalogStatus = "Active generator is not an ArtifactInventoryGenerator"; } MethodInfo methodInfo2 = FindMethod(type2, "GetAllPossibleArtifacts", 0); if (methodInfo2 == null) { return ScrollCatalogStatus = "Native GetAllPossibleArtifacts not available"; } Logger.LogInfo((object)"RUN SCAN STEP: invoking native GetAllPossibleArtifacts() (NO Generate hook)"); object obj5 = methodInfo2.Invoke(obj4, null); Logger.LogInfo((object)("RUN SCAN STEP: returned wrapper=" + ((obj5 == null) ? "NULL" : obj5.GetType().FullName))); if (obj5 == null) { return ScrollCatalogStatus = "Native candidate query returned null"; } List<object> list = new List<object>(); string problem; bool flag3 = TryReadCachedSpellItemsDirect(obj5, list, out problem); Logger.LogInfo((object)("RUN SCAN STEP: enumerated=" + flag3 + " count=" + list.Count + " reason=" + problem)); if (!flag3) { return ScrollCatalogStatus = "Native list could not be read: " + problem; } Type artifactType = FindType("Il2Cpp.ArtifactItem"); MethodInfo checkedArtifactCast2 = GetCheckedArtifactCast(list.Find((object item) => item != null), artifactType); MethodInfo methodInfo3 = (checkNativeAvailability ? FindMethod(type2, "IsValidForMode", 1) : null); MethodInfo methodInfo4 = (checkNativeAvailability ? FindMethod(type2, "IsArtifactAvailable", 1) : null); if (checkNativeAvailability && (methodInfo3 == null || methodInfo4 == null || checkedArtifactCast2 == null)) { return ScrollCatalogStatus = "Game native availability predicates or safe artifact cast unavailable"; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; foreach (object item in list) { if (item == null) { continue; } num4++; if (num4 > 100) { break; } string text = SafeStoreItemTitle(item); bool? flag4 = null; bool? flag5 = null; if (checkNativeAvailability) { object obj6 = checkedArtifactCast2.Invoke(item, null); if (obj6 == null) { num3++; continue; } Logger.LogInfo((object)("RUN SCAN CHECK: " + text + " mode predicate")); flag4 = Convert.ToBoolean(methodInfo3.Invoke(obj4, new object[1] { obj6 })); Logger.LogInfo((object)("RUN SCAN CHECK: " + text + " availability predicate")); flag5 = Convert.ToBoolean(methodInfo4.Invoke(obj4, new object[1] { obj6 })); } string text2 = ((!checkNativeAvailability) ? "[candidate; not verified]" : ((flag4 == true && flag5 == true) ? "[mode+available PASS]" : "[filtered by native check]")); if (checkNativeAvailability) { if (flag4 == true && flag5 == true) { num++; } else { num2++; } } ScrollCatalogPreview.Add(num4.ToString("00") + ". " + text + " " + text2); Logger.LogInfo((object)("RUN SCAN ITEM " + num4.ToString("00") + ". " + text + " mode=" + (flag4.HasValue ? flag4.Value.ToString() : "not tested") + " available=" + (flag5.HasValue ? flag5.Value.ToString() : "not tested"))); } ScrollCatalogStatus = (checkNativeAvailability ? ("Native check: " + num + " pass, " + num2 + " filtered, " + num3 + " unknown of " + num4 + ". Other eligibility rules may still apply. READ ONLY.") : ("Native generator reported " + num4 + " possible artifacts. Eligibility NOT verified. READ ONLY.")); Logger.LogInfo((object)("RUN SCAN COMPLETE: " + ScrollCatalogStatus)); return ScrollCatalogStatus; } catch (Exception ex2) { string message = ex2.GetBaseException().Message; Logger.LogWarning((object)("RUN SCAN FAILED at previous STEP: " + ex2)); return ScrollCatalogStatus = "Run scan failed: " + message + ". No scroll changes intentionally made."; } finally { Logger.LogInfo((object)"========== v0.1.46 RUN ARTIFACT SCAN END =========="); } } internal static void ScanPlayers() { if (!PlayerHookOk || Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 0.25f; try { if (LocalPlayer != null && (Flag(LocalPlayer, "WasCollected") == true || Flag(LocalPlayer, "IsSpawned") == false)) { LocalPlayer = null; InvalidatePlayerMode(); _restoreSavedBonusesPending = false; Rows.Clear(); GameStats.Clear(); SpellDisplays.Clear(); EquippedSpells.Clear(); PerSpellDisplays.Clear(); UnreadableSpellLists.Clear(); PerSpellBonuses.Clear(); SelectedSpell = null; _spellReadPlayer = null; } for (int num = PendingPlayers.Count - 1; num >= 0; num--) { object obj = PendingPlayers[num]; if (obj == null || Flag(obj, "WasCollected") == true) { PendingPlayers.RemoveAt(num); } else if (Flag(obj, "IsSpawned") == true && Flag(obj, "IsOwner") == true) { PendingPlayers.RemoveAt(num); if (LocalPlayer == null) { LocalPlayer = obj; _restoreSavedBonusesPending = false; InvalidatePlayerMode(); RefreshMultiplayerMode(Time.unscaledTime, force: true); Rows.Clear(); GameStats.Clear(); SpellDisplays.Clear(); EquippedSpells.Clear(); PerSpellDisplays.Clear(); UnreadableSpellLists.Clear(); PerSpellBonuses.Clear(); SelectedSpell = null; _spellReadPlayer = null; _nextSpellRead = 0f; _nextGameStatScan = 0f; foreach (StatRow definition in StatRow.Definitions) { StatRow item = definition.Copy(); Rows.Add(item); } if (KeepBonuses.Value) { _restoreSavedBonusesPending = true; RefreshMultiplayerMode(Time.unscaledTime, force: true); } IndexGameStats(); Status = "Local wizard identified; editing enabled"; Logger.LogInfo((object)Status); } } } } catch (Exception ex) { if (Time.unscaledTime > _nextScanWarning) { _nextScanWarning = Time.unscaledTime + 10f; Logger.LogWarning((object)("Stat player scan error: " + ex.Message)); } } } internal static bool TryRead(StatRow row, out float value) { value = 0f; if (LocalPlayer == null || ReadValueMethod == null) { return false; } try { object obj = Enum.Parse(StatEnum, row.Name, ignoreCase: true); value = Convert.ToSingle(ReadValueMethod.Invoke(LocalPlayer, new object[1] { obj })); return true; } catch (Exception ex) { if (_readWarnings.Add(row.Name)) { Logger.LogWarning((object)("Can't read " + row.Name + ": " + ex.Message)); } return false; } } internal static void IndexGameStats() { if (LocalPlayer == null || PlayerStatsType == null || Rows.Count == 0 || GameStats.Count >= Rows.Count || Time.unscaledTime < _nextGameStatScan) { return; } _nextGameStatScan = Time.unscaledTime + 2f; try { if (_gameStatsMethod == null) { _gameStatsMethod = FindMethod(PlayerStatsType, "GetPlayerStats", 0); } if (_gameStatsMethod == null) { return; } object obj = _gameStatsMethod.Invoke(LocalPlayer, null); if (obj == null) { return; } Type type = obj.GetType(); PropertyInfo property = type.GetProperty("Count", BindingFlags.Instance | BindingFlags.Public); PropertyInfo property2 = type.GetProperty("Item", BindingFlags.Instance | BindingFlags.Public); MethodInfo methodInfo = ((property2 == null) ? FindMethod(type, "get_Item", 1) : null); if (property == null || (property2 == null && methodInfo == null)) { return; } int num = Math.Min(Convert.ToInt32(property.GetValue(obj)), 256); int num2 = 0; for (int i = 0; i < num; i++) { object obj2 = ((property2 != null) ? property2.GetValue(obj, new object[1] { i }) : methodInfo.Invoke(obj, new object[1] { i })); if (obj2 == null) { continue; } object obj3 = ReadPropertyOrField(obj2, "StatType"); if (obj3 != null) { string key = obj3.ToString(); if (!GameStats.ContainsKey(key)) { GameStats.Add(key, obj2); num2++; } } } if (num2 > 0) { Logger.LogInfo((object)("Read " + GameStats.Count + " game Stat objects for signed CURRENT display.")); } } catch (Exception ex) { Logger.LogWarning((object)("Game Stat object lookup unavailable, using original value reader: " + ex.Message)); } } private static object ReadPropertyOrField(object obj, string name) { if (obj == null) { return null; } Type type = obj.GetType(); PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { return property.GetValue(obj); } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null)) { return field.GetValue(obj); } return null; } private static string ReadPercentStatGameDisplay(object stat, string statName) { if (stat == null) { return null; } try { MethodInfo methodInfo = FindMethod(stat.GetType(), "ToCachedStat", 0); if (methodInfo != null) { object obj = methodInfo.Invoke(stat, null); if (obj != null) { object obj2 = ReadPropertyOrField(obj, "DisplayText"); if (obj2 != null && !string.IsNullOrWhiteSpace(obj2.ToString())) { string text = obj2.ToString().Trim(); if (!float.TryParse(text.Replace("%", "").Replace("+", "").Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !(Math.Abs(result) < 1E-05f)) { if (_readWarnings.Add(statName + "-cached")) { Logger.LogInfo((object)("CURRENT " + statName + " uses Stat.ToCachedStat().DisplayText")); } return text; } } } } } catch (Exception ex) { if (_readWarnings.Add(statName + "-cached-error")) { Logger.LogWarning((object)("CURRENT " + statName + " cached display unavailable: " + ex.Message)); } } try { MethodInfo methodInfo2 = FindMethod(stat.GetType(), "GetDisplayValue", 0); if (methodInfo2 != null) { float num = Convert.ToSingle(methodInfo2.Invoke(stat, null)); if (!float.IsNaN(num) && !float.IsInfinity(num) && Math.Abs(num) > 1E-05f) { if (_readWarnings.Add(statName + "-display")) { Logger.LogInfo((object)("CURRENT " + statName + " uses Stat.GetDisplayValue()=" + num.ToString("0.##"))); } return num.ToString("0.##"); } } } catch (Exception ex2) { if (_readWarnings.Add(statName + "-display-error")) { Logger.LogWarning((object)("CURRENT " + statName + " GetDisplayValue unavailable: " + ex2.Message)); } } try { MethodInfo methodInfo3 = FindMethod(stat.GetType(), "GetModifierPercentString", 0); if (methodInfo3 != null) { object obj3 = methodInfo3.Invoke(stat, null); string text2 = ((obj3 == null) ? "" : obj3.ToString().Trim()); if (text2.Length > 0 && text2.Length <= 8 && text2.IndexOfAny(new char[3] { '+', '-', '%' }) >= 0 && float.TryParse(text2.Replace("%", "").Replace("+", "").Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && Math.Abs(result2) > 1E-05f) { if (_readWarnings.Add(statName + "-modifier-display")) { Logger.LogInfo((object)("CURRENT " + statName + " uses game modifier string (marked *): " + text2)); } return text2 + "*"; } } } catch (Exception ex3) { if (_readWarnings.Add(statName + "-percent-error")) { Logger.LogWarning((object)("CURRENT " + statName + " GetModifierPercentString unavailable: " + ex3.Message)); } } return null; } private static bool TryReadNegativeBase(object stat, out float value) { value = 0f; try { object obj = ReadPropertyOrField(stat, "BaseValue"); if (obj == null) { return false; } value = Convert.ToSingle(obj); return !float.IsNaN(value) && !float.IsInfinity(value) && value < 0f; } catch (Exception) { return false; } } private static List<Type> CollectionTypes(Type type) { List<Type> list = new List<Type>(); HashSet<Type> hashSet = new HashSet<Type>(); Type type2 = type; while (type2 != null) { if (hashSet.Add(type2)) { list.Add(type2); } try { Type[] interfaces = type2.GetInterfaces(); foreach (Type type3 in interfaces) { if (type3 != null && hashSet.Add(type3)) { list.Add(type3); } } } catch (Exception) { } type2 = type2.BaseType; } return list; } private static object ReadCollectionMember(object target, string name) { if (target == null) { return null; } foreach (Type item in CollectionTypes(target.GetType())) { try { PropertyInfo property = item.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.GetIndexParameters().Length == 0) { return property.GetValue(target); } } catch (Exception) { } try { MethodInfo methodInfo = FindMethod(item, "get_" + name, 0); if (methodInfo != null) { return methodInfo.Invoke(target, null); } } catch (Exception) { } } return null; } private static bool TryReadCachedSpellItemsDirect(object collection, List<object> output, out string problem) { problem = null; if (collection == null) { problem = "null collection"; return false; } if (collection is IEnumerable enumerable) { try { foreach (object item in enumerable) { if (item != null) { output.Add(item); } if (output.Count >= 128) { break; } } return true; } catch (Exception ex) { problem = "CLR iterator: " + ex.GetBaseException().Message; } } List<Type> list = CollectionTypes(collection.GetType()); foreach (Type item2 in list) { int num; try { object obj = null; PropertyInfo property = item2.GetProperty("Count", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.GetIndexParameters().Length == 0) { obj = property.GetValue(collection); } if (obj == null) { MethodInfo methodInfo = FindMethod(item2, "get_Count", 0); if (methodInfo != null) { obj = methodInfo.Invoke(collection, null); } } if (obj == null) { continue; } num = Math.Max(0, Math.Min(128, Convert.ToInt32(obj))); goto IL_0127; } catch (Exception) { } continue; IL_0127: foreach (Type item3 in list) { try { PropertyInfo property2 = item3.GetProperty("Item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo methodInfo2 = ((property2 == null) ? FindMethod(item3, "get_Item", 1) : null); if (property2 == null && methodInfo2 == null) { continue; } List<object> list2 = new List<object>(); for (int i = 0; i < num; i++) { object obj2 = ((property2 != null) ? property2.GetValue(collection, new object[1] { i }) : methodInfo2.Invoke(collection, new object[1] { i })); if (obj2 != null) { list2.Add(obj2); } } output.AddRange(list2); return true; } catch (Exception ex3) { problem = "indexer: " + ex3.GetBaseException().Message; } } } foreach (Type item4 in list) { object obj3; try { MethodInfo methodInfo3 = FindMethod(item4, "GetEnumerator", 0); if (!(methodInfo3 == null)) { obj3 = methodInfo3.Invoke(collection, null); if (obj3 != null) { goto IL_02b3; } } } catch (Exception ex4) { problem = "enumerator: " + ex4.GetBaseException().Message; } continue; IL_02b3: try { int num2 = 0; while (num2++ < 128) { MethodInfo methodInfo4 = null; foreach (Type item5 in CollectionTypes(obj3.GetType())) { methodInfo4 = FindMethod(item5, "MoveNext", 0); if (methodInfo4 != null) { break; } } if (methodInfo4 == null) { throw new InvalidOperationException("MoveNext unavailable"); } if (!Convert.ToBoolean(methodInfo4.Invoke(obj3, null))) { break; } object obj4 = ReadCollectionMember(obj3, "Current"); if (obj4 == null) { throw new InvalidOperationException("Current unavailable"); } output.Add(obj4); } return true; } catch (Exception ex5) { problem = "iteration: " + ex5.GetBaseException().Message; output.Clear(); } finally { try { if (obj3 is IDisposable disposable) { disposable.Dispose(); } } catch (Exception) { } } } if (problem == null) { problem = "no supported collection accessors (" + collection.GetType().FullName + ")"; } return false; } private static bool TryReadCachedSpellItems(object collection, List<object> output, out string problem) { bool flag = TryReadCachedSpellItemsDirect(collection, output, out problem); if (flag && output.Count > 0) { return true; } output.Clear(); if (collection == null) { return false; } string text = (flag ? "managed reader returned zero entries" : problem); Type type = null; try { Type[] genericArguments = collection.GetType().GetGenericArguments(); if (genericArguments.Length == 1) { type = genericArguments[0]; } } catch (Exception) { } if (type == null) { type = FindType("Il2Cpp.CachedStat"); } if (type == null) { problem = text + "; CachedStat type not found"; return false; } MethodInfo methodInfo = null; MethodInfo methodInfo2 = null; try { Type type2 = collection.GetType(); while (type2 != null) { MethodInfo[] methods = type2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo3 in methods) { if (methodInfo3.IsGenericMethodDefinition && methodInfo3.GetGenericArguments().Length == 1 && methodInfo3.GetParameters().Length == 0) { if (methodInfo3.Name == "TryCast") { methodInfo2 = methodInfo3; } if (methodInfo3.Name == "Cast") { methodInfo = methodInfo3; } } } if (!(methodInfo != null) && !(methodInfo2 != null)) { type2 = type2.BaseType; continue; } break; } } catch (Exception ex2) { problem = text + "; IL2CPP Cast method lookup failed: " + ex2.GetBaseException().Message; return false; } if (methodInfo == null && methodInfo2 == null) { problem = text + "; IL2CPP Cast<T> unavailable on " + collection.GetType().Name; return false; } string text2 = ""; string[] array = new string[5] { "Il2CppSystem.Collections.Generic.List`1", "Il2CppSystem.Collections.Generic.IList`1", "Il2CppSystem.Collections.ObjectModel.ReadOnlyCollection`1", "Il2CppSystem.Collections.Generic.IReadOnlyList`1", "Il2CppInterop.Runtime.InteropTypes.Arrays.Il2CppReferenceArray`1" }; foreach (string text3 in array) { Type type3 = FindType(text3); if (type3 == null || !type3.IsGenericTypeDefinition) { continue; } Type type4; try { type4 = type3.MakeGenericType(type); } catch (Exception ex3) { text2 = text3 + " generic error: " + ex3.GetBaseException().Message; continue; } MethodInfo[] methods = new MethodInfo[2] { methodInfo2, methodInfo }; foreach (MethodInfo methodInfo4 in methods) { if (methodInfo4 == null) { continue; } try { object obj = methodInfo4.MakeGenericMethod(type4).Invoke(collection, null); if (obj != null) { List<object> list = new List<object>(); string problem2; bool flag2 = TryReadCachedSpellItemsDirect(obj, list, out problem2); if (flag2 && list.Count > 0) { output.AddRange(list); problem = null; return true; } text2 = type4.Name + (flag2 ? " cast returned zero entries" : (" cast read failed: " + problem2)); } } catch (Exception ex4) { text2 = type4.Name + " cast failed: " + ex4.GetBaseException().Message; } } } problem = text + ((text2.Length > 0) ? ("; " + text2) : "; no IL2CPP collection cast succeeded"); return false; } private static string FormatSpellCurrent(string statName, object cachedStat, string displayText) { if (statName == "FireRate" && cachedStat != null) { try { object obj = ReadPropertyOrField(cachedStat, "Value"); if (obj != null) { double d = Convert.ToDouble(obj, CultureInfo.InvariantCulture); if (!double.IsNaN(d) && !double.IsInfinity(d)) { return d.ToString("0.00", CultureInfo.InvariantCulture) + "/s"; } } } catch (Exception ex) { if (_readWarnings.Add("spell-FireRate-precise")) { Logger.LogWarning((object)("Spell Cast Speed precise CURRENT unavailable: " + ex.GetBaseException().Message)); } } } if (!string.IsNullOrWhiteSpace(displayText)) { return displayText.Trim(); } return "--"; } internal static void RefreshSpellDisplays(bool diagnostics) { if (LocalPlayer == null) { return; } if (_spellReadPlayer != LocalPlayer) { SpellDisplays.Clear(); EquippedSpells.Clear(); PerSpellDisplays.Clear(); UnreadableSpellLists.Clear(); _spellReadPlayer = LocalPlayer; _nextSpellRead = 0f; } if (!diagnostics && Time.unscaledTime < _nextSpellRead) { return; } _nextSpellRead = Time.unscaledTime + 1f; SpellDisplays.Clear(); EquippedSpells.Clear(); PerSpellDisplays.Clear(); UnreadableSpellLists.Clear(); _spellReadStatus = "not available"; try { Type type = LocalPlayer.GetType(); MethodInfo methodInfo = FindMethod(type, "GetEquippedSpellStats", 0); MethodInfo methodInfo2 = FindMethod(type, "GetStatsForSpell", 1); if (methodInfo == null || methodInfo2 == null) { _spellReadStatus = "GetEquippedSpellStats/GetStatsForSpell unavailable"; if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT: " + _spellReadStatus)); } return; } object obj = methodInfo.Invoke(LocalPlayer, null); if (obj == null) { _spellReadStatus = "equipped spells unavailable"; return; } MethodInfo methodInfo3 = FindMethod(obj.GetType(), "ContainsKey", 1); Type parameterType = methodInfo2.GetParameters()[0].ParameterType; if (methodInfo3 == null || !parameterType.IsEnum) { _spellReadStatus = "equipped-spell dictionary cannot be read"; if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT: " + _spellReadStatus)); } return; } Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>(); string[] array = new string[3] { "Range", "Speed", "LifeTime" }; foreach (string key in array) { dictionary[key] = new List<string>(); } int num = 0; foreach (object value2 in Enum.GetValues(parameterType)) { bool flag = false; try { flag = Convert.ToBoolean(methodInfo3.Invoke(obj, new object[1] { value2 })); } catch (Exception ex) { if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT ContainsKey error: " + ex.GetBaseException().Message)); } continue; } if (!flag) { continue; } if (++num > 16) { break; } string text = value2.ToString(); EquippedSpells.Add(text); Dictionary<string, string> dictionary2 = new Dictionary<string, string>(StringComparer.Ordinal); PerSpellDisplays[text] = dictionary2; object obj2 = null; try { obj2 = methodInfo2.Invoke(LocalPlayer, new object[1] { value2 }); } catch (Exception ex2) { if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT " + value2?.ToString() + " failed: " + ex2.GetBaseException().Message)); } continue; } if (obj2 == null) { continue; } List<object> list = new List<object>(); if (!TryReadCachedSpellItems(obj2, list, out var problem)) { UnreadableSpellLists.Add(text); if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT " + value2?.ToString() + " collection unreadable: " + problem + "; enabling experimental edits")); } continue; } int count = list.Count; if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT " + text + " collection wrapper=" + obj2.GetType().FullName + "; entries=" + count)); } if (count == 0) { UnreadableSpellLists.Add(text); if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT " + value2?.ToString() + " returned zero cached entries; enabling experimental controls")); } } if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT " + value2?.ToString() + " has " + count + " cached stat entries")); } for (int j = 0; j < count; j++) { try { object obj3 = list[j]; if (obj3 == null) { continue; } string text2 = Convert.ToString(ReadPropertyOrField(obj3, "StatType")); string text3 = Convert.ToString(ReadPropertyOrField(obj3, "DisplayText")); if (!string.IsNullOrEmpty(text2)) { string text4 = (dictionary2[text2] = FormatSpellCurrent(text2, obj3, text3)); if (diagnostics && Array.IndexOf(SpellStatNames, text2) >= 0) { Logger.LogInfo((object)("SPELL CURRENT " + value2?.ToString() + " " + text2 + " DisplayText=" + (text3 ?? "<null>") + " Value=" + Convert.ToString(ReadPropertyOrField(obj3, "Value")) + " Current=" + text4 + " SumOfModifiers=" + Convert.ToString(ReadPropertyOrField(obj3, "SumOfModifiers")))); } if (dictionary.TryGetValue(text2, out var value) && text4 != "--") { value.Add(text4); } } } catch (Exception ex3) { if (diagnostics) { Logger.LogInfo((object)("SPELL CURRENT " + value2?.ToString() + " item " + j + " error: " + ex3.GetBaseException().Message)); } } } } foreach (KeyValuePair<string, List<string>> item in dictionary) { if (item.Value.Count == 0) { continue; } string text6 = item.Value[0]; bool flag2 = false; for (int k = 1; k < item.Value.Count; k++) { if (!string.Equals(text6, item.Value[k], StringComparison.Ordinal)) { flag2 = true; } } SpellDisplays[item.Key] = (flag2 ? "MIXED" : text6); } if (SelectedSpell == null || !EquippedSpells.Contains(SelectedSpell)) { SelectedSpell = ((EquippedSpells.Count > 0) ? EquippedSpells[0] : null); } _spellReadStatus = "equipped=" + num + ", found=" + SpellDisplays.Count; if (!diagnostics) { return; } Logger.LogInfo((object)("SPELL CURRENT scan: " + _spellReadStatus)); foreach (KeyValuePair<string, string> spellDisplay in SpellDisplays) { Logger.LogInfo((object)("SPELL CURRENT display " + spellDisplay.Key + "=" + spellDisplay.Value)); } } catch (Exception ex4) { _spellReadStatus = ex4.GetBaseException().Message; if (diagnostics) { Logger.LogWarning((object)("SPELL CURRENT scan failed: " + ex4)); } } } internal static void CycleSelectedSpell(int direction) { RefreshSpellDisplays(diagnostics: false); if (EquippedSpells.Count == 0) { SelectedSpell = null; return; } int num = EquippedSpells.IndexOf(SelectedSpell); if (num < 0) { num = 0; } SelectedSpell = EquippedSpells[(num + direction + EquippedSpells.Count) % EquippedSpells.Count]; } internal static string SpellCurrent(string spell, string stat) { if (string.IsNullOrEmpty(spell)) { return "--"; } RefreshSpellDisplays(diagnostics: false); if (PerSpellDisplays.TryGetValue(spell, out var value) && value.TryGetValue(stat, out var value2)) { return value2; } return "--"; } internal static bool SpellStatAvailable(string spell, string stat) { if (string.IsNullOrEmpty(spell) || !EquippedSpells.Contains(spell)) { return false; } if (PerSpellDisplays.TryGetValue(spell, out var value) && value.ContainsKey(stat)) { return true; } if (UnreadableSpellLists.Contains(spell) && Array.IndexOf(SpellStatNames, stat) >= 0 && StatEnum != null) { return Enum.IsDefined(StatEnum, stat); } return false; } internal static bool SpellStatVerified(string spell, string stat) { if (PerSpellDisplays.TryGetValue(spell ?? "", out var value)) { return value.ContainsKey(stat); } return false; } private static string SpellBonusKey(string spell, string stat) { return spell + "|" + stat; } internal static float SpellBonus(string spell, string stat) { if (string.IsNullOrEmpty(spell) || !PerSpellBonuses.TryGetValue(SpellBonusKey(spell, stat), out var value)) { return 0f; } return value; } internal static int K