using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PSS; using SenpaisChest.ChestLabels; using SenpaisChest.ChestLabels.Extensions; using SenpaisChest.Config; using SenpaisChest.Data; using SenpaisChest.Integration; using SenpaisChest.UI; using SunHavenMuseumUtilityTracker; using SunHavenMuseumUtilityTracker.Data; using SunhavenMods.Shared; using SunhavenTodo; using SunhavenTodo.Data; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; using Wish; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SenpaisChest")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+871217776acdadbaabcc0e4af36feeef0cd58101")] [assembly: AssemblyProduct("SenpaisChest")] [assembly: AssemblyTitle("SenpaisChest")] [assembly: InternalsVisibleTo("HavenDevTools")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SunhavenMods.Shared { public static class ConfigFileHelper { public static ConfigFile CreateNamedConfig(string pluginGuid, string configFileName, Action logWarning = null) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, configFileName); string text2 = Path.Combine(Paths.ConfigPath, pluginGuid + ".cfg"); try { if (!File.Exists(text) && File.Exists(text2)) { File.Copy(text2, text); } } catch (Exception ex) { logWarning?.Invoke("[Config] Migration to " + configFileName + " failed: " + ex.Message); } return new ConfigFile(text, true); } public static bool ReplacePluginConfig(BaseUnityPlugin plugin, ConfigFile newConfig, Action logWarning = null) { if ((Object)(object)plugin == (Object)null || newConfig == null) { return false; } try { Type typeFromHandle = typeof(BaseUnityPlugin); PropertyInfo property = typeFromHandle.GetProperty("Config", BindingFlags.Instance | BindingFlags.Public); if (property != null && property.CanWrite) { property.SetValue(plugin, newConfig, null); return true; } FieldInfo field = typeFromHandle.GetField("k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(plugin, newConfig); return true; } FieldInfo[] fields = typeFromHandle.GetFields(BindingFlags.Instance | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(ConfigFile)) { fieldInfo.SetValue(plugin, newConfig); return true; } } } catch (Exception ex) { logWarning?.Invoke("[Config] ReplacePluginConfig failed: " + ex.Message); } return false; } } public static class VersionChecker { public class VersionCheckResult { public bool Success { get; set; } public bool UpdateAvailable { get; set; } public string CurrentVersion { get; set; } public string LatestVersion { get; set; } public string ModName { get; set; } public string NexusUrl { get; set; } public string Changelog { get; set; } public string ErrorMessage { get; set; } } public class ModHealthSnapshot { public string PluginGuid { get; set; } public DateTime LastCheckUtc { get; set; } public int ExceptionCount { get; set; } public string LastError { get; set; } } private class VersionCheckRunner : MonoBehaviour { private ManualLogSource _pluginLog; public void StartCheck(string pluginGuid, string currentVersion, ManualLogSource pluginLog, Action onComplete) { _pluginLog = pluginLog; ((MonoBehaviour)this).StartCoroutine(CheckVersionCoroutine(pluginGuid, currentVersion, onComplete)); } private void LogInfo(string message) { ManualLogSource pluginLog = _pluginLog; if (pluginLog != null) { pluginLog.LogInfo((object)("[VersionChecker] " + message)); } } private void LogWarningMsg(string message) { ManualLogSource pluginLog = _pluginLog; if (pluginLog != null) { pluginLog.LogWarning((object)("[VersionChecker] " + message)); } } private void LogErrorMsg(string message) { ManualLogSource pluginLog = _pluginLog; if (pluginLog != null) { pluginLog.LogError((object)("[VersionChecker] " + message)); } } private IEnumerator CheckVersionCoroutine(string pluginGuid, string currentVersion, Action onComplete) { VersionCheckResult result = new VersionCheckResult { CurrentVersion = currentVersion }; UnityWebRequest www = UnityWebRequest.Get("https://azraelgodking.github.io/SunhavenMod/versions.json"); try { www.timeout = 10; yield return www.SendWebRequest(); if ((int)www.result == 2 || (int)www.result == 3) { result.Success = false; result.ErrorMessage = "Network error: " + www.error; RecordHealthError(pluginGuid, result.ErrorMessage); LogWarningMsg(result.ErrorMessage); onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); yield break; } try { string text = www.downloadHandler.text; Match match = GetModPattern(pluginGuid).Match(text); if (!match.Success) { result.Success = false; result.ErrorMessage = "Mod '" + pluginGuid + "' not found in versions.json"; RecordHealthError(pluginGuid, result.ErrorMessage); LogWarningMsg(result.ErrorMessage); onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); yield break; } string value = match.Groups[1].Value; result.LatestVersion = ExtractJsonString(value, "version"); result.ModName = ExtractJsonString(value, "name"); result.NexusUrl = ExtractJsonString(value, "nexus"); result.Changelog = ExtractJsonString(value, "changelog"); if (string.IsNullOrEmpty(result.LatestVersion)) { result.Success = false; result.ErrorMessage = "Could not parse version from response"; RecordHealthError(pluginGuid, result.ErrorMessage); LogWarningMsg(result.ErrorMessage); onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); yield break; } result.Success = true; result.UpdateAvailable = CompareVersions(currentVersion, result.LatestVersion) < 0; if (result.UpdateAvailable) { LogInfo("Update available for " + result.ModName + ": " + currentVersion + " -> " + result.LatestVersion); } else { LogInfo(result.ModName + " is up to date (v" + currentVersion + ")"); } } catch (Exception ex) { result.Success = false; result.ErrorMessage = "Parse error: " + ex.Message; RecordHealthError(pluginGuid, result.ErrorMessage); LogErrorMsg(result.ErrorMessage); } } finally { ((IDisposable)www)?.Dispose(); } onComplete?.Invoke(result); Object.Destroy((Object)(object)((Component)this).gameObject); } private string ExtractJsonString(string json, string key) { Match match = ExtractFieldRegex.Match(json); while (match.Success) { if (string.Equals(match.Groups["key"].Value, key, StringComparison.Ordinal)) { return match.Groups["value"].Value; } match = match.NextMatch(); } return null; } } private const string VersionsUrl = "https://azraelgodking.github.io/SunhavenMod/versions.json"; private static readonly Dictionary HealthByPluginGuid = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly object HealthLock = new object(); private static readonly Dictionary ModPatternCache = new Dictionary(StringComparer.Ordinal); private static readonly object ModPatternCacheLock = new object(); private static readonly Regex ExtractFieldRegex = new Regex("\"(?[^\"]+)\"\\s*:\\s*(?:\"(?[^\"]*)\"|null)", RegexOptions.Compiled); public static void CheckForUpdate(string pluginGuid, string currentVersion, ManualLogSource logger = null, Action onComplete = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) TouchHealth(pluginGuid); VersionCheckRunner versionCheckRunner = new GameObject("VersionChecker").AddComponent(); Object.DontDestroyOnLoad((Object)(object)((Component)versionCheckRunner).gameObject); SceneRootSurvivor.TryRegisterPersistentRunnerGameObject(((Component)versionCheckRunner).gameObject); versionCheckRunner.StartCheck(pluginGuid, currentVersion, logger, onComplete); } public static ModHealthSnapshot GetHealthSnapshot(string pluginGuid) { if (string.IsNullOrWhiteSpace(pluginGuid)) { return null; } lock (HealthLock) { if (!HealthByPluginGuid.TryGetValue(pluginGuid, out ModHealthSnapshot value)) { return null; } return new ModHealthSnapshot { PluginGuid = value.PluginGuid, LastCheckUtc = value.LastCheckUtc, ExceptionCount = value.ExceptionCount, LastError = value.LastError }; } } public static int CompareVersions(string v1, string v2) { if (string.IsNullOrEmpty(v1) || string.IsNullOrEmpty(v2)) { return 0; } v1 = v1.TrimStart('v', 'V'); v2 = v2.TrimStart('v', 'V'); int num = v1.IndexOfAny(new char[2] { '-', '+' }); if (num >= 0) { v1 = v1.Substring(0, num); } int num2 = v2.IndexOfAny(new char[2] { '-', '+' }); if (num2 >= 0) { v2 = v2.Substring(0, num2); } string[] array = v1.Split(new char[1] { '.' }); string[] array2 = v2.Split(new char[1] { '.' }); int num3 = Math.Max(array.Length, array2.Length); for (int i = 0; i < num3; i++) { int result; int num4 = ((i < array.Length && int.TryParse(array[i], out result)) ? result : 0); int result2; int num5 = ((i < array2.Length && int.TryParse(array2[i], out result2)) ? result2 : 0); if (num4 < num5) { return -1; } if (num4 > num5) { return 1; } } return 0; } private static void TouchHealth(string pluginGuid) { if (string.IsNullOrWhiteSpace(pluginGuid)) { return; } lock (HealthLock) { if (!HealthByPluginGuid.TryGetValue(pluginGuid, out ModHealthSnapshot value)) { value = new ModHealthSnapshot { PluginGuid = pluginGuid }; HealthByPluginGuid[pluginGuid] = value; } value.LastCheckUtc = DateTime.UtcNow; } } private static void RecordHealthError(string pluginGuid, string errorMessage) { if (string.IsNullOrWhiteSpace(pluginGuid)) { return; } lock (HealthLock) { if (!HealthByPluginGuid.TryGetValue(pluginGuid, out ModHealthSnapshot value)) { value = new ModHealthSnapshot { PluginGuid = pluginGuid }; HealthByPluginGuid[pluginGuid] = value; } value.LastCheckUtc = DateTime.UtcNow; value.ExceptionCount++; value.LastError = errorMessage; } } private static Regex GetModPattern(string pluginGuid) { lock (ModPatternCacheLock) { if (!ModPatternCache.TryGetValue(pluginGuid, out Regex value)) { value = new Regex("\"" + Regex.Escape(pluginGuid) + "\"\\s*:\\s*\\{([^}]+)\\}", RegexOptions.Compiled | RegexOptions.Singleline); ModPatternCache[pluginGuid] = value; } return value; } } } public static class VersionCheckerExtensions { public static void NotifyUpdateAvailable(this VersionChecker.VersionCheckResult result, ManualLogSource logger = null) { if (!result.UpdateAvailable) { return; } string text = result.ModName + " update available: v" + result.LatestVersion; try { Type type = ReflectionHelper.FindWishType("NotificationStack"); if (type != null) { Type type2 = ReflectionHelper.FindType("SingletonBehaviour`1", "Wish"); if (type2 != null) { object obj = type2.MakeGenericType(type).GetProperty("Instance")?.GetValue(null); if (obj != null) { MethodInfo method = type.GetMethod("SendNotification", new Type[5] { typeof(string), typeof(int), typeof(int), typeof(bool), typeof(bool) }); if (method != null) { method.Invoke(obj, new object[5] { text, 0, 1, false, true }); return; } } } } } catch (Exception ex) { if (logger != null) { logger.LogWarning((object)("Failed to send native notification: " + ex.Message)); } } if (logger != null) { logger.LogWarning((object)("[UPDATE AVAILABLE] " + text)); } if (!string.IsNullOrEmpty(result.NexusUrl) && logger != null) { logger.LogWarning((object)("Download at: " + result.NexusUrl)); } } } public static class SceneRootSurvivor { private static readonly object Lock = new object(); private static readonly List NoKillSubstrings = new List(); private static Harmony _harmony; public static void TryRegisterPersistentRunnerGameObject(GameObject go) { if (!((Object)(object)go == (Object)null)) { TryAddNoKillListSubstring(((Object)go).name); } } public static void TryAddNoKillListSubstring(string nameSubstring) { if (string.IsNullOrEmpty(nameSubstring)) { return; } lock (Lock) { bool flag = false; for (int i = 0; i < NoKillSubstrings.Count; i++) { if (string.Equals(NoKillSubstrings[i], nameSubstring, StringComparison.OrdinalIgnoreCase)) { flag = true; break; } } if (!flag) { NoKillSubstrings.Add(nameSubstring); } } EnsurePatched(); } private static void EnsurePatched() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00a3: Expected O, but got Unknown if (_harmony != null) { return; } lock (Lock) { if (_harmony == null) { MethodInfo methodInfo = AccessTools.Method(typeof(Scene), "GetRootGameObjects", Type.EmptyTypes, (Type[])null); if (!(methodInfo == null)) { string text = typeof(SceneRootSurvivor).Assembly.GetName().Name ?? "Unknown"; Harmony val = new Harmony("SunhavenMods.SceneRootSurvivor." + text); val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(SceneRootSurvivor), "OnGetRootGameObjectsPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony = val; } } } } private static void OnGetRootGameObjectsPostfix(ref GameObject[] __result) { if (__result == null || __result.Length == 0) { return; } List list; lock (Lock) { if (NoKillSubstrings.Count == 0) { return; } list = new List(NoKillSubstrings); } List list2 = new List(__result); for (int i = 0; i < list.Count; i++) { string noKill = list[i]; list2.RemoveAll((GameObject a) => (Object)(object)a != (Object)null && ((Object)a).name.IndexOf(noKill, StringComparison.OrdinalIgnoreCase) >= 0); } __result = list2.ToArray(); } } public static class ReflectionHelper { public static readonly BindingFlags AllBindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; public static Type FindType(string typeName, params string[] namespaces) { string typeName2 = typeName; Type type = AccessTools.TypeByName(typeName2); if (type != null) { return type; } for (int i = 0; i < namespaces.Length; i++) { type = AccessTools.TypeByName(namespaces[i] + "." + typeName2); if (type != null) { return type; } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { type = assembly.GetTypes().FirstOrDefault((Type t) => t.Name == typeName2 || t.FullName == typeName2); if (type != null) { return type; } } catch (ReflectionTypeLoadException) { } } return null; } public static Type FindWishType(string typeName) { return FindType(typeName, "Wish"); } public static object GetStaticValue(Type type, string memberName) { if (type == null) { return null; } try { PropertyInfo property = type.GetProperty(memberName, AllBindingFlags); if (property != null && property.GetMethod != null && property.GetIndexParameters().Length == 0) { return property.GetValue(null); } } catch (AmbiguousMatchException) { return null; } FieldInfo field = type.GetField(memberName, AllBindingFlags); if (field != null) { return field.GetValue(null); } return null; } public static object GetSingletonInstance(Type type) { if (type == null) { return null; } string[] array = new string[5] { "Instance", "instance", "_instance", "Singleton", "singleton" }; foreach (string memberName in array) { object staticValue = GetStaticValue(type, memberName); if (staticValue != null) { return staticValue; } } return null; } public static object GetInstanceValue(object instance, string memberName) { if (instance == null) { return null; } Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(memberName, AllBindingFlags); if (property != null && property.GetMethod != null) { return property.GetValue(instance); } FieldInfo field = type.GetField(memberName, AllBindingFlags); if (field != null) { return field.GetValue(instance); } type = type.BaseType; } return null; } public static bool SetInstanceValue(object instance, string memberName, object value) { if (instance == null) { return false; } Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(memberName, AllBindingFlags); if (property != null && property.SetMethod != null) { property.SetValue(instance, value); return true; } FieldInfo field = type.GetField(memberName, AllBindingFlags); if (field != null) { field.SetValue(instance, value); return true; } type = type.BaseType; } return false; } public static object InvokeMethod(object instance, string methodName, params object[] args) { if (instance == null) { return null; } Type type = instance.GetType(); Type[] array = args?.Select((object a) => a?.GetType() ?? typeof(object)).ToArray() ?? Type.EmptyTypes; MethodInfo methodInfo = AccessTools.Method(type, methodName, array, (Type[])null); if (methodInfo == null) { methodInfo = type.GetMethod(methodName, AllBindingFlags); } if (methodInfo == null) { return null; } return methodInfo.Invoke(instance, args); } public static object InvokeStaticMethod(Type type, string methodName, params object[] args) { if (type == null) { return null; } Type[] array = args?.Select((object a) => a?.GetType() ?? typeof(object)).ToArray() ?? Type.EmptyTypes; MethodInfo methodInfo = AccessTools.Method(type, methodName, array, (Type[])null); if (methodInfo == null) { methodInfo = type.GetMethod(methodName, AllBindingFlags); } if (methodInfo == null) { return null; } return methodInfo.Invoke(null, args); } public static FieldInfo[] GetAllFields(Type type) { if (type == null) { return Array.Empty(); } FieldInfo[] fields = type.GetFields(AllBindingFlags); IEnumerable second; if (!(type.BaseType != null) || !(type.BaseType != typeof(object))) { second = Enumerable.Empty(); } else { IEnumerable allFields = GetAllFields(type.BaseType); second = allFields; } return fields.Concat(second).Distinct().ToArray(); } public static PropertyInfo[] GetAllProperties(Type type) { if (type == null) { return Array.Empty(); } PropertyInfo[] properties = type.GetProperties(AllBindingFlags); IEnumerable second; if (!(type.BaseType != null) || !(type.BaseType != typeof(object))) { second = Enumerable.Empty(); } else { IEnumerable allProperties = GetAllProperties(type.BaseType); second = allProperties; } return (from p in properties.Concat(second) group p by p.Name into g select g.First()).ToArray(); } public static T TryGetValue(object instance, string memberName, T defaultValue = default(T)) { try { object instanceValue = GetInstanceValue(instance, memberName); if (instanceValue is T result) { return result; } if (instanceValue != null && typeof(T).IsAssignableFrom(instanceValue.GetType())) { return (T)instanceValue; } return defaultValue; } catch { return defaultValue; } } } public static class ItemSearch { private static readonly ManualLogSource _log = Logger.CreateLogSource("ItemSearch"); private static object _dbInstance; private static FieldInfo _dictField; public static string FormatDisplay(string name, int itemId) { if (string.IsNullOrEmpty(name)) { return $"#{itemId}"; } return $"{name} (#{itemId})"; } public static List> SearchItems(string query, int maxResults = 50) { List> list = new List>(); if (string.IsNullOrEmpty(query) || query.Trim().Length < 2) { return list; } try { Dictionary itemDictionary = GetItemDictionary(); if (itemDictionary == null) { return list; } string text = query.Trim().ToLowerInvariant(); int result; bool flag = int.TryParse(query.Trim(), out result); List> list2 = new List>(); List> list3 = new List>(); List> list4 = new List>(); foreach (KeyValuePair item2 in itemDictionary) { int key = item2.Key; string text2 = item2.Value?.name; if (!string.IsNullOrEmpty(text2)) { KeyValuePair item = new KeyValuePair(key, text2); string text3 = text2.ToLowerInvariant(); if (flag && key == result) { list2.Add(item); } else if (text3 == text) { list2.Add(item); } else if (text3.StartsWith(text)) { list3.Add(item); } else if (text3.Contains(text)) { list4.Add(item); } else if (flag && key.ToString().Contains(query.Trim())) { list4.Add(item); } } } list3.Sort((KeyValuePair a, KeyValuePair b) => string.Compare(a.Value, b.Value, StringComparison.OrdinalIgnoreCase)); list4.Sort((KeyValuePair a, KeyValuePair b) => string.Compare(a.Value, b.Value, StringComparison.OrdinalIgnoreCase)); list.AddRange(list2); list.AddRange(list3); list.AddRange(list4); if (list.Count > maxResults) { list.RemoveRange(maxResults, list.Count - maxResults); } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)("[ItemSearch] SearchItems error: " + ex.Message)); } } return list; } public static string GetItemName(int itemId) { try { Dictionary itemDictionary = GetItemDictionary(); if (itemDictionary == null || !itemDictionary.ContainsKey(itemId)) { return null; } return itemDictionary[itemId]?.name; } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"[ItemSearch] GetItemName({itemId}): {ex.Message}"); } return null; } } public static ItemSellInfo GetItemSellInfo(int itemId) { try { Dictionary itemDictionary = GetItemDictionary(); if (itemDictionary != null && itemDictionary.TryGetValue(itemId, out var value)) { return value; } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"[ItemSearch] GetItemSellInfo({itemId}): {ex.Message}"); } } return null; } public static List> GetAllItems() { List> list = new List>(); try { Dictionary itemDictionary = GetItemDictionary(); if (itemDictionary == null) { return list; } foreach (KeyValuePair item in itemDictionary) { string value = item.Value?.name; if (!string.IsNullOrEmpty(value)) { list.Add(new KeyValuePair(item.Key, value)); } } list.Sort((KeyValuePair a, KeyValuePair b) => string.Compare(a.Value, b.Value, StringComparison.OrdinalIgnoreCase)); } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)("[ItemSearch] GetAllItems: " + ex.Message)); } } return list; } private static Dictionary GetItemDictionary() { try { if (_dbInstance != null) { object dbInstance = _dbInstance; Object val = (Object)((dbInstance is Object) ? dbInstance : null); if (val == null || !(val == (Object)null)) { goto IL_005b; } } _dbInstance = null; _dictField = null; _dbInstance = GetSingletonInstance("Wish.ItemInfoDatabase"); if (_dbInstance != null) { _dictField = _dbInstance.GetType().GetField("allItemSellInfos", BindingFlags.Instance | BindingFlags.Public); } goto IL_005b; IL_005b: if (_dbInstance == null || _dictField == null) { return null; } return _dictField.GetValue(_dbInstance) as Dictionary; } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)("[ItemSearch] GetItemDictionary: " + ex.Message)); } return null; } } private static object GetSingletonInstance(string typeName) { try { Type type = AccessTools.TypeByName("Wish.SingletonBehaviour`1"); if (type == null) { return null; } Type type2 = AccessTools.TypeByName(typeName); if (type2 == null) { return null; } return type.MakeGenericType(type2).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy)?.GetValue(null); } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)("[ItemSearch] GetSingletonInstance(" + typeName + "): " + ex.Message)); } return null; } } } public static class TextInputFocusGuard { private const float DefaultPollIntervalSeconds = 0.25f; private static float _nextPollTime = -1f; private static bool _cachedDefer; private static bool _tmpTypeLookupDone; private static Type _tmpInputFieldType; private static bool _qcLookupDone; private static Type _qcType; private static PropertyInfo _qcInstanceProp; private static PropertyInfo _qcIsActiveProp; private static FieldInfo _qcIsActiveField; public static bool ShouldDeferModHotkeys(ManualLogSource debugLog = null, float pollIntervalSeconds = 0.25f) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < _nextPollTime) { return _cachedDefer; } _nextPollTime = realtimeSinceStartup + Mathf.Max(0.05f, pollIntervalSeconds); bool flag = false; try { if (GUIUtility.keyboardControl != 0) { flag = true; } if (!flag) { EventSystem current = EventSystem.current; GameObject val = ((current != null) ? current.currentSelectedGameObject : null); if ((Object)(object)val != (Object)null) { if ((Object)(object)val.GetComponent() != (Object)null) { flag = true; } else if (TryGetTmpInputField(val)) { flag = true; } } } if (!flag && IsQuantumConsoleActive(debugLog)) { flag = true; } } catch (Exception ex) { if (debugLog != null) { debugLog.LogDebug((object)("[TextInputFocusGuard] " + ex.Message)); } } _cachedDefer = flag; return flag; } private static bool TryGetTmpInputField(GameObject go) { if (!_tmpTypeLookupDone) { _tmpTypeLookupDone = true; _tmpInputFieldType = AccessTools.TypeByName("TMPro.TMP_InputField"); } if (_tmpInputFieldType == null) { return false; } return (Object)(object)go.GetComponent(_tmpInputFieldType) != (Object)null; } private static bool IsQuantumConsoleActive(ManualLogSource debugLog) { try { if (!_qcLookupDone) { _qcLookupDone = true; _qcType = AccessTools.TypeByName("QFSW.QC.QuantumConsole"); if (_qcType != null) { _qcInstanceProp = AccessTools.Property(_qcType, "Instance"); _qcIsActiveProp = AccessTools.Property(_qcType, "IsActive"); _qcIsActiveField = AccessTools.Field(_qcType, "isActive") ?? AccessTools.Field(_qcType, "_isActive"); } } if (_qcType == null) { return false; } object obj = _qcInstanceProp?.GetValue(null); if (obj == null) { return false; } if (_qcIsActiveProp != null && _qcIsActiveProp.PropertyType == typeof(bool)) { return (bool)_qcIsActiveProp.GetValue(obj); } if (_qcIsActiveField != null && _qcIsActiveField.FieldType == typeof(bool)) { return (bool)_qcIsActiveField.GetValue(obj); } } catch (Exception ex) { if (debugLog != null) { debugLog.LogDebug((object)("[TextInputFocusGuard] Quantum Console focus check failed: " + ex.Message)); } } return false; } } internal static class MinimalJsonParser { internal static void WriteJsonString(StringBuilder sb, string value) { sb.Append('"'); if (value != null) { foreach (char c in value) { switch (c) { case '"': sb.Append("\\\""); break; case '\\': sb.Append("\\\\"); break; case '\n': sb.Append("\\n"); break; case '\r': sb.Append("\\r"); break; case '\t': sb.Append("\\t"); break; case '\b': sb.Append("\\b"); break; case '\f': sb.Append("\\f"); break; default: sb.Append(c); break; } } } sb.Append('"'); } internal static void SkipWhitespace(string json, ref int pos) { while (pos < json.Length && char.IsWhiteSpace(json[pos])) { pos++; } } internal static object ParseValue(string json, ref int pos) { SkipWhitespace(json, ref pos); if (pos >= json.Length) { return null; } char c = json[pos]; switch (c) { case '"': return ParseString(json, ref pos); case '{': return ParseObject(json, ref pos); case '[': return ParseArray(json, ref pos); case 't': return ParseLiteral(json, ref pos, "true", true); case 'f': return ParseLiteral(json, ref pos, "false", false); case 'n': return ParseLiteral(json, ref pos, "null", null); default: if (!char.IsDigit(c)) { return null; } goto case '-'; case '-': return ParseNumber(json, ref pos); } } internal static Dictionary ParseObject(string json, ref int pos) { SkipWhitespace(json, ref pos); if (pos >= json.Length || json[pos] != '{') { return null; } pos++; Dictionary dictionary = new Dictionary(); SkipWhitespace(json, ref pos); if (pos < json.Length && json[pos] == '}') { pos++; return dictionary; } while (pos < json.Length) { SkipWhitespace(json, ref pos); string text = ParseString(json, ref pos); if (text == null) { break; } SkipWhitespace(json, ref pos); if (pos >= json.Length || json[pos] != ':') { break; } pos++; SkipWhitespace(json, ref pos); dictionary[text] = ParseValue(json, ref pos); SkipWhitespace(json, ref pos); if (pos >= json.Length || json[pos] != ',') { break; } pos++; } SkipWhitespace(json, ref pos); if (pos < json.Length && json[pos] == '}') { pos++; } return dictionary; } internal static List ParseArray(string json, ref int pos) { SkipWhitespace(json, ref pos); if (pos >= json.Length || json[pos] != '[') { return null; } pos++; List list = new List(); SkipWhitespace(json, ref pos); if (pos < json.Length && json[pos] == ']') { pos++; return list; } while (pos < json.Length) { SkipWhitespace(json, ref pos); list.Add(ParseValue(json, ref pos)); SkipWhitespace(json, ref pos); if (pos >= json.Length || json[pos] != ',') { break; } pos++; } SkipWhitespace(json, ref pos); if (pos < json.Length && json[pos] == ']') { pos++; } return list; } internal static string ParseString(string json, ref int pos) { SkipWhitespace(json, ref pos); if (pos >= json.Length || json[pos] != '"') { return null; } pos++; StringBuilder stringBuilder = new StringBuilder(); while (pos < json.Length) { char c = json[pos]; if (c == '\\' && pos + 1 < json.Length) { pos++; switch (json[pos]) { case '"': stringBuilder.Append('"'); break; case '\\': stringBuilder.Append('\\'); break; case '/': stringBuilder.Append('/'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'u': { if (pos + 4 < json.Length && ushort.TryParse(json.Substring(pos + 1, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result)) { pos += 4; if (result >= 55296 && result <= 56319 && pos + 5 < json.Length && json[pos] == '\\' && json[pos + 1] == 'u' && ushort.TryParse(json.Substring(pos + 2, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result2) && result2 >= 56320 && result2 <= 57343) { stringBuilder.Append(char.ConvertFromUtf32(char.ConvertToUtf32((char)result, (char)result2))); pos += 6; } else { stringBuilder.Append((char)result); } } else { stringBuilder.Append('u'); } break; } default: stringBuilder.Append(json[pos]); break; } pos++; } else { if (c == '"') { pos++; return stringBuilder.ToString(); } stringBuilder.Append(c); pos++; } } return stringBuilder.ToString(); } internal static object ParseNumber(string json, ref int pos) { int num = pos; bool flag = false; if (pos < json.Length && json[pos] == '-') { pos++; } while (pos < json.Length && char.IsDigit(json[pos])) { pos++; } if (pos < json.Length && json[pos] == '.') { flag = true; pos++; while (pos < json.Length && char.IsDigit(json[pos])) { pos++; } } if (pos < json.Length && (json[pos] == 'e' || json[pos] == 'E')) { flag = true; pos++; if (pos < json.Length && (json[pos] == '+' || json[pos] == '-')) { pos++; } while (pos < json.Length && char.IsDigit(json[pos])) { pos++; } } string s = json.Substring(num, pos - num); if (flag && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } if (!flag && long.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2)) { return result2; } return 0L; } internal static object ParseLiteral(string json, ref int pos, string literal, object result) { if (pos + literal.Length <= json.Length && json.Substring(pos, literal.Length) == literal) { pos += literal.Length; return result; } pos++; return null; } internal static int ToInt(object val) { if (val is long num) { return (int)num; } if (val is double num2) { return (int)num2; } if (val is int) { return (int)val; } return 0; } } } namespace SenpaisChest { [BepInPlugin("com.azraelgodking.senpaischest", "Senpai's Chest", "2.7.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private static SmartChestManager _staticManager; private static SmartChestSaveSystem _staticSaveSystem; private static SmartChestUI _staticUI; private static SmartChestConfig _staticConfig; private static MuseumTodoIntegration _museumTodoIntegration; internal static Chest CurrentInteractingChest; private static string _gameplaySessionCharacter; private static bool _applicationQuitting; private static readonly Dictionary _sceneDiscardSuppressByHandle = new Dictionary(); private const float SceneDiscardSuppressSeconds = 20f; private Harmony _harmony; private SmartChestManager _manager; private SmartChestSaveSystem _saveSystem; private SmartChestUI _ui; private SmartChestConfig _config; private static GameObject _persistentRunner; private static SmartChestPersistentRunner _updateRunner; private bool _wasInMenuScene = true; private static GameObject _pendingChestPanel; private static Chest _pendingChest; private static int _pendingChestButtonFrames; private const string SenpaisChestConfigPanelName = "SenpaisChest_ConfigPanel"; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static ConfigFile ConfigFile { get; private set; } private void Awake() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ConfigFile = CreateNamedConfig(); ConfigFileHelper.ReplacePluginConfig((BaseUnityPlugin)(object)this, ConfigFile, (Action)Log.LogWarning); Log.LogInfo((object)"Loading Senpai's Chest v2.7.0"); CreatePersistentRunner(); try { _config = new SmartChestConfig(); _config.Initialize(ConfigFile); _staticConfig = _config; _config.UIScale.SettingChanged += delegate { float scale = Mathf.Clamp(_config.UIScale.Value, 0.5f, 2.5f); _staticUI?.SetScale(scale); }; _manager = new SmartChestManager(); _saveSystem = new SmartChestSaveSystem(_manager); _staticManager = _manager; _staticSaveSystem = _saveSystem; GameObject val = new GameObject("SenpaisChest_UI"); Object.DontDestroyOnLoad((Object)(object)val); _ui = val.AddComponent(); _ui.Initialize(_manager); _ui.SetScale(Mathf.Clamp(_config.UIScale.Value, 0.5f, 2.5f)); _staticUI = _ui; _harmony = new Harmony("com.azraelgodking.senpaischest"); ApplyPatches(); InitializeIntegrations(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.activeSceneChanged += OnActiveSceneChanged; if (_config.CheckForUpdates.Value) { VersionChecker.CheckForUpdate("com.azraelgodking.senpaischest", "2.7.0", Log, delegate(VersionChecker.VersionCheckResult result) { result.NotifyUpdateAvailable(Log); }); } Log.LogInfo((object)"Senpai's Chest loaded successfully!"); Log.LogInfo((object)string.Format("Press {0}{1} to configure a chest while interacting with it", _config.RequireCtrlModifier.Value ? "Ctrl+" : "", _config.ToggleKey.Value)); if (_config.EnableChestLabels.Value) { Log.LogInfo((object)"Chest Labels enabled - labels shown above Chest and BankChest (not Hoppers/Animal Feeders)"); } } catch (Exception arg) { Log.LogError((object)string.Format("Failed to load {0}: {1}", "Senpai's Chest", arg)); } } private void CreatePersistentRunner() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown if ((Object)(object)_persistentRunner != (Object)null) { Log.LogInfo((object)"PersistentRunner already exists"); return; } _persistentRunner = new GameObject("SenpaisChest_PersistentRunner"); Object.DontDestroyOnLoad((Object)(object)_persistentRunner); ((Object)_persistentRunner).hideFlags = (HideFlags)61; SceneRootSurvivor.TryRegisterPersistentRunnerGameObject(_persistentRunner); _updateRunner = _persistentRunner.AddComponent(); Log.LogInfo((object)"Created hidden PersistentRunner"); } private static ConfigFile CreateNamedConfig() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, "SenpaisChest.cfg"); string text2 = Path.Combine(Paths.ConfigPath, "com.azraelgodking.senpaischest.cfg"); try { if (!File.Exists(text) && File.Exists(text2)) { File.Copy(text2, text); } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[Config] Migration to SenpaisChest.cfg failed: " + ex.Message)); } } return new ConfigFile(text, true); } public static void EnsureUIComponentsExist() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown try { if ((Object)(object)_persistentRunner == (Object)null || (Object)(object)_updateRunner == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"[EnsureUI] Recreating PersistentRunner..."); } _persistentRunner = new GameObject("SenpaisChest_PersistentRunner"); Object.DontDestroyOnLoad((Object)(object)_persistentRunner); ((Object)_persistentRunner).hideFlags = (HideFlags)61; SceneRootSurvivor.TryRegisterPersistentRunnerGameObject(_persistentRunner); _updateRunner = _persistentRunner.AddComponent(); } if ((Object)(object)_staticUI == (Object)null) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)"[EnsureUI] Recreating SmartChestUI..."); } GameObject val = new GameObject("SenpaisChest_UI"); Object.DontDestroyOnLoad((Object)val); _staticUI = val.AddComponent(); _staticUI.Initialize(_staticManager); _staticUI.SetScale(Mathf.Clamp(_staticConfig.UIScale.Value, 0.5f, 2.5f)); } } catch (Exception ex) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogError((object)("[EnsureUI] Error recreating UI: " + ex.Message)); } } } private void InitializeIntegrations() { try { _museumTodoIntegration?.Dispose(); _museumTodoIntegration = null; Dictionary pluginInfos = Chainloader.PluginInfos; bool flag = pluginInfos.ContainsKey("com.azraelgodking.sunhavenmuseumutilitytracker"); bool flag2 = pluginInfos.ContainsKey("com.azraelgodking.sunhaventodo"); if (flag && flag2) { _museumTodoIntegration = new MuseumTodoIntegration(); return; } if (!flag) { Log.LogInfo((object)"[Integrations] S.M.U.T. not found"); } if (!flag2) { Log.LogInfo((object)"[Integrations] SunhavenTodo not found"); } Log.LogInfo((object)"[Integrations] Museum todo integration disabled (requires both S.M.U.T. and Todo)"); } catch (Exception ex) { Log.LogWarning((object)("[Integrations] Error initializing: " + ex.Message)); } } private void ApplyPatches() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Expected O, but got Unknown try { PatchMethod(typeof(Player), "InitializeAsOwner", typeof(Plugin), "OnPlayerInitialized"); PatchMethod(typeof(Chest), "Interact", typeof(Plugin), "OnChestInteract", new Type[1] { typeof(int) }); MethodInfo methodInfo = AccessTools.Method(typeof(Chest), "EndInteract", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo != null) { HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnChestEndInteract_Prefix", (Type[])null, (Type[])null)); _harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Chest.EndInteract (prefix)"); } else { Log.LogWarning((object)"Could not find method Chest.EndInteract"); } Type type = AccessTools.TypeByName("Wish.UIHandler"); Type type2 = AccessTools.TypeByName("Wish.IExternalUIHandler"); if (type != null && type2 != null) { MethodInfo methodInfo2 = AccessTools.Method(type, "OpenUI", new Type[5] { typeof(GameObject), typeof(Transform), typeof(bool), typeof(bool), type2 }, (Type[])null); if (methodInfo2 != null) { HarmonyMethod val2 = new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnUIHandlerOpenUI_Postfix", (Type[])null, (Type[])null)); _harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched UIHandler.OpenUI (postfix)"); } else { Log.LogWarning((object)"Could not find method UIHandler.OpenUI"); } } else { Log.LogWarning((object)"Could not find Wish.UIHandler or Wish.IExternalUIHandler for chest button integration"); } MethodInfo methodInfo3 = AccessTools.Method(typeof(Input), "GetKeyDown", new Type[1] { typeof(KeyCode) }, (Type[])null); if (methodInfo3 != null) { _harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnInputGetKeyDown_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Input.GetKeyDown (prefix)"); } MethodInfo methodInfo4 = AccessTools.Method(typeof(Input), "GetKey", new Type[1] { typeof(KeyCode) }, (Type[])null); if (methodInfo4 != null) { _harmony.Patch((MethodBase)methodInfo4, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnInputGetKey_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Input.GetKey (prefix)"); } MethodInfo methodInfo5 = AccessTools.Method(typeof(Input), "GetButtonDown", new Type[1] { typeof(string) }, (Type[])null); if (methodInfo5 != null) { _harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnInputGetButtonDown_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Input.GetButtonDown (prefix)"); } Type type3 = AccessTools.TypeByName("Wish.PlayerInput"); if (type3 != null) { MethodInfo methodInfo6 = AccessTools.Method(type3, "GetButtonDown", new Type[1] { typeof(string) }, (Type[])null); if (methodInfo6 != null) { _harmony.Patch((MethodBase)methodInfo6, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnPlayerInputGetButtonDown_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched PlayerInput.GetButtonDown(string) (prefix)"); } else { Log.LogWarning((object)"Could not find method PlayerInput.GetButtonDown(string)"); } } else { Log.LogWarning((object)"Could not find Wish.PlayerInput type for UICancel blocking"); } MethodInfo methodInfo7 = AccessTools.Method(typeof(Chest), "OnDisable", (Type[])null, (Type[])null); if (methodInfo7 != null) { _harmony.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(Plugin), "OnChestOnDisable_Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Chest.OnDisable (cleanup when chest removed from world)"); } ApplyChestLabelPatches(); Log.LogInfo((object)"Harmony patches applied successfully"); } catch (Exception arg) { Log.LogError((object)$"Failed to apply patches: {arg}"); } } private void ApplyChestLabelPatches() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown Type typeFromHandle = typeof(ChestLabelPatch); MethodInfo methodInfo = AccessTools.Method(typeFromHandle, "SetMeta_Postfix", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeFromHandle, "OnEnable_Postfix", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeFromHandle, "InteractionPoint_Postfix", (Type[])null, (Type[])null); string[] array = new string[3] { "SetMeta", "ReceiveNewMeta", "SaveMeta" }; foreach (string text in array) { MethodInfo methodInfo4 = AccessTools.Method(typeof(Chest), text, (Type[])null, (Type[])null); if (methodInfo4 != null) { _harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)("Patched Chest." + text + " (labels)")); } } MethodInfo methodInfo5 = AccessTools.Method(typeof(Chest), "OnEnable", (Type[])null, (Type[])null); if (methodInfo5 != null) { _harmony.Patch((MethodBase)methodInfo5, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Chest.OnEnable (labels)"); } MethodInfo methodInfo6 = AccessTools.Method(typeof(Chest), "get_InteractionPoint", (Type[])null, (Type[])null); if (methodInfo6 != null) { _harmony.Patch((MethodBase)methodInfo6, (HarmonyMethod)null, new HarmonyMethod(methodInfo3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched Chest.get_InteractionPoint (labels)"); } } private void PatchMethod(Type targetType, string methodName, Type patchType, string patchMethodName, Type[] parameters = null) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown MethodInfo methodInfo = ((parameters != null) ? AccessTools.Method(targetType, methodName, parameters, (Type[])null) : AccessTools.Method(targetType, methodName, (Type[])null, (Type[])null)); if (methodInfo == null) { Log.LogWarning((object)("Could not find method " + targetType.Name + "." + methodName)); return; } MethodInfo methodInfo2 = AccessTools.Method(patchType, patchMethodName, (Type[])null, (Type[])null); _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)("Patched " + targetType.Name + "." + methodName)); } private static void OnPlayerInitialized(Player __instance) { try { if ((Object)(object)__instance != (Object)(object)Player.Instance) { return; } EnsureUIComponentsExist(); string text = null; CharacterData currentCharacter = GameSave.CurrentCharacter; if (currentCharacter != null) { text = currentCharacter.characterName; } if (string.IsNullOrEmpty(text)) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)"Player initialized but no character name found"); } return; } ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("Player initialized: " + text)); } _staticManager?.SetCharacterName(text); _museumTodoIntegration?.Reset(); SmartChestSaveData data = _staticSaveSystem?.Load(text); _staticManager?.LoadData(data); _gameplaySessionCharacter = text; } catch (Exception arg) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogError((object)$"Error in OnPlayerInitialized: {arg}"); } } } private static void OnChestInteract(Chest __instance, int interactType) { if (interactType != 0) { return; } CurrentInteractingChest = __instance; try { FieldInfo field = ((object)__instance).GetType().GetField("ui", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field != null)) { return; } object? value = field.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null && (Object)(object)val != (Object)null) { _pendingChestPanel = val; _pendingChest = __instance; _pendingChestButtonFrames = 3; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"[SenpaisChest] Scheduled embedded panel from Chest.Interact (will add in 3 frames) - UI active: {val.activeInHierarchy}"); } } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogDebug((object)("[SenpaisChest] Could not schedule chest button: " + ex.Message)); } } } private static void OnChestOnDisable_Postfix(Chest __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) try { if (_applicationQuitting || !Application.isPlaying || (Object)(object)__instance == (Object)null) { return; } GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject == (Object)null) { return; } Scene scene = gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { return; } if (IsDiscardedSceneSuppressed(scene)) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)("[SenpaisChest] OnDisable: skip rule removal (scene '" + ((Scene)(ref scene)).name + "' discarded)")); } return; } string chestId = SmartChestManager.GetChestId(__instance); if (!string.IsNullOrEmpty(chestId) && _staticManager != null && _staticManager.RemoveSmartChest(chestId)) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("[SenpaisChest] Removed smart chest rules (chest left world): " + chestId)); } } } catch (Exception ex) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogError((object)("[SenpaisChest] OnChestOnDisable_Postfix: " + ex.Message)); } } } private static bool OnInputGetKeyDown_Prefix(KeyCode key, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)key != 8) { return true; } if (!SmartChestConfig.StaticBlockInputWhenTyping) { return true; } if (!SmartChestUI.ShouldBlockGameInput(_staticUI)) { return true; } __result = false; return false; } private static bool OnInputGetKey_Prefix(KeyCode key, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)key != 8) { return true; } if (!SmartChestConfig.StaticBlockInputWhenTyping) { return true; } if (!SmartChestUI.ShouldBlockGameInput(_staticUI)) { return true; } __result = false; return false; } private static bool OnInputGetButtonDown_Prefix(string buttonName, ref bool __result) { if (string.IsNullOrEmpty(buttonName)) { return true; } if (!buttonName.Equals("Cancel", StringComparison.OrdinalIgnoreCase)) { return true; } if (!SmartChestConfig.StaticBlockInputWhenTyping) { return true; } if (!SmartChestUI.ShouldBlockGameInput(_staticUI)) { return true; } __result = false; return false; } private static bool OnPlayerInputGetButtonDown_Prefix(string button, ref bool __result) { if (!SmartChestConfig.StaticBlockInputWhenTyping) { return true; } if (!SmartChestUI.ShouldBlockGameInput(_staticUI)) { return true; } if (button == "UICancel" || button == "Close") { __result = false; return false; } return true; } private static bool OnChestEndInteract_Prefix(Chest __instance, int interactType) { if ((Object)(object)CurrentInteractingChest == (Object)(object)__instance && (Object)(object)_staticUI != (Object)null && _staticUI.IsVisible && !_staticUI.IsEmbedded) { return false; } if ((Object)(object)CurrentInteractingChest == (Object)(object)__instance) { CurrentInteractingChest = null; _staticUI?.Hide(); } return true; } private static void OnUIHandlerOpenUI_Postfix(object __instance, GameObject ui, Transform parent, bool playAudio, bool animate, object externalUIHandler) { if ((Object)(object)ui == (Object)null || externalUIHandler == null) { return; } Chest val = (Chest)((externalUIHandler is Chest) ? externalUIHandler : null); if (val == null) { return; } try { _pendingChestPanel = ui; _pendingChest = val; _pendingChestButtonFrames = 3; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"[SenpaisChest] Scheduled embedded panel (will add in 3 frames) - UI active: {ui.activeInHierarchy}"); } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)("[SenpaisChest] Failed to schedule embedded panel: " + ex.Message)); } } } internal static void ProcessPendingChestButton() { //IL_014b: Unknown result type (might be due to invalid IL or missing references) if (_pendingChestButtonFrames <= 0 || (Object)(object)_pendingChestPanel == (Object)null || (Object)(object)_pendingChest == (Object)null) { return; } _pendingChestButtonFrames--; if (_pendingChestButtonFrames != 0) { return; } GameObject pendingChestPanel = _pendingChestPanel; Chest pendingChest = _pendingChest; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"[SenpaisChest] Processing pending panel: panel={(Object)(object)pendingChestPanel != (Object)null}, active={((pendingChestPanel != null) ? new bool?(pendingChestPanel.activeInHierarchy) : null)}, chest={(Object)(object)pendingChest != (Object)null}"); } if ((Object)(object)pendingChestPanel == (Object)null || !pendingChestPanel.activeInHierarchy) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)$"[SenpaisChest] Skip add panel: panel null or inactive (panel={(Object)(object)pendingChestPanel != (Object)null}, active={((pendingChestPanel != null) ? new bool?(pendingChestPanel.activeInHierarchy) : null)})"); } _pendingChestPanel = null; _pendingChest = null; return; } Canvas componentInParent = pendingChestPanel.GetComponentInParent(); ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)$"[SenpaisChest] Chest UI state - Canvas: {(Object)(object)componentInParent != (Object)null}, Canvas active: {((componentInParent != null) ? new bool?(((Component)componentInParent).gameObject.activeInHierarchy) : null)}, RenderMode: {((componentInParent != null) ? new RenderMode?(componentInParent.renderMode) : null)}"); } try { AddSenpaisChestNotePanel(pendingChestPanel, pendingChest); } catch (Exception ex) { ManualLogSource log4 = Log; if (log4 != null) { log4.LogWarning((object)("[SenpaisChest] Failed to add embedded panel: " + ex.Message + "\n" + ex.StackTrace)); } } finally { _pendingChestPanel = null; _pendingChest = null; } } private static void AddSenpaisChestNotePanel(GameObject chestUiRoot, Chest chest) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chestUiRoot == (Object)null || !chestUiRoot.activeInHierarchy) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)$"[SenpaisChest] Cannot add panel: chestUiRoot is null or inactive (null={(Object)(object)chestUiRoot == (Object)null}, active={((chestUiRoot != null) ? new bool?(chestUiRoot.activeInHierarchy) : null)})"); } return; } Transform val = chestUiRoot.transform.Find("SenpaisChest_ConfigPanel"); if ((Object)(object)val != (Object)null) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)$"[SenpaisChest] Panel already exists, reusing - active: {((Component)val).gameObject.activeInHierarchy}"); } SmartChestUI uI = GetUI(); if ((Object)(object)uI != (Object)null) { uI.ShowNoteForChest(chest, ((Component)val).gameObject); } return; } if ((Object)(object)chestUiRoot.GetComponentInParent() == (Object)null) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogWarning((object)"[SenpaisChest] Chest UI root is not under a Canvas, cannot create embedded panel"); } return; } Transform transform = chestUiRoot.transform; try { GameObject val2 = new GameObject("SenpaisChest_ConfigPanel"); val2.transform.SetParent(transform, false); val2.transform.SetAsLastSibling(); val2.SetActive(true); RectTransform val3 = val2.AddComponent(); val3.anchorMin = new Vector2(0.5f, 0f); val3.anchorMax = new Vector2(0.5f, 0f); val3.pivot = new Vector2(0.5f, 0f); val3.anchoredPosition = Vector2.zero; val3.sizeDelta = new Vector2(340f, 34f); ManualLogSource log4 = Log; if (log4 != null) { log4.LogInfo((object)$"[SenpaisChest] Panel RectTransform - anchorMin={val3.anchorMin}, anchorMax={val3.anchorMax}, sizeDelta={val3.sizeDelta}, rect={val3.rect}"); } CanvasGroup obj = val2.AddComponent(); obj.blocksRaycasts = false; obj.interactable = false; obj.alpha = 1f; LayoutRebuilder.ForceRebuildLayoutImmediate(val3); Rect rect = val3.rect; if (!(((Rect)(ref rect)).width <= 0f)) { rect = val3.rect; if (!(((Rect)(ref rect)).height <= 0f)) { SmartChestUI uI2 = GetUI(); if ((Object)(object)uI2 != (Object)null) { uI2.ShowNoteForChest(chest, val2); ManualLogSource log5 = Log; if (log5 != null) { log5.LogInfo((object)$"[SenpaisChest] Added note panel (Press F9 to configure) - chestUiRoot active: {chestUiRoot.activeInHierarchy}, panel active: {val2.activeInHierarchy}, rect: {val3.rect}"); } } else { ManualLogSource log6 = Log; if (log6 != null) { log6.LogWarning((object)"[SenpaisChest] UI component is null, cannot show embedded panel"); } } return; } } ManualLogSource log7 = Log; if (log7 != null) { rect = val3.rect; object arg = ((Rect)(ref rect)).width; rect = val3.rect; log7.LogWarning((object)$"[SenpaisChest] Panel rect is invalid (width={arg}, height={((Rect)(ref rect)).height}), waiting one more frame"); } _pendingChestPanel = chestUiRoot; _pendingChest = chest; _pendingChestButtonFrames = 1; } catch (Exception arg2) { ManualLogSource log8 = Log; if (log8 != null) { log8.LogError((object)$"[SenpaisChest] Exception creating embedded panel: {arg2}"); } } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { bool flag = ((Scene)(ref scene)).name == "MainMenu" || ((Scene)(ref scene)).name == "Menu"; if (flag && !_wasInMenuScene) { Log.LogInfo((object)"Returned to menu, saving data..."); _staticSaveSystem?.Save(); _gameplaySessionCharacter = null; } else if (!flag) { string currentCharacterName = GetCurrentCharacterName(); if (!string.IsNullOrEmpty(currentCharacterName)) { if (string.Equals(_gameplaySessionCharacter, currentCharacterName, StringComparison.Ordinal)) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)("[SenpaisChest] Skip disk reload on scene '" + ((Scene)(ref scene)).name + "' — '" + currentCharacterName + "' already active")); } } else { _staticManager?.SetCharacterName(currentCharacterName); SmartChestSaveData data = _staticSaveSystem?.Load(currentCharacterName); _staticManager?.LoadData(data); _gameplaySessionCharacter = currentCharacterName; ManualLogSource log2 = Log; if (log2 != null) { log2.LogDebug((object)("[SenpaisChest] Loaded smart chest data from disk for '" + currentCharacterName + "' on scene load")); } } } } _wasInMenuScene = flag; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.activeSceneChanged -= OnActiveSceneChanged; _museumTodoIntegration?.Dispose(); _museumTodoIntegration = null; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"Plugin OnDestroy called — static references preserved"); } _staticSaveSystem?.Save(); } private void OnApplicationQuit() { _applicationQuitting = true; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"Application quitting — saving data"); } _staticSaveSystem?.Save(); } private static bool IsDiscardedSceneSuppressed(Scene scene) { if (!((Scene)(ref scene)).IsValid()) { return false; } float realtimeSinceStartup = Time.realtimeSinceStartup; CleanupDiscardSuppressionMap(realtimeSinceStartup); if (_sceneDiscardSuppressByHandle.TryGetValue(((Scene)(ref scene)).handle, out var value)) { return realtimeSinceStartup < value; } return false; } private static void CleanupDiscardSuppressionMap(float now) { int[] array = null; int num = 0; foreach (KeyValuePair item in _sceneDiscardSuppressByHandle) { if (!(item.Value > now)) { if (array == null) { array = new int[_sceneDiscardSuppressByHandle.Count]; } array[num++] = item.Key; } } for (int i = 0; i < num; i++) { _sceneDiscardSuppressByHandle.Remove(array[i]); } } private static void OnActiveSceneChanged(Scene previous, Scene next) { if (((Scene)(ref previous)).IsValid()) { CleanupDiscardSuppressionMap(Time.realtimeSinceStartup); _sceneDiscardSuppressByHandle[((Scene)(ref previous)).handle] = Time.realtimeSinceStartup + 20f; } } internal static SmartChestManager GetManager() { return _staticManager; } internal static SmartChestSaveSystem GetSaveSystem() { return _staticSaveSystem; } internal static string GetCurrentCharacterName() { try { CharacterData currentCharacter = GameSave.CurrentCharacter; return (currentCharacter != null) ? currentCharacter.characterName : null; } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)("[SenpaisChest] GetCurrentCharacterName: " + ex.Message)); } return null; } } internal static SmartChestUI GetUI() { return _staticUI; } internal static SmartChestConfig GetConfig() { return _staticConfig; } internal static MuseumTodoIntegration GetMuseumTodoIntegration() { return _museumTodoIntegration; } } public class SmartChestPersistentRunner : MonoBehaviour { private float _scanTimer; private float _autoSaveTimer; private float _chestLabelScanTimer; private const float AUTO_SAVE_INTERVAL = 300f; private const float CHEST_LABEL_SCAN_INTERVAL = 2f; private int _lastCountdownSecond = -1; private void Update() { Plugin.ProcessPendingChestButton(); SmartChestConfig config = Plugin.GetConfig(); if (config != null && config.EnableChestLabels.Value) { _chestLabelScanTimer += Time.unscaledDeltaTime; if (_chestLabelScanTimer >= 2f) { _chestLabelScanTimer = 0f; Chest[] array = Object.FindObjectsOfType(); foreach (Chest val in array) { if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) { ChestLabelPatch.EnsureLabel(val); } } } } SmartChestManager manager = Plugin.GetManager(); if (config == null || manager == null) { return; } float unscaledDeltaTime = Time.unscaledDeltaTime; float scanInterval = config.GetScanInterval(); _scanTimer += unscaledDeltaTime; int num = (int)Math.Ceiling(scanInterval - _scanTimer); if (num >= 1 && num <= 10 && num != _lastCountdownSecond) { _lastCountdownSecond = num; if (SmartChestConfig.StaticEnableScanCountdownDebug) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)$"[Scan] Next scan in {num}..."); } } } if (_scanTimer >= scanInterval) { _scanTimer = 0f; _lastCountdownSecond = -1; try { manager.ExecuteScan(config.MaxItemsPerScan.Value, config.EnableNotifications.Value); Plugin.GetMuseumTodoIntegration()?.OnScanComplete(); } catch (Exception arg) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)$"Error during scan: {arg}"); } } } _autoSaveTimer += unscaledDeltaTime; if (_autoSaveTimer >= 300f) { _autoSaveTimer = 0f; if (manager.IsDirty) { Plugin.GetSaveSystem()?.Save(); } } DetectHotkey(config); } private void DetectHotkey(SmartChestConfig config) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (TextInputFocusGuard.ShouldDeferModHotkeys(Plugin.Log)) { return; } KeyCode staticToggleKey = SmartChestConfig.StaticToggleKey; bool staticRequireCtrl = SmartChestConfig.StaticRequireCtrl; if (Input.GetKeyDown(staticToggleKey) && (!staticRequireCtrl || Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305))) { SmartChestUI uI = Plugin.GetUI(); if (!((Object)(object)uI == (Object)null) && (Object)(object)Plugin.CurrentInteractingChest != (Object)null) { uI.ToggleForChest(Plugin.CurrentInteractingChest); } } } private void OnDestroy() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string text = (((Scene)(ref activeScene)).name ?? string.Empty).ToLowerInvariant(); if (!Application.isPlaying || text.Contains("menu") || text.Contains("title")) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[PersistentRunner] OnDestroy during app quit/menu unload (expected)."); } } else { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[PersistentRunner] OnDestroy outside quit/menu (unexpected)."); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "com.azraelgodking.senpaischest"; public const string PLUGIN_NAME = "Senpai's Chest"; public const string PLUGIN_VERSION = "2.7.0"; } } namespace SenpaisChest.UI { [DefaultExecutionOrder(-30000)] public class SmartChestUI : MonoBehaviour { private const string PAUSE_ID = "SenpaisChest_Config"; private SmartChestManager _manager; private bool _isVisible; private Chest _currentChest; private SmartChestData _currentData; private string _chestId; private bool _confirmCopyRules; private float _confirmCopyRulesUntil; private float _scale = 1f; private const float BASE_WINDOW_WIDTH = 420f; private const float BASE_WINDOW_HEIGHT = 500f; private const float BASE_GROUPS_WIDTH = 400f; private const float BASE_GROUPS_HEIGHT = 450f; private Rect _windowRect = new Rect(100f, 100f, 420f, 500f); private GameObject _notePanelRoot; private Rect _noteRect; private bool _noteRectDirty = true; private float _contentHeight = 500f; private int _selectedRuleType; private string _itemIdInput = ""; private int _selectedCategory; private int _selectedItemType; private int _selectedProperty; private int _selectedGroup; private string _lastSearchQuery = ""; private List> _searchResults = new List>(); private Vector2 _searchScrollPos; private int _selectedItemId = -1; private string _selectedItemName = ""; private bool _groupsWindowVisible; private Rect _groupsWindowRect; private ItemGroup _editingGroup; private string _newGroupName = ""; private string _groupItemSearch = ""; private string _groupItemSearchLast = ""; private string _groupPatternInput = ""; private List> _groupSearchResults = new List>(); private Vector2 _groupSearchScroll; private Vector2 _groupListScroll; private Vector2 _groupItemsScroll; private static readonly string[] RuleTypeNames = new string[6] { "By Item", "By Category", "By Item Type", "By Property", "By Group", "By wildcard name" }; private string _wildcardPatternInput = ""; private static readonly string[] BaseCategoryNames = new string[6] { "Equip", "Use", "Craftable", "Monster", "Furniture", "Quest" }; private static readonly string[] CategoryNamesWithMuseum = new string[7] { "Equip", "Use", "Craftable", "Monster", "Furniture", "Quest", "Undonated Items" }; private static readonly string[] ItemTypeNames = new string[9] { "Normal", "Armor", "Food", "Fish", "Crop", "WateringCan", "Animal", "Pet", "Tool" }; private static readonly string[] PropertyNames = new string[8] { "isGem", "isForageable", "isAnimalProduct", "isMeal", "isFruit", "isArtisanryItem", "isPotion", "isNotDonated" }; private static readonly string[] PropertyDisplayNames = new string[8] { "Gems", "Forageables", "Animal Products", "Meals", "Fruits", "Artisanry Items", "Potions", "Museum (Not Donated)" }; internal const string SearchFieldControlName = "SmartChestItemSearch"; internal const string GroupSearchFieldControlName = "SmartChestGroupItemSearch"; internal const string WildcardPatternControlName = "SmartChestWildcardPattern"; private readonly Color _bgDark = new Color(0.15f, 0.16f, 0.24f, 1f); private readonly Color _borderGold = new Color(0.75f, 0.65f, 0.3f, 1f); private readonly Color _goldText = new Color(0.95f, 0.85f, 0.35f, 1f); private readonly Color _whiteText = new Color(0.95f, 0.95f, 0.95f, 1f); private readonly Color _dimText = new Color(0.6f, 0.6f, 0.7f, 1f); private readonly Color _greenActive = new Color(0.2f, 0.55f, 0.45f, 1f); private readonly Color _greenHover = new Color(0.25f, 0.65f, 0.52f, 1f); private readonly Color _greenBright = new Color(0.3f, 0.7f, 0.55f, 1f); private readonly Color _redDanger = new Color(0.75f, 0.2f, 0.2f, 1f); private readonly Color _redHover = new Color(0.85f, 0.28f, 0.28f, 1f); private readonly Color _btnInactive = new Color(0.22f, 0.24f, 0.34f, 1f); private readonly Color _btnHover = new Color(0.3f, 0.32f, 0.44f, 1f); private readonly Color _ruleBoxColor = new Color(0.18f, 0.19f, 0.28f, 1f); private readonly Color _fieldBg = new Color(0.12f, 0.13f, 0.22f, 1f); private readonly Color _museumHighlight = new Color(0.35f, 0.65f, 0.85f, 1f); private readonly Color _parchmentLight = new Color(0.96f, 0.93f, 0.86f, 0.98f); private readonly Color _parchment = new Color(0.92f, 0.87f, 0.78f, 0.97f); private readonly Color _parchmentDark = new Color(0.85f, 0.78f, 0.65f, 0.95f); private readonly Color _woodDark = new Color(0.35f, 0.25f, 0.15f); private readonly Color _woodMedium = new Color(0.5f, 0.38f, 0.25f); private readonly Color _woodLight = new Color(0.65f, 0.52f, 0.38f); private readonly Color _goldPale = new Color(0.92f, 0.82f, 0.55f); private readonly Color _goldRich = new Color(0.72f, 0.55f, 0.2f); private readonly Color _borderWood = new Color(0.45f, 0.35f, 0.22f, 0.9f); private readonly Color _chestTextDark = new Color(0.08f, 0.06f, 0.05f, 1f); private readonly Color _chestTextDim = new Color(0.14f, 0.11f, 0.09f, 1f); private readonly Color _crimsonTitle = new Color(0.52f, 0.18f, 0.12f, 1f); private readonly Color _crimsonTitleLight = new Color(0.58f, 0.22f, 0.16f, 1f); private readonly Color _innerBorderCrimson = new Color(0.42f, 0.18f, 0.14f, 1f); private Texture2D _solidBg; private Texture2D _windowBg; private Texture2D _ruleBg; private Texture2D _btnInactiveTex; private Texture2D _btnHoverTex; private Texture2D _btnActiveTex; private Texture2D _btnActiveHoverTex; private Texture2D _redBtnTex; private Texture2D _redBtnHoverTex; private Texture2D _greenBtnTex; private Texture2D _greenBtnHoverTex; private Texture2D _closeBtnTex; private Texture2D _closeBtnHoverTex; private Texture2D _fieldBgTex; private Texture2D _chestParchmentBg; private Texture2D _chestWoodBorderTex; private Texture2D _chestRuleBoxTex; private Texture2D _chestSelectorTex; private Texture2D _chestSelectorHoverTex; private Texture2D _chestSelectorActiveTex; private Texture2D _chestAddBtnTex; private Texture2D _chestAddBtnHoverTex; private Texture2D _chestWoodBtnTex; private Texture2D _chestWoodBtnHoverTex; private Texture2D _chestDangerBtnTex; private Texture2D _chestDangerBtnHoverTex; private Texture2D _chestFieldBgTex; private Texture2D _chestGoldLineTex; private Texture2D _noteBannerBg; private Texture2D _noteBannerBorderTex; private Texture2D _configTitleBarTex; private Texture2D _configContentBg; private Texture2D _configGoldSeparatorTex; private Texture2D _configSectionHeaderTex; private Texture2D _configSearchFieldTex; private Texture2D _configRemoveBtnTex; private Texture2D _configRemoveBtnHoverTex; private Texture2D _configCloseBtnTex; private Texture2D _configCloseBtnHoverTex; private Texture2D _configWindowBg; private Texture2D _configInnerBorderTex; private GUIStyle _windowStyle; private GUIStyle _titleStyle; private GUIStyle _chestTitleStyle; private GUIStyle _chestLabelStyle; private GUIStyle _chestLabelBoldStyle; private GUIStyle _chestLabelDimStyle; private GUIStyle _chestSectionHeaderStyle; private GUIStyle _chestToggleStyle; private GUIStyle _sectionHeaderStyle; private GUIStyle _labelStyle; private GUIStyle _labelBoldStyle; private GUIStyle _labelDimStyle; private GUIStyle _ruleBoxStyle; private GUIStyle _ruleTextStyle; private GUIStyle _removeRuleBtnStyle; private GUIStyle _closeButtonStyle; private GUIStyle _toggleStyle; private GUIStyle _textFieldStyle; private GUIStyle _selectorStyle; private GUIStyle _selectorActiveStyle; private GUIStyle _addButtonStyle; private GUIStyle _dangerButtonStyle; private GUIStyle _closeBottomButtonStyle; private GUIStyle _searchResultStyle; private GUIStyle _searchResultSelectedStyle; private GUIStyle _chestRuleBoxStyle; private GUIStyle _chestRuleTextStyle; private GUIStyle _chestSelectorStyle; private GUIStyle _chestSelectorActiveStyle; private GUIStyle _chestAddButtonStyle; private GUIStyle _chestDangerButtonStyle; private GUIStyle _chestCloseButtonStyle; private GUIStyle _chestSearchFieldStyle; private GUIStyle _chestRemoveRuleBtnStyle; private GUIStyle _chestSearchResultStyle; private GUIStyle _chestSearchResultSelectedStyle; private GUIStyle _noteBannerStyle; private GUIStyle _configTitleStyle; private GUIStyle _configSectionHeaderBoxStyle; private GUIStyle _configSearchFieldStyle; private GUIStyle _configRemoveButtonStyle; private GUIStyle _configCloseBottomStyle; private GUIStyle _configWindowStyle; private bool _stylesDirty = true; private float WindowWidth => 420f * _scale; private float WindowHeight => 500f * _scale; private float GroupsWindowWidth => 400f * _scale; private float GroupsWindowHeight => 450f * _scale; public bool IsVisible => _isVisible; public bool IsEmbedded => false; private float Scaled(float value) { return value * _scale; } private int ScaledFont(int baseSize) { return Mathf.Max(8, Mathf.RoundToInt((float)baseSize * _scale)); } private int ScaledInt(float value) { return Mathf.RoundToInt(value * _scale); } internal static bool ShouldBlockGameInput(SmartChestUI ui) { if ((Object)(object)ui == (Object)null || !ui.IsVisible) { return false; } string nameOfFocusedControl = GUI.GetNameOfFocusedControl(); if (!(nameOfFocusedControl == "SmartChestItemSearch") && !(nameOfFocusedControl == "SmartChestGroupItemSearch")) { return nameOfFocusedControl == "SmartChestWildcardPattern"; } return true; } public void Initialize(SmartChestManager manager) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) _manager = manager; _windowRect = new Rect(100f, 100f, WindowWidth, WindowHeight); _groupsWindowRect = new Rect(150f, 150f, GroupsWindowWidth, GroupsWindowHeight); } public void SetScale(float scale) { _scale = Mathf.Clamp(scale, 0.5f, 2.5f); _stylesDirty = true; _configWindowStyle = null; ((Rect)(ref _windowRect)).width = WindowWidth; ((Rect)(ref _windowRect)).height = WindowHeight; ((Rect)(ref _groupsWindowRect)).width = GroupsWindowWidth; ((Rect)(ref _groupsWindowRect)).height = GroupsWindowHeight; } public void Show() { _isVisible = true; } public void Hide() { _isVisible = false; _confirmCopyRules = false; BlockGameInput(block: false); Chest currentChest = _currentChest; _currentChest = null; _currentData = null; _notePanelRoot = null; _noteRectDirty = true; Plugin.CurrentInteractingChest = null; SaveIfDirty(); if (!((Object)(object)currentChest != (Object)null)) { return; } try { currentChest.EndInteract(0); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("[SmartChestUI] EndInteract on close: " + ex.Message)); } } } public void HideConfig() { SaveIfDirty(); _isVisible = false; _confirmCopyRules = false; _groupsWindowVisible = false; BlockGameInput(block: false); } private void BlockGameInput(bool block) { try { if ((Object)(object)Player.Instance != (Object)null) { if (block) { Player.Instance.AddPauseObject("SenpaisChest_Config"); } else { Player.Instance.RemovePauseObject("SenpaisChest_Config"); } } Type type = Type.GetType("PlayerInput, Assembly-CSharp"); if (type != null) { type.GetMethod(block ? "DisableInput" : "EnableInput", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null)?.Invoke(null, new object[1] { "SenpaisChest_Config" }); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("[SmartChestUI] BlockGameInput failed: " + ex.Message)); } } } public void Toggle() { if (_isVisible) { Hide(); } else { Show(); } } public void ToggleForChest(Chest chest) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (_isVisible && (Object)(object)_currentChest == (Object)(object)chest) { HideConfig(); return; } _currentChest = chest; _chestId = SmartChestManager.GetChestId(chest); if (string.IsNullOrEmpty(_chestId)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"Cannot configure chest: no valid ID"); } return; } string chestName = GetChestName(chest); _currentData = _manager.GetOrCreateSmartChest(_chestId, chestName); _selectedRuleType = 0; _itemIdInput = ""; _lastSearchQuery = ""; _searchResults.Clear(); _selectedItemId = -1; _selectedItemName = ""; _searchScrollPos = Vector2.zero; _selectedCategory = 0; _selectedItemType = 0; _selectedProperty = 0; _wildcardPatternInput = ""; _confirmCopyRules = false; _isVisible = true; BlockGameInput(block: true); PositionWindowNextToChestPanel(); } public void ShowNoteForChest(Chest chest, GameObject panelRoot) { _currentChest = chest; _chestId = SmartChestManager.GetChestId(chest); if (string.IsNullOrEmpty(_chestId)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[SmartChestUI] Cannot show note: no valid chest ID"); } return; } _currentData = null; _notePanelRoot = panelRoot; _noteRectDirty = true; _isVisible = false; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogDebug((object)$"[SmartChestUI] ShowNoteForChest: chest={(Object)(object)chest != (Object)null}, panelRoot={(Object)(object)panelRoot != (Object)null}"); } } private void PositionWindowNextToChestPanel() { if (!((Object)(object)_currentChest == (Object)null)) { float num = Scaled(8f); float height = Mathf.Min(Scaled(400f), (float)Screen.height - num); ((Rect)(ref _windowRect)).width = WindowWidth; ((Rect)(ref _windowRect)).height = height; ((Rect)(ref _windowRect)).x = Mathf.Clamp(((float)Screen.width - ((Rect)(ref _windowRect)).width) * 0.5f, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); ((Rect)(ref _windowRect)).y = num; } } private string GetChestName(Chest chest) { return SmartChestManager.GetChestName(chest); } private void OnGUI() { //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (_stylesDirty || _configWindowStyle == null) { InitializeStyles(); } if (_configWindowStyle == null) { return; } if ((Object)(object)_notePanelRoot != (Object)null && !_isVisible) { if (!_notePanelRoot.activeInHierarchy) { _notePanelRoot = null; return; } if (_noteRectDirty || (int)Event.current.type == 8) { _noteRect = GetScreenRectFromTransform(_notePanelRoot.transform); _noteRectDirty = false; } Rect val = _noteRect; if (((Rect)(ref val)).width <= 0f || ((Rect)(ref val)).height <= 0f) { ((Rect)(ref val))..ctor(((float)Screen.width - Scaled(340f)) * 0.5f, Scaled(8f), Scaled(340f), Scaled(34f)); } val = ClampRectToScreen(val); GUI.BeginGroup(val); DrawNoteContent(((Rect)(ref val)).width, ((Rect)(ref val)).height); GUI.EndGroup(); } else if (_isVisible && _currentData != null) { float num = (float)Screen.height - Scaled(40f); ((Rect)(ref _windowRect)).width = WindowWidth; ((Rect)(ref _windowRect)).height = Mathf.Clamp(_contentHeight, Scaled(300f), num); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height); _windowRect = GUI.Window("com.azraelgodking.senpaischest".GetHashCode(), _windowRect, new WindowFunction(DrawWindow), "", _configWindowStyle); if (_groupsWindowVisible) { _groupsWindowRect = GUI.Window("com.azraelgodking.senpaischest".GetHashCode() + 1, _groupsWindowRect, new WindowFunction(DrawGroupsWindow), "Manage Groups", _configWindowStyle); } } } private static Rect GetScreenRectFromTransform(Transform transform) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val == (Object)null) { return new Rect(0f, 0f, 400f, 400f); } Canvas componentInParent = ((Component)val).GetComponentInParent(); Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); Vector2 val2 = default(Vector2); Vector2 val3 = default(Vector2); if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode == 0) { ((Vector2)(ref val2))..ctor(array[0].x, array[0].y); ((Vector2)(ref val3))..ctor(array[2].x, array[2].y); } else { Camera obj = (((Object)(object)componentInParent != (Object)null) ? componentInParent.worldCamera : Camera.main); val2 = RectTransformUtility.WorldToScreenPoint(obj, array[0]); val3 = RectTransformUtility.WorldToScreenPoint(obj, array[2]); } float x = val2.x; float num = (float)Screen.height - val3.y; float num2 = val3.x - val2.x; float num3 = val3.y - val2.y; return new Rect(x, num, num2, num3); } private static Rect ClampRectToScreen(Rect rect) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min(((Rect)(ref rect)).width, (float)Screen.width); float num2 = Mathf.Min(((Rect)(ref rect)).height, (float)Screen.height); float num3 = Mathf.Clamp(((Rect)(ref rect)).x, 0f, (float)Screen.width - num); float num4 = Mathf.Clamp(((Rect)(ref rect)).y, 0f, (float)Screen.height - num2); return new Rect(num3, num4, num, num2); } private void DrawWindow(int windowId) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) DrawConfigContent(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height), withWindowChrome: true); } private void DrawConfigContent(Rect rect, bool withWindowChrome) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_08e0: Unknown result type (might be due to invalid IL or missing references) //IL_0934: Unknown result type (might be due to invalid IL or missing references) //IL_0b47: Unknown result type (might be due to invalid IL or missing references) //IL_0c65: Unknown result type (might be due to invalid IL or missing references) //IL_0c6b: Invalid comparison between Unknown and I4 //IL_0c12: Unknown result type (might be due to invalid IL or missing references) //IL_0c18: Invalid comparison between Unknown and I4 //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c78: Invalid comparison between Unknown and I4 //IL_0c56: Unknown result type (might be due to invalid IL or missing references) //IL_0c1a: Unknown result type (might be due to invalid IL or missing references) //IL_0c1f: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { Event.current.Use(); HideConfig(); return; } bool flag = !withWindowChrome; bool flag2 = withWindowChrome; if (withWindowChrome) { float num = Scaled(36f); float num2 = Scaled(5f); float num3 = Scaled(1f); if ((Object)(object)_configInnerBorderTex != (Object)null) { float num4 = num2; float num5 = ((Rect)(ref rect)).width - num2 * 2f; float num6 = ((Rect)(ref rect)).height - num2 * 2f; GUI.DrawTexture(new Rect(num2, num4, num5, num3), (Texture)(object)_configInnerBorderTex); GUI.DrawTexture(new Rect(num2, num4 + num6 - num3, num5, num3), (Texture)(object)_configInnerBorderTex); GUI.DrawTexture(new Rect(num2, num4, num3, num6), (Texture)(object)_configInnerBorderTex); GUI.DrawTexture(new Rect(num2 + num5 - num3, num4, num3, num6), (Texture)(object)_configInnerBorderTex); } if ((Object)(object)_configTitleBarTex != (Object)null) { GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref rect)).width, num), (Texture)(object)_configTitleBarTex); } GUILayout.BeginArea(new Rect(0f, 0f, ((Rect)(ref rect)).width, num)); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label("Senpai's Chest Config", _configTitleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.FlexibleSpace(); if (GUILayout.Button("X", _closeButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(Scaled(28f)), GUILayout.Height(Scaled(24f)) })) { HideConfig(); } GUILayout.Space(Scaled(4f)); GUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.Space(num + Scaled(2f)); if ((Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - Scaled(24f), Scaled(2f)), (Texture)(object)_configGoldSeparatorTex); } GUILayout.Space(Scaled(8f)); } if (withWindowChrome) { GUILayout.Space(4f); } float num7 = (flag ? ((((Rect)(ref rect)).width - 8f) / 2f) : 0f); if (flag) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(((Rect)(ref rect)).width) }); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num7) }); } GUILayout.BeginHorizontal(Array.Empty()); bool flag3 = GUILayout.Toggle(_currentData.IsEnabled, " Smart Chest Enabled", flag2 ? _chestToggleStyle : _toggleStyle, Array.Empty()); if (flag3 != _currentData.IsEnabled) { _currentData.IsEnabled = flag3; _manager.MarkDirty(); SaveIfDirty(); } GUILayout.EndHorizontal(); if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(6f); } else { GUILayout.Space((float)(flag ? 4 : 8)); } GUIStyle val = (flag2 ? _configSectionHeaderBoxStyle : (flag ? _chestSectionHeaderStyle : _sectionHeaderStyle)); GUILayout.Label("Item Rules", val, Array.Empty()); GUILayout.Space((float)(flag ? 2 : 4)); if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(4f); } if (_currentData.Rules.Count == 0) { GUILayout.Label(" No rules configured. Add rules below.", flag2 ? _chestLabelDimStyle : (flag ? _chestLabelDimStyle : _labelDimStyle), Array.Empty()); } else { float num8 = (flag ? 24f : 36f); float num9 = (flag ? 100f : 180f); float num10 = Mathf.Min((float)_currentData.Rules.Count * num8, num9); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num10) }); int num11 = -1; for (int i = 0; i < _currentData.Rules.Count; i++) { GUIStyle obj = (flag2 ? _chestRuleBoxStyle : (flag ? _chestRuleBoxStyle : _ruleBoxStyle)); GUIStyle val2 = (flag2 ? _chestRuleTextStyle : (flag ? _chestRuleTextStyle : _ruleTextStyle)); GUIStyle val3 = (flag2 ? _chestRemoveRuleBtnStyle : (flag ? _chestRemoveRuleBtnStyle : _removeRuleBtnStyle)); GUILayout.BeginHorizontal(obj, Array.Empty()); GUILayout.Label($"{i + 1}. {GetRuleDisplayText(_currentData.Rules[i])}", val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("X", val3, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(26f), GUILayout.Height(22f) })) { num11 = i; } GUILayout.EndHorizontal(); GUILayout.Space((float)(flag ? 1 : 2)); } GUILayout.EndVertical(); if (num11 >= 0) { _currentData.Rules.RemoveAt(num11); _manager.MarkDirty(); SaveIfDirty(); } } if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(8f); } else { GUILayout.Space((float)(flag ? 4 : 10)); } GUILayout.Label("Add New Rule", val, Array.Empty()); GUILayout.Space((float)(flag ? 2 : 6)); if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(4f); } GUILayout.Label("Presets", flag2 ? _chestLabelBoldStyle : _labelBoldStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Equipment", flag2 ? _chestSelectorStyle : _selectorStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)((flag2 || flag) ? 24 : 28)) })) { ApplyPreset("Equipment"); } if (GUILayout.Button("Consumables", flag2 ? _chestSelectorStyle : _selectorStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)((flag2 || flag) ? 24 : 28)) })) { ApplyPreset("Consumables"); } if (GUILayout.Button("Crafting", flag2 ? _chestSelectorStyle : _selectorStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)((flag2 || flag) ? 24 : 28)) })) { ApplyPreset("Crafting"); } GUILayout.EndHorizontal(); GUILayout.Space((float)(flag ? 4 : 6)); GUILayout.BeginHorizontal(Array.Empty()); DrawSelectorButton(0, flag2 || flag, GUILayout.Height((float)((flag2 || flag) ? 24 : 28))); DrawSelectorButton(1, flag2 || flag, GUILayout.Height((float)((flag2 || flag) ? 24 : 28))); DrawSelectorButton(2, flag2 || flag, GUILayout.Height((float)((flag2 || flag) ? 24 : 28))); GUILayout.EndHorizontal(); GUILayout.Space((float)(flag ? 1 : 2)); GUILayout.BeginHorizontal(Array.Empty()); DrawSelectorButton(3, flag2 || flag, GUILayout.Height((float)((flag2 || flag) ? 24 : 28))); DrawSelectorButton(4, flag2 || flag, GUILayout.Height((float)((flag2 || flag) ? 24 : 28))); if (IsSeparateWildcardRuleEnabled()) { DrawSelectorButton(5, flag2 || flag, GUILayout.Height((float)((flag2 || flag) ? 24 : 28))); } GUILayout.EndHorizontal(); GUILayout.Space((float)(flag ? 1 : 2)); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Manage Groups", flag2 ? _configCloseBottomStyle : _closeBottomButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height((float)((flag2 || flag) ? 22 : 26)) })) { _groupsWindowVisible = true; } GUILayout.EndHorizontal(); GUILayout.Space((float)(flag ? 4 : 8)); if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(4f); } DrawRuleInput(flag2 || flag, flag2); GUILayout.Space((float)(flag ? 4 : 8)); if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(6f); } GUIStyle val4 = (flag2 ? _chestAddButtonStyle : (flag ? _chestAddButtonStyle : _addButtonStyle)); if (GUILayout.Button("Add Rule", val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)((flag2 || flag) ? 24 : 30)) })) { AddRule(); } if (_currentData.Rules.Count > 0) { int num12 = _manager.CountSameNameChests(_chestId); if (num12 > 0) { GUILayout.Space((float)(flag ? 2 : 4)); GUIStyle val5 = (flag2 ? _chestSelectorStyle : (flag ? _chestSelectorStyle : _selectorStyle)); bool flag4 = _confirmCopyRules && Time.unscaledTime <= _confirmCopyRulesUntil; if (!flag4) { _confirmCopyRules = false; } if (GUILayout.Button(flag4 ? $"Click Again to Confirm ({num12})" : $"Copy Rules to All \"{_currentData.ChestName}\" ({num12})", val5, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)((flag2 || flag) ? 24 : 28)) })) { if (flag4) { int num13 = _manager.CopyRulesToSameNameChests(_chestId); _confirmCopyRules = false; SaveIfDirty(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[SmartChestUI] Copied rules to {num13} same-name chest(s)"); } } else { _confirmCopyRules = true; _confirmCopyRulesUntil = Time.unscaledTime + 3f; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)"[SmartChestUI] Copy-rules confirmation armed for 3 seconds"); } } } } } if (flag) { GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num7) }); DrawEmbeddedRightColumn(flag); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } else { if (flag2 && (Object)(object)_configGoldSeparatorTex != (Object)null) { GUI.DrawTexture(GUILayoutUtility.GetRect(((Rect)(ref rect)).width - 24f, 2f), (Texture)(object)_configGoldSeparatorTex); GUILayout.Space(8f); } else { GUILayout.Space(12f); } GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Remove Smart Chest", flag2 ? _configRemoveButtonStyle : _dangerButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { _manager.RemoveSmartChest(_chestId); SaveIfDirty(); HideConfig(); } GUILayout.Space(8f); if (GUILayout.Button("Close", flag2 ? _configCloseBottomStyle : _closeBottomButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { HideConfig(); } GUILayout.EndHorizontal(); } if (withWindowChrome) { if ((int)Event.current.type == 7) { Rect lastRect = GUILayoutUtility.GetLastRect(); _contentHeight = ((Rect)(ref lastRect)).yMax + Scaled(24f); } GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref rect)).width, Scaled(28f))); } if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 8) { Event.current.Use(); } } private void DrawEmbeddedRightColumn(bool compact) { GUILayout.Space(4f); GUILayout.Label("Summary", _chestSectionHeaderStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); int valueOrDefault = (_currentData?.Rules?.Count).GetValueOrDefault(); SmartChestData currentData = _currentData; string arg = ((currentData != null && currentData.IsEnabled) ? "Active" : "Disabled"); GUILayout.BeginVertical(_chestRuleBoxStyle, Array.Empty()); GUILayout.Label($"Rules: {valueOrDefault} | Status: {arg}", _chestLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (valueOrDefault > 0) { GUILayout.Label("Accepts:", _chestLabelBoldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); for (int i = 0; i < valueOrDefault; i++) { GUILayout.Label(" • " + GetRuleDisplayText(_currentData.Rules[i]), _chestLabelDimStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } } GUILayout.EndVertical(); GUILayout.Space(4f); GUILayout.Label("Tips", _chestSectionHeaderStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.BeginVertical(_chestRuleBoxStyle, Array.Empty()); GUILayout.Label("• Rules filter auto-sort. Multiple = AND.", _chestRuleTextStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("• Transfer SAME/ALL applies rules.", _chestRuleTextStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (IsSeparateWildcardRuleEnabled()) { GUILayout.Label("• Wildcard name rule: * = any chars, ? = one char.", _chestRuleTextStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } else { GUILayout.Label("• Add wildcard patterns in Manage Groups (* = any chars, ? = one char).", _chestRuleTextStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } GUILayout.EndVertical(); GUILayout.Space(8f); if (GUILayout.Button("Remove Smart Chest", _chestDangerButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(20f), GUILayout.ExpandWidth(true) })) { _manager.RemoveSmartChest(_chestId); SaveIfDirty(); HideConfig(); } GUILayout.Space(2f); if (GUILayout.Button("Close", _chestCloseButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(20f), GUILayout.ExpandWidth(true) })) { HideConfig(); } } private void DrawGroupsWindow(int windowId) { //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0974: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) if (_configWindowStyle == null) { InitializeStyles(); } GUIStyle chestLabelBoldStyle = _chestLabelBoldStyle; GUIStyle chestLabelStyle = _chestLabelStyle; GUIStyle chestLabelDimStyle = _chestLabelDimStyle; GUILayout.Label("Create or edit groups. Add item IDs and wildcard name patterns here, then use 'By Group' rules on chests.", chestLabelDimStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty()); _newGroupName = GUILayout.TextField(_newGroupName ?? "", _configSearchFieldStyle ?? _chestSearchFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("New Group", _chestAddButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { string text = (_newGroupName ?? "").Trim(); if (text.Length > 0 && _manager.GetGroup(text) == null) { _manager.GetOrCreateGroup(text); _newGroupName = ""; _editingGroup = _manager.GetGroup(text); _manager.MarkDirty(); SaveIfDirty(); } } GUILayout.EndHorizontal(); GUILayout.Space(8f); IReadOnlyList groups = _manager.GetGroups(); if (groups.Count > 0) { GUILayout.Label("Groups:", chestLabelBoldStyle, Array.Empty()); _groupListScroll = GUILayout.BeginScrollView(_groupListScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(100f) }); for (int i = 0; i < groups.Count; i++) { ItemGroup itemGroup = groups[i]; GUILayout.BeginHorizontal(Array.Empty()); GUIStyle val = ((_editingGroup == itemGroup) ? _chestSelectorActiveStyle : _chestSelectorStyle); if (GUILayout.Button($"{itemGroup.Name} ({itemGroup.ItemIds?.Count ?? 0})", val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { _editingGroup = itemGroup; } if (GUILayout.Button("X", _chestRemoveRuleBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(26f), GUILayout.Height(22f) })) { _manager.RemoveGroup(itemGroup.Name); if (_editingGroup == itemGroup) { _editingGroup = null; } _manager.MarkDirty(); SaveIfDirty(); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.Space(6f); } if (_editingGroup != null && _manager.GetGroup(_editingGroup.Name) != null) { GUILayout.Label("Editing: " + _editingGroup.Name, chestLabelBoldStyle, Array.Empty()); if (_editingGroup.ItemIds != null && _editingGroup.ItemIds.Count > 0) { _groupItemsScroll = GUILayout.BeginScrollView(_groupItemsScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(80f) }); for (int num = _editingGroup.ItemIds.Count - 1; num >= 0; num--) { int num2 = _editingGroup.ItemIds[num]; string obj = ItemSearch.GetItemName(num2) ?? $"#{num2}"; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(obj, chestLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("X", _chestRemoveRuleBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(20f) })) { _editingGroup.ItemIds.RemoveAt(num); _manager.MarkDirty(); SaveIfDirty(); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } else { GUILayout.Label(" No items. Search below to add.", chestLabelDimStyle, Array.Empty()); } if (_editingGroup.NamePatterns != null && _editingGroup.NamePatterns.Count > 0) { GUILayout.Space(4f); GUILayout.Label("Wildcard patterns:", chestLabelBoldStyle, Array.Empty()); for (int num3 = _editingGroup.NamePatterns.Count - 1; num3 >= 0; num3--) { string text2 = _editingGroup.NamePatterns[num3]; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(text2, chestLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("+IDs", _chestAddButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(52f), GUILayout.Height(20f) })) { int num4 = ExpandPatternToItemIds(_editingGroup, text2); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[SmartChestUI] Group '{_editingGroup.Name}': pattern '{text2}' added {num4} item ID(s)"); } } if (GUILayout.Button("X", _chestRemoveRuleBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(20f) })) { _editingGroup.NamePatterns.RemoveAt(num3); _manager.MarkDirty(); SaveIfDirty(); } GUILayout.EndHorizontal(); } } GUILayout.Space(4f); GUILayout.Label("Add item (search):", chestLabelBoldStyle, Array.Empty()); if (_groupItemSearch != _groupItemSearchLast) { _groupItemSearchLast = _groupItemSearch ?? ""; _groupSearchResults = (List>)((string.IsNullOrEmpty(_groupItemSearchLast) || _groupItemSearchLast.Length < 2) ? ((IList)new List>()) : ((IList)ItemSearch.SearchItems(_groupItemSearchLast, 15))); } GUI.SetNextControlName("SmartChestGroupItemSearch"); _groupItemSearch = GUILayout.TextField(_groupItemSearch ?? "", _configSearchFieldStyle ?? _chestSearchFieldStyle, Array.Empty()); if (_groupSearchResults.Count > 0) { _groupSearchScroll = GUILayout.BeginScrollView(_groupSearchScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(100f) }); foreach (KeyValuePair groupSearchResult in _groupSearchResults) { if (GUILayout.Button(ItemSearch.FormatDisplay(groupSearchResult.Value, groupSearchResult.Key), _chestSearchResultStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { if (_editingGroup.ItemIds == null) { _editingGroup.ItemIds = new List(); } if (!_editingGroup.ItemIds.Contains(groupSearchResult.Key)) { _editingGroup.ItemIds.Add(groupSearchResult.Key); _manager.MarkDirty(); SaveIfDirty(); } _groupItemSearch = ""; _groupItemSearchLast = ""; _groupSearchResults.Clear(); break; } } GUILayout.EndScrollView(); } GUILayout.Space(6f); GUILayout.Label("Add wildcard pattern (* / ?):", chestLabelBoldStyle, Array.Empty()); GUI.SetNextControlName("SmartChestWildcardPattern"); _groupPatternInput = GUILayout.TextField(_groupPatternInput ?? "", _configSearchFieldStyle ?? _chestSearchFieldStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Examples: Tomato* | *Ore | Gold ???", chestLabelDimStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("Add Pattern", _chestAddButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(100f), GUILayout.Height(22f) })) { string text3 = (_groupPatternInput ?? "").Trim(); if (!string.IsNullOrEmpty(text3)) { if (_editingGroup.NamePatterns == null) { _editingGroup.NamePatterns = new List(); } if (!_editingGroup.NamePatterns.Contains(text3)) { _editingGroup.NamePatterns.Add(text3); _manager.MarkDirty(); SaveIfDirty(); } _groupPatternInput = ""; } } if (GUILayout.Button("Add Matches to IDs", _chestAddButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(132f), GUILayout.Height(22f) })) { string text4 = (_groupPatternInput ?? "").Trim(); if (!string.IsNullOrEmpty(text4)) { int num5 = ExpandPatternToItemIds(_editingGroup, text4); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"[SmartChestUI] Group '{_editingGroup.Name}': input pattern '{text4}' added {num5} item ID(s)"); } } else { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"Enter a wildcard pattern first, then click Add Matches to IDs"); } } } GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Close", _chestCloseButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { _groupsWindowVisible = false; _editingGroup = null; _newGroupName = ""; _groupPatternInput = ""; } GUI.DragWindow(new Rect(0f, 0f, GroupsWindowWidth, Scaled(24f))); } private void DrawNoteContent(float width, float height) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (_configWindowStyle == null) { InitializeStyles(); } string text = (SmartChestConfig.StaticRequireCtrl ? $"Ctrl+{SmartChestConfig.StaticToggleKey}" : ((object)(KeyCode)(ref SmartChestConfig.StaticToggleKey)).ToString()); string text2 = "Press [" + text + "] to configure smart chest rules"; if ((Object)(object)_noteBannerBg != (Object)null) { GUI.DrawTexture(new Rect(0f, 0f, width, height), (Texture)(object)_noteBannerBg); } if ((Object)(object)_noteBannerBorderTex != (Object)null) { GUI.DrawTexture(new Rect(0f, 0f, width, 1f), (Texture)(object)_noteBannerBorderTex); GUI.DrawTexture(new Rect(0f, height - 1f, width, 1f), (Texture)(object)_noteBannerBorderTex); GUI.DrawTexture(new Rect(0f, 0f, 1f, height), (Texture)(object)_noteBannerBorderTex); GUI.DrawTexture(new Rect(width - 1f, 0f, 1f, height), (Texture)(object)_noteBannerBorderTex); } GUILayout.BeginArea(new Rect(0f, 0f, width, height)); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.Label(text2, _noteBannerStyle, Array.Empty()); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndArea(); } private void DrawSelectorButton(int index, bool compact, params GUILayoutOption[] options) { GUIStyle val = ((!compact) ? ((index == _selectedRuleType) ? _selectorActiveStyle : _selectorStyle) : ((index == _selectedRuleType) ? _chestSelectorActiveStyle : _chestSelectorStyle)); if (GUILayout.Button(RuleTypeNames[index], val, options)) { _selectedRuleType = index; } } private void DrawRuleInput(bool useChestStyles, bool useWhiteSearchField = false) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = (useChestStyles ? _chestLabelBoldStyle : _labelBoldStyle); GUIStyle val2 = (useChestStyles ? _chestLabelStyle : _labelStyle); GUIStyle val3 = (useChestStyles ? _chestLabelDimStyle : _labelDimStyle); GUIStyle val4 = (useWhiteSearchField ? _configSearchFieldStyle : (useChestStyles ? _chestSearchFieldStyle : _textFieldStyle)); switch (_selectedRuleType) { case 0: if (_itemIdInput != _lastSearchQuery) { _lastSearchQuery = _itemIdInput; _searchResults = ItemSearch.SearchItems(_itemIdInput, 20); _searchScrollPos = Vector2.zero; } GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search:", val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) }); GUI.SetNextControlName("SmartChestItemSearch"); _itemIdInput = GUILayout.TextField(_itemIdInput, val4, Array.Empty()); GUILayout.EndHorizontal(); if (_selectedItemId > 0) { GUILayout.Space(2f); GUILayout.Label("Selected: " + ItemSearch.FormatDisplay(_selectedItemName, _selectedItemId), val2, Array.Empty()); } if (_searchResults.Count > 0) { GUILayout.Space(4f); _searchScrollPos = GUILayout.BeginScrollView(_searchScrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) }); foreach (KeyValuePair searchResult in _searchResults) { bool num = IsUndonatedMuseumItem(searchResult.Key); string text = ItemSearch.FormatDisplay(searchResult.Value, searchResult.Key); if (num) { text += " [Museum]"; } GUILayout.BeginHorizontal(Array.Empty()); if (num) { Rect rect = GUILayoutUtility.GetRect(4f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(4f), GUILayout.Height(22f) }); GUI.color = _museumHighlight; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; } GUIStyle val6 = ((!useChestStyles) ? ((searchResult.Key == _selectedItemId) ? _searchResultSelectedStyle : _searchResultStyle) : ((searchResult.Key == _selectedItemId) ? _chestSearchResultSelectedStyle : _chestSearchResultStyle)); if (GUILayout.Button(text, val6, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) })) { _selectedItemId = searchResult.Key; _selectedItemName = searchResult.Value; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } else if (_itemIdInput.Length >= 2) { GUILayout.Space(2f); GUILayout.Label(" No items found.", val3, Array.Empty()); } break; case 1: { GUILayout.Label("Category:", val, Array.Empty()); string[] categoryNames = GetCategoryNames(); if (_selectedCategory < 0 || _selectedCategory >= categoryNames.Length) { _selectedCategory = 0; } DrawOptionGrid(categoryNames, ref _selectedCategory, 3, useChestStyles); break; } case 2: GUILayout.Label("Item Type:", val, Array.Empty()); DrawOptionGrid(ItemTypeNames, ref _selectedItemType, 3, useChestStyles); break; case 3: GUILayout.Label("Property:", val, Array.Empty()); DrawOptionGrid(PropertyDisplayNames, ref _selectedProperty, useChestStyles ? 3 : 2, useChestStyles); break; case 4: { IReadOnlyList groups = _manager.GetGroups(); GUILayout.Label("Group:", val, Array.Empty()); if (groups.Count == 0) { GUILayout.Label(" No groups yet. Click Manage Groups to create one.", val3, Array.Empty()); break; } for (int i = 0; i < groups.Count; i++) { ItemGroup itemGroup = groups[i]; GUIStyle val5 = ((!useChestStyles) ? ((i == _selectedGroup) ? _searchResultSelectedStyle : _searchResultStyle) : ((i == _selectedGroup) ? _chestSearchResultSelectedStyle : _chestSearchResultStyle)); if (GUILayout.Button($"{itemGroup.Name} ({itemGroup.ItemIds?.Count ?? 0} items)", val5, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })) { _selectedGroup = i; } } break; } case 5: if (!IsSeparateWildcardRuleEnabled()) { GUILayout.Label("Wildcard rules are managed via Manage Groups.", val3, Array.Empty()); GUILayout.Label("Add patterns to a group, then add a By Group rule.", val3, Array.Empty()); break; } GUILayout.Label("Item name pattern:", val, Array.Empty()); GUI.SetNextControlName("SmartChestWildcardPattern"); _wildcardPatternInput = GUILayout.TextField(_wildcardPatternInput ?? "", val4, Array.Empty()) ?? ""; GUILayout.Space(2f); GUILayout.Label(" Examples: Tomato*, *Ore, Gold ??? (letters match any case)", val3, Array.Empty()); break; } } private void DrawOptionGrid(string[] options, ref int selected, int columns, bool useChestStyles = false) { GUIStyle val = (useChestStyles ? _chestSelectorStyle : _selectorStyle); GUIStyle val2 = (useChestStyles ? _chestSelectorActiveStyle : _selectorActiveStyle); int num = (options.Length + columns - 1) / columns; for (int i = 0; i < num; i++) { GUILayout.BeginHorizontal(Array.Empty()); for (int j = 0; j < columns; j++) { int num2 = i * columns + j; if (num2 < options.Length) { GUIStyle val3 = ((num2 == selected) ? val2 : val); if (GUILayout.Button(options[num2], val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })) { selected = num2; } } else { GUILayout.FlexibleSpace(); } } GUILayout.EndHorizontal(); GUILayout.Space(2f); } } private string GetRuleDisplayText(SmartChestRule rule) { if (rule.Type == RuleType.ByItemId) { string itemName = ItemSearch.GetItemName(rule.ItemId); string text = ((!string.IsNullOrEmpty(itemName)) ? $"{itemName} ({rule.ItemId})" : $"Item ID: {rule.ItemId}"); if (IsUndonatedMuseumItem(rule.ItemId)) { text += " [Museum]"; } return text; } return rule.GetDisplayText(); } private bool IsUndonatedMuseumItem(int gameItemId) { try { DonationManager donationManager = Plugin.GetDonationManager(); if (donationManager == null || !donationManager.IsLoaded) { return false; } if (MuseumContent.FindByGameItemId(gameItemId) == null) { return false; } return !donationManager.HasDonatedByGameId(gameItemId); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)$"[SmartChestUI] IsUndonatedMuseumItem({gameItemId}): {ex.Message}"); } return false; } } private static string[] GetCategoryNames() { if (!IsSmutAvailable()) { return BaseCategoryNames; } return CategoryNamesWithMuseum; } private static bool IsSmutAvailable() { try { return Chainloader.PluginInfos?.ContainsKey("com.azraelgodking.sunhavenmuseumutilitytracker") ?? false; } catch { return false; } } private int ExpandPatternToItemIds(ItemGroup group, string pattern) { if (group == null || string.IsNullOrWhiteSpace(pattern)) { return 0; } if (group.ItemIds == null) { group.ItemIds = new List(); } int num = 0; List> allItems = ItemSearch.GetAllItems(); for (int i = 0; i < allItems.Count; i++) { KeyValuePair keyValuePair = allItems[i]; if (ItemNamePatternMatch.Matches(keyValuePair.Value, pattern) && !group.ItemIds.Contains(keyValuePair.Key)) { group.ItemIds.Add(keyValuePair.Key); num++; } } if (num > 0) { _manager.MarkDirty(); SaveIfDirty(); } return num; } private static bool IsSeparateWildcardRuleEnabled() { SmartChestConfig config = Plugin.GetConfig(); if (config?.SeparateWildcardRuleInUI != null) { return config.SeparateWildcardRuleInUI.Value; } return SmartChestConfig.StaticSeparateWildcardRule; } private void AddRule() { SmartChestRule smartChestRule = null; switch (_selectedRuleType) { case 0: if (_selectedItemId > 0) { smartChestRule = new SmartChestRule { Type = RuleType.ByItemId, ItemId = _selectedItemId }; _itemIdInput = ""; _lastSearchQuery = ""; _searchResults.Clear(); _selectedItemId = -1; _selectedItemName = ""; } else { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"Select an item from the search results first"); } } break; case 1: { string[] categoryNames = GetCategoryNames(); if (_selectedCategory >= 0 && _selectedCategory < categoryNames.Length) { smartChestRule = new SmartChestRule { Type = RuleType.ByCategory, CategoryName = categoryNames[_selectedCategory] }; } break; } case 2: if (_selectedItemType >= 0 && _selectedItemType < ItemTypeNames.Length) { smartChestRule = new SmartChestRule { Type = RuleType.ByItemType, ItemTypeName = ItemTypeNames[_selectedItemType] }; } break; case 3: if (_selectedProperty >= 0 && _selectedProperty < PropertyNames.Length) { smartChestRule = new SmartChestRule { Type = RuleType.ByProperty, PropertyName = PropertyNames[_selectedProperty] }; } break; case 4: { IReadOnlyList groups = _manager.GetGroups(); if (_selectedGroup >= 0 && _selectedGroup < groups.Count) { ItemGroup itemGroup = groups[_selectedGroup]; if (itemGroup != null && !string.IsNullOrEmpty(itemGroup.Name)) { smartChestRule = new SmartChestRule { Type = RuleType.ByGroup, GroupName = itemGroup.Name }; } } else { ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)"Select a group, or create one in Manage Groups first"); } } break; } case 5: { if (!IsSeparateWildcardRuleEnabled()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"Separate wildcard rule is disabled. Add wildcard patterns in Manage Groups."); } break; } string text = (_wildcardPatternInput ?? "").Trim(); if (!string.IsNullOrEmpty(text)) { smartChestRule = new SmartChestRule { Type = RuleType.ByNamePattern, NamePattern = text }; _wildcardPatternInput = ""; } else { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"Enter a name pattern (* and ? wildcards)"); } } break; } } if (smartChestRule == null) { return; } foreach (SmartChestRule rule in _currentData.Rules) { if (rule.Type == smartChestRule.Type && rule.ItemId == smartChestRule.ItemId && rule.CategoryName == smartChestRule.CategoryName && rule.ItemTypeName == smartChestRule.ItemTypeName && rule.PropertyName == smartChestRule.PropertyName && rule.GroupName == smartChestRule.GroupName && rule.NamePattern == smartChestRule.NamePattern) { ManualLogSource log5 = Plugin.Log; if (log5 != null) { log5.LogInfo((object)"Rule already exists, skipping duplicate"); } return; } } _currentData.Rules.Add(smartChestRule); SmartChestConfig config = Plugin.GetConfig(); if (!_currentData.IsEnabled && (config == null || config.AutoEnableSmartChestOnRuleAdd.Value)) { _currentData.IsEnabled = true; ManualLogSource log6 = Plugin.Log; if (log6 != null) { log6.LogInfo((object)"Auto-enabled Smart Chest after adding a rule"); } } _manager.MarkDirty(); SaveIfDirty(); ManualLogSource log7 = Plugin.Log; if (log7 != null) { log7.LogInfo((object)("Added rule: " + smartChestRule.GetDisplayText())); } } private void SaveIfDirty() { if (_manager == null || !_manager.IsDirty) { return; } SmartChestSaveSystem saveSystem = Plugin.GetSaveSystem(); if (saveSystem == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[UI] SaveIfDirty: SaveSystem is null!"); } } else { saveSystem.Save(); } } private void ApplyPreset(string presetName) { if (_currentData == null || string.IsNullOrWhiteSpace(presetName)) { return; } List list = new List(); switch (presetName) { default: return; case "Equipment": list.Add(new SmartChestRule { Type = RuleType.ByCategory, CategoryName = "Equip" }); break; case "Consumables": list.Add(new SmartChestRule { Type = RuleType.ByCategory, CategoryName = "Use" }); list.Add(new SmartChestRule { Type = RuleType.ByItemType, ItemTypeName = "Food" }); list.Add(new SmartChestRule { Type = RuleType.ByProperty, PropertyName = "isPotion" }); break; case "Crafting": list.Add(new SmartChestRule { Type = RuleType.ByCategory, CategoryName = "Craftable" }); list.Add(new SmartChestRule { Type = RuleType.ByProperty, PropertyName = "isArtisanryItem" }); break; } int num = 0; foreach (SmartChestRule rule in list) { if (!_currentData.Rules.Exists((SmartChestRule existing) => existing.Type == rule.Type && existing.ItemId == rule.ItemId && existing.CategoryName == rule.CategoryName && existing.ItemTypeName == rule.ItemTypeName && existing.PropertyName == rule.PropertyName && existing.GroupName == rule.GroupName)) { _currentData.Rules.Add(rule); num++; } } if (num > 0) { _currentData.IsEnabled = true; _manager.MarkDirty(); SaveIfDirty(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[SmartChestUI] Applied preset '{presetName}' (+{num} rule(s))"); } } } private void InitializeStyles() { if (_stylesDirty || _configWindowStyle == null) { CreateTextures(); CreateStyles(); _stylesDirty = false; } } private void CreateTextures() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) DestroyTextures(); _solidBg = MakeTex(4, 4, _bgDark); _windowBg = MakeBorderedTex(16, 16, _bgDark, _borderGold, 2); _ruleBg = MakeTex(1, 1, _ruleBoxColor); _btnInactiveTex = MakeTex(1, 1, _btnInactive); _btnHoverTex = MakeTex(1, 1, _btnHover); _btnActiveTex = MakeTex(1, 1, _greenActive); _btnActiveHoverTex = MakeTex(1, 1, _greenHover); _redBtnTex = MakeTex(1, 1, _redDanger); _redBtnHoverTex = MakeTex(1, 1, _redHover); _greenBtnTex = MakeTex(1, 1, _greenActive); _greenBtnHoverTex = MakeTex(1, 1, _greenBright); _closeBtnTex = MakeTex(1, 1, _redDanger); _closeBtnHoverTex = MakeTex(1, 1, _redHover); _fieldBgTex = MakeTex(1, 1, _fieldBg); _chestParchmentBg = MakeParchmentTexture(32, 64, _parchment, _parchmentLight, _borderWood, 3); _chestWoodBorderTex = MakeTex(1, 1, _borderWood); _chestRuleBoxTex = MakeRoundedRect(16, 16, _parchmentDark, _borderWood, 2); _chestSelectorTex = MakeRoundedRect(8, 8, _parchmentDark, _borderWood, 2); _chestSelectorHoverTex = MakeRoundedRect(8, 8, _woodLight, _borderWood, 2); _chestSelectorActiveTex = MakeRoundedRect(8, 8, _goldPale, _goldRich, 2); _chestAddBtnTex = MakeRoundedRect(8, 8, new Color(0.3f, 0.55f, 0.45f), new Color(0.2f, 0.4f, 0.35f), 2); _chestAddBtnHoverTex = MakeRoundedRect(8, 8, new Color(0.38f, 0.65f, 0.52f), new Color(0.25f, 0.48f, 0.42f), 2); _chestWoodBtnTex = MakeRoundedRect(8, 8, _woodMedium, _woodDark, 2); _chestWoodBtnHoverTex = MakeRoundedRect(8, 8, _woodLight, _woodMedium, 2); _chestDangerBtnTex = MakeRoundedRect(8, 8, _redDanger, new Color(0.55f, 0.15f, 0.15f), 2); _chestDangerBtnHoverTex = MakeRoundedRect(8, 8, _redHover, new Color(0.65f, 0.18f, 0.18f), 2); _chestFieldBgTex = MakeRoundedRect(6, 6, _parchmentLight, _borderWood, 1); _chestGoldLineTex = MakeGradientTex(64, 3, _goldPale, _goldRich); _noteBannerBg = MakeTex(4, 4, new Color(0.45f, 0.1f, 0.08f, 1f)); _noteBannerBorderTex = MakeTex(1, 1, _goldRich); _configTitleBarTex = MakeGradientTex(64, 32, _crimsonTitleLight, _crimsonTitle); _configContentBg = MakeParchmentTexture(64, 128, _parchment, _parchmentLight, _borderWood, 0); _configGoldSeparatorTex = MakeGradientTex(64, 2, _goldPale, _goldRich); _configSectionHeaderTex = MakeRoundedRect(16, 16, _parchmentDark, _goldRich, 2); _configSearchFieldTex = MakeRoundedRect(8, 8, Color.white, new Color(0.25f, 0.2f, 0.18f), 1); _configRemoveBtnTex = MakeRoundedRect(8, 8, _crimsonTitle, new Color(0.4f, 0.12f, 0.08f), 1); _configRemoveBtnHoverTex = MakeRoundedRect(8, 8, _crimsonTitleLight, new Color(0.45f, 0.15f, 0.1f), 1); _configCloseBtnTex = MakeRoundedRect(8, 8, _woodMedium, _woodDark, 1); _configCloseBtnHoverTex = MakeRoundedRect(8, 8, _woodLight, _woodMedium, 1); _configWindowBg = MakeBorderedTex(64, 64, _parchmentLight, _goldRich, 5); _configInnerBorderTex = MakeTex(1, 1, _innerBorderCrimson); } private void DestroyTextures() { if ((Object)(object)_solidBg != (Object)null) { Object.Destroy((Object)(object)_solidBg); } if ((Object)(object)_windowBg != (Object)null) { Object.Destroy((Object)(object)_windowBg); } if ((Object)(object)_ruleBg != (Object)null) { Object.Destroy((Object)(object)_ruleBg); } if ((Object)(object)_btnInactiveTex != (Object)null) { Object.Destroy((Object)(object)_btnInactiveTex); } if ((Object)(object)_btnHoverTex != (Object)null) { Object.Destroy((Object)(object)_btnHoverTex); } if ((Object)(object)_btnActiveTex != (Object)null) { Object.Destroy((Object)(object)_btnActiveTex); } if ((Object)(object)_btnActiveHoverTex != (Object)null) { Object.Destroy((Object)(object)_btnActiveHoverTex); } if ((Object)(object)_redBtnTex != (Object)null) { Object.Destroy((Object)(object)_redBtnTex); } if ((Object)(object)_redBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_redBtnHoverTex); } if ((Object)(object)_greenBtnTex != (Object)null) { Object.Destroy((Object)(object)_greenBtnTex); } if ((Object)(object)_greenBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_greenBtnHoverTex); } if ((Object)(object)_closeBtnTex != (Object)null) { Object.Destroy((Object)(object)_closeBtnTex); } if ((Object)(object)_closeBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_closeBtnHoverTex); } if ((Object)(object)_fieldBgTex != (Object)null) { Object.Destroy((Object)(object)_fieldBgTex); } if ((Object)(object)_chestParchmentBg != (Object)null) { Object.Destroy((Object)(object)_chestParchmentBg); } if ((Object)(object)_chestWoodBorderTex != (Object)null) { Object.Destroy((Object)(object)_chestWoodBorderTex); } if ((Object)(object)_chestRuleBoxTex != (Object)null) { Object.Destroy((Object)(object)_chestRuleBoxTex); } if ((Object)(object)_chestSelectorTex != (Object)null) { Object.Destroy((Object)(object)_chestSelectorTex); } if ((Object)(object)_chestSelectorHoverTex != (Object)null) { Object.Destroy((Object)(object)_chestSelectorHoverTex); } if ((Object)(object)_chestSelectorActiveTex != (Object)null) { Object.Destroy((Object)(object)_chestSelectorActiveTex); } if ((Object)(object)_chestAddBtnTex != (Object)null) { Object.Destroy((Object)(object)_chestAddBtnTex); } if ((Object)(object)_chestAddBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_chestAddBtnHoverTex); } if ((Object)(object)_chestWoodBtnTex != (Object)null) { Object.Destroy((Object)(object)_chestWoodBtnTex); } if ((Object)(object)_chestWoodBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_chestWoodBtnHoverTex); } if ((Object)(object)_chestDangerBtnTex != (Object)null) { Object.Destroy((Object)(object)_chestDangerBtnTex); } if ((Object)(object)_chestDangerBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_chestDangerBtnHoverTex); } if ((Object)(object)_chestFieldBgTex != (Object)null) { Object.Destroy((Object)(object)_chestFieldBgTex); } if ((Object)(object)_chestGoldLineTex != (Object)null) { Object.Destroy((Object)(object)_chestGoldLineTex); } if ((Object)(object)_noteBannerBg != (Object)null) { Object.Destroy((Object)(object)_noteBannerBg); } if ((Object)(object)_noteBannerBorderTex != (Object)null) { Object.Destroy((Object)(object)_noteBannerBorderTex); } if ((Object)(object)_configTitleBarTex != (Object)null) { Object.Destroy((Object)(object)_configTitleBarTex); } if ((Object)(object)_configContentBg != (Object)null) { Object.Destroy((Object)(object)_configContentBg); } if ((Object)(object)_configGoldSeparatorTex != (Object)null) { Object.Destroy((Object)(object)_configGoldSeparatorTex); } if ((Object)(object)_configSectionHeaderTex != (Object)null) { Object.Destroy((Object)(object)_configSectionHeaderTex); } if ((Object)(object)_configSearchFieldTex != (Object)null) { Object.Destroy((Object)(object)_configSearchFieldTex); } if ((Object)(object)_configRemoveBtnTex != (Object)null) { Object.Destroy((Object)(object)_configRemoveBtnTex); } if ((Object)(object)_configRemoveBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_configRemoveBtnHoverTex); } if ((Object)(object)_configCloseBtnTex != (Object)null) { Object.Destroy((Object)(object)_configCloseBtnTex); } if ((Object)(object)_configCloseBtnHoverTex != (Object)null) { Object.Destroy((Object)(object)_configCloseBtnHoverTex); } if ((Object)(object)_configWindowBg != (Object)null) { Object.Destroy((Object)(object)_configWindowBg); } if ((Object)(object)_configInnerBorderTex != (Object)null) { Object.Destroy((Object)(object)_configInnerBorderTex); } } private void CreateStyles() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0083: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_014a: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01b9: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_0301: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Expected O, but got Unknown //IL_03e4: Expected O, but got Unknown //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Expected O, but got Unknown //IL_04a8: Expected O, but got Unknown //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Expected O, but got Unknown //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Expected O, but got Unknown //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Expected O, but got Unknown //IL_05ee: Expected O, but got Unknown //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Expected O, but got Unknown //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Expected O, but got Unknown //IL_06e9: Expected O, but got Unknown //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Unknown result type (might be due to invalid IL or missing references) //IL_0717: Unknown result type (might be due to invalid IL or missing references) //IL_0728: Unknown result type (might be due to invalid IL or missing references) //IL_072f: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Expected O, but got Unknown //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0752: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b5: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Expected O, but got Unknown //IL_07dc: Expected O, but got Unknown //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Unknown result type (might be due to invalid IL or missing references) //IL_07f0: Unknown result type (might be due to invalid IL or missing references) //IL_07f7: Unknown result type (might be due to invalid IL or missing references) //IL_0808: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0864: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Expected O, but got Unknown //IL_087a: Expected O, but got Unknown //IL_087b: Unknown result type (might be due to invalid IL or missing references) //IL_0880: Unknown result type (might be due to invalid IL or missing references) //IL_088e: Unknown result type (might be due to invalid IL or missing references) //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_08ad: Unknown result type (might be due to invalid IL or missing references) //IL_08b7: Unknown result type (might be due to invalid IL or missing references) //IL_08c8: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Unknown result type (might be due to invalid IL or missing references) //IL_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_0902: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Expected O, but got Unknown //IL_0918: Expected O, but got Unknown //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_091e: Unknown result type (might be due to invalid IL or missing references) //IL_092c: Unknown result type (might be due to invalid IL or missing references) //IL_093d: Unknown result type (might be due to invalid IL or missing references) //IL_0944: Unknown result type (might be due to invalid IL or missing references) //IL_094e: Unknown result type (might be due to invalid IL or missing references) //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0966: Unknown result type (might be due to invalid IL or missing references) //IL_0970: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_0988: Unknown result type (might be due to invalid IL or missing references) //IL_0992: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Unknown result type (might be due to invalid IL or missing references) //IL_09c6: Unknown result type (might be due to invalid IL or missing references) //IL_09d0: Expected O, but got Unknown //IL_09d0: Unknown result type (might be due to invalid IL or missing references) //IL_09e9: Unknown result type (might be due to invalid IL or missing references) //IL_09f3: Expected O, but got Unknown //IL_09f8: Expected O, but got Unknown //IL_09ff: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Unknown result type (might be due to invalid IL or missing references) //IL_0a0b: Unknown result type (might be due to invalid IL or missing references) //IL_0a1c: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) //IL_0a2d: Unknown result type (might be due to invalid IL or missing references) //IL_0a3e: Unknown result type (might be due to invalid IL or missing references) //IL_0a45: Unknown result type (might be due to invalid IL or missing references) //IL_0a54: Expected O, but got Unknown //IL_0a5b: Unknown result type (might be due to invalid IL or missing references) //IL_0a60: Unknown result type (might be due to invalid IL or missing references) //IL_0a73: Expected O, but got Unknown //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0aab: Unknown result type (might be due to invalid IL or missing references) //IL_0ac1: Unknown result type (might be due to invalid IL or missing references) //IL_0ad2: Unknown result type (might be due to invalid IL or missing references) //IL_0ad7: Unknown result type (might be due to invalid IL or missing references) //IL_0ade: Unknown result type (might be due to invalid IL or missing references) //IL_0ae8: Unknown result type (might be due to invalid IL or missing references) //IL_0aef: Unknown result type (might be due to invalid IL or missing references) //IL_0af9: Unknown result type (might be due to invalid IL or missing references) //IL_0b00: Unknown result type (might be due to invalid IL or missing references) //IL_0b0a: Unknown result type (might be due to invalid IL or missing references) //IL_0b11: Unknown result type (might be due to invalid IL or missing references) //IL_0b1b: Unknown result type (might be due to invalid IL or missing references) //IL_0b22: Unknown result type (might be due to invalid IL or missing references) //IL_0b2c: Unknown result type (might be due to invalid IL or missing references) //IL_0b33: Unknown result type (might be due to invalid IL or missing references) //IL_0b3d: Unknown result type (might be due to invalid IL or missing references) //IL_0b44: Unknown result type (might be due to invalid IL or missing references) //IL_0b4e: Unknown result type (might be due to invalid IL or missing references) //IL_0b55: Unknown result type (might be due to invalid IL or missing references) //IL_0b5f: Unknown result type (might be due to invalid IL or missing references) //IL_0b72: Expected O, but got Unknown //IL_0b79: Unknown result type (might be due to invalid IL or missing references) //IL_0b7e: Unknown result type (might be due to invalid IL or missing references) //IL_0b85: Unknown result type (might be due to invalid IL or missing references) //IL_0b8f: Unknown result type (might be due to invalid IL or missing references) //IL_0b96: Unknown result type (might be due to invalid IL or missing references) //IL_0ba0: Unknown result type (might be due to invalid IL or missing references) //IL_0ba7: Unknown result type (might be due to invalid IL or missing references) //IL_0bb1: Unknown result type (might be due to invalid IL or missing references) //IL_0bb8: Unknown result type (might be due to invalid IL or missing references) //IL_0bc2: Unknown result type (might be due to invalid IL or missing references) //IL_0bc9: Unknown result type (might be due to invalid IL or missing references) //IL_0bd3: Unknown result type (might be due to invalid IL or missing references) //IL_0bda: Unknown result type (might be due to invalid IL or missing references) //IL_0be4: Unknown result type (might be due to invalid IL or missing references) //IL_0beb: Unknown result type (might be due to invalid IL or missing references) //IL_0bf5: Unknown result type (might be due to invalid IL or missing references) //IL_0bfc: Unknown result type (might be due to invalid IL or missing references) //IL_0c06: Unknown result type (might be due to invalid IL or missing references) //IL_0c19: Expected O, but got Unknown //IL_0c20: Unknown result type (might be due to invalid IL or missing references) //IL_0c25: Unknown result type (might be due to invalid IL or missing references) //IL_0c2c: Unknown result type (might be due to invalid IL or missing references) //IL_0c36: Unknown result type (might be due to invalid IL or missing references) //IL_0c49: Expected O, but got Unknown //IL_0c50: Unknown result type (might be due to invalid IL or missing references) //IL_0c55: Unknown result type (might be due to invalid IL or missing references) //IL_0c61: Expected O, but got Unknown //IL_0c68: Unknown result type (might be due to invalid IL or missing references) //IL_0c6d: Unknown result type (might be due to invalid IL or missing references) //IL_0c7b: Unknown result type (might be due to invalid IL or missing references) //IL_0c82: Unknown result type (might be due to invalid IL or missing references) //IL_0c89: Unknown result type (might be due to invalid IL or missing references) //IL_0c98: Expected O, but got Unknown //IL_0c99: Unknown result type (might be due to invalid IL or missing references) //IL_0c9e: Unknown result type (might be due to invalid IL or missing references) //IL_0caf: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0ce6: Expected O, but got Unknown //IL_0ce6: Unknown result type (might be due to invalid IL or missing references) //IL_0d13: Unknown result type (might be due to invalid IL or missing references) //IL_0d1d: Expected O, but got Unknown //IL_0d22: Expected O, but got Unknown //IL_0d29: Unknown result type (might be due to invalid IL or missing references) //IL_0d2e: Unknown result type (might be due to invalid IL or missing references) //IL_0d3c: Unknown result type (might be due to invalid IL or missing references) //IL_0d43: Unknown result type (might be due to invalid IL or missing references) //IL_0d4d: Unknown result type (might be due to invalid IL or missing references) //IL_0d54: Unknown result type (might be due to invalid IL or missing references) //IL_0d5e: Unknown result type (might be due to invalid IL or missing references) //IL_0d65: Unknown result type (might be due to invalid IL or missing references) //IL_0d74: Expected O, but got Unknown //IL_0d75: Unknown result type (might be due to invalid IL or missing references) //IL_0d7a: Unknown result type (might be due to invalid IL or missing references) //IL_0d88: Unknown result type (might be due to invalid IL or missing references) //IL_0d8f: Unknown result type (might be due to invalid IL or missing references) //IL_0da0: Unknown result type (might be due to invalid IL or missing references) //IL_0da7: Unknown result type (might be due to invalid IL or missing references) //IL_0db1: Unknown result type (might be due to invalid IL or missing references) //IL_0dc2: Unknown result type (might be due to invalid IL or missing references) //IL_0dc9: Unknown result type (might be due to invalid IL or missing references) //IL_0dd3: Unknown result type (might be due to invalid IL or missing references) //IL_0de4: Unknown result type (might be due to invalid IL or missing references) //IL_0deb: Unknown result type (might be due to invalid IL or missing references) //IL_0df5: Unknown result type (might be due to invalid IL or missing references) //IL_0dfc: Unknown result type (might be due to invalid IL or missing references) //IL_0e29: Unknown result type (might be due to invalid IL or missing references) //IL_0e33: Expected O, but got Unknown //IL_0e33: Unknown result type (might be due to invalid IL or missing references) //IL_0e60: Unknown result type (might be due to invalid IL or missing references) //IL_0e6a: Expected O, but got Unknown //IL_0e6f: Expected O, but got Unknown //IL_0e76: Unknown result type (might be due to invalid IL or missing references) //IL_0e7b: Unknown result type (might be due to invalid IL or missing references) //IL_0e8c: Unknown result type (might be due to invalid IL or missing references) //IL_0e93: Unknown result type (might be due to invalid IL or missing references) //IL_0e9d: Unknown result type (might be due to invalid IL or missing references) //IL_0eae: Unknown result type (might be due to invalid IL or missing references) //IL_0eb5: Unknown result type (might be due to invalid IL or missing references) //IL_0ec4: Expected O, but got Unknown //IL_0ec5: Unknown result type (might be due to invalid IL or missing references) //IL_0eca: Unknown result type (might be due to invalid IL or missing references) //IL_0ed8: Unknown result type (might be due to invalid IL or missing references) //IL_0edf: Unknown result type (might be due to invalid IL or missing references) //IL_0ef0: Unknown result type (might be due to invalid IL or missing references) //IL_0ef7: Unknown result type (might be due to invalid IL or missing references) //IL_0f01: Unknown result type (might be due to invalid IL or missing references) //IL_0f12: Unknown result type (might be due to invalid IL or missing references) //IL_0f19: Unknown result type (might be due to invalid IL or missing references) //IL_0f23: Unknown result type (might be due to invalid IL or missing references) //IL_0f34: Unknown result type (might be due to invalid IL or missing references) //IL_0f3b: Unknown result type (might be due to invalid IL or missing references) //IL_0f45: Unknown result type (might be due to invalid IL or missing references) //IL_0f4c: Unknown result type (might be due to invalid IL or missing references) //IL_0f53: Unknown result type (might be due to invalid IL or missing references) //IL_0f5d: Expected O, but got Unknown //IL_0f62: Expected O, but got Unknown //IL_0f63: Unknown result type (might be due to invalid IL or missing references) //IL_0f68: Unknown result type (might be due to invalid IL or missing references) //IL_0f76: Unknown result type (might be due to invalid IL or missing references) //IL_0f7d: Unknown result type (might be due to invalid IL or missing references) //IL_0f8e: Unknown result type (might be due to invalid IL or missing references) //IL_0f95: Unknown result type (might be due to invalid IL or missing references) //IL_0f9f: Unknown result type (might be due to invalid IL or missing references) //IL_0fb0: Unknown result type (might be due to invalid IL or missing references) //IL_0fb7: Unknown result type (might be due to invalid IL or missing references) //IL_0fc1: Unknown result type (might be due to invalid IL or missing references) //IL_0fd2: Unknown result type (might be due to invalid IL or missing references) //IL_0fd9: Unknown result type (might be due to invalid IL or missing references) //IL_0fe3: Unknown result type (might be due to invalid IL or missing references) //IL_0fea: Unknown result type (might be due to invalid IL or missing references) //IL_0ff1: Unknown result type (might be due to invalid IL or missing references) //IL_0ffb: Expected O, but got Unknown //IL_1000: Expected O, but got Unknown //IL_1001: Unknown result type (might be due to invalid IL or missing references) //IL_1006: Unknown result type (might be due to invalid IL or missing references) //IL_1014: Unknown result type (might be due to invalid IL or missing references) //IL_101b: Unknown result type (might be due to invalid IL or missing references) //IL_102c: Unknown result type (might be due to invalid IL or missing references) //IL_1033: Unknown result type (might be due to invalid IL or missing references) //IL_103d: Unknown result type (might be due to invalid IL or missing references) //IL_104e: Unknown result type (might be due to invalid IL or missing references) //IL_1055: Unknown result type (might be due to invalid IL or missing references) //IL_105f: Unknown result type (might be due to invalid IL or missing references) //IL_1070: Unknown result type (might be due to invalid IL or missing references) //IL_1077: Unknown result type (might be due to invalid IL or missing references) //IL_1081: Unknown result type (might be due to invalid IL or missing references) //IL_1088: Unknown result type (might be due to invalid IL or missing references) //IL_108f: Unknown result type (might be due to invalid IL or missing references) //IL_1099: Expected O, but got Unknown //IL_109e: Expected O, but got Unknown //IL_109f: Unknown result type (might be due to invalid IL or missing references) //IL_10a4: Unknown result type (might be due to invalid IL or missing references) //IL_10b2: Unknown result type (might be due to invalid IL or missing references) //IL_10c3: Unknown result type (might be due to invalid IL or missing references) //IL_10ca: Unknown result type (might be due to invalid IL or missing references) //IL_10d4: Unknown result type (might be due to invalid IL or missing references) //IL_10e5: Unknown result type (might be due to invalid IL or missing references) //IL_10ec: Unknown result type (might be due to invalid IL or missing references) //IL_10f6: Unknown result type (might be due to invalid IL or missing references) //IL_1107: Unknown result type (might be due to invalid IL or missing references) //IL_110e: Unknown result type (might be due to invalid IL or missing references) //IL_1118: Unknown result type (might be due to invalid IL or missing references) //IL_1145: Unknown result type (might be due to invalid IL or missing references) //IL_114f: Expected O, but got Unknown //IL_114f: Unknown result type (might be due to invalid IL or missing references) //IL_117c: Unknown result type (might be due to invalid IL or missing references) //IL_1186: Expected O, but got Unknown //IL_118b: Expected O, but got Unknown //IL_118c: Unknown result type (might be due to invalid IL or missing references) //IL_1191: Unknown result type (might be due to invalid IL or missing references) //IL_119f: Unknown result type (might be due to invalid IL or missing references) //IL_11a6: Unknown result type (might be due to invalid IL or missing references) //IL_11b7: Unknown result type (might be due to invalid IL or missing references) //IL_11be: Unknown result type (might be due to invalid IL or missing references) //IL_11c8: Unknown result type (might be due to invalid IL or missing references) //IL_11d9: Unknown result type (might be due to invalid IL or missing references) //IL_11e0: Unknown result type (might be due to invalid IL or missing references) //IL_11ea: Unknown result type (might be due to invalid IL or missing references) //IL_11fb: Unknown result type (might be due to invalid IL or missing references) //IL_1202: Unknown result type (might be due to invalid IL or missing references) //IL_120c: Unknown result type (might be due to invalid IL or missing references) //IL_1213: Unknown result type (might be due to invalid IL or missing references) //IL_1218: Unknown result type (might be due to invalid IL or missing references) //IL_1222: Expected O, but got Unknown //IL_1227: Expected O, but got Unknown //IL_1228: Unknown result type (might be due to invalid IL or missing references) //IL_122d: Unknown result type (might be due to invalid IL or missing references) //IL_123b: Unknown result type (might be due to invalid IL or missing references) //IL_124c: Unknown result type (might be due to invalid IL or missing references) //IL_1253: Unknown result type (might be due to invalid IL or missing references) //IL_125d: Unknown result type (might be due to invalid IL or missing references) //IL_126e: Unknown result type (might be due to invalid IL or missing references) //IL_1275: Unknown result type (might be due to invalid IL or missing references) //IL_127f: Unknown result type (might be due to invalid IL or missing references) //IL_1290: Unknown result type (might be due to invalid IL or missing references) //IL_1297: Unknown result type (might be due to invalid IL or missing references) //IL_12a1: Unknown result type (might be due to invalid IL or missing references) //IL_12a8: Unknown result type (might be due to invalid IL or missing references) //IL_12d5: Unknown result type (might be due to invalid IL or missing references) //IL_12df: Expected O, but got Unknown //IL_12df: Unknown result type (might be due to invalid IL or missing references) //IL_12f8: Unknown result type (might be due to invalid IL or missing references) //IL_1302: Expected O, but got Unknown //IL_1307: Expected O, but got Unknown //IL_130e: Unknown result type (might be due to invalid IL or missing references) //IL_1313: Unknown result type (might be due to invalid IL or missing references) //IL_131a: Unknown result type (might be due to invalid IL or missing references) //IL_132b: Unknown result type (might be due to invalid IL or missing references) //IL_1332: Unknown result type (might be due to invalid IL or missing references) //IL_133c: Unknown result type (might be due to invalid IL or missing references) //IL_134d: Unknown result type (might be due to invalid IL or missing references) //IL_1354: Unknown result type (might be due to invalid IL or missing references) //IL_1363: Expected O, but got Unknown //IL_1364: Unknown result type (might be due to invalid IL or missing references) //IL_1369: Unknown result type (might be due to invalid IL or missing references) //IL_1377: Unknown result type (might be due to invalid IL or missing references) //IL_137e: Unknown result type (might be due to invalid IL or missing references) //IL_1393: Unknown result type (might be due to invalid IL or missing references) //IL_139d: Unknown result type (might be due to invalid IL or missing references) //IL_13a4: Unknown result type (might be due to invalid IL or missing references) //IL_13d1: Unknown result type (might be due to invalid IL or missing references) //IL_13db: Expected O, but got Unknown //IL_13e0: Expected O, but got Unknown //IL_13e1: Unknown result type (might be due to invalid IL or missing references) //IL_13e6: Unknown result type (might be due to invalid IL or missing references) //IL_13f4: Unknown result type (might be due to invalid IL or missing references) //IL_13fb: Unknown result type (might be due to invalid IL or missing references) //IL_1401: Unknown result type (might be due to invalid IL or missing references) //IL_140b: Unknown result type (might be due to invalid IL or missing references) //IL_1412: Unknown result type (might be due to invalid IL or missing references) //IL_143f: Unknown result type (might be due to invalid IL or missing references) //IL_1449: Expected O, but got Unknown //IL_144e: Expected O, but got Unknown //IL_144f: Unknown result type (might be due to invalid IL or missing references) //IL_1454: Unknown result type (might be due to invalid IL or missing references) //IL_1462: Unknown result type (might be due to invalid IL or missing references) //IL_1469: Unknown result type (might be due to invalid IL or missing references) //IL_147a: Unknown result type (might be due to invalid IL or missing references) //IL_1481: Unknown result type (might be due to invalid IL or missing references) //IL_148b: Unknown result type (might be due to invalid IL or missing references) //IL_1492: Unknown result type (might be due to invalid IL or missing references) //IL_14bf: Unknown result type (might be due to invalid IL or missing references) //IL_14c9: Expected O, but got Unknown //IL_14c9: Unknown result type (might be due to invalid IL or missing references) //IL_14ce: Unknown result type (might be due to invalid IL or missing references) //IL_14d8: Expected O, but got Unknown //IL_14dd: Expected O, but got Unknown //IL_14de: Unknown result type (might be due to invalid IL or missing references) //IL_14e3: Unknown result type (might be due to invalid IL or missing references) //IL_14f1: Unknown result type (might be due to invalid IL or missing references) //IL_1502: Unknown result type (might be due to invalid IL or missing references) //IL_1509: Unknown result type (might be due to invalid IL or missing references) //IL_1513: Unknown result type (might be due to invalid IL or missing references) //IL_1524: Unknown result type (might be due to invalid IL or missing references) //IL_152b: Unknown result type (might be due to invalid IL or missing references) //IL_1535: Unknown result type (might be due to invalid IL or missing references) //IL_1562: Unknown result type (might be due to invalid IL or missing references) //IL_156c: Expected O, but got Unknown //IL_156c: Unknown result type (might be due to invalid IL or missing references) //IL_1599: Unknown result type (might be due to invalid IL or missing references) //IL_15a3: Expected O, but got Unknown //IL_15a8: Expected O, but got Unknown //IL_15a9: Unknown result type (might be due to invalid IL or missing references) //IL_15ae: Unknown result type (might be due to invalid IL or missing references) //IL_15bc: Unknown result type (might be due to invalid IL or missing references) //IL_15c3: Unknown result type (might be due to invalid IL or missing references) //IL_15d4: Unknown result type (might be due to invalid IL or missing references) //IL_15da: Unknown result type (might be due to invalid IL or missing references) //IL_15e4: Unknown result type (might be due to invalid IL or missing references) //IL_15f5: Unknown result type (might be due to invalid IL or missing references) //IL_15fb: Unknown result type (might be due to invalid IL or missing references) //IL_1605: Unknown result type (might be due to invalid IL or missing references) //IL_1616: Unknown result type (might be due to invalid IL or missing references) //IL_161c: Unknown result type (might be due to invalid IL or missing references) //IL_1626: Unknown result type (might be due to invalid IL or missing references) //IL_162d: Unknown result type (might be due to invalid IL or missing references) //IL_1634: Unknown result type (might be due to invalid IL or missing references) //IL_163e: Expected O, but got Unknown //IL_1643: Expected O, but got Unknown //IL_1644: Unknown result type (might be due to invalid IL or missing references) //IL_1649: Unknown result type (might be due to invalid IL or missing references) //IL_1657: Unknown result type (might be due to invalid IL or missing references) //IL_165e: Unknown result type (might be due to invalid IL or missing references) //IL_166f: Unknown result type (might be due to invalid IL or missing references) //IL_1675: Unknown result type (might be due to invalid IL or missing references) //IL_167f: Unknown result type (might be due to invalid IL or missing references) //IL_1690: Unknown result type (might be due to invalid IL or missing references) //IL_1696: Unknown result type (might be due to invalid IL or missing references) //IL_16a0: Unknown result type (might be due to invalid IL or missing references) //IL_16b1: Unknown result type (might be due to invalid IL or missing references) //IL_16b7: Unknown result type (might be due to invalid IL or missing references) //IL_16c1: Unknown result type (might be due to invalid IL or missing references) //IL_16c8: Unknown result type (might be due to invalid IL or missing references) //IL_16cf: Unknown result type (might be due to invalid IL or missing references) //IL_16d9: Expected O, but got Unknown //IL_16de: Expected O, but got Unknown //IL_16e9: Unknown result type (might be due to invalid IL or missing references) //IL_16ee: Unknown result type (might be due to invalid IL or missing references) //IL_171b: Unknown result type (might be due to invalid IL or missing references) //IL_1725: Expected O, but got Unknown //IL_1725: Unknown result type (might be due to invalid IL or missing references) //IL_1752: Unknown result type (might be due to invalid IL or missing references) //IL_175c: Expected O, but got Unknown //IL_1761: Expected O, but got Unknown _windowStyle = new GUIStyle(GUI.skin.window) { padding = new RectOffset(ScaledInt(14f), ScaledInt(14f), ScaledInt(12f), ScaledInt(12f)), border = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)) }; _windowStyle.normal.background = _windowBg; _windowStyle.normal.textColor = _whiteText; _windowStyle.onNormal.background = _windowBg; _windowStyle.onNormal.textColor = _whiteText; GUIStyle val = new GUIStyle { fontSize = ScaledFont(15), fontStyle = (FontStyle)1 }; val.normal.textColor = _whiteText; val.alignment = (TextAnchor)3; val.padding = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)); _titleStyle = val; GUIStyle val2 = new GUIStyle { fontSize = ScaledFont(15), fontStyle = (FontStyle)1 }; val2.normal.textColor = _goldText; val2.alignment = (TextAnchor)4; val2.padding = new RectOffset(ScaledInt(4f), ScaledInt(4f), ScaledInt(2f), ScaledInt(2f)); _sectionHeaderStyle = val2; GUIStyle val3 = new GUIStyle { fontSize = ScaledFont(13) }; val3.normal.textColor = _whiteText; val3.alignment = (TextAnchor)3; val3.padding = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)); val3.wordWrap = true; _labelStyle = val3; _labelBoldStyle = new GUIStyle(_labelStyle) { fontStyle = (FontStyle)1 }; GUIStyle val4 = new GUIStyle(_labelStyle) { fontSize = ScaledFont(12), fontStyle = (FontStyle)2 }; val4.normal.textColor = _dimText; _labelDimStyle = val4; GUIStyle val5 = new GUIStyle(); val5.normal.background = _ruleBg; val5.padding = new RectOffset(ScaledInt(10f), ScaledInt(8f), ScaledInt(6f), ScaledInt(6f)); val5.margin = new RectOffset(ScaledInt(4f), ScaledInt(4f), ScaledInt(2f), ScaledInt(2f)); _ruleBoxStyle = val5; _ruleTextStyle = new GUIStyle(_labelStyle) { fontSize = ScaledFont(13) }; GUIStyle val6 = new GUIStyle { fontSize = ScaledFont(13), fontStyle = (FontStyle)1 }; val6.normal.background = _redBtnTex; val6.normal.textColor = _whiteText; val6.hover.background = _redBtnHoverTex; val6.hover.textColor = _whiteText; val6.active.background = _redBtnHoverTex; val6.active.textColor = _whiteText; val6.alignment = (TextAnchor)4; val6.padding = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)); _removeRuleBtnStyle = val6; GUIStyle val7 = new GUIStyle { fontSize = ScaledFont(14), fontStyle = (FontStyle)1 }; val7.normal.background = _closeBtnTex; val7.normal.textColor = _whiteText; val7.hover.background = _closeBtnHoverTex; val7.hover.textColor = _whiteText; val7.active.background = _closeBtnHoverTex; val7.active.textColor = _whiteText; val7.alignment = (TextAnchor)4; val7.padding = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(1f), ScaledInt(1f)); _closeButtonStyle = val7; _toggleStyle = new GUIStyle(GUI.skin.toggle) { fontSize = ScaledFont(13) }; _toggleStyle.normal.textColor = _whiteText; _toggleStyle.onNormal.textColor = _whiteText; _toggleStyle.hover.textColor = _whiteText; _toggleStyle.onHover.textColor = _whiteText; GUIStyle val8 = new GUIStyle { fontSize = ScaledFont(13) }; val8.normal.background = _fieldBgTex; val8.normal.textColor = _whiteText; val8.focused.background = _fieldBgTex; val8.focused.textColor = _whiteText; val8.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(5f), ScaledInt(5f)); val8.border = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)); _textFieldStyle = val8; GUIStyle val9 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val9.normal.background = _btnInactiveTex; val9.normal.textColor = _whiteText; val9.hover.background = _btnHoverTex; val9.hover.textColor = _whiteText; val9.active.background = _btnActiveTex; val9.active.textColor = _whiteText; val9.alignment = (TextAnchor)4; val9.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(5f), ScaledInt(5f)); val9.margin = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(1f), ScaledInt(1f)); _selectorStyle = val9; GUIStyle val10 = new GUIStyle(_selectorStyle); val10.normal.background = _btnActiveTex; val10.normal.textColor = _whiteText; val10.hover.background = _btnActiveHoverTex; val10.hover.textColor = _whiteText; _selectorActiveStyle = val10; GUIStyle val11 = new GUIStyle { fontSize = ScaledFont(14), fontStyle = (FontStyle)1 }; val11.normal.background = _greenBtnTex; val11.normal.textColor = _whiteText; val11.hover.background = _greenBtnHoverTex; val11.hover.textColor = _whiteText; val11.active.background = _greenBtnHoverTex; val11.active.textColor = _whiteText; val11.alignment = (TextAnchor)4; val11.padding = new RectOffset(10, 10, 5, 5); _addButtonStyle = val11; GUIStyle val12 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val12.normal.background = _redBtnTex; val12.normal.textColor = _whiteText; val12.hover.background = _redBtnHoverTex; val12.hover.textColor = _whiteText; val12.active.background = _redBtnHoverTex; val12.active.textColor = _whiteText; val12.alignment = (TextAnchor)4; val12.padding = new RectOffset(10, 10, 4, 4); _dangerButtonStyle = val12; GUIStyle val13 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val13.normal.background = _btnInactiveTex; val13.normal.textColor = _whiteText; val13.hover.background = _btnHoverTex; val13.hover.textColor = _whiteText; val13.active.background = _btnHoverTex; val13.active.textColor = _whiteText; val13.alignment = (TextAnchor)4; val13.padding = new RectOffset(10, 10, 4, 4); _closeBottomButtonStyle = val13; GUIStyle val14 = new GUIStyle { fontSize = ScaledFont(12) }; val14.normal.background = _ruleBg; val14.normal.textColor = _whiteText; val14.hover.background = _btnHoverTex; val14.hover.textColor = _whiteText; val14.active.background = _btnActiveTex; val14.active.textColor = _whiteText; val14.alignment = (TextAnchor)3; val14.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(3f), ScaledInt(3f)); val14.margin = new RectOffset(0, 0, ScaledInt(1f), ScaledInt(1f)); _searchResultStyle = val14; GUIStyle val15 = new GUIStyle(_searchResultStyle) { fontStyle = (FontStyle)1 }; val15.normal.background = _btnActiveTex; val15.normal.textColor = _whiteText; val15.hover.background = _btnActiveHoverTex; val15.hover.textColor = _whiteText; _searchResultSelectedStyle = val15; _chestToggleStyle = new GUIStyle(_toggleStyle) { fontSize = ScaledFont(14) }; _chestToggleStyle.normal.textColor = _chestTextDark; _chestToggleStyle.onNormal.textColor = _chestTextDark; _chestToggleStyle.hover.textColor = _chestTextDark; _chestToggleStyle.onHover.textColor = _chestTextDark; GUIStyle val16 = new GUIStyle(_titleStyle); val16.normal.textColor = _woodDark; val16.hover.textColor = _woodDark; val16.active.textColor = _woodDark; val16.focused.textColor = _woodDark; val16.onNormal.textColor = _woodDark; val16.onHover.textColor = _woodDark; val16.onActive.textColor = _woodDark; val16.onFocused.textColor = _woodDark; val16.fontSize = ScaledFont(17); _chestTitleStyle = val16; GUIStyle val17 = new GUIStyle(_sectionHeaderStyle); val17.normal.textColor = _woodDark; val17.hover.textColor = _woodDark; val17.active.textColor = _woodDark; val17.focused.textColor = _woodDark; val17.onNormal.textColor = _woodDark; val17.onHover.textColor = _woodDark; val17.onActive.textColor = _woodDark; val17.onFocused.textColor = _woodDark; val17.fontSize = ScaledFont(16); _chestSectionHeaderStyle = val17; GUIStyle val18 = new GUIStyle(_labelStyle); val18.normal.textColor = _chestTextDark; val18.fontSize = ScaledFont(14); _chestLabelStyle = val18; _chestLabelBoldStyle = new GUIStyle(_chestLabelStyle) { fontStyle = (FontStyle)1 }; GUIStyle val19 = new GUIStyle(_chestLabelStyle) { fontSize = ScaledFont(13), fontStyle = (FontStyle)2 }; val19.normal.textColor = _chestTextDim; _chestLabelDimStyle = val19; GUIStyle val20 = new GUIStyle(); val20.normal.background = _chestRuleBoxTex; val20.padding = new RectOffset(ScaledInt(10f), ScaledInt(8f), ScaledInt(6f), ScaledInt(6f)); val20.margin = new RectOffset(ScaledInt(4f), ScaledInt(4f), ScaledInt(2f), ScaledInt(2f)); _chestRuleBoxStyle = val20; GUIStyle val21 = new GUIStyle(_labelStyle) { fontSize = ScaledFont(13) }; val21.normal.textColor = _woodDark; val21.hover.textColor = _woodDark; val21.active.textColor = _woodDark; _chestRuleTextStyle = val21; GUIStyle val22 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val22.normal.background = _chestSelectorTex; val22.normal.textColor = _woodDark; val22.hover.background = _chestSelectorHoverTex; val22.hover.textColor = _woodDark; val22.active.background = _chestSelectorActiveTex; val22.active.textColor = _woodDark; val22.alignment = (TextAnchor)4; val22.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(5f), ScaledInt(5f)); val22.margin = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(1f), ScaledInt(1f)); _chestSelectorStyle = val22; GUIStyle val23 = new GUIStyle(_chestSelectorStyle); val23.normal.background = _chestSelectorActiveTex; val23.normal.textColor = _woodDark; val23.hover.background = _chestSelectorActiveTex; val23.hover.textColor = _woodDark; _chestSelectorActiveStyle = val23; GUIStyle val24 = new GUIStyle { fontSize = ScaledFont(14), fontStyle = (FontStyle)1 }; val24.normal.background = _chestAddBtnTex; val24.normal.textColor = _parchmentLight; val24.hover.background = _chestAddBtnHoverTex; val24.hover.textColor = _parchmentLight; val24.active.background = _chestAddBtnHoverTex; val24.active.textColor = _parchmentLight; val24.alignment = (TextAnchor)4; val24.padding = new RectOffset(10, 10, 5, 5); _chestAddButtonStyle = val24; GUIStyle val25 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val25.normal.background = _chestDangerBtnTex; val25.normal.textColor = _whiteText; val25.hover.background = _chestDangerBtnHoverTex; val25.hover.textColor = _whiteText; val25.active.background = _chestDangerBtnHoverTex; val25.active.textColor = _whiteText; val25.alignment = (TextAnchor)4; val25.padding = new RectOffset(10, 10, 4, 4); _chestDangerButtonStyle = val25; GUIStyle val26 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val26.normal.background = _chestWoodBtnTex; val26.normal.textColor = _parchmentLight; val26.hover.background = _chestWoodBtnHoverTex; val26.hover.textColor = _parchmentLight; val26.active.background = _chestWoodBtnHoverTex; val26.active.textColor = _parchmentLight; val26.alignment = (TextAnchor)4; val26.padding = new RectOffset(10, 10, 4, 4); _chestCloseButtonStyle = val26; GUIStyle val27 = new GUIStyle { fontSize = ScaledFont(13) }; val27.normal.background = _chestFieldBgTex; val27.normal.textColor = _woodDark; val27.focused.background = _chestFieldBgTex; val27.focused.textColor = _woodDark; val27.hover.background = _chestFieldBgTex; val27.hover.textColor = _woodDark; val27.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(5f), ScaledInt(5f)); val27.border = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)); _chestSearchFieldStyle = val27; GUIStyle val28 = new GUIStyle { fontSize = ScaledFont(13), fontStyle = (FontStyle)1 }; val28.normal.background = _chestDangerBtnTex; val28.normal.textColor = _whiteText; val28.hover.background = _chestDangerBtnHoverTex; val28.hover.textColor = _whiteText; val28.active.background = _chestDangerBtnHoverTex; val28.active.textColor = _whiteText; val28.alignment = (TextAnchor)4; val28.padding = new RectOffset(2, 2, 2, 2); _chestRemoveRuleBtnStyle = val28; GUIStyle val29 = new GUIStyle { fontSize = ScaledFont(12) }; val29.normal.background = _chestRuleBoxTex; val29.normal.textColor = _woodDark; val29.hover.background = _chestSelectorHoverTex; val29.hover.textColor = _woodDark; val29.active.background = _chestSelectorActiveTex; val29.active.textColor = _woodDark; val29.alignment = (TextAnchor)3; val29.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(3f), ScaledInt(3f)); val29.margin = new RectOffset(0, 0, ScaledInt(1f), ScaledInt(1f)); _chestSearchResultStyle = val29; GUIStyle val30 = new GUIStyle(_chestSearchResultStyle) { fontStyle = (FontStyle)1 }; val30.normal.background = _chestSelectorActiveTex; val30.normal.textColor = _woodDark; val30.hover.background = _chestSelectorActiveTex; val30.hover.textColor = _woodDark; _chestSearchResultSelectedStyle = val30; GUIStyle val31 = new GUIStyle { fontSize = ScaledFont(14), fontStyle = (FontStyle)1 }; val31.normal.textColor = new Color(0.95f, 0.92f, 0.85f); val31.alignment = (TextAnchor)4; val31.padding = new RectOffset(ScaledInt(8f), ScaledInt(4f), ScaledInt(8f), ScaledInt(4f)); _noteBannerStyle = val31; GUIStyle val32 = new GUIStyle { fontSize = ScaledFont(16), fontStyle = (FontStyle)1 }; val32.normal.textColor = Color.white; val32.alignment = (TextAnchor)4; val32.padding = new RectOffset(ScaledInt(4f), ScaledInt(4f), ScaledInt(4f), ScaledInt(4f)); _configTitleStyle = val32; GUIStyle val33 = new GUIStyle { fontSize = ScaledFont(14), fontStyle = (FontStyle)1 }; val33.normal.background = _configSectionHeaderTex; val33.normal.textColor = _chestTextDark; val33.alignment = (TextAnchor)4; val33.padding = new RectOffset(ScaledInt(12f), ScaledInt(8f), ScaledInt(6f), ScaledInt(6f)); val33.margin = new RectOffset(0, 0, 0, 0); _configSectionHeaderBoxStyle = val33; GUIStyle val34 = new GUIStyle { fontSize = ScaledFont(13) }; val34.normal.background = _configSearchFieldTex; val34.normal.textColor = _chestTextDark; val34.focused.background = _configSearchFieldTex; val34.focused.textColor = _chestTextDark; val34.padding = new RectOffset(ScaledInt(8f), ScaledInt(8f), ScaledInt(5f), ScaledInt(5f)); val34.border = new RectOffset(ScaledInt(2f), ScaledInt(2f), ScaledInt(2f), ScaledInt(2f)); _configSearchFieldStyle = val34; GUIStyle val35 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val35.normal.background = _configRemoveBtnTex; val35.normal.textColor = Color.white; val35.hover.background = _configRemoveBtnHoverTex; val35.hover.textColor = Color.white; val35.active.background = _configRemoveBtnHoverTex; val35.active.textColor = Color.white; val35.alignment = (TextAnchor)4; val35.padding = new RectOffset(10, 10, 6, 6); _configRemoveButtonStyle = val35; GUIStyle val36 = new GUIStyle { fontSize = ScaledFont(12), fontStyle = (FontStyle)1 }; val36.normal.background = _configCloseBtnTex; val36.normal.textColor = Color.white; val36.hover.background = _configCloseBtnHoverTex; val36.hover.textColor = Color.white; val36.active.background = _configCloseBtnHoverTex; val36.active.textColor = Color.white; val36.alignment = (TextAnchor)4; val36.padding = new RectOffset(10, 10, 6, 6); _configCloseBottomStyle = val36; _configWindowStyle = new GUIStyle(GUI.skin.window) { padding = new RectOffset(ScaledInt(5f), ScaledInt(5f), ScaledInt(5f), ScaledInt(5f)), border = new RectOffset(ScaledInt(5f), ScaledInt(5f), ScaledInt(5f), ScaledInt(5f)) }; _configWindowStyle.normal.background = _configWindowBg; _configWindowStyle.onNormal.background = _configWindowBg; } private Texture2D MakeTex(int width, int height, Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeBorderedTex(int width, int height, Color fillColor, Color borderColor, int borderWidth) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = j < borderWidth || j >= width - borderWidth || i < borderWidth || i >= height - borderWidth; array[i * width + j] = (flag ? borderColor : fillColor); } } val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeGradientTex(int width, int height, Color topColor, Color bottomColor) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { float num = (float)i / (float)(height - 1); Color val2 = Color.Lerp(bottomColor, topColor, num); for (int j = 0; j < width; j++) { array[i * width + j] = val2; } } val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeRoundedRect(int width, int height, Color fillColor, Color borderColor, int borderWidth) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = j < borderWidth || j >= width - borderWidth || i < borderWidth || i >= height - borderWidth; array[i * width + j] = (flag ? borderColor : fillColor); } } val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeParchmentTexture(int width, int height, Color baseColor, Color lightColor, Color borderColor, int borderWidth) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; Random random = new Random(42); for (int i = 0; i < height; i++) { float num = (float)i / (float)(height - 1); Color val2 = Color.Lerp(lightColor, baseColor, num * 0.3f); for (int j = 0; j < width; j++) { if (j < borderWidth || j >= width - borderWidth || i < borderWidth || i >= height - borderWidth) { array[i * width + j] = borderColor; continue; } float num2 = (float)random.NextDouble() * 0.03f - 0.015f; array[i * width + j] = new Color(Mathf.Clamp01(val2.r + num2), Mathf.Clamp01(val2.g + num2), Mathf.Clamp01(val2.b + num2), val2.a); } } val.SetPixels(array); val.Apply(); return val; } private void OnDestroy() { DestroyTextures(); } private void Awake() { _stylesDirty = true; _configWindowStyle = null; } private void OnEnable() { _stylesDirty = true; _configWindowStyle = null; } } } namespace SenpaisChest.Integration { public class MuseumTodoIntegration { private DonationManager _subscribedDonationManager; private readonly Dictionary _museumTodoIds = new Dictionary(); private readonly Dictionary _bundleTodoIds = new Dictionary(); private int _scanCounter; private const int SCAN_INTERVAL = 3; public MuseumTodoIntegration() { _subscribedDonationManager = Plugin.GetDonationManager(); if (_subscribedDonationManager != null) { _subscribedDonationManager.OnDonationsChanged += OnDonationsChanged; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[MuseumTodoIntegration] Initialized - museum item todos will sync with S.M.U.T. and Todo"); } } public void Dispose() { if (_subscribedDonationManager != null) { _subscribedDonationManager.OnDonationsChanged -= OnDonationsChanged; _subscribedDonationManager = null; } } public void OnScanComplete() { _scanCounter++; if (_scanCounter < 3) { return; } _scanCounter = 0; try { DonationManager donationManager = Plugin.GetDonationManager(); TodoManager todoManager = Plugin.GetTodoManager(); if (donationManager == null || !donationManager.IsLoaded || todoManager == null) { return; } HashSet inventories = ChestManager.inventories; if (inventories == null || inventories.Count == 0) { return; } foreach (Inventory item in inventories) { if ((Object)(object)item == (Object)null) { continue; } List items = item.Items; if (items == null) { continue; } int num = Math.Min(item.maxSlots, items.Count); for (int i = 0; i < num; i++) { SlotItemData val = items[i]; if (val.id > 0 && val.amount > 0) { CheckMuseumItem(val.id, donationManager, todoManager); } } } SyncOneItemShortBundleTodos(donationManager, todoManager); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[MuseumTodoIntegration] Error during scan: " + ex.Message)); } } } private void SyncOneItemShortBundleTodos(DonationManager donationManager, TodoManager todoManager) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown HashSet activeBundleIds = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (MuseumSection allSection in MuseumContent.GetAllSections()) { foreach (MuseumBundle bundle in allSection.Bundles) { List neededItems = donationManager.GetNeededItems(bundle); if (neededItems == null || neededItems.Count != 1) { continue; } MuseumItem val = neededItems[0]; if (val != null) { activeBundleIds.Add(bundle.Id); if (!_bundleTodoIds.ContainsKey(bundle.Id)) { string text = "Museum nearly complete: " + bundle.Name; string text2 = "One item left: " + val.Name; TodoItem val2 = new TodoItem(text, text2, (TodoPriority)2, (TodoCategory)8); SetTodoMetadata(val2, val.GameItemId, allSection.Name); todoManager.AddTodo(val2); _bundleTodoIds[bundle.Id] = val2.Id; } } } } foreach (string item in _bundleTodoIds.Keys.Where((string id) => !activeBundleIds.Contains(id)).ToList()) { string todoId = _bundleTodoIds[item]; TodoItem val3 = todoManager.GetAllTodos().FirstOrDefault((Func)((TodoItem t) => t.Id == todoId)); if (val3 != null && !val3.IsCompleted) { todoManager.RemoveTodo(todoId); } _bundleTodoIds.Remove(item); } } private void CheckMuseumItem(int gameItemId, DonationManager donationManager, TodoManager todoManager) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown if (_museumTodoIds.ContainsKey(gameItemId)) { return; } MuseumItem val = MuseumContent.FindByGameItemId(gameItemId); if (val != null && !donationManager.HasDonatedByGameId(gameItemId)) { string destinationHallForItem = GetDestinationHallForItem(gameItemId); string text = "Donate " + val.Name + " -> " + destinationHallForItem; string text2 = "Found in a chest. Needed in " + destinationHallForItem + "."; TodoItem val2 = new TodoItem(text, text2, (TodoPriority)2, (TodoCategory)8); SetTodoMetadata(val2, gameItemId, destinationHallForItem); todoManager.AddTodo(val2); _museumTodoIds[gameItemId] = val2.Id; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[MuseumTodoIntegration] Created todo for museum item: {val.Name} -> {destinationHallForItem} (ID: {gameItemId})"); } } } private void OnDonationsChanged() { try { DonationManager donationManager = Plugin.GetDonationManager(); TodoManager todoManager = Plugin.GetTodoManager(); if (donationManager == null || todoManager == null) { return; } List list = new List(); foreach (KeyValuePair museumTodoId in _museumTodoIds) { if (donationManager.HasDonatedByGameId(museumTodoId.Key)) { list.Add(museumTodoId.Key); } } foreach (int item in list) { if (!_museumTodoIds.TryGetValue(item, out string todoId)) { continue; } TodoItem val = todoManager.GetAllTodos().FirstOrDefault((Func)((TodoItem t) => t.Id == todoId)); if (val != null && !val.IsCompleted) { todoManager.ToggleComplete(todoId); MuseumItem val2 = MuseumContent.FindByGameItemId(item); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[MuseumTodoIntegration] Completed todo for donated item: " + (((val2 != null) ? val2.Name : null) ?? item.ToString()))); } } _museumTodoIds.Remove(item); } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[MuseumTodoIntegration] Error processing donation change: " + ex.Message)); } } } public void Reset() { _museumTodoIds.Clear(); _bundleTodoIds.Clear(); _scanCounter = 0; } private static string GetDestinationHallForItem(int gameItemId) { HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (MuseumSection allSection in MuseumContent.GetAllSections()) { foreach (MuseumBundle bundle in allSection.Bundles) { foreach (MuseumItem item in bundle.Items) { if (item.GameItemId == gameItemId) { hashSet.Add(allSection.Name); } } } } if (hashSet.Count == 0) { return "the museum"; } return string.Join(" / ", hashSet); } private static void SetTodoMetadata(TodoItem todoItem, int gameItemId, string destinationHall) { if (todoItem != null) { todoItem.IconItemId = gameItemId; todoItem.MuseumDestination = destinationHall ?? ""; } } } } namespace SenpaisChest.Data { internal static class ItemNamePatternMatch { private sealed class RegexCache { internal static readonly RegexCache Instance = new RegexCache(); private readonly Dictionary _map = new Dictionary(StringComparer.Ordinal); internal Regex GetOrAdd(string glob) { lock (_map) { if (!_map.TryGetValue(glob, out Regex value)) { value = BuildRegex(glob); _map[glob] = value; } return value; } } } internal static bool Matches(string itemName, string pattern) { if (string.IsNullOrEmpty(pattern)) { return false; } Regex orAdd; try { orAdd = RegexCache.Instance.GetOrAdd(pattern.Trim()); } catch (ArgumentException) { return false; } if (itemName != null) { return orAdd.IsMatch(itemName); } return false; } private static Regex BuildRegex(string glob) { StringBuilder stringBuilder = new StringBuilder("^"); for (int i = 0; i < glob.Length; i++) { char c = glob[i]; switch (c) { case '*': stringBuilder.Append(".*"); break; case '?': stringBuilder.Append("."); break; default: stringBuilder.Append(Regex.Escape(c.ToString())); break; } } stringBuilder.Append('$'); return new Regex(stringBuilder.ToString(), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } } public enum RuleType { ByItemId, ByCategory, ByItemType, ByProperty, ByGroup, ByNamePattern } [Serializable] public class ItemGroup { public string Name = ""; public List ItemIds = new List(); public List NamePatterns = new List(); } [Serializable] public class SmartChestRule { public RuleType Type; public int ItemId; public string CategoryName = ""; public string ItemTypeName = ""; public string PropertyName = ""; public string GroupName = ""; public string NamePattern = ""; public string GetDisplayText() { return Type switch { RuleType.ByItemId => $"Item ID: {ItemId}", RuleType.ByCategory => "Category: " + CategoryName, RuleType.ByItemType => "Type: " + ItemTypeName, RuleType.ByProperty => "Property: " + PropertyName, RuleType.ByGroup => "Group: " + GroupName, RuleType.ByNamePattern => "Name glob: " + NamePattern, _ => "Unknown Rule", }; } } [Serializable] public class SmartChestData { public string ChestId = ""; public string ChestName = ""; public bool IsEnabled; public List Rules = new List(); public SmartChestData() { } public SmartChestData(string chestId, string chestName) { ChestId = chestId; ChestName = chestName; IsEnabled = false; Rules = new List(); } } [Serializable] public class SmartChestSaveData { public string CharacterName = ""; public List Chests = new List(); public List Groups = new List(); public SmartChestSaveData() { } public SmartChestSaveData(string characterName) { CharacterName = characterName; Chests = new List(); Groups = new List(); } } internal static class SmartChestJson { internal static string Serialize(SmartChestSaveData data) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("{"); stringBuilder.Append(" \"CharacterName\": "); MinimalJsonParser.WriteJsonString(stringBuilder, data.CharacterName); stringBuilder.AppendLine(","); stringBuilder.AppendLine(" \"Chests\": ["); for (int i = 0; i < data.Chests.Count; i++) { SmartChestData smartChestData = data.Chests[i]; stringBuilder.AppendLine(" {"); stringBuilder.Append(" \"ChestId\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestData.ChestId); stringBuilder.AppendLine(","); stringBuilder.Append(" \"ChestName\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestData.ChestName); stringBuilder.AppendLine(","); stringBuilder.AppendLine(" \"IsEnabled\": " + (smartChestData.IsEnabled ? "true" : "false") + ","); stringBuilder.AppendLine(" \"Rules\": ["); for (int j = 0; j < smartChestData.Rules.Count; j++) { SmartChestRule smartChestRule = smartChestData.Rules[j]; stringBuilder.AppendLine(" {"); stringBuilder.AppendLine($" \"Type\": {(int)smartChestRule.Type},"); stringBuilder.AppendLine($" \"ItemId\": {smartChestRule.ItemId},"); stringBuilder.Append(" \"CategoryName\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestRule.CategoryName ?? ""); stringBuilder.AppendLine(","); stringBuilder.Append(" \"ItemTypeName\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestRule.ItemTypeName ?? ""); stringBuilder.AppendLine(","); stringBuilder.Append(" \"PropertyName\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestRule.PropertyName ?? ""); stringBuilder.AppendLine(","); stringBuilder.Append(" \"GroupName\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestRule.GroupName ?? ""); stringBuilder.AppendLine(","); stringBuilder.Append(" \"NamePattern\": "); MinimalJsonParser.WriteJsonString(stringBuilder, smartChestRule.NamePattern ?? ""); stringBuilder.AppendLine(); stringBuilder.Append(" }"); if (j < smartChestData.Rules.Count - 1) { stringBuilder.AppendLine(","); } else { stringBuilder.AppendLine(); } } stringBuilder.AppendLine(" ]"); stringBuilder.Append(" }"); if (i < data.Chests.Count - 1) { stringBuilder.AppendLine(","); } else { stringBuilder.AppendLine(); } } stringBuilder.AppendLine(" ],"); stringBuilder.AppendLine(" \"Groups\": ["); List list = data.Groups ?? new List(); for (int k = 0; k < list.Count; k++) { ItemGroup itemGroup = list[k]; stringBuilder.AppendLine(" {"); stringBuilder.Append(" \"Name\": "); MinimalJsonParser.WriteJsonString(stringBuilder, itemGroup.Name ?? ""); stringBuilder.AppendLine(","); stringBuilder.AppendLine(" \"ItemIds\": ["); List list2 = itemGroup.ItemIds ?? new List(); for (int l = 0; l < list2.Count; l++) { stringBuilder.Append(" "); stringBuilder.Append(list2[l]); if (l < list2.Count - 1) { stringBuilder.AppendLine(","); } else { stringBuilder.AppendLine(); } } stringBuilder.AppendLine(" ],"); stringBuilder.AppendLine(" \"NamePatterns\": ["); List list3 = itemGroup.NamePatterns ?? new List(); for (int m = 0; m < list3.Count; m++) { stringBuilder.Append(" "); MinimalJsonParser.WriteJsonString(stringBuilder, list3[m] ?? ""); if (m < list3.Count - 1) { stringBuilder.AppendLine(","); } else { stringBuilder.AppendLine(); } } stringBuilder.AppendLine(" ]"); stringBuilder.Append(" }"); if (k < list.Count - 1) { stringBuilder.AppendLine(","); } else { stringBuilder.AppendLine(); } } stringBuilder.AppendLine(" ]"); stringBuilder.Append("}"); return stringBuilder.ToString(); } internal static SmartChestSaveData Deserialize(string json) { if (string.IsNullOrEmpty(json)) { return null; } try { return DeserializeCore(json); } catch (Exception) { return null; } } private static SmartChestSaveData DeserializeCore(string json) { int pos = 0; Dictionary dictionary = MinimalJsonParser.ParseObject(json, ref pos); if (dictionary == null) { return null; } SmartChestSaveData smartChestSaveData = new SmartChestSaveData(); if (dictionary.TryGetValue("CharacterName", out var value)) { smartChestSaveData.CharacterName = (value as string) ?? ""; } if (dictionary.TryGetValue("Chests", out var value2) && value2 is List list) { foreach (object item in list) { if (!(item is Dictionary dictionary2)) { continue; } SmartChestData smartChestData = new SmartChestData(); if (dictionary2.TryGetValue("ChestId", out var value3)) { smartChestData.ChestId = (value3 as string) ?? ""; } if (dictionary2.TryGetValue("ChestName", out var value4)) { smartChestData.ChestName = (value4 as string) ?? ""; } if (dictionary2.TryGetValue("IsEnabled", out var value5)) { smartChestData.IsEnabled = value5 is bool flag && flag; } if (dictionary2.TryGetValue("Rules", out var value6) && value6 is List list2) { foreach (object item2 in list2) { if (item2 is Dictionary dictionary3) { SmartChestRule smartChestRule = new SmartChestRule(); if (dictionary3.TryGetValue("Type", out var value7)) { smartChestRule.Type = (RuleType)MinimalJsonParser.ToInt(value7); } if (dictionary3.TryGetValue("ItemId", out var value8)) { smartChestRule.ItemId = MinimalJsonParser.ToInt(value8); } if (dictionary3.TryGetValue("CategoryName", out var value9)) { smartChestRule.CategoryName = (value9 as string) ?? ""; } if (dictionary3.TryGetValue("ItemTypeName", out var value10)) { smartChestRule.ItemTypeName = (value10 as string) ?? ""; } if (dictionary3.TryGetValue("PropertyName", out var value11)) { smartChestRule.PropertyName = (value11 as string) ?? ""; } if (dictionary3.TryGetValue("GroupName", out var value12)) { smartChestRule.GroupName = (value12 as string) ?? ""; } if (dictionary3.TryGetValue("NamePattern", out var value13)) { smartChestRule.NamePattern = (value13 as string) ?? ""; } smartChestData.Rules.Add(smartChestRule); } } } smartChestSaveData.Chests.Add(smartChestData); } } if (dictionary.TryGetValue("Groups", out var value14) && value14 is List list3) { foreach (object item3 in list3) { if (!(item3 is Dictionary dictionary4)) { continue; } ItemGroup itemGroup = new ItemGroup(); if (dictionary4.TryGetValue("Name", out var value15)) { itemGroup.Name = (value15 as string) ?? ""; } if (dictionary4.TryGetValue("ItemIds", out var value16) && value16 is List list4) { foreach (object item4 in list4) { itemGroup.ItemIds.Add(MinimalJsonParser.ToInt(item4)); } } if (dictionary4.TryGetValue("NamePatterns", out var value17) && value17 is List list5) { foreach (object item5 in list5) { string text = (item5 as string) ?? ""; if (!string.IsNullOrWhiteSpace(text)) { itemGroup.NamePatterns.Add(text); } } } if (!string.IsNullOrWhiteSpace(itemGroup.Name)) { smartChestSaveData.Groups.Add(itemGroup); } } } return smartChestSaveData; } } public class SmartChestManager { private readonly Dictionary _smartChests = new Dictionary(); private readonly Dictionary _groups = new Dictionary(StringComparer.OrdinalIgnoreCase); private string _characterName = ""; private bool _isDirty; private readonly Dictionary _categoryCache = new Dictionary(); private static FieldInfo _chestDataField; private static object _notificationStackInstance; private static MethodInfo _sendNotificationMethod; private static MethodInfo _databaseGetDataMethod; private static bool _reflectionInitialized; private static bool _museumReflectionInitialized; private static bool _museumModAvailable; private static MethodInfo _getDonationManagerMethod; private static MethodInfo _hasDonatedByGameIdMethod; private static MethodInfo _findByGameItemIdMethod; private static PropertyInfo _isLoadedProperty; public bool IsDirty => _isDirty; public void LoadData(SmartChestSaveData data) { _smartChests.Clear(); _groups.Clear(); _categoryCache.Clear(); if (data == null) { return; } _characterName = data.CharacterName; foreach (SmartChestData chest in data.Chests) { _smartChests[chest.ChestId] = chest; } if (data.Groups != null) { foreach (ItemGroup group in data.Groups) { if (!string.IsNullOrWhiteSpace(group.Name) && group.ItemIds != null) { _groups[group.Name] = group; } } } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"Loaded {_smartChests.Count} smart chest(s), {_groups.Count} group(s)"); } } public SmartChestSaveData GetSaveData() { return new SmartChestSaveData { CharacterName = _characterName, Chests = _smartChests.Values.ToList(), Groups = _groups.Values.ToList() }; } public IReadOnlyList GetGroups() { return _groups.Values.ToList(); } public ItemGroup GetGroup(string name) { if (string.IsNullOrEmpty(name) || !_groups.TryGetValue(name, out ItemGroup value)) { return null; } return value; } public ItemGroup GetOrCreateGroup(string name) { if (string.IsNullOrWhiteSpace(name)) { return null; } string text = name.Trim(); if (_groups.TryGetValue(text, out ItemGroup value)) { return value; } ItemGroup itemGroup = new ItemGroup { Name = text, ItemIds = new List() }; _groups[text] = itemGroup; _isDirty = true; return itemGroup; } public void RenameGroup(string oldName, string newName) { if (!string.IsNullOrWhiteSpace(oldName) && !string.IsNullOrWhiteSpace(newName)) { string text = oldName.Trim(); string text2 = newName.Trim(); if (_groups.TryGetValue(text, out ItemGroup value) && (!_groups.ContainsKey(text2) || string.Equals(text, text2, StringComparison.OrdinalIgnoreCase))) { _groups.Remove(text); value.Name = text2; _groups[text2] = value; _isDirty = true; } } } public void RemoveGroup(string name) { if (!string.IsNullOrEmpty(name) && _groups.Remove(name.Trim())) { _isDirty = true; } } public void SetCharacterName(string name) { _characterName = name; } public void MarkClean() { _isDirty = false; } public void MarkDirty() { _isDirty = true; } public SmartChestData GetOrCreateSmartChest(string chestId, string chestName) { if (_smartChests.TryGetValue(chestId, out SmartChestData value)) { value.ChestName = chestName; return value; } SmartChestData smartChestData = new SmartChestData(chestId, chestName); _smartChests[chestId] = smartChestData; _isDirty = true; return smartChestData; } public SmartChestData GetSmartChest(string chestId) { _smartChests.TryGetValue(chestId, out SmartChestData value); return value; } public bool IsSmartChest(string chestId) { if (_smartChests.ContainsKey(chestId) && _smartChests[chestId].IsEnabled) { return _smartChests[chestId].Rules.Count > 0; } return false; } public int CountSameNameChests(string chestId) { if (!_smartChests.TryGetValue(chestId, out SmartChestData value)) { return 0; } int num = 0; foreach (KeyValuePair smartChest in _smartChests) { if (!(smartChest.Key == chestId) && string.Equals(smartChest.Value.ChestName, value.ChestName, StringComparison.OrdinalIgnoreCase)) { num++; } } return num; } public int CopyRulesToSameNameChests(string sourceChestId) { if (!_smartChests.TryGetValue(sourceChestId, out SmartChestData value) || value.Rules.Count == 0) { return 0; } int num = 0; foreach (KeyValuePair smartChest in _smartChests) { if (smartChest.Key == sourceChestId || !string.Equals(smartChest.Value.ChestName, value.ChestName, StringComparison.OrdinalIgnoreCase)) { continue; } smartChest.Value.Rules.Clear(); foreach (SmartChestRule rule in value.Rules) { smartChest.Value.Rules.Add(CloneRule(rule)); } num++; } if (num > 0) { _isDirty = true; } return num; } private static SmartChestRule CloneRule(SmartChestRule r) { return new SmartChestRule { Type = r.Type, ItemId = r.ItemId, CategoryName = r.CategoryName, ItemTypeName = r.ItemTypeName, PropertyName = r.PropertyName, GroupName = r.GroupName, NamePattern = r.NamePattern }; } public bool RemoveSmartChest(string chestId) { if (_smartChests.Remove(chestId)) { _isDirty = true; return true; } return false; } public static string GetChestId(Chest chest) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chest == (Object)null) { return null; } if ((Object)(object)chest == (Object)null) { return null; } Vector3Int position = ((Decoration)chest).Position; int num = (int)Math.Round((double)((Vector3Int)(ref position)).x); int num2 = (int)Math.Round((double)((Vector3Int)(ref position)).y); int num3 = (int)Math.Round((double)((Vector3Int)(ref position)).z); return $"{num}_{num2}_{num3}"; } public static string GetChestName(Chest chest) { try { InitReflection(); if (_chestDataField != null) { object? value = _chestDataField.GetValue(chest); ChestData val = (ChestData)((value is ChestData) ? value : null); if (val != null && !string.IsNullOrEmpty(val.name)) { return val.name; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("[SmartChestManager] GetChestName: " + ex.Message)); } } return "Chest"; } private static void InitReflection() { if (_reflectionInitialized) { return; } try { _chestDataField = typeof(Chest).GetField("data", BindingFlags.Instance | BindingFlags.NonPublic); Type type = AccessTools.TypeByName("Wish.Database") ?? AccessTools.TypeByName("Database"); if (type != null) { MethodInfo methodInfo = type.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "GetData" && m.IsGenericMethod && m.GetParameters().Length == 3); if (methodInfo != null) { _databaseGetDataMethod = methodInfo.MakeGenericMethod(typeof(ItemData)); } } _reflectionInitialized = true; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("Failed to initialize reflection: " + ex.Message)); } } } private static ItemSellInfo GetItemSellInfo(int itemId) { return ItemSearch.GetItemSellInfo(itemId); } private static void SendNotification(string message) { try { if (_notificationStackInstance != null) { object notificationStackInstance = _notificationStackInstance; Object val = (Object)((notificationStackInstance is Object) ? notificationStackInstance : null); if (val == null || !(val == (Object)null)) { goto IL_00ad; } } Type type = ReflectionHelper.FindWishType("NotificationStack"); _notificationStackInstance = ((type != null) ? ReflectionHelper.GetSingletonInstance(type) : null); if (_notificationStackInstance != null) { _sendNotificationMethod = _notificationStackInstance.GetType().GetMethod("SendNotification", new Type[5] { typeof(string), typeof(int), typeof(int), typeof(bool), typeof(bool) }); } goto IL_00ad; IL_00ad: _sendNotificationMethod?.Invoke(_notificationStackInstance, new object[5] { message, 0, 0, true, false }); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("[SmartChestManager] SendNotification: " + ex.Message)); } } } private bool IsChestInUse(Chest chest) { try { InitReflection(); if (_chestDataField != null) { object? value = _chestDataField.GetValue(chest); object? obj = ((value is ChestData) ? value : null); return obj != null && ((ChestData)obj).inUse; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("[SmartChestManager] IsChestInUse: " + ex.Message)); } } return false; } public void ExecuteScan(int maxItemsPerScan, bool enableNotifications) { if (_smartChests.Count == 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)"[Scan] No smart chests configured, skipping scan"); } return; } InitReflection(); HashSet inventories = ChestManager.inventories; Dictionary associatedChests = ChestManager.associatedChests; if (inventories == null || inventories.Count == 0) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogDebug((object)"[Scan] No inventories loaded, skipping scan"); } return; } if (associatedChests == null || associatedChests.Count == 0) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogDebug((object)"[Scan] No associated chests found, skipping scan"); } return; } ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogInfo((object)$"[Scan] Starting scan: {_smartChests.Count} smart chest(s), {associatedChests.Count} associated chest(s)"); } int num = 0; HashSet hashSet = new HashSet(); Dictionary> dictionary = new Dictionary>(); foreach (KeyValuePair item in associatedChests) { string chestId = GetChestId(item.Value); if (chestId != null && !dictionary.ContainsKey(chestId)) { dictionary[chestId] = new KeyValuePair(item.Key, item.Value); } } ManualLogSource log5 = Plugin.Log; if (log5 != null) { log5.LogDebug((object)$"[Scan] Built chest lookup: {dictionary.Count} unique chests"); } foreach (KeyValuePair smartChest in _smartChests) { if (num >= maxItemsPerScan) { break; } SmartChestData value = smartChest.Value; if (!value.IsEnabled || value.Rules.Count == 0) { ManualLogSource log6 = Plugin.Log; if (log6 != null) { log6.LogDebug((object)$"[Scan] Skipping '{value.ChestName}' (enabled={value.IsEnabled}, rules={value.Rules.Count})"); } continue; } if (!dictionary.TryGetValue(value.ChestId, out var value2)) { ManualLogSource log7 = Plugin.Log; if (log7 != null) { log7.LogWarning((object)("[Scan] Smart chest '" + value.ChestName + "' (id=" + value.ChestId + ") not found in loaded chests")); } continue; } Inventory key = value2.Key; Chest value3 = value2.Value; if (IsChestInUse(value3)) { ManualLogSource log8 = Plugin.Log; if (log8 != null) { log8.LogDebug((object)("[Scan] Target chest '" + value.ChestName + "' is in use, skipping")); } continue; } ManualLogSource log9 = Plugin.Log; if (log9 != null) { log9.LogInfo((object)$"[Scan] Scanning for items matching '{value.ChestName}' ({value.Rules.Count} rules)"); } int num2 = 0; foreach (KeyValuePair> item2 in dictionary) { if (num >= maxItemsPerScan) { break; } if (item2.Key == value.ChestId) { continue; } Inventory key2 = item2.Value.Key; Chest value4 = item2.Value.Value; if (!IsChestInUse(value4) && !IsSmartChest(item2.Key)) { num2++; int num3 = TransferMatchingItems(key2, value4, key, value3, value.Rules, maxItemsPerScan - num); if (num3 > 0) { num += num3; hashSet.Add(value4); hashSet.Add(value3); } } } ManualLogSource log10 = Plugin.Log; if (log10 != null) { log10.LogDebug((object)$"[Scan] Scanned {num2} source chests for '{value.ChestName}'"); } } int num5 = default(int); int num6 = default(int); foreach (KeyValuePair smartChest2 in _smartChests) { if (num >= maxItemsPerScan) { break; } SmartChestData value5 = smartChest2.Value; if (!value5.IsEnabled || value5.Rules.Count == 0 || !dictionary.TryGetValue(value5.ChestId, out var value6)) { continue; } Inventory key3 = value6.Key; Chest value7 = value6.Value; if (IsChestInUse(value7)) { continue; } List items = key3.Items; if (items == null) { continue; } int num4 = Mathf.Min(key3.maxSlots, items.Count) - 1; while (num4 >= 0 && num < maxItemsPerScan) { SlotItemData val = items[num4]; if (val.id > 0 && val.amount > 0 && !MatchesAnyRule(val.id, value5.Rules)) { string text = GetItemSellInfo(val.id)?.name ?? $"Item {val.id}"; bool flag = false; foreach (KeyValuePair smartChest3 in _smartChests) { if (!(smartChest3.Key == value5.ChestId) && smartChest3.Value.IsEnabled && smartChest3.Value.Rules.Count != 0 && MatchesAnyRule(val.id, smartChest3.Value.Rules) && dictionary.TryGetValue(smartChest3.Value.ChestId, out var value8) && !IsChestInUse(value8.Value) && value8.Key.CanAcceptItem(val.item, val.amount, ref num5) && num5 > 0) { ManualLogSource log11 = Plugin.Log; if (log11 != null) { log11.LogInfo((object)$"[Scan] Ejecting {text} x{num5} from '{value5.ChestName}' to smart chest '{smartChest3.Value.ChestName}'"); } TransferItemData(key3, num4, value8.Key, val.item, num5); hashSet.Add(value7); hashSet.Add(value8.Value); num++; flag = true; break; } } if (!flag) { foreach (KeyValuePair> item3 in dictionary) { if (!IsSmartChest(item3.Key) && !IsChestInUse(item3.Value.Value) && item3.Value.Key.CanAcceptItem(val.item, val.amount, ref num6) && num6 > 0) { ManualLogSource log12 = Plugin.Log; if (log12 != null) { log12.LogInfo((object)$"[Scan] Ejecting {text} x{num6} from '{value5.ChestName}' to normal chest"); } TransferItemData(key3, num4, item3.Value.Key, val.item, num6); hashSet.Add(value7); hashSet.Add(item3.Value.Value); num++; break; } } } } num4--; } } foreach (Chest item4 in hashSet) { try { ((Decoration)item4).SaveMeta(); ((Decoration)item4).SendNewMeta(((Decoration)item4).meta); } catch (Exception ex) { ManualLogSource log13 = Plugin.Log; if (log13 != null) { log13.LogError((object)("Error saving chest meta: " + ex.Message)); } } } if (num > 0) { ManualLogSource log14 = Plugin.Log; if (log14 != null) { log14.LogInfo((object)$"[Scan] Complete: sorted {num} item stack(s)"); } if (enableNotifications) { SendNotification("Senpai's Chest: Sorted"); } } else { ManualLogSource log15 = Plugin.Log; if (log15 != null) { log15.LogInfo((object)"[Scan] Complete: no items to sort"); } } } private int TransferMatchingItems(Inventory sourceInv, Chest sourceChest, Inventory targetInv, Chest targetChest, List rules, int maxItems) { int num = 0; List items = sourceInv.Items; if (items == null) { return 0; } int num2 = Mathf.Min(sourceInv.maxSlots, items.Count) - 1; int num3 = default(int); while (num2 >= 0 && num < maxItems) { SlotItemData val = items[num2]; if (val.id > 0 && val.amount > 0 && MatchesAnyRule(val.id, rules)) { if (!targetInv.CanAcceptItem(val.item, val.amount, ref num3)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)$"[Scan] Target cannot accept item {val.id} (amount={val.amount})"); } } else if (num3 > 0) { string arg = GetItemSellInfo(val.id)?.name ?? $"Item {val.id}"; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"[Scan] Moving {arg} x{num3}"); } TransferItemData(sourceInv, num2, targetInv, val.item, num3); num++; } } num2--; } return num; } private void TransferItemData(Inventory sourceInv, int sourceSlot, Inventory targetInv, Item item, int amount) { targetInv.AddItem(item, amount, false); sourceInv.RemoveItemAt(sourceSlot, amount); } private bool MatchesAnyRule(int itemId, List rules) { foreach (SmartChestRule rule in rules) { if (MatchesRule(itemId, rule)) { return true; } } return false; } private bool MatchesRule(int itemId, SmartChestRule rule) { switch (rule.Type) { case RuleType.ByItemId: return itemId == rule.ItemId; case RuleType.ByItemType: { ItemSellInfo itemSellInfo2 = GetItemSellInfo(itemId); if (itemSellInfo2 == null) { return false; } return ((object)(ItemType)(ref itemSellInfo2.itemType)).ToString() == rule.ItemTypeName; } case RuleType.ByProperty: { if (rule.PropertyName == "isNotDonated") { return IsMuseumItemNotDonated(itemId); } ItemSellInfo itemSellInfo = GetItemSellInfo(itemId); if (itemSellInfo == null) { return false; } return rule.PropertyName switch { "isGem" => itemSellInfo.isGem, "isForageable" => itemSellInfo.isForageable, "isAnimalProduct" => itemSellInfo.isAnimalProduct, "isMeal" => itemSellInfo.isMeal, "isFruit" => itemSellInfo.isFruit, "isArtisanryItem" => itemSellInfo.isArtisanryItem, "isPotion" => itemSellInfo.isPotion, _ => false, }; } case RuleType.ByCategory: return MatchesCategory(itemId, rule.CategoryName); case RuleType.ByGroup: return MatchesGroup(itemId, rule.GroupName); case RuleType.ByNamePattern: return ItemNamePatternMatch.Matches(GetItemSellInfo(itemId)?.name ?? ItemSearch.GetItemName(itemId) ?? "", rule.NamePattern); default: return false; } } private bool MatchesCategory(int itemId, string categoryName) { string categoryName2 = categoryName; if (string.Equals(categoryName2, "Undonated Items", StringComparison.OrdinalIgnoreCase)) { return IsMuseumItemNotDonated(itemId); } if (_categoryCache.TryGetValue(itemId, out string value)) { return value == categoryName2; } bool matched = false; try { if (_databaseGetDataMethod != null) { Action action = delegate(ItemData itemData) { if ((Object)(object)itemData != (Object)null) { _categoryCache[itemId] = ((object)(ItemCategory)(ref itemData.category)).ToString(); matched = ((object)(ItemCategory)(ref itemData.category)).ToString() == categoryName2; } }; _databaseGetDataMethod.Invoke(null, new object[3] { itemId, action, null }); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"Failed to lookup category for item {itemId}: {ex.Message}"); } } return matched; } private bool MatchesGroup(int itemId, string groupName) { if (string.IsNullOrEmpty(groupName)) { return false; } ItemGroup group = GetGroup(groupName); if (group == null) { return false; } if (group.ItemIds != null && group.ItemIds.Contains(itemId)) { return true; } if (group.NamePatterns != null && group.NamePatterns.Count > 0) { string itemName = GetItemSellInfo(itemId)?.name ?? ItemSearch.GetItemName(itemId) ?? ""; for (int i = 0; i < group.NamePatterns.Count; i++) { if (ItemNamePatternMatch.Matches(itemName, group.NamePatterns[i])) { return true; } } } return false; } private static bool IsMuseumItemNotDonated(int itemId) { if (!_museumReflectionInitialized) { _museumReflectionInitialized = true; try { Type type = AccessTools.TypeByName("SunHavenMuseumUtilityTracker.Plugin"); if (type != null) { _getDonationManagerMethod = type.GetMethod("GetDonationManager", BindingFlags.Static | BindingFlags.Public); Type type2 = AccessTools.TypeByName("SunHavenMuseumUtilityTracker.Data.MuseumContent"); if (type2 != null) { _findByGameItemIdMethod = type2.GetMethod("FindByGameItemId", BindingFlags.Static | BindingFlags.Public); } _museumModAvailable = _getDonationManagerMethod != null && _findByGameItemIdMethod != null; if (_museumModAvailable) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[Museum] S.M.U.T. integration available for isNotDonated rule"); } } else { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[Museum] S.M.U.T. found but missing expected methods"); } } } else { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)"[Museum] S.M.U.T. not installed — isNotDonated rule will not match any items"); } } } catch (Exception ex) { ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)("[Museum] Failed to initialize S.M.U.T. reflection: " + ex.Message)); } } } if (!_museumModAvailable) { return false; } try { if (_findByGameItemIdMethod.Invoke(null, new object[1] { itemId }) == null) { return false; } object obj = _getDonationManagerMethod.Invoke(null, null); if (obj == null) { return false; } if (_hasDonatedByGameIdMethod == null) { _hasDonatedByGameIdMethod = obj.GetType().GetMethod("HasDonatedByGameId", BindingFlags.Instance | BindingFlags.Public); if (_hasDonatedByGameIdMethod == null) { return false; } _isLoadedProperty = obj.GetType().GetProperty("IsLoaded", BindingFlags.Instance | BindingFlags.Public); } if (_isLoadedProperty != null && !(bool)_isLoadedProperty.GetValue(obj)) { return false; } return !(bool)_hasDonatedByGameIdMethod.Invoke(obj, new object[1] { itemId }); } catch (Exception ex2) { ManualLogSource log5 = Plugin.Log; if (log5 != null) { log5.LogDebug((object)$"[SmartChestManager] IsMuseumItemNotDonated({itemId}): {ex2.Message}"); } return false; } } } public class SmartChestSaveSystem { private readonly SmartChestManager _manager; private readonly string _savePath; private readonly HashSet _successfulLoadsThisSession = new HashSet(StringComparer.Ordinal); public SmartChestSaveSystem(SmartChestManager manager) { _manager = manager; _savePath = Path.Combine(Paths.ConfigPath, "SenpaisChest", "Saves"); if (!Directory.Exists(_savePath)) { Directory.CreateDirectory(_savePath); } } private string GetSaveFilePath(string characterName) { string text = SanitizeFileName(characterName); return Path.Combine(_savePath, text + "_smartchests.json"); } private string SanitizeFileName(string name) { if (string.IsNullOrEmpty(name)) { return "unknown"; } char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { name = name.Replace(oldChar, '_'); } return name; } public void Save() { string currentCharacterName = Plugin.GetCurrentCharacterName(); if (!string.IsNullOrEmpty(currentCharacterName)) { _manager.SetCharacterName(currentCharacterName); } SmartChestSaveData saveData = _manager.GetSaveData(); if (saveData == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Save] Cannot save: GetSaveData returned null"); } return; } if (string.IsNullOrEmpty(saveData.CharacterName)) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogDebug((object)"[Save] Cannot save: CharacterName is empty (expected on main menu)"); } return; } int num = 0; foreach (SmartChestData chest in saveData.Chests) { num += chest.Rules.Count; } string saveFilePath = GetSaveFilePath(saveData.CharacterName); ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)$"[Save] Saving {saveData.Chests.Count} chest(s) with {num} total rule(s) for '{saveData.CharacterName}' -> {saveFilePath}"); } bool num2 = num > 0; bool flag = FileContainsRules(saveFilePath) || FileContainsRules(saveFilePath + ".bak"); if (!num2 && flag && !HasSuccessfulLoadThisSession(saveData.CharacterName)) { ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)("[Save] Skipping write for '" + saveData.CharacterName + "': in-memory rules are empty before any successful load this session. Existing non-empty file preserved.")); } return; } try { string text = SerializeToJson(saveData); ManualLogSource log5 = Plugin.Log; if (log5 != null) { log5.LogDebug((object)$"[Save] JSON length: {text.Length} chars"); } string text2 = saveFilePath + ".tmp"; try { File.WriteAllText(text2, text); if (File.Exists(saveFilePath)) { string text3 = saveFilePath + ".bak"; if (File.Exists(text3)) { File.Delete(text3); } File.Move(saveFilePath, text3); } File.Move(text2, saveFilePath); } finally { if (File.Exists(text2)) { File.Delete(text2); } } _manager.MarkClean(); ManualLogSource log6 = Plugin.Log; if (log6 != null) { log6.LogInfo((object)("[Save] Saved successfully: " + saveFilePath)); } } catch (Exception arg) { ManualLogSource log7 = Plugin.Log; if (log7 != null) { log7.LogError((object)$"[Save] Failed to save: {arg}"); } } } public SmartChestSaveData Load(string characterName) { if (string.IsNullOrEmpty(characterName)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"Cannot load: No character name"); } return null; } string saveFilePath = GetSaveFilePath(characterName); string text = saveFilePath + ".bak"; if (File.Exists(saveFilePath)) { SmartChestSaveData smartChestSaveData = TryLoadFromFile(saveFilePath, characterName); if (smartChestSaveData != null) { MarkSuccessfulLoad(characterName); return smartChestSaveData; } ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("Main save file corrupted for " + characterName + ", trying backup...")); } } if (File.Exists(text)) { SmartChestSaveData smartChestSaveData2 = TryLoadFromFile(text, characterName); if (smartChestSaveData2 != null) { MarkSuccessfulLoad(characterName); ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)("Loaded from backup for " + characterName)); } return smartChestSaveData2; } ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)("Backup file also corrupted for " + characterName)); } } ManualLogSource log5 = Plugin.Log; if (log5 != null) { log5.LogInfo((object)("No save file found for " + characterName + ", creating new config")); } return new SmartChestSaveData(characterName); } private bool HasSuccessfulLoadThisSession(string characterName) { if (string.IsNullOrEmpty(characterName)) { return false; } return _successfulLoadsThisSession.Contains(characterName); } private void MarkSuccessfulLoad(string characterName) { if (!string.IsNullOrEmpty(characterName)) { _successfulLoadsThisSession.Add(characterName); } } private static bool FileContainsRules(string filePath) { if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { return false; } try { SmartChestSaveData smartChestSaveData = DeserializeFromJson(File.ReadAllText(filePath)); if (smartChestSaveData == null || smartChestSaveData.Chests == null) { return false; } for (int i = 0; i < smartChestSaveData.Chests.Count; i++) { SmartChestData smartChestData = smartChestSaveData.Chests[i]; if (smartChestData?.Rules != null && smartChestData.Rules.Count > 0) { return true; } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogDebug((object)("[Save] FileContainsRules inspection failed for '" + filePath + "': " + ex.Message)); } } return false; } private SmartChestSaveData TryLoadFromFile(string filePath, string characterName) { try { string text = File.ReadAllText(filePath); if (string.IsNullOrWhiteSpace(text) || !text.TrimStart(Array.Empty()).StartsWith("{")) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("File " + filePath + " does not contain valid JSON")); } return null; } SmartChestSaveData smartChestSaveData = DeserializeFromJson(text); if (smartChestSaveData == null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("Failed to deserialize " + filePath)); } return null; } int num = 0; foreach (SmartChestData chest in smartChestSaveData.Chests) { num += chest.Rules.Count; } ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)$"Loaded smart chest config for {characterName}: {smartChestSaveData.Chests.Count} chest(s), {num} rule(s)"); } return smartChestSaveData; } catch (Exception ex) { ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogError((object)("Error loading " + filePath + ": " + ex.Message)); } return null; } } private static string SerializeToJson(SmartChestSaveData data) { return SmartChestJson.Serialize(data); } private static SmartChestSaveData DeserializeFromJson(string json) { return SmartChestJson.Deserialize(json); } } } namespace SenpaisChest.Config { public class SmartChestConfig { public enum ChestLabelVisibility { Hidden, OnHover, Visible } private readonly HashSet _labeledChestDecorationIdSet = new HashSet(); internal static KeyCode StaticToggleKey = (KeyCode)290; internal static bool StaticRequireCtrl = false; internal static bool StaticBlockInputWhenTyping = true; internal static bool StaticSeparateWildcardRule = false; internal static bool StaticEnableScanCountdownDebug = false; public ConfigEntry ScanInterval { get; private set; } public ConfigEntry EnableNotifications { get; private set; } public ConfigEntry MaxItemsPerScan { get; private set; } public ConfigEntry ToggleKey { get; private set; } public ConfigEntry RequireCtrlModifier { get; private set; } public ConfigEntry AutoEnableSmartChestOnRuleAdd { get; private set; } public ConfigEntry CheckForUpdates { get; private set; } public ConfigEntry EnableChestLabels { get; private set; } public ConfigEntry LabelVisibility { get; private set; } public ConfigEntry IconVisibility { get; private set; } public ConfigEntry LabeledChestDecorationIds { get; private set; } public ConfigEntry UIScale { get; private set; } public ConfigEntry BlockInputWhenTypingInConfig { get; private set; } public ConfigEntry SeparateWildcardRuleInUI { get; private set; } public ConfigEntry EnableScanCountdownDebugLog { get; private set; } public void Initialize(ConfigFile config) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) ScanInterval = config.Bind("General", "ScanInterval", 60f, "Seconds between automatic item scans (min: 10)"); EnableNotifications = config.Bind("General", "EnableNotifications", true, "Show notifications when items are moved by Smart Chests"); MaxItemsPerScan = config.Bind("General", "MaxItemsPerScan", 50, "Maximum item stacks to move per scan cycle (prevents lag)"); ToggleKey = config.Bind("UI", "ToggleKey", (KeyCode)290, "Key to open Smart Chest configuration UI while interacting with a chest"); RequireCtrlModifier = config.Bind("UI", "RequireCtrlModifier", false, "Require Ctrl key to be held when pressing the toggle key"); AutoEnableSmartChestOnRuleAdd = config.Bind("UI", "AutoEnableSmartChestOnRuleAdd", true, "Automatically enable Smart Chest when adding a new rule to a chest"); UIScale = config.Bind("UI", "UIScale", 1f, new ConfigDescription("Scale factor for Smart Chest config window (1.0 = default)", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 2.5f), Array.Empty())); BlockInputWhenTypingInConfig = config.Bind("UI", "BlockInputWhenTypingInConfig", true, "When true, Backspace/Cancel won't close the chest while typing in the config search. Set to FALSE if the in-game chat or cheat console cannot receive input (fixes conflict with some mods)."); SeparateWildcardRuleInUI = config.Bind("UI", "SeparateWildcardRuleInUI", false, "When true, wildcard/glob matching appears as its own rule type. Default false keeps wildcard patterns in Manage Groups."); CheckForUpdates = config.Bind("Updates", "CheckForUpdates", true, "Check for mod updates on startup"); EnableScanCountdownDebugLog = config.Bind("Debug", "EnableScanCountdownDebugLog", false, "When true, logs '[Scan] Next scan in ...' countdown lines at Debug level."); EnableChestLabels = config.Bind("ChestLabels", "EnableChestLabels", true, "Show labels above chests (Wooden Chest, Large Wooden Chest, etc.). Excludes Hoppers and Animal Feeders."); LabelVisibility = config.Bind("ChestLabels", "LabelVisibility", ChestLabelVisibility.Visible, "When to show chest labels: Visible, OnHover, or Hidden"); IconVisibility = config.Bind("ChestLabels", "IconVisibility", ChestLabelVisibility.Visible, "When to show item icons (when label starts with item ID): Visible, OnHover, or Hidden"); LabeledChestDecorationIds = config.Bind("ChestLabels", "LabeledChestDecorationIds", "10110", "Comma-separated chest decoration IDs allowed to show labels (example: 10110,10111)"); StaticToggleKey = ToggleKey.Value; StaticRequireCtrl = RequireCtrlModifier.Value; StaticBlockInputWhenTyping = BlockInputWhenTypingInConfig.Value; StaticSeparateWildcardRule = SeparateWildcardRuleInUI.Value; StaticEnableScanCountdownDebug = EnableScanCountdownDebugLog.Value; RefreshLabeledChestDecorationIds(); ToggleKey.SettingChanged += delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) StaticToggleKey = ToggleKey.Value; }; RequireCtrlModifier.SettingChanged += delegate { StaticRequireCtrl = RequireCtrlModifier.Value; }; BlockInputWhenTypingInConfig.SettingChanged += delegate { StaticBlockInputWhenTyping = BlockInputWhenTypingInConfig.Value; }; SeparateWildcardRuleInUI.SettingChanged += delegate { StaticSeparateWildcardRule = SeparateWildcardRuleInUI.Value; }; EnableScanCountdownDebugLog.SettingChanged += delegate { StaticEnableScanCountdownDebug = EnableScanCountdownDebugLog.Value; }; LabeledChestDecorationIds.SettingChanged += delegate { RefreshLabeledChestDecorationIds(); }; } public float GetScanInterval() { return Mathf.Max(10f, ScanInterval.Value); } public bool IsLabeledChestDecorationId(int decorationId) { return _labeledChestDecorationIdSet.Contains(decorationId); } private void RefreshLabeledChestDecorationIds() { _labeledChestDecorationIdSet.Clear(); string text = LabeledChestDecorationIds?.Value; if (string.IsNullOrWhiteSpace(text)) { return; } string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (int.TryParse(array[i].Trim(), out var result)) { _labeledChestDecorationIdSet.Add(result); } } } } } namespace SenpaisChest.ChestLabels { internal class ChestHitbox : MonoBehaviour { public bool MouseOver { get; private set; } private void Start() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) BoxCollider2D obj = ((Component)this).gameObject.AddComponent(); ((Collider2D)obj).isTrigger = true; obj.size = new Vector2(1.8f, 2f); ((Collider2D)obj).offset = new Vector2(0.6667f, 0.6667f); } private void OnMouseEnter() { MouseOver = true; } private void OnMouseExit() { MouseOver = false; } } internal class ChestLabel : MonoBehaviour { private const float LabelVerticalOffset = 0.45f; private const float ScreenYOffset = 16f; private static readonly (Color32 color, Color32 outlineColor)[] ChestColors = new(int, int)[11] { (6045747, 3021313), (8723740, 3476491), (14375446, 4529159), (13220101, 4735746), (5403146, 2107141), (224944, 1908533), (6098836, 2759479), (13334429, 5838661), (16776438, 1840926), (7237744, 1840926), (2761770, 854797) }.Select(((int, int) hex) => (hex.Item1.ToColor(), hex.Item2.ToColor())).ToArray(); private static Canvas _overlayCanvas; private static RectTransform _overlayRoot; private RectTransform _labelRoot; private Image _iconImage; private TextMeshProUGUI _label; private ChestHitbox _hitbox; private Chest _chest; private bool _hasIcon; private int _pendingItemId = -1; public bool PlayerOver { get; private set; } public ChestLabel Init() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) _chest = ((Component)((Component)this).transform).GetComponentInParent(); if ((Object)(object)_chest == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)"ChestLabel.Init: Could not find Chest in parent."); } return this; } if ((Object)(object)(((Component)_chest).GetComponent() ?? ((Component)_chest).GetComponentInChildren()) == (Object)null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)"ChestLabel.Init: Chest has no BoxCollider2D - labels will not show."); } return this; } EnsureOverlayCanvas(); if ((Object)(object)_overlayRoot == (Object)null) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogError((object)"ChestLabel.Init: Could not initialize overlay canvas."); } return this; } _labelRoot = new GameObject("SenpaisChest_LabelRoot", new Type[1] { typeof(RectTransform) }).GetComponent(); ((Transform)_labelRoot).SetParent((Transform)(object)_overlayRoot, false); _labelRoot.anchorMin = new Vector2(0.5f, 0.5f); _labelRoot.anchorMax = new Vector2(0.5f, 0.5f); _labelRoot.pivot = new Vector2(0.5f, 0f); _labelRoot.sizeDelta = new Vector2(240f, 42f); _label = new GameObject("SenpaisChest_LabelText", new Type[1] { typeof(RectTransform) }).AddComponent(); ((TMP_Text)_label).transform.SetParent((Transform)(object)_labelRoot, false); ((TMP_Text)_label).alignment = (TextAlignmentOptions)514; ((TMP_Text)_label).enableWordWrapping = false; ((TMP_Text)_label).overflowMode = (TextOverflowModes)0; ((TMP_Text)_label).fontSize = 24f; ((TMP_Text)_label).outlineWidth = 0.15f; ((TMP_Text)_label).text = "Chest"; RectTransform rectTransform = ((TMP_Text)_label).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0f); rectTransform.anchorMax = new Vector2(0.5f, 0f); rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = new Vector2(240f, 30f); _iconImage = new GameObject("SenpaisChest_LabelIcon", new Type[1] { typeof(RectTransform) }).AddComponent(); ((Component)_iconImage).transform.SetParent((Transform)(object)_labelRoot, false); RectTransform rectTransform2 = ((Graphic)_iconImage).rectTransform; rectTransform2.anchorMin = new Vector2(0.5f, 0f); rectTransform2.anchorMax = new Vector2(0.5f, 0f); rectTransform2.pivot = new Vector2(0.5f, 0f); rectTransform2.anchoredPosition = new Vector2(0f, -18f); rectTransform2.sizeDelta = new Vector2(16f, 16f); ((Behaviour)_iconImage).enabled = false; ((Graphic)_iconImage).raycastTarget = false; GameObject val = new GameObject("SenpaisChest_LabelHitbox"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = new Vector3(0f, -0.2f, -0.3f); _hitbox = val.AddComponent(); return this; } public void DoUpdate() { if ((Object)(object)_label == (Object)null) { return; } if ((Object)(object)_chest == (Object)null) { _chest = ((Component)((Component)this).transform).GetComponentInParent(); } if (!((Object)(object)_chest == (Object)null)) { UpdateAnchor(); ChestData chestData = _chest.GetChestData(); string text = chestData.name; if (string.IsNullOrWhiteSpace(text)) { text = SmartChestManager.GetChestName(_chest); } if (string.Equals(text, "Chest", StringComparison.OrdinalIgnoreCase)) { text = string.Empty; } SetTextAndIcon(text, chestData.color); } } public string GetText() { if (!((Object)(object)_label != (Object)null)) { return ""; } return ((TMP_Text)_label).text; } public void SetTextAndIcon(string text, int color) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_label == (Object)null) { return; } if (text == null) { text = ""; } string[] array = text.Split(new char[1] { ' ' }, 2); int num = Mathf.Clamp(color, 0, ChestColors.Length - 1); var (val, outlineColor) = ChestColors[num]; ((Graphic)_label).color = Color32.op_Implicit(val); ((TMP_Text)_label).outlineColor = outlineColor; if (array.Length == 1 || !int.TryParse(array[0], out var itemId)) { ((TMP_Text)_label).text = text; _hasIcon = false; _pendingItemId = -1; if ((Object)(object)_iconImage != (Object)null) { ((Behaviour)_iconImage).enabled = false; } return; } try { if (!Database.ValidID(itemId)) { ((TMP_Text)_label).text = text; _hasIcon = false; _pendingItemId = -1; if ((Object)(object)_iconImage != (Object)null) { ((Behaviour)_iconImage).enabled = false; } return; } ((TMP_Text)_label).text = array[^1]; _pendingItemId = itemId; _hasIcon = false; if ((Object)(object)_iconImage != (Object)null) { _iconImage.sprite = null; ((Behaviour)_iconImage).enabled = false; } Database.GetData(itemId, (Action)delegate(ItemData data) { if ((Object)(object)data != (Object)null && (Object)(object)_iconImage != (Object)null && _pendingItemId == itemId) { _iconImage.sprite = data.icon; _hasIcon = (Object)(object)_iconImage.sprite != (Object)null; ((Behaviour)_iconImage).enabled = _hasIcon; } }, (Action)null); } catch { ((TMP_Text)_label).text = text; _hasIcon = false; _pendingItemId = -1; if ((Object)(object)_iconImage != (Object)null) { ((Behaviour)_iconImage).enabled = false; } } } private void LateUpdate() { SmartChestConfig config = Plugin.GetConfig(); if (config != null && config.EnableChestLabels.Value) { UpdateAnchor(); if ((Object)(object)_label != (Object)null) { ((Behaviour)_label).enabled = ShouldBeVisible(config.LabelVisibility.Value); } if ((Object)(object)_iconImage != (Object)null) { ((Behaviour)_iconImage).enabled = _hasIcon && ShouldBeVisible(config.IconVisibility.Value); } } } private void UpdateAnchor(BoxCollider2D fallbackCollider = null) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_labelRoot == (Object)null) { return; } if ((Object)(object)_chest == (Object)null) { _chest = ((Component)((Component)this).transform).GetComponentInParent(); } if ((Object)(object)_chest == (Object)null) { return; } Vector3 val = ResolveAnchorWorldPosition(_chest, fallbackCollider); Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } Vector3 val2 = main.WorldToScreenPoint(val); if (val2.z <= 0f) { ((Component)_labelRoot).gameObject.SetActive(false); return; } ((Component)_labelRoot).gameObject.SetActive(true); if (!((Object)(object)_overlayRoot == (Object)null)) { Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val2.x, val2.y + 16f); Vector2 anchoredPosition = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_overlayRoot, val3, (Camera)null, ref anchoredPosition)) { _labelRoot.anchoredPosition = anchoredPosition; } } } private static Vector3 ResolveAnchorWorldPosition(Chest chest, BoxCollider2D fallbackCollider) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) BoxCollider2D val = fallbackCollider ?? ((Component)chest).GetComponent() ?? ((Component)chest).GetComponentInChildren(); if ((Object)(object)val != (Object)null) { Bounds bounds = ((Collider2D)val).bounds; return new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y + 0.45f, ((Component)chest).transform.position.z); } bool flag = false; Bounds val2 = default(Bounds); SpriteRenderer[] componentsInChildren = ((Component)chest).GetComponentsInChildren(true); foreach (SpriteRenderer val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && ((Renderer)val3).enabled) { if (!flag) { val2 = ((Renderer)val3).bounds; flag = true; } else { ((Bounds)(ref val2)).Encapsulate(((Renderer)val3).bounds); } } } if (flag) { return new Vector3(((Bounds)(ref val2)).center.x, ((Bounds)(ref val2)).max.y + 0.45f, ((Component)chest).transform.position.z); } Vector3 position = ((Component)chest).transform.position; return new Vector3(position.x, position.y + 1f, position.z); } private void OnTriggerEnter2D(Collider2D other) { if ((Object)(object)Player.Instance != (Object)null && (Object)(object)((Component)other).gameObject == (Object)(object)((Component)Player.Instance).gameObject) { PlayerOver = true; } } private void OnTriggerExit2D(Collider2D other) { if ((Object)(object)Player.Instance != (Object)null && (Object)(object)((Component)other).gameObject == (Object)(object)((Component)Player.Instance).gameObject) { PlayerOver = false; } } private bool ShouldBeVisible(SmartChestConfig.ChestLabelVisibility visibility) { if ((Object)(object)Plugin.CurrentInteractingChest != (Object)null) { return false; } switch (visibility) { case SmartChestConfig.ChestLabelVisibility.Hidden: return false; case SmartChestConfig.ChestLabelVisibility.Visible: return true; default: if ((Object)(object)_hitbox != (Object)null) { if (!_hitbox.MouseOver) { return PlayerOver; } return true; } return false; } } private static void EnsureOverlayCanvas() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_overlayCanvas != (Object)null) || !((Object)(object)_overlayRoot != (Object)null)) { GameObject val = new GameObject("SenpaisChest_LabelOverlayCanvas", new Type[3] { typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)val); _overlayCanvas = val.GetComponent(); _overlayCanvas.renderMode = (RenderMode)0; _overlayCanvas.sortingOrder = 32767; CanvasScaler component = val.GetComponent(); component.uiScaleMode = (ScaleMode)1; component.referenceResolution = new Vector2(1920f, 1080f); component.matchWidthOrHeight = 0.5f; _overlayRoot = val.GetComponent(); } } private void OnDestroy() { if ((Object)(object)_labelRoot != (Object)null) { Object.Destroy((Object)(object)((Component)_labelRoot).gameObject); } } } internal static class ChestLabelPatch { private static readonly HashSet AllowedChestTypes; static ChestLabelPatch() { AllowedChestTypes = new HashSet(); AllowedChestTypes.Add(typeof(Chest)); Type type = AccessTools.TypeByName("Wish.BankChest"); if (type != null) { AllowedChestTypes.Add(type); } } internal static void EnsureLabel(Chest chest) { SmartChestConfig config = Plugin.GetConfig(); if (config == null || !config.EnableChestLabels.Value || (Object)(object)chest == (Object)null || (Object)(object)((Component)chest).gameObject == (Object)null || !AllowedChestTypes.Contains(((object)chest).GetType())) { return; } ChestLabel chestLabel2 = default(ChestLabel); if (!ShouldShowLabelForChest(chest)) { ChestLabel chestLabel = default(ChestLabel); if (((Component)chest).TryGetComponent(ref chestLabel)) { Object.Destroy((Object)(object)chestLabel); } } else if (!((Component)chest).TryGetComponent(ref chestLabel2)) { chestLabel2 = ((Component)chest).gameObject.AddComponent(); ((MonoBehaviour)chest).StartCoroutine(InitWhenReady(chestLabel2)); } else { chestLabel2.DoUpdate(); } } private static IEnumerator InitWhenReady(ChestLabel label) { if ((Object)(object)label == (Object)null) { yield break; } for (int i = 0; i < 10; i++) { yield return null; if ((Object)(object)SingletonBehaviour.Instance != (Object)null) { break; } } label.Init(); label.DoUpdate(); } internal static void SetMeta_Postfix(Chest __instance) { EnsureLabel(__instance); } internal static void OnEnable_Postfix(Chest __instance) { EnsureLabel(__instance); } internal static void InteractionPoint_Postfix(Chest __instance, ref InteractionInfo __result) { if (__result == null) { return; } SmartChestConfig config = Plugin.GetConfig(); if (config != null && config.EnableChestLabels.Value && ShouldShowLabelForChest(__instance)) { ChestLabel component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { string text = component.GetText(); __result.interactionText = new List { (!string.IsNullOrWhiteSpace(text)) ? text : "Chest" }; } } } private static bool ShouldShowLabelForChest(Chest chest) { if ((Object)(object)chest == (Object)null) { return false; } SmartChestConfig config = Plugin.GetConfig(); if ((Object)(object)chest == (Object)null || config == null) { return false; } return config.IsLabeledChestDecorationId(((Decoration)chest).id); } } } namespace SenpaisChest.ChestLabels.Extensions { internal static class ChestExtensions { private static readonly FieldInfo DataField = AccessTools.Field(typeof(Chest), "data"); public static ChestData GetChestData(this Chest chest) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chest == (Object)null) { return new ChestData(); } try { object? obj = DataField?.GetValue(chest); return (ChestData)(((obj is ChestData) ? obj : null) ?? ((object)new ChestData())); } catch { return new ChestData(); } } } internal static class ColorExtensions { public static Color32 ToColor(this int hexVal) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) return new Color32((byte)((uint)(hexVal >> 16) & 0xFFu), (byte)((uint)(hexVal >> 8) & 0xFFu), (byte)((uint)hexVal & 0xFFu), byte.MaxValue); } } internal static class DayCycleExtensions { private static readonly FieldInfo YearTextField = AccessTools.Field(typeof(DayCycle), "_yearTMP"); public static TextMeshProUGUI GetYearUI(this DayCycle dayCycle) { if ((Object)(object)dayCycle == (Object)null) { return null; } try { object? obj = YearTextField?.GetValue(dayCycle); return (TextMeshProUGUI)((obj is TextMeshProUGUI) ? obj : null); } catch { return null; } } } }