using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.RepresentationModel; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("InventorySlots")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("sighsorry")] [assembly: AssemblyProduct("InventorySlots")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("A57F2112-F59E-48EF-9D76-F2E4580F7401")] [assembly: AssemblyFileVersion("1.3.3")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 LocalizationManager { internal static class Localizer { private static readonly string[] FileExtensions = new string[2] { ".yml", ".json" }; private static readonly ManualLogSource Log = Logger.CreateLogSource("InventorySlots.Localization"); private static BaseUnityPlugin? _plugin; private static bool _loaded; public static event Action? OnLocalizationComplete; public static void Load(BaseUnityPlugin plugin) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown _plugin = plugin; if (_loaded) { TryLoadCurrentLanguage(); return; } _loaded = true; PatchLocalization(new Harmony(plugin.Info.Metadata.GUID + ".LocalizationManager")); TryLoadCurrentLanguage(); } private static void PatchLocalization(Harmony harmony) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Localizer), "LocalizationSetupLanguagePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(Localizer), "FejdStartupSetupGuiPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void LocalizationSetupLanguagePostfix(Localization __instance, string language) { LoadLocalization(__instance, language); } private static void FejdStartupSetupGuiPostfix() { TryLoadCurrentLanguage(); } private static void TryLoadCurrentLanguage() { if (Localization.instance != null) { LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } } private static void LoadLocalization(Localization localization, string language) { if ((Object)(object)_plugin == (Object)null || localization == null) { return; } Dictionary dictionary = LoadLanguageDictionary("English"); if (!string.Equals(language, "English", StringComparison.OrdinalIgnoreCase)) { Merge(dictionary, LoadLanguageDictionary(language)); } foreach (KeyValuePair item in dictionary) { localization.AddWord(item.Key, item.Value); } Localizer.OnLocalizationComplete?.Invoke(); } private static Dictionary LoadLanguageDictionary(string language) { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); Merge(dictionary, LoadEmbeddedLanguage(language)); foreach (string item in FindExternalTranslationFiles(language)) { try { Merge(dictionary, ParseTranslations(File.ReadAllText(item), item)); } catch (Exception ex) { Log.LogWarning((object)("Failed to load localization file " + item + ": " + ex.Message)); } } return dictionary; } private static Dictionary LoadEmbeddedLanguage(string language) { string[] fileExtensions = FileExtensions; foreach (string text in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + text); if (array != null) { return ParseTranslations(Encoding.UTF8.GetString(array), language + text); } } if (string.Equals(language, "English", StringComparison.OrdinalIgnoreCase)) { Log.LogWarning((object)"Found no embedded English localization for InventorySlots."); } return new Dictionary(StringComparer.OrdinalIgnoreCase); } private static IEnumerable FindExternalTranslationFiles(string language) { if ((Object)(object)_plugin == (Object)null) { yield break; } string modName = _plugin.Info.Metadata.Name; foreach (string root in GetExternalTranslationRoots()) { if (!Directory.Exists(root)) { continue; } string[] fileExtensions = FileExtensions; foreach (string text in fileExtensions) { string searchPattern = modName + "." + language + text; string[] files = Directory.GetFiles(root, searchPattern, SearchOption.AllDirectories); for (int j = 0; j < files.Length; j++) { yield return files[j]; } } } } private static IEnumerable GetExternalTranslationRoots() { if (!string.IsNullOrWhiteSpace(Paths.PluginPath)) { yield return Paths.PluginPath; } if ((Object)(object)_plugin != (Object)null) { yield return Path.Combine(Paths.ConfigPath, _plugin.Info.Metadata.GUID + "Translations"); } } private static Dictionary ParseTranslations(string text, string source) { try { return new DeserializerBuilder().IgnoreFields().Build().Deserialize>(text) ?? new Dictionary(StringComparer.OrdinalIgnoreCase); } catch (Exception ex) { Log.LogWarning((object)("Failed to parse localization source " + source + ": " + ex.Message)); return new Dictionary(StringComparer.OrdinalIgnoreCase); } } private static void Merge(Dictionary target, Dictionary source) { foreach (KeyValuePair item in source) { target[item.Key] = item.Value; } } private static byte[]? ReadEmbeddedFileBytes(string resourceFileName) { if ((Object)(object)_plugin == (Object)null) { return null; } Assembly assembly = ((object)_plugin).GetType().Assembly; string text = assembly.GetManifestResourceNames().FirstOrDefault((string name) => name.EndsWith(resourceFileName, StringComparison.OrdinalIgnoreCase)); if (text == null) { return null; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace InventorySlots { [BepInPlugin("sighsorry.InventorySlots", "InventorySlots", "1.3.3")] [BepInIncompatibility("Azumatt.AzuExtendedPlayerInventory")] [BepInIncompatibility("shudnal.ExtraSlots")] [BepInIncompatibility("shudnal.ExtraSlotsCustomSlots")] [BepInIncompatibility("randyknapp.mods.equipmentandquickslots")] [BepInIncompatibility("com.bruce.valheim.comfyquickslots")] [BepInIncompatibility("goldenrevolver.quick_stack_store")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class InventorySlotsPlugin : BaseUnityPlugin { private sealed class AzuCraftyBoxesApi { private readonly MethodInfo _getNearbyContainersMethod; private readonly MethodInfo _canItemBePulledMethod; private readonly MethodInfo? _shouldPreventMethod; private readonly FieldInfo? _rangeField; private readonly FieldInfo? _leaveOneField; private readonly FieldInfo? _resourceStringField; private readonly FieldInfo? _flashColorField; private readonly FieldInfo? _unFlashColorField; private readonly Dictionary _getPrefabNameMethods = new Dictionary(); private readonly Dictionary _itemCountMethods = new Dictionary(); private ConfigEntryBase? _rangeConfig; private ConfigEntryBase? _leaveOneConfig; private ConfigEntryBase? _resourceStringConfig; private ConfigEntryBase? _flashColorConfig; private ConfigEntryBase? _unFlashColorConfig; private AzuCraftyBoxesApi(MethodInfo getNearbyContainersMethod, MethodInfo canItemBePulledMethod, MethodInfo? shouldPreventMethod, FieldInfo? rangeField, FieldInfo? leaveOneField, FieldInfo? resourceStringField, FieldInfo? flashColorField, FieldInfo? unFlashColorField) { _getNearbyContainersMethod = getNearbyContainersMethod; _canItemBePulledMethod = canItemBePulledMethod; _shouldPreventMethod = shouldPreventMethod; _rangeField = rangeField; _leaveOneField = leaveOneField; _resourceStringField = resourceStringField; _flashColorField = flashColorField; _unFlashColorField = unFlashColorField; } public static bool TryCreate(Assembly assembly, out AzuCraftyBoxesApi? api, out string detail) { api = null; Type type = assembly.GetType("AzuCraftyBoxes.API"); Type type2 = assembly.GetType("AzuCraftyBoxes.AzuCraftyBoxesPlugin"); Type type3 = assembly.GetType("AzuCraftyBoxes.Util.Functions.MiscFunctions"); MethodInfo methodInfo = (type?.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo method) => method.Name == "GetNearbyContainers" && method.IsGenericMethodDefinition && method.GetParameters().Length == 2))?.MakeGenericMethod(typeof(Player)); MethodInfo methodInfo2 = type?.GetMethod("CanItemBePulled", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(string), typeof(string) }, null); if (methodInfo == null || methodInfo2 == null) { detail = "required API methods were not found"; return false; } api = new AzuCraftyBoxesApi(methodInfo, methodInfo2, type3?.GetMethod("ShouldPrevent", BindingFlags.Static | BindingFlags.NonPublic), type2?.GetField("mRange", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), type2?.GetField("leaveOne", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), type2?.GetField("resourceString", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), type2?.GetField("flashColor", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), type2?.GetField("unFlashColor", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); detail = ""; return true; } public IEnumerable? GetNearbyContainers(Player player, float range) { return _getNearbyContainersMethod.Invoke(null, new object[2] { player, range }) as IEnumerable; } public bool CanItemBePulled(string containerPrefab, string itemPrefab) { try { object obj = _canItemBePulledMethod.Invoke(null, new object[2] { containerPrefab, itemPrefab }); return obj is bool && (bool)obj; } catch { return false; } } public bool ShouldPrevent() { if (_shouldPreventMethod == null) { return false; } try { object obj = _shouldPreventMethod.Invoke(null, null); return obj is bool && (bool)obj; } catch { return false; } } public float GetRange() { object cachedConfigEntryValue = GetCachedConfigEntryValue(_rangeField, ref _rangeConfig); if (cachedConfigEntryValue == null) { return 20f; } try { return Convert.ToSingle(cachedConfigEntryValue); } catch { return 20f; } } public bool GetLeaveOne() { string a = GetCachedConfigEntryValue(_leaveOneField, ref _leaveOneConfig)?.ToString() ?? ""; if (!string.Equals(a, "On", StringComparison.OrdinalIgnoreCase)) { return string.Equals(a, "True", StringComparison.OrdinalIgnoreCase); } return true; } public string InvokeString(object instance, string methodName) { Type type = instance.GetType(); if (!_getPrefabNameMethods.TryGetValue(type, out MethodInfo value)) { value = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public); _getPrefabNameMethods[type] = value; } try { return (value?.Invoke(instance, null) as string) ?? ""; } catch { return ""; } } public int InvokeInt(object instance, string methodName, string argument) { Type type = instance.GetType(); if (!_itemCountMethods.TryGetValue(type, out MethodInfo value)) { value = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); _itemCountMethods[type] = value; } try { return (value?.Invoke(instance, new object[1] { argument }) is int num) ? num : 0; } catch { return 0; } } public bool TryFormatRequirementAmount(int available, int required, out string text) { text = ""; string text2 = (GetCachedConfigEntryValue(_resourceStringField, ref _resourceStringConfig) as string) ?? ""; if (string.IsNullOrWhiteSpace(text2)) { text = required.ToString(); return true; } try { text = string.Format(text2, FormatThousands(available), required); return true; } catch { text = $"{FormatThousands(available)}/{required}"; return true; } } public bool TryGetRequirementFlashColor(out Color color) { //IL_0001: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) color = default(Color); FieldInfo fieldInfo = ((Mathf.Sin(Time.time * 10f) > 0f) ? _flashColorField : _unFlashColorField); if (((fieldInfo == _flashColorField) ? GetCachedConfigEntryValue(fieldInfo, ref _flashColorConfig) : GetCachedConfigEntryValue(fieldInfo, ref _unFlashColorConfig)) is Color val) { color = val; return true; } return false; } private object? GetCachedConfigEntryValue(FieldInfo? field, ref ConfigEntryBase? config) { if (field == null) { return null; } try { if (config == null) { object? value = field.GetValue(null); config = (ConfigEntryBase?)((value is ConfigEntryBase) ? value : null); } ConfigEntryBase? obj = config; return (obj != null) ? obj.BoxedValue : null; } catch { config = null; return null; } } private static string FormatThousands(int number) { if (number >= 1000000) { return ((double)number / 1000000.0).ToString("0.#") + "M"; } if (number < 1000) { return number.ToString(); } return ((double)number / 1000.0).ToString("0.#") + "K"; } } private sealed class AdventureBackpacksApi { private readonly MethodInfo _isBackpackMethod; private readonly MethodInfo? _equipItemPostfixMethod; private readonly MethodInfo? _unequipItemPrefixMethod; private readonly MethodInfo? _isBackpackEquippedMethod; private readonly MethodInfo? _isThisBackpackEquippedMethod; private readonly MethodInfo? _getEquippedBackpackMethod; private readonly MethodInfo? _reorderBonesMethod; private readonly FieldInfo? _backpackEquippedField; private AdventureBackpacksApi(MethodInfo isBackpackMethod, MethodInfo? equipItemPostfixMethod, MethodInfo? unequipItemPrefixMethod, MethodInfo? isBackpackEquippedMethod, MethodInfo? isThisBackpackEquippedMethod, MethodInfo? getEquippedBackpackMethod, MethodInfo? reorderBonesMethod, FieldInfo? backpackEquippedField) { _isBackpackMethod = isBackpackMethod; _equipItemPostfixMethod = equipItemPostfixMethod; _unequipItemPrefixMethod = unequipItemPrefixMethod; _isBackpackEquippedMethod = isBackpackEquippedMethod; _isThisBackpackEquippedMethod = isThisBackpackEquippedMethod; _getEquippedBackpackMethod = getEquippedBackpackMethod; _reorderBonesMethod = reorderBonesMethod; _backpackEquippedField = backpackEquippedField; } public static bool TryCreate(Assembly assembly, out AdventureBackpacksApi? api, out string detail) { api = null; MethodInfo methodInfo = assembly.GetType("AdventureBackpacks.API.ABAPI")?.GetMethod("IsBackpack", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ItemData) }, null); if (methodInfo == null) { detail = "AdventureBackpacks.API.ABAPI.IsBackpack was not found"; return false; } Type? type = assembly.GetType("AdventureBackpacks.Patches.HumanoidPatches"); Type type2 = type?.GetNestedType("HumanoidEquipItemPatch", BindingFlags.NonPublic); Type type3 = type?.GetNestedType("HumanoidUnequipItemPatch", BindingFlags.NonPublic); Type type4 = assembly.GetType("AdventureBackpacks.Extensions.PlayerExtensions"); Type type5 = assembly.GetType("AdventureBackpacks.Patches.InventoryGuiPatches"); Type type6 = assembly.GetType("Vapok.Common.Tools.BoneReorder"); api = new AdventureBackpacksApi(methodInfo, type2?.GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic), type3?.GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic), type4?.GetMethod("IsBackpackEquipped", BindingFlags.Static | BindingFlags.Public), type4?.GetMethod("IsThisBackpackEquipped", BindingFlags.Static | BindingFlags.Public), type4?.GetMethod("GetEquippedBackpack", BindingFlags.Static | BindingFlags.Public), AccessTools.Method(type6, "ReorderBones", (Type[])null, (Type[])null), type5?.GetField("BackpackEquipped", BindingFlags.Static | BindingFlags.Public)); detail = ""; return true; } public bool IsBackpack(ItemData? item) { if (item == null) { return false; } try { object obj = _isBackpackMethod.Invoke(null, new object[1] { item }); return obj is bool && (bool)obj; } catch { return false; } } public bool IsBackpackEquippedFlagSet() { try { object obj = _backpackEquippedField?.GetValue(null); return obj is bool && (bool)obj; } catch { return false; } } public void OnCustomBackpackEquipped(Player player, ItemData item) { if ((Object)(object)player == (Object)null || item == null || !IsBackpack(item)) { return; } try { _equipItemPostfixMethod?.Invoke(null, new object[2] { item, true }); _backpackEquippedField?.SetValue(null, true); } catch (Exception) { } } public void OnCustomBackpackUnequipping(Player player, ItemData item) { if ((Object)(object)player == (Object)null || item == null || !IsBackpack(item)) { return; } ItemData shoulderItem = ((Humanoid)player).m_shoulderItem; try { ((Humanoid)player).m_shoulderItem = item; _unequipItemPrefixMethod?.Invoke(null, new object[1] { item }); } catch (Exception) { } finally { ((Humanoid)player).m_shoulderItem = shoulderItem; } } public void ReorderBones(VisEquipment visEquipment, int itemHash, List? instances) { if (_reorderBonesMethod == null || IsUnityNull((Object?)(object)visEquipment) || instances == null || instances.Count == 0) { return; } try { _reorderBonesMethod.Invoke(null, new object[3] { visEquipment, itemHash, instances }); } catch { } } public void ApplyPatches(Harmony harmony) { PatchOptional(harmony, _isBackpackEquippedMethod, null, "AdventureBackpackIsBackpackEquippedPostfix", "AdventureBackpacks IsBackpackEquipped"); PatchOptional(harmony, _isThisBackpackEquippedMethod, null, "AdventureBackpackIsThisBackpackEquippedPostfix", "AdventureBackpacks IsThisBackpackEquipped"); PatchOptional(harmony, _getEquippedBackpackMethod, "AdventureBackpackGetEquippedBackpackPrefix", "AdventureBackpackGetEquippedBackpackPostfix", "AdventureBackpacks GetEquippedBackpack"); } private static void PatchOptional(Harmony harmony, MethodInfo? target, string? prefix = null, string? postfix = null, string? label = null) { //IL_004b: 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) if (harmony != null && !(target == null)) { MethodInfo methodInfo = ((prefix == null) ? null : AccessTools.Method(typeof(InventorySlotsPlugin), prefix, (Type[])null, (Type[])null)); MethodInfo methodInfo2 = ((postfix == null) ? null : AccessTools.Method(typeof(InventorySlotsPlugin), postfix, (Type[])null, (Type[])null)); harmony.Patch((MethodBase)target, (methodInfo == null) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo), (methodInfo2 == null) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private sealed class SmoothbrainBackpacksApi { private readonly MethodInfo _validateBackpackMethod; private readonly FieldInfo _visualsField; private readonly FieldInfo _equippedBackpackItemField; private readonly FieldInfo? _currentBackpackItemHashField; private readonly MethodInfo? _setBackpackItemMethod; private readonly MethodInfo? _forceSetBackpackEquippedMethod; private SmoothbrainBackpacksApi(MethodInfo validateBackpackMethod, FieldInfo visualsField, FieldInfo equippedBackpackItemField, FieldInfo? currentBackpackItemHashField, MethodInfo? setBackpackItemMethod, MethodInfo? forceSetBackpackEquippedMethod) { _validateBackpackMethod = validateBackpackMethod; _visualsField = visualsField; _equippedBackpackItemField = equippedBackpackItemField; _currentBackpackItemHashField = currentBackpackItemHashField; _setBackpackItemMethod = setBackpackItemMethod; _forceSetBackpackEquippedMethod = forceSetBackpackEquippedMethod; } public static bool TryCreate(Assembly assembly, out SmoothbrainBackpacksApi? api, out string detail) { api = null; Type? type = assembly.GetType("Backpacks.Backpacks"); Type type2 = assembly.GetType("Backpacks.Visual"); MethodInfo methodInfo = type?.GetMethod("validateBackpack", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[1] { typeof(ItemData) }, null); FieldInfo fieldInfo = type2?.GetField("visuals", BindingFlags.Static | BindingFlags.Public); FieldInfo fieldInfo2 = type2?.GetField("equippedBackpackItem", BindingFlags.Instance | BindingFlags.Public); if (methodInfo == null || fieldInfo == null || fieldInfo2 == null) { detail = "validateBackpack or Visual fields were not found"; return false; } api = new SmoothbrainBackpacksApi(methodInfo, fieldInfo, fieldInfo2, type2?.GetField("currentBackpackItemHash", BindingFlags.Instance | BindingFlags.Public), type2?.GetMethod("setBackpackItem", BindingFlags.Instance | BindingFlags.NonPublic), type2?.GetMethod("forceSetBackpackEquipped", BindingFlags.Instance | BindingFlags.Public)); detail = ""; return true; } public bool IsBackpack(ItemData? item) { if (item == null) { return false; } try { object obj = _validateBackpackMethod.Invoke(null, new object[1] { item }); return obj is bool && (bool)obj; } catch { return false; } } public void SyncEquippedBackpack(Player player, ItemData? item) { if ((Object)(object)player == (Object)null || IsUnityNull((Object?)(object)((Humanoid)player).m_visEquipment) || !TryGetVisual(((Humanoid)player).m_visEquipment, out object visual) || visual == null) { return; } try { string text = (((Object)(object)item?.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : ""); int num = ((!string.IsNullOrWhiteSpace(text)) ? StringExtensionMethods.GetStableHashCode(text) : 0); if (_equippedBackpackItemField.GetValue(visual) != item) { _equippedBackpackItemField.SetValue(visual, item); } _setBackpackItemMethod?.Invoke(visual, new object[1] { text }); if (_forceSetBackpackEquippedMethod != null && GetCurrentHash(visual) != num) { _forceSetBackpackEquippedMethod.Invoke(visual, new object[1] { num }); } } catch (Exception) { } } private bool TryGetVisual(VisEquipment visEquipment, out object? visual) { visual = null; if (!(_visualsField.GetValue(null) is IDictionary dictionary) || !dictionary.Contains(visEquipment)) { return false; } visual = dictionary[visEquipment]; return visual != null; } private int GetCurrentHash(object visual) { try { return (_currentBackpackItemHashField?.GetValue(visual) is int num) ? num : 0; } catch { return 0; } } } private sealed class RustyBagsApi { private readonly MethodInfo _isBagMethod; private readonly MethodInfo _isQuiverMethod; private readonly Type _bagEquipmentType; private readonly Type _bagType; private readonly Type _quiverType; private readonly MethodInfo _getBagMethod; private readonly MethodInfo _getQuiverMethod; private readonly MethodInfo _setBagMethod; private readonly MethodInfo _setQuiverMethod; private RustyBagsApi(MethodInfo isBagMethod, MethodInfo isQuiverMethod, Type bagEquipmentType, Type bagType, Type quiverType, MethodInfo getBagMethod, MethodInfo getQuiverMethod, MethodInfo setBagMethod, MethodInfo setQuiverMethod) { _isBagMethod = isBagMethod; _isQuiverMethod = isQuiverMethod; _bagEquipmentType = bagEquipmentType; _bagType = bagType; _quiverType = quiverType; _getBagMethod = getBagMethod; _getQuiverMethod = getQuiverMethod; _setBagMethod = setBagMethod; _setQuiverMethod = setQuiverMethod; } public static bool TryCreate(Assembly assembly, out RustyBagsApi? api, out string detail) { api = null; Type type = assembly.GetType("RustyBags.API"); Type type2 = assembly.GetType("RustyBags.BagEquipment"); Type type3 = assembly.GetType("RustyBags.Bag"); Type type4 = assembly.GetType("RustyBags.Quiver"); MethodInfo methodInfo = type?.GetMethod("IsBag", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); MethodInfo methodInfo2 = type?.GetMethod("IsQuiver", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); MethodInfo methodInfo3 = type2?.GetMethod("GetBag", BindingFlags.Instance | BindingFlags.Public); MethodInfo methodInfo4 = type2?.GetMethod("GetQuiver", BindingFlags.Instance | BindingFlags.Public); MethodInfo methodInfo5 = type2?.GetMethod("SetBag", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo methodInfo6 = type2?.GetMethod("SetQuiver", BindingFlags.Instance | BindingFlags.Public); if (methodInfo == null || methodInfo2 == null || type2 == null || type3 == null || type4 == null || methodInfo3 == null || methodInfo4 == null || methodInfo5 == null || methodInfo6 == null) { detail = "RustyBags API or BagEquipment methods were not found"; return false; } api = new RustyBagsApi(methodInfo, methodInfo2, type2, type3, type4, methodInfo3, methodInfo4, methodInfo5, methodInfo6); detail = ""; return true; } public bool IsBag(ItemData? item) { if (item?.m_shared == null) { return false; } try { object obj = _isBagMethod.Invoke(null, new object[1] { item.m_shared.m_name }); return obj is bool && (bool)obj; } catch { return false; } } public bool IsQuiver(ItemData? item) { if (item?.m_shared == null) { return false; } try { object obj = _isQuiverMethod.Invoke(null, new object[1] { item.m_shared.m_name }); return obj is bool && (bool)obj; } catch { return false; } } public void SyncBag(Player player, ItemData? item) { if (item == null || _bagType.IsInstanceOfType(item)) { InvokeEquipmentSetter(player, _setBagMethod, item); } } public void SyncQuiver(Player player, ItemData? item) { if (item == null || _quiverType.IsInstanceOfType(item)) { InvokeEquipmentSetter(player, _setQuiverMethod, item); } } public void ClearBagIfCurrent(Player player, ItemData item) { object bagEquipment = GetBagEquipment(player); if (bagEquipment != null && _getBagMethod.Invoke(bagEquipment, Array.Empty()) == item) { _setBagMethod.Invoke(bagEquipment, new object[1]); } } public void ClearQuiverIfCurrent(Player player, ItemData item) { object bagEquipment = GetBagEquipment(player); if (bagEquipment != null && _getQuiverMethod.Invoke(bagEquipment, Array.Empty()) == item) { _setQuiverMethod.Invoke(bagEquipment, new object[1]); } } private void InvokeEquipmentSetter(Player player, MethodInfo setter, ItemData? item) { object bagEquipment = GetBagEquipment(player); if (bagEquipment == null) { return; } try { setter.Invoke(bagEquipment, new object[1] { item }); } catch (Exception) { } } private object? GetBagEquipment(Player player) { if ((Object)(object)player == (Object)null) { return null; } try { return ((Component)player).GetComponent(_bagEquipmentType); } catch { return null; } } } private sealed class BetterArcheryQuiverApi { private readonly FieldInfo _quiverEnabledField; private readonly FieldInfo _quiverRowIndexField; private ConfigEntry? _quiverEnabledConfig; private bool _quiverRowIndexResolved; private int _quiverRowIndex; private BetterArcheryQuiverApi(FieldInfo quiverEnabledField, FieldInfo quiverRowIndexField) { _quiverEnabledField = quiverEnabledField; _quiverRowIndexField = quiverRowIndexField; } public static bool TryCreate(Assembly assembly, out BetterArcheryQuiverApi? api, out string detail) { api = null; Type type = assembly.GetTypes().FirstOrDefault((Type candidate) => candidate.IsClass && candidate.Name == "BetterArchery"); if (type == null) { detail = "BetterArchery type was not found"; return false; } FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public); FieldInfo fieldInfo = fields.FirstOrDefault((FieldInfo field) => string.Equals(field.Name, "ConfigQuiverEnabled", StringComparison.OrdinalIgnoreCase)); FieldInfo fieldInfo2 = fields.FirstOrDefault((FieldInfo field) => string.Equals(field.Name, "QuiverRowIndex", StringComparison.OrdinalIgnoreCase)); if (fieldInfo == null || fieldInfo2 == null) { detail = "quiver config fields were not found"; return false; } api = new BetterArcheryQuiverApi(fieldInfo, fieldInfo2); detail = ""; return true; } public bool IsQuiverCell(Vector2i pos, bool includeRestockableSlots) { //IL_00a0: 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) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) try { if (_quiverEnabledConfig == null) { _quiverEnabledConfig = _quiverEnabledField.GetValue(null) as ConfigEntry; } } catch { _quiverEnabledConfig = null; } if (_quiverEnabledConfig == null || !_quiverEnabledConfig.Value) { return false; } if (!_quiverRowIndexResolved || _quiverRowIndex == 0) { try { _quiverRowIndex = ((_quiverRowIndexField.GetValue(null) is int num) ? num : 0); } catch { _quiverRowIndex = 0; } _quiverRowIndexResolved = _quiverRowIndex != 0; } if (_quiverRowIndex == 0) { return false; } if (pos.y == _quiverRowIndex - 1) { return true; } if (pos.y == _quiverRowIndex) { if (!includeRestockableSlots) { return pos.x > 2; } return true; } return false; } } private sealed class CompatApiRuntimeState where TApi : class { public TApi? Api; public bool ReflectionFailed; } private sealed class CompatRuntimeState { public readonly CompatApiRuntimeState AzuCraftyBoxes = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingTooltip = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingGem = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingEffect = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingSlot = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingCraftingSocketUi = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingGemCutting = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState JewelcraftingVisual = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState ItemRequiresSkillLevel = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState RecycleNReclaim = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState AdventureBackpacks = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState SmoothbrainBackpacks = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState RustyBags = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState MagicSupremacy = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState BetterArcheryQuiver = new CompatApiRuntimeState(); public readonly CompatApiRuntimeState VeiledRecipes = new CompatApiRuntimeState(); } private delegate bool CompatApiFactory(Assembly assembly, out TApi? api, out string detail) where TApi : class; private enum ContainerAccessMode { Unavailable, DirectOwner, MultiUserChestRemote } private delegate bool TryGetContainerHoldContext(Player player, out Container container); private enum ContainerPreviewPhase { Hidden, PreviewVisible, RestorePending, RealInventoryVisible } private enum ContainerTakeStacksMode { CurrentContainerMatchingStacks, AreaFavoriteRestock } private sealed class ControllerActionOption { public ControllerHotkeyAction Action { get; } public string Label { get; } public ControllerActionOption(ControllerHotkeyAction action, string label) { Action = action; Label = label; } } private readonly struct CraftingRequirementAvailabilityCacheEntry { public int Amount { get; } public float ExpiresAt { get; } public CraftingRequirementAvailabilityCacheEntry(int amount, float expiresAt) { Amount = amount; ExpiresAt = expiresAt; } } private sealed class CraftingRequirementRuntimeState { public readonly Dictionary AvailabilityCache = new Dictionary(StringComparer.OrdinalIgnoreCase); public readonly List VisibleRequirements = new List(); public readonly List VisibleRequirementCandidates = new List(); public readonly List OwnedSlots = new List(); public int AvailabilityVersion; } private sealed class CraftingRecipeRuntimeState { public readonly List GridCells = new List(); public readonly List View = new List(); public readonly Dictionary ViewIndexByOriginal = new Dictionary(); public readonly List GroupPanels = new List(); public readonly List GroupButtons = new List(); public readonly Dictionary Variants = new Dictionary(); public readonly Dictionary SearchTextCache = new Dictionary(); public readonly Dictionary HoverTooltipContentCache = new Dictionary(StringComparer.Ordinal); public readonly List HoverGemIconCache = new List(); public readonly Dictionary EnglishLocalizationCache = new Dictionary(StringComparer.OrdinalIgnoreCase); public readonly Dictionary EnglishLocalizationIndex = new Dictionary(StringComparer.OrdinalIgnoreCase); public readonly Dictionary SortKeyCache = new Dictionary(); public readonly Dictionary> GroupMatchCache = new Dictionary>(); public readonly List SelectableGroupFilterCache = new List(); public readonly Dictionary GroupHasRecipesCache = new Dictionary(StringComparer.OrdinalIgnoreCase); } private sealed class CraftingGridRuntimeState { public RectTransform? RecipeGrid; public bool RecipeGridDirty = true; public int RecipePage; public CraftingRecipeGridStamp RecipeGridStamp; public string RecipeGridLayoutSignature = ""; public int RecipeGridCellCapacity = -1; } private sealed class CraftingScrollbarRuntimeState { public RectTransform? RecipeScrollbar; public Scrollbar? RecipeScrollbarComponent; public bool UpdatingRecipeScrollbar; public bool RecipeScrollbarDirty = true; public CraftingRecipeScrollbarStamp RecipeScrollbarStamp; } private sealed class CraftingQueueRuntimeState { public bool ContinuingQueue; public int QueueTotal; public int QueueRemaining; public int QueueVariant; public int ProgressLabelCount; public int ProgressLabelVariant; public Recipe? QueueRecipe; public Recipe? ProgressLabelRecipe; public int InventoryLimitNoticeDepth; public ItemData? PendingInventoryLimitItem; public int PendingInventoryLimitMax = -1; } private sealed class CraftingUiRuntimeState { public GameObject? HoverTooltip; public RectTransform? HoverTooltipPanel; public TMP_Text? HoverTooltipTopic; public TMP_Text? HoverTooltipText; public readonly ScrollableTooltipBodyState HoverTooltipTextScroll = new ScrollableTooltipBodyState(); public RectTransform? TooltipRecipeOverlay; public RectTransform? TooltipGemIconRow; public TMP_InputField? SearchInput; public RectTransform? SearchInputRect; public RectTransform? RecipeGridZoomHint; public RectTransform? GroupRail; public TMP_InputField? CountInput; public RectTransform? CountInputRect; public RectTransform? CountInputViewport; public RectTransform? UpgradeProgressionRect; public TMP_Text? UpgradeProgressionText; public RectTransform? SortModeButtonGroup; public RectTransform? ControlsBackground; public RectTransform? SocketWarningRect; public TMP_Text? SocketWarningText; public Transform? RequiredStationLevelOriginalRoot; public RectTransform? RequiredStationLevelHitbox; public RectTransformSnapshot? PanelRootSnapshot; public Vector2 PanelOriginalSizeDelta; public bool SearchInputDirty = true; public int HoveredRecipeIndex = -1; public CraftingSearchInputStamp SearchInputStamp; public string HoverTooltipSignature = ""; public string HoverTooltipLayoutSignature = ""; public string HoverTooltipVisualSignature = ""; public string HoverGemIconSignature = ""; public float HoverTooltipScrollOffset; public float HoverTooltipMaxScroll; public bool RecipeHoverMouseSyncPending; } private sealed class CraftingRefreshRuntimeState { public bool RecipeViewDirty = true; public string RecipeViewSignature = ""; public bool GroupRailDirty = true; public CraftingGroupRailStamp GroupRailStamp; public bool BottomControlsDirty = true; public string BottomControlsSignature = ""; public CraftingStatusHudStamp SocketWarningStamp; public CraftingSortModeButtonsStamp SortModeButtonsStamp; public CraftingFrameFastPathStamp FrameFastPathStamp; public string RecipeListChangeSignature = ""; } private static class CraftingController { public static int HoveredRecipeIndex => CraftingUi.HoveredRecipeIndex; public static bool IsSearchInputDirty => CraftingUi.SearchInputDirty; public static bool NeedsModelRefresh(CraftingPanelUpdateReason reason, bool firstApply) { if (!firstApply && reason == CraftingPanelUpdateReason.FrameTick) { return HasModelRefreshWork(); } return true; } public static bool HasModelRefreshWork() { if (!CraftingRefresh.RecipeViewDirty && !CraftingGrid.RecipeGridDirty && !CraftingScrollbar.RecipeScrollbarDirty) { return CraftingRefresh.GroupRailDirty; } return true; } public static bool HasFrameRebuildWork() { if (!HasModelRefreshWork()) { return CraftingRefresh.BottomControlsDirty; } return true; } public static void MarkRecipeViewDirty() { CraftingRefresh.RecipeViewDirty = true; CraftingRefresh.RecipeViewSignature = ""; } public static void MarkRecipeGridDirty() { CraftingGrid.RecipeGridDirty = true; CraftingGrid.RecipeGridStamp = default(CraftingRecipeGridStamp); } public static void MarkRecipeScrollbarDirty() { CraftingScrollbar.RecipeScrollbarDirty = true; CraftingScrollbar.RecipeScrollbarStamp = default(CraftingRecipeScrollbarStamp); } public static void MarkGroupRailDirty() { CraftingRefresh.GroupRailDirty = true; CraftingRefresh.GroupRailStamp = default(CraftingGroupRailStamp); } public static void MarkBottomControlsDirty() { CraftingRefresh.BottomControlsDirty = true; CraftingRefresh.BottomControlsSignature = ""; } public static void MarkSearchInputDirty() { CraftingUi.SearchInputDirty = true; CraftingUi.SearchInputStamp = default(CraftingSearchInputStamp); } public static bool CanReuseRecipeView(string signature) { if (!CraftingRefresh.RecipeViewDirty) { return string.Equals(CraftingRefresh.RecipeViewSignature, signature, StringComparison.Ordinal); } return false; } public static void StoreRecipeViewSignature(string signature) { CraftingRefresh.RecipeViewSignature = signature; CraftingRefresh.RecipeViewDirty = false; } public static bool CanReuseRecipeGrid(CraftingRecipeGridStamp stamp) { if (!CraftingGrid.RecipeGridDirty) { return CraftingGrid.RecipeGridStamp.Equals(stamp); } return false; } public static void StoreRecipeGridStamp(CraftingRecipeGridStamp stamp) { CraftingGrid.RecipeGridStamp = stamp; CraftingGrid.RecipeGridDirty = false; } public static bool CanReuseRecipeScrollbar(CraftingRecipeScrollbarStamp stamp) { if (!CraftingScrollbar.RecipeScrollbarDirty) { return CraftingScrollbar.RecipeScrollbarStamp.Equals(stamp); } return false; } public static void StoreRecipeScrollbarStamp(CraftingRecipeScrollbarStamp stamp) { CraftingScrollbar.RecipeScrollbarStamp = stamp; CraftingScrollbar.RecipeScrollbarDirty = false; } public static bool CanReuseGroupRail(CraftingGroupRailStamp stamp) { if (!CraftingRefresh.GroupRailDirty) { return CraftingRefresh.GroupRailStamp.Equals(stamp); } return false; } public static void StoreGroupRailStamp(CraftingGroupRailStamp stamp) { CraftingRefresh.GroupRailStamp = stamp; CraftingRefresh.GroupRailDirty = false; } public static bool CanReuseSearchInput(CraftingSearchInputStamp stamp) { if (!CraftingUi.SearchInputDirty) { return CraftingUi.SearchInputStamp.Equals(stamp); } return false; } public static void StoreSearchInputStamp(CraftingSearchInputStamp stamp) { CraftingUi.SearchInputStamp = stamp; CraftingUi.SearchInputDirty = false; } public static bool NeedsBottomControlsLayout(string signature) { if (!CraftingRefresh.BottomControlsDirty) { return !string.Equals(CraftingRefresh.BottomControlsSignature, signature, StringComparison.Ordinal); } return true; } public static void StoreBottomControlsSignature(string signature) { CraftingRefresh.BottomControlsSignature = signature; CraftingRefresh.BottomControlsDirty = false; } public static bool CanReuseFrameFastPath(CraftingFrameFastPathStamp stamp) { return CraftingRefresh.FrameFastPathStamp.Equals(stamp); } public static void StoreFrameFastPathStamp(CraftingFrameFastPathStamp stamp) { CraftingRefresh.FrameFastPathStamp = stamp; } public static void ResetFrameFastPathStamp() { CraftingRefresh.FrameFastPathStamp = default(CraftingFrameFastPathStamp); } public static bool CanReuseSortModeButtons(CraftingSortModeButtonsStamp stamp) { return CraftingRefresh.SortModeButtonsStamp.Equals(stamp); } public static void StoreSortModeButtonsStamp(CraftingSortModeButtonsStamp stamp) { CraftingRefresh.SortModeButtonsStamp = stamp; } public static void ResetSortModeButtonsStamp() { CraftingRefresh.SortModeButtonsStamp = default(CraftingSortModeButtonsStamp); } public static bool CanReuseSocketWarning(CraftingStatusHudStamp stamp) { return CraftingRefresh.SocketWarningStamp.Equals(stamp); } public static void StoreSocketWarningStamp(CraftingStatusHudStamp stamp) { CraftingRefresh.SocketWarningStamp = stamp; } public static void ResetSocketWarningStamp() { CraftingRefresh.SocketWarningStamp = default(CraftingStatusHudStamp); } public static bool TryStoreRecipeListChangeSignature(string signature) { if (string.Equals(CraftingRefresh.RecipeListChangeSignature, signature, StringComparison.Ordinal)) { return false; } CraftingRefresh.RecipeListChangeSignature = signature; return true; } public static void ResetRecipeListChangeSignature() { CraftingRefresh.RecipeListChangeSignature = ""; } public static void MarkRecipeGridLayoutDirty() { MarkRecipeGridDirty(); MarkRecipeScrollbarDirty(); MarkBottomControlsDirty(); } public static void SetHoveredRecipe(int index) { CraftingUi.HoveredRecipeIndex = index; } public static void ClearHoveredRecipe() { CraftingUi.HoveredRecipeIndex = -1; } public static bool IsHoveredRecipe(int index) { return CraftingUi.HoveredRecipeIndex == index; } public static void ClearHoveredRecipeAndRequestMouseSync() { ClearHoveredRecipe(); CraftingUi.RecipeHoverMouseSyncPending = true; } public static bool ConsumeRecipeHoverMouseSync() { if (!CraftingUi.RecipeHoverMouseSyncPending) { return false; } CraftingUi.RecipeHoverMouseSyncPending = false; return true; } } private sealed class CustomEquipmentVisualState { public string SlotId { get; } public int ItemHash { get; } public int Variant { get; } public string PrefabName { get; } public ItemType ItemType { get; } public bool ReorderAdventureBackpackBones { get; } public CustomEquipmentVisualState(string slotId, int itemHash, int variant, string prefabName, ItemType itemType, bool reorderAdventureBackpackBones) { //IL_0024: 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) SlotId = slotId; ItemHash = itemHash; Variant = variant; PrefabName = prefabName; ItemType = itemType; ReorderAdventureBackpackBones = reorderAdventureBackpackBones; } } private sealed class CustomEquipmentVisual { private readonly List _instances = new List(); public string Key { get; } public VisEquipment Owner { get; } public string PrefabName { get; } public int Variant { get; } public CustomEquipmentVisual(string key, VisEquipment owner, string prefabName, int variant) { Key = key; Owner = owner; PrefabName = prefabName; Variant = variant; } public bool Matches(VisEquipment owner, string prefabName, int variant) { if (!IsUnityNull((Object?)(object)Owner) && (Object)(object)Owner == (Object)(object)owner && string.Equals(PrefabName, prefabName, StringComparison.Ordinal)) { return Variant == variant; } return false; } public bool IsOwnedBy(VisEquipment owner) { if (!IsUnityNull((Object?)(object)Owner)) { return (Object)(object)Owner == (Object)(object)owner; } return false; } public void Add(GameObject? instance) { if (!IsUnityNull((Object?)(object)instance)) { _instances.Add(instance); } } public void AddRange(IEnumerable? instances) { if (instances == null) { return; } foreach (GameObject instance in instances) { Add(instance); } } public void AddActiveInstancesTo(List roots) { foreach (GameObject instance in _instances) { if (!IsUnityNull((Object?)(object)instance)) { roots.Add(instance); } } } public void Destroy() { foreach (GameObject instance in _instances) { if (!IsUnityNull((Object?)(object)instance)) { if (!IsUnityNull((Object?)(object)Owner) && !IsUnityNull((Object?)(object)Owner.m_lodGroup)) { Utils.RemoveFromLodgroup(Owner.m_lodGroup, instance); } Object.Destroy((Object)(object)instance); } } _instances.Clear(); } } internal sealed class KeepOnDeathItemState { public ItemData Item { get; } public Vector2i OriginalGridPos { get; } public string OriginalSlotId { get; } public SlotKind? OriginalSlotKind { get; } public bool WasQuickSlot => OriginalSlotKind == SlotKind.Quick; public bool WasSpecialSlot => OriginalSlotKind.HasValue; public KeepOnDeathItemState(ItemData item, Vector2i originalGridPos, string originalSlotId, SlotKind? originalSlotKind) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Item = item; OriginalGridPos = originalGridPos; OriginalSlotId = originalSlotId; OriginalSlotKind = originalSlotKind; } } internal sealed class TombStonePreparationState { public List KeptItems { get; } public bool DeathDropUnequipPrepared { get; } public bool Completed { get; set; } public TombStonePreparationState(List keptItems, bool deathDropUnequipPrepared) { KeptItems = keptItems; DeathDropUnequipPrepared = deathDropUnequipPrepared; } } private sealed class InventoryHoverTooltipRuntimeState { public GameObject? HoverTooltip; public RectTransform? HoverTooltipPanel; public TMP_Text? HoverTooltipTopic; public TMP_Text? HoverTooltipText; public readonly ScrollableTooltipBodyState HoverTooltipTextScroll = new ScrollableTooltipBodyState(); public readonly TooltipSourceCacheCore HoverTooltipItems = new TooltipSourceCacheCore(64); public string HoverTooltipSignature = ""; public string HoverTooltipLayoutSignature = ""; public float HoverTooltipScrollOffset; public float HoverTooltipMaxScroll; public bool HoverTooltipNeedsScroll; public RectTransform? HoverJewelcraftingTooltipRoot; public string HoverJewelcraftingTooltipSignature = ""; public int HoverJewelcraftingTooltipLayoutRefreshFrames; public GameObject? SimpleNameTooltip; public RectTransform? SimpleNameTooltipRect; public TMP_Text? SimpleNameTooltipText; public string SimpleNameTooltipValue = ""; public SimpleNameTooltipPlacement SimpleNameTooltipPlacement; public readonly SimpleTooltipOwnershipCore SimpleNameTooltipOwner = new SimpleTooltipOwnershipCore(); public readonly object SimpleNameTooltipFallbackOwner = new object(); public object? PinnedGemNameTooltipOwner; public float PinnedGemNameTooltipHoldUntil = -1000f; public UITooltip? ContainerHoverTooltipSource; public UITooltip? OwnedHoverTooltipSource; public bool LateUpdateExceptionLogged; } private enum SimpleNameTooltipPlacement { RightOfCursor, LeftOfCursor } private readonly struct InventoryHoverTooltipItemSource { public InventoryGrid? Grid { get; } public ItemData Item { get; } public InventoryHoverTooltipItemSource(InventoryGrid? grid, ItemData item) { Grid = grid; Item = item; } } private readonly struct PlayerInventoryPanelBackgroundSnapshot { public bool ActiveSelf { get; } public bool ImageEnabled { get; } public Sprite? Sprite { get; } public Type Type { get; } public float PixelsPerUnitMultiplier { get; } public Material? Material { get; } public Color Color { get; } public Vector2 AnchorMax { get; } public Vector2 Pivot { get; } public Vector2 OffsetMin { get; } public Vector2 OffsetMax { get; } public Vector2 AnchoredPosition { get; } public Vector2 SizeDelta { get; } public Vector3 LocalScale { get; } public Quaternion LocalRotation { get; } public PlayerInventoryPanelBackgroundSnapshot(bool activeSelf, bool imageEnabled, Sprite? sprite, Type type, float pixelsPerUnitMultiplier, Material? material, Color color, Vector2 anchorMax, Vector2 pivot, Vector2 offsetMin, Vector2 offsetMax, Vector2 anchoredPosition, Vector2 sizeDelta, Vector3 localScale, Quaternion localRotation) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_0070: Unknown result type (might be due to invalid IL or missing references) ActiveSelf = activeSelf; ImageEnabled = imageEnabled; Sprite = sprite; Type = type; PixelsPerUnitMultiplier = pixelsPerUnitMultiplier; Material = material; Color = color; AnchorMax = anchorMax; Pivot = pivot; OffsetMin = offsetMin; OffsetMax = offsetMax; AnchoredPosition = anchoredPosition; SizeDelta = sizeDelta; LocalScale = localScale; LocalRotation = localRotation; } } internal enum InventoryStateEnsureReason { Unknown, PeriodicAudit, PlayerAwake, PlayerSpawned, PlayerLoad, PlayerSave, InventoryChanged, EquipmentChanged, InventoryLoad, InventoryMove, Tombstone, GuiShow, SlotAction, BackupRestore, YamlReload, JewelcraftingSlotRefresh, ProgressionReset, ConfigChanged, ReentrantFollowUp } internal enum InventoryStateAuditLevel { None, HeightOnly, SlotLight, FullIntegrity } private sealed class InventoryPanelRuntimeState { public readonly Dictionary CustomSlotPanels = new Dictionary(); public readonly Dictionary QuickSlotPanels = new Dictionary(); public readonly List MovedPlayerStatPanels = new List(); public readonly Dictionary QuickSlotPanelOutroStartPositions = new Dictionary(); public readonly Dictionary FavoriteKeyHintObjects = new Dictionary(); public readonly Dictionary PinnedTooltipKeyHintObjects = new Dictionary(); public RectTransform? QuickSlotsHotkeyBarRect; public HotkeyBar? QuickSlotsHotkeyBar; public RectTransform? PlayerStatPanelHost; public RectTransform? InventorySortPanel; public RectTransform? CurrencyPocketPanel; public Button? ContainerRestockButton; public Button? ContainerStoreAllButton; public Button? ContainerSortButton; public RectTransformSnapshot? TakeAllButtonOriginal; public RectTransformSnapshot? StackAllButtonOriginal; public RectTransform? TrackedContainerPanel; public RectTransform? TrackedContainerWeightPanel; public Vector3 ContainerPanelBasePosition; public Vector3 ContainerPanelAppliedOffset; public Vector3 ContainerWeightPanelBasePosition; public float ContainerWeightPanelAppliedYOffset; public RectTransform? DraggedInventoryPanel; public Vector2 InventoryPanelDragStartLocalMouse; public Vector2 InventoryPanelDragStartOffset; public bool ContainerPanelBasePositionSet; public bool ContainerWeightPanelBasePositionSet; public bool DraggingQuickSlotsPanelOffset; public bool DraggingEquipmentSlotsPanelOffset; public Vector2 EquipmentSlotsPanelRuntimeOffset = EquipmentSlotsPanelFixedOffset; public Vector2 QuickSlotsPanelRuntimeOffset = QuickSlotsPanelFixedOffset; public int LastExpandableInventoryRows = 4; public float QuickSlotPanelIntroStartTime = -1f; public float QuickSlotPanelIntroDuration = 0.25f; public float QuickSlotPanelOutroStartTime = -1f; public float QuickSlotPanelOutroDuration = 0.25f; public float QuickSlotHudElementSpace = 70f; public readonly ContainerHoldActionState ContainerRestockHold = new ContainerHoldActionState(); public readonly ContainerHoldActionState ContainerQuickStackHold = new ContainerHoldActionState(); public bool QuickSlotPanelIntroActive; public bool QuickSlotPanelOutroActive; public bool QuickSlotHudAnchorValid; public bool LastExpandableInventoryRowsLoaded; public Vector3 QuickSlotHudAnchoredPosition; } private sealed class ContainerHoldActionState { public Container? Container; public float StartTime = -1f; public bool Triggered; } private sealed class InventorySafetyRuntimeState { public readonly Dictionary PendingSlotEquips = new Dictionary(); public readonly Dictionary PendingSlotUnequips = new Dictionary(); public readonly Dictionary LoadPreservationInventoryDepth = new Dictionary(); public readonly Stack InventoryAddItemDataStackLookupItems = new Stack(); public readonly HashSet SlotRecoveryWarnings = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly HashSet ForeignSlotPreservationWarnings = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly Dictionary SlotUnequipToInventoryRequests = new Dictionary(); public bool RoutingEquipToDedicatedSlot; public bool RestoringSlotBackup; public bool EnsuringInventoryState; public InventoryStateEnsureReason PendingEnsureReason; public InventoryStateAuditLevel PendingAuditLevel; public InventoryStateEnsureReason DeferredEnsureReason; public InventoryStateAuditLevel DeferredAuditLevel; public int DeferredEnsureFrame = -1; public float HeavyAuditDelayUntil = -1f; public int LastFullIntegrityAuditSignature = int.MinValue; public int LastSlotLightProjectionSignature = int.MinValue; public int InventoryPlacementCacheVersion; public Inventory? UsableRegularEmptyCellCacheInventory; public int UsableRegularEmptyCellCacheVersion = -1; public int UsableRegularEmptyCellCacheContext; public int UsableRegularEmptyCellCacheCount; public Inventory? DedicatedSlotRouteFailureCacheInventory; public int DedicatedSlotRouteFailureCacheVersion = -1; public int DedicatedSlotRouteFailureCacheContext; public int DedicatedSlotRouteFailureCacheItemKey; public Inventory? CanAddItemFailureCacheInventory; public int CanAddItemFailureCacheVersion = -1; public int CanAddItemFailureCacheContext; public int CanAddItemFailureCacheItemKey; public int CanAddItemFailureCacheRequestedStack; public Inventory? InventoryLimitCountCacheInventory; public int InventoryLimitCountCachePlacementVersion = -1; public int InventoryLimitCountCacheRuleVersion = -1; public readonly Dictionary InventoryLimitCountCache = new Dictionary(StringComparer.OrdinalIgnoreCase); public string LastInventoryLimitMessageKey = ""; public float LastInventoryLimitMessageTime = -1f; public bool SlotUnequipInProgress; public bool SuppressSlotAutoEquip; public bool SuppressKnownItemRediscovery; public bool HandlingSlotDropOutside; } private sealed class InventoryContainerRuntimeState { public readonly List KnownContainers = new List(); } private sealed class InventoryDefinitionRuntimeState { public readonly List SlotDefinitions = new List(); public readonly List CustomPanelSlotCache = new List(); public readonly List VisibleCustomPanelSlotCache = new List(); public readonly List QuickPanelSlotCache = new List(); public readonly Dictionary QuickSlotDefinitionCache = new Dictionary(); public readonly Dictionary EquipmentSlotUnlockCache = new Dictionary(StringComparer.Ordinal); public readonly Dictionary> PredefinedGroupDefinitions = new Dictionary>(StringComparer.OrdinalIgnoreCase); public readonly List PredefinedGroupOrder = new List(); public readonly Dictionary> PredefinedGroupOrders = new Dictionary>(StringComparer.OrdinalIgnoreCase); public readonly Dictionary InventoryLimits = new Dictionary(StringComparer.OrdinalIgnoreCase); public readonly Dictionary ResourceTierByToken = new Dictionary(StringComparer.OrdinalIgnoreCase); public readonly HashSet CookingStationInputTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly HashSet CraftingRecipeFoodInputTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly HashSet CookingStationFoodInputTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly HashSet FermenterInputTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly HashSet FermenterOutputTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly HashSet FermenterFoodInputTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public readonly Dictionary ItemNameTokens = new Dictionary(StringComparer.OrdinalIgnoreCase); public Dictionary RestockTargetStackLimits = new Dictionary(StringComparer.OrdinalIgnoreCase); public int SlotDefinitionVersion; public int InventoryLimitVersion; public int CustomPanelSlotCacheVersion = -1; public int VisibleCustomPanelSlotCacheVersion = -1; public string VisibleCustomPanelSlotCacheSignature = ""; public string EquipmentSlotUnlockCacheSignature = ""; public int QuickPanelSlotCacheVersion = -1; public int QuickPanelSlotCacheUnlockedCount = -1; public int QuickSlotDefinitionCacheVersion = -1; public int CachedObjectDbItemCount = -1; public int CachedStationInputObjectDbItemCount = -1; public int CachedStationInputPrefabCount = -1; public int CachedStationInputRecipeCount = -1; public bool StationInputTokensInitialized; } private sealed class InventoryClientRuntimeState { public bool ClientStateLoaded; public string LoadedFavoritesPlayerId = ""; public InventorySlotsClientState ClientState = new InventorySlotsClientState(); public readonly HashSet FavoriteSlots = new HashSet(); } private sealed class EquipmentVisualRuntimeState { public readonly Dictionary Visuals = new Dictionary(StringComparer.Ordinal); public readonly HashSet StatusEffects = new HashSet(); public readonly Dictionary StatusEffectLevels = new Dictionary(); public int LocalPlayerUpdateFrame = -1; public int LocalPlayerUpdateSignature = int.MinValue; public int LocalPlayerUpdateStateCount; } private sealed class InventorySortRuntimeState { public readonly Dictionary RecipeOutputLookupCache = new Dictionary(StringComparer.OrdinalIgnoreCase); public string RecipeOutputLookupSignature = ""; } private sealed class ItemClassification { public readonly Dictionary BuiltInGroupMatches = new Dictionary(StringComparer.OrdinalIgnoreCase); public bool BigGroupResolved; public string BigGroupId = ""; } private sealed class ItemClassifierRuntimeState { public readonly Dictionary Cache = new Dictionary(StringComparer.OrdinalIgnoreCase); public readonly HashSet FeastMaterialTokens = new HashSet(StringComparer.OrdinalIgnoreCase); public string FeastMaterialSignature = ""; public int Version; public int AppliedVersion = -1; } private sealed class ItemRequiresSkillLevelApi { private readonly MethodInfo _tryGetReqForItemMethod; private readonly MethodInfo _tryGetReqForPrefabNameMethod; private readonly MethodInfo _getTextEquipMethod; private readonly MethodInfo _getTextCraftMethod; private ItemRequiresSkillLevelApi(MethodInfo tryGetReqForItemMethod, MethodInfo tryGetReqForPrefabNameMethod, MethodInfo getTextEquipMethod, MethodInfo getTextCraftMethod) { _tryGetReqForItemMethod = tryGetReqForItemMethod; _tryGetReqForPrefabNameMethod = tryGetReqForPrefabNameMethod; _getTextEquipMethod = getTextEquipMethod; _getTextCraftMethod = getTextCraftMethod; } public static bool TryCreate(Assembly assembly, out ItemRequiresSkillLevelApi? api, out string detail) { api = null; Type? type = assembly.GetType("ItemRequiresSkillLevel.Patches"); MethodInfo methodInfo = type?.GetMethod("TryGetReqForItem", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo methodInfo2 = type?.GetMethod("TryGetReqForPrefabName", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo methodInfo3 = type?.GetMethod("GetTextEquip", BindingFlags.Static | BindingFlags.Public); MethodInfo methodInfo4 = type?.GetMethod("GetTextCraft", BindingFlags.Static | BindingFlags.Public); if (type == null || methodInfo == null || methodInfo2 == null || methodInfo3 == null || methodInfo4 == null) { detail = "ItemRequiresSkillLevel tooltip methods were not found"; return false; } api = new ItemRequiresSkillLevelApi(methodInfo, methodInfo2, methodInfo3, methodInfo4); detail = ""; return true; } public string GetTooltipText(ItemData? item, string? prefabName, bool includeEquip, bool includeCraft) { if (!includeEquip && !includeCraft) { return ""; } if (!TryGetRequirement(item, prefabName, out object requirement) || requirement == null) { return ""; } StringBuilder stringBuilder = new StringBuilder(); if (includeEquip) { stringBuilder.Append(GetText(_getTextEquipMethod, requirement)); } if (includeCraft) { stringBuilder.Append(GetText(_getTextCraftMethod, requirement)); } return stringBuilder.ToString(); } private bool TryGetRequirement(ItemData? item, string? prefabName, out object? requirement) { requirement = null; if (item != null && TryGetRequirementForItem(item, out requirement)) { return true; } if (!string.IsNullOrWhiteSpace(prefabName)) { return TryGetRequirementForPrefabName(prefabName, out requirement); } return false; } private bool TryGetRequirementForItem(ItemData item, out object? requirement) { requirement = null; try { object[] array = new object[2] { item, null }; object obj = _tryGetReqForItemMethod.Invoke(null, array); bool num = obj is bool && (bool)obj; requirement = array[1]; return num && requirement != null; } catch { requirement = null; return false; } } private bool TryGetRequirementForPrefabName(string prefabName, out object? requirement) { requirement = null; try { object[] array = new object[2] { prefabName, null }; object obj = _tryGetReqForPrefabNameMethod.Invoke(null, array); bool num = obj is bool && (bool)obj; requirement = array[1]; return num && requirement != null; } catch { requirement = null; return false; } } private static string GetText(MethodInfo method, object requirement) { try { return (method.Invoke(null, new object[1] { requirement }) as string) ?? ""; } catch { return ""; } } } private sealed class JewelcraftingCraftingSocketUiApi { private readonly FieldInfo _socketIconsField; private readonly FieldInfo? _socketingButtonField; private readonly FieldInfo? _socketTabField; private readonly FieldInfo? _socketCostField; private readonly MethodInfo? _socketTabOpenMethod; private JewelcraftingCraftingSocketUiApi(FieldInfo socketIconsField, FieldInfo? socketingButtonField, FieldInfo? socketTabField, FieldInfo? socketCostField, MethodInfo? socketTabOpenMethod) { _socketIconsField = socketIconsField; _socketingButtonField = socketingButtonField; _socketTabField = socketTabField; _socketCostField = socketCostField; _socketTabOpenMethod = socketTabOpenMethod; } public static bool TryCreate(Assembly assembly, out JewelcraftingCraftingSocketUiApi? api, out string detail) { api = null; Type type = assembly.GetType("Jewelcrafting.GemStones+AddSocketIcons"); Type type2 = assembly.GetType("Jewelcrafting.GemStones+AddSocketAddingTab"); Type type3 = assembly.GetType("Jewelcrafting.Jewelcrafting"); FieldInfo fieldInfo = type?.GetField("socketIcons", BindingFlags.Static | BindingFlags.Public); if (fieldInfo == null) { detail = "AddSocketIcons.socketIcons was not found"; return false; } api = new JewelcraftingCraftingSocketUiApi(fieldInfo, type?.GetField("socketingButton", BindingFlags.Static | BindingFlags.Public), type2?.GetField("tab", BindingFlags.Static | BindingFlags.Public), type3?.GetField("socketCost", BindingFlags.Static | BindingFlags.Public), type2?.GetMethod("TabOpen", BindingFlags.Static | BindingFlags.Public)); detail = ""; return true; } public Array? GetSocketIcons() { return _socketIconsField.GetValue(null) as Array; } public Button? GetSocketingButton() { object? obj = _socketingButtonField?.GetValue(null); return (Button?)((obj is Button) ? obj : null); } public Transform? GetSocketTab() { object? obj = _socketTabField?.GetValue(null); return (Transform?)((obj is Transform) ? obj : null); } public string GetSocketCostMode() { try { object? obj = _socketCostField?.GetValue(null); ConfigEntryBase val = (ConfigEntryBase)((obj is ConfigEntryBase) ? obj : null); return (val == null) ? "" : (val.BoxedValue?.ToString() ?? ""); } catch { return ""; } } public bool IsSocketTabOpen() { try { object obj = _socketTabOpenMethod?.Invoke(null, null); return obj is bool && (bool)obj; } catch { return false; } } } private enum JewelcraftingSocketTabState { Unavailable, PrimaryCraftingTab, Closed, Selected } private sealed class JewelcraftingEffectApi { private readonly MethodInfo _calculateEffectsMethod; private bool _warningLogged; private JewelcraftingEffectApi(MethodInfo calculateEffectsMethod) { _calculateEffectsMethod = calculateEffectsMethod; } public static bool TryCreate(Assembly assembly, out JewelcraftingEffectApi? api, out string detail) { api = null; MethodInfo methodInfo = assembly.GetType("Jewelcrafting.GemEffects.TrackEquipmentChanges")?.GetMethod("CalculateEffects", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Player) }, null); if (methodInfo == null) { detail = "TrackEquipmentChanges.CalculateEffects(Player) was not found"; return false; } api = new JewelcraftingEffectApi(methodInfo); detail = ""; return true; } public void Recalculate(Player player) { if ((Object)(object)player == (Object)null || IsUnityNull((Object?)(object)player)) { return; } try { _calculateEffectsMethod.Invoke(null, new object[1] { player }); } catch (Exception ex) { if (!_warningLogged) { _warningLogged = true; Log.LogWarning((object)("Failed to recalculate Jewelcrafting equipment effects: " + ex.GetBaseException().Message)); } } } } private sealed class JewelcraftingGemApi { private readonly MethodInfo _getGemsMethod; private readonly MethodInfo? _itemDataMethod; private readonly MethodInfo? _itemInfoGetSocketableMethod; private readonly MethodInfo? _itemInfoGetItemContainerMethod; private readonly FieldInfo? _socketedGemsField; private readonly FieldInfo? _socketNameField; private readonly FieldInfo? _socketSeedField; private readonly FieldInfo? _openEquipmentField; private readonly FieldInfo? _openInventoryField; private readonly MethodInfo? _openSocketContainerMethod; private readonly FieldInfo? _inventoryInteractBehaviourField; private readonly FieldInfo? _inventorySocketingField; private readonly Type? _itemBagType; private readonly PropertyInfo? _itemInfoItemDataProperty; private readonly MethodInfo? _itemInfoGetAllSocketSeedsMethod; private readonly PropertyInfo? _socketSeedSeedProperty; private readonly Dictionary _gemSpriteMembers = new Dictionary(); private readonly Dictionary _gemPrefabMembers = new Dictionary(); private JewelcraftingGemApi(MethodInfo getGemsMethod, MethodInfo? itemDataMethod, MethodInfo? itemInfoGetSocketableMethod, MethodInfo? itemInfoGetItemContainerMethod, FieldInfo? socketedGemsField, FieldInfo? socketNameField, FieldInfo? socketSeedField, FieldInfo? openEquipmentField, FieldInfo? openInventoryField, MethodInfo? openSocketContainerMethod, FieldInfo? inventoryInteractBehaviourField, FieldInfo? inventorySocketingField, Type? itemBagType, PropertyInfo? itemInfoItemDataProperty, MethodInfo? itemInfoGetAllSocketSeedsMethod, PropertyInfo? socketSeedSeedProperty) { _getGemsMethod = getGemsMethod; _itemDataMethod = itemDataMethod; _itemInfoGetSocketableMethod = itemInfoGetSocketableMethod; _itemInfoGetItemContainerMethod = itemInfoGetItemContainerMethod; _socketedGemsField = socketedGemsField; _socketNameField = socketNameField; _socketSeedField = socketSeedField; _openEquipmentField = openEquipmentField; _openInventoryField = openInventoryField; _openSocketContainerMethod = openSocketContainerMethod; _inventoryInteractBehaviourField = inventoryInteractBehaviourField; _inventorySocketingField = inventorySocketingField; _itemBagType = itemBagType; _itemInfoItemDataProperty = itemInfoItemDataProperty; _itemInfoGetAllSocketSeedsMethod = itemInfoGetAllSocketSeedsMethod; _socketSeedSeedProperty = socketSeedSeedProperty; } public static bool TryCreate(Assembly assembly, out JewelcraftingGemApi? api, out string detail) { api = null; MethodInfo methodInfo = assembly.GetType("Jewelcrafting.API")?.GetMethod("GetGems", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ItemData) }, null); if (methodInfo == null) { detail = "API.GetGems was not found"; return false; } Type? type = assembly.GetType("ItemDataManager.ItemExtensions"); Type type2 = assembly.GetType("ItemDataManager.ItemInfo"); Type type3 = assembly.GetType("Jewelcrafting.Socketable"); Type type4 = assembly.GetType("Jewelcrafting.ItemContainer"); Type type5 = assembly.GetType("Jewelcrafting.ItemBag"); Type type6 = assembly.GetType("Jewelcrafting.SocketItem"); Type type7 = assembly.GetType("Jewelcrafting.Jewelcrafting"); Type type8 = assembly.GetType("Jewelcrafting.GemStones+AddFakeSocketsContainer"); Type type9 = assembly.GetType("Jewelcrafting.GemStones+OpenFakeSocketsContainer"); Type type10 = assembly.GetType("Jewelcrafting.SocketSeed"); MethodInfo itemDataMethod = type?.GetMethod("Data", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ItemData) }, null); MethodInfo itemInfoGetAllSocketSeedsMethod = null; MethodInfo itemInfoGetSocketableMethod = null; MethodInfo methodInfo2 = null; if (type2 != null) { MethodInfo[] methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo3 in methods) { if (methodInfo3.Name == "Get" && methodInfo3.IsGenericMethodDefinition) { ParameterInfo[] parameters = methodInfo3.GetParameters(); if (type3 != null && parameters.Length == 1) { itemInfoGetSocketableMethod = methodInfo3.MakeGenericMethod(type3); } if (type4 != null && (parameters.Length == 0 || (parameters.Length == 1 && methodInfo2 == null))) { methodInfo2 = methodInfo3.MakeGenericMethod(type4); } } else if (type10 != null && methodInfo3.Name == "GetAll" && methodInfo3.IsGenericMethodDefinition && methodInfo3.GetParameters().Length == 0) { itemInfoGetAllSocketSeedsMethod = methodInfo3.MakeGenericMethod(type10); } } } api = new JewelcraftingGemApi(methodInfo, itemDataMethod, itemInfoGetSocketableMethod, methodInfo2, type3?.GetField("socketedGems", BindingFlags.Instance | BindingFlags.Public), type6?.GetField("Name", BindingFlags.Instance | BindingFlags.Public), type6?.GetField("Seed", BindingFlags.Instance | BindingFlags.Public), type8?.GetField("openEquipment", BindingFlags.Static | BindingFlags.Public), type8?.GetField("openInventory", BindingFlags.Static | BindingFlags.Public), type9?.GetMethod("Open", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(InventoryGui), typeof(ItemData) }, null), type7?.GetField("inventoryInteractBehaviour", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), type7?.GetField("inventorySocketing", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), type5, type2?.GetProperty("ItemData", BindingFlags.Instance | BindingFlags.Public), itemInfoGetAllSocketSeedsMethod, type10?.GetProperty("Seed", BindingFlags.Instance | BindingFlags.Public)); detail = ""; return true; } public object? GetGems(ItemData item) { return _getGemsMethod.Invoke(null, new object[1] { item }); } public bool CanOpenSocketContainerFromInventory(ItemData item, bool gemcutterStationActive) { object itemContainer = GetItemContainer(item); if (itemContainer == null || string.Equals(GetConfigEntryValueName(_inventoryInteractBehaviourField), "Enabled", StringComparison.Ordinal)) { return false; } string configEntryValueName = GetConfigEntryValueName(_inventorySocketingField); return string.IsNullOrWhiteSpace(configEntryValueName) || string.Equals(configEntryValueName, "On", StringComparison.Ordinal) || IsItemBag(itemContainer) || gemcutterStationActive; } public bool HasSocketContainer(ItemData item) { return GetItemContainer(item) != null; } public bool TryOpenSocketContainer(InventoryGui gui, ItemData item) { if (_openSocketContainerMethod == null || (Object)(object)gui == (Object)null || item?.m_shared == null) { return false; } try { return _openSocketContainerMethod.Invoke(null, new object[2] { gui, item }) is bool flag && !flag; } catch (Exception) { return false; } } public ItemData? GetOpenSocketContainerItem() { if (_openEquipmentField == null || _itemInfoItemDataProperty == null) { return null; } try { object value = _openEquipmentField.GetValue(null); return (ItemData?)((value != null) ? /*isinst with value type is only supported in some contexts*/: null); } catch { return null; } } private object? GetItemContainer(ItemData item) { if (_itemDataMethod == null || _itemInfoGetItemContainerMethod == null || item?.m_shared == null) { return null; } try { object obj = _itemDataMethod.Invoke(null, new object[1] { item }); return (obj != null) ? InvokeItemInfoGet(_itemInfoGetItemContainerMethod, obj) : null; } catch { return null; } } private static object? InvokeItemInfoGet(MethodInfo method, object itemInfo) { if (method.GetParameters().Length != 0) { return method.Invoke(itemInfo, new object[1] { "" }); } return method.Invoke(itemInfo, Array.Empty()); } private bool IsItemBag(object itemContainer) { if (_itemBagType != null) { return _itemBagType.IsInstanceOfType(itemContainer); } return false; } private static string GetConfigEntryValueName(FieldInfo? field) { if (field == null) { return ""; } try { object value = field.GetValue(null); return (value?.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value))?.ToString() ?? ""; } catch { return ""; } } public Inventory? GetOpenSocketContainerInventory() { if (_openInventoryField == null) { return null; } try { object? value = _openInventoryField.GetValue(null); return (Inventory?)((value is Inventory) ? value : null); } catch { return null; } } public bool TryGetGemIconData(object gem, out Sprite? sprite, out string prefabName) { sprite = null; prefabName = ""; if (gem == null) { return false; } Type type = gem.GetType(); if (!_gemSpriteMembers.TryGetValue(type, out MemberInfo value)) { value = FindGemMember(type, typeof(Sprite), "gemSprite", "GemSprite", "sprite", "Sprite", "icon", "Icon", "gemIcon", "GemIcon"); _gemSpriteMembers[type] = value; } if (!_gemPrefabMembers.TryGetValue(type, out MemberInfo value2)) { value2 = FindGemMember(type, null, "gemPrefab", "GemPrefab", "prefab", "Prefab", "prefabName", "PrefabName", "name", "Name"); _gemPrefabMembers[type] = value2; } object? gemMemberValue = GetGemMemberValue(value, gem); sprite = (Sprite?)((gemMemberValue is Sprite) ? gemMemberValue : null); object gemMemberValue2 = GetGemMemberValue(value2, gem); object obj = gemMemberValue2; string text2; if (!(obj is string text)) { GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (val == null) { ItemDrop val2 = (ItemDrop)((obj is ItemDrop) ? obj : null); if (val2 == null || !((Object)(object)val2 != (Object)null) || IsUnityNull((Object?)(object)val2)) { goto IL_017e; } text2 = ((Object)((Component)val2).gameObject).name; } else { if (!((Object)(object)val != (Object)null) || IsUnityNull((Object?)(object)val)) { goto IL_017e; } text2 = ((Object)val).name; } } else { text2 = text; } goto IL_0195; IL_017e: text2 = gemMemberValue2?.ToString() ?? ""; goto IL_0195; IL_0195: prefabName = text2; if (!((Object)(object)sprite != (Object)null)) { return !string.IsNullOrWhiteSpace(prefabName); } return true; } public List GetSocketGemData(ItemData item) { List list = new List(); if (_itemDataMethod == null || _itemInfoGetSocketableMethod == null || _socketedGemsField == null || _socketNameField == null) { return list; } try { object obj = _itemDataMethod.Invoke(null, new object[1] { item }); object obj2 = ((obj != null) ? _itemInfoGetSocketableMethod.Invoke(obj, new object[1] { "" }) : null); if (obj2 == null || !(_socketedGemsField.GetValue(obj2) is IEnumerable enumerable)) { return list; } foreach (object item2 in enumerable) { if (item2 == null) { list.Add(new JewelcraftingSocketGemData("", null)); continue; } string prefabName = (_socketNameField.GetValue(item2) as string) ?? ""; Dictionary seeds = CopySocketSeeds(_socketSeedField?.GetValue(item2)); list.Add(new JewelcraftingSocketGemData(prefabName, seeds)); } } catch (Exception) { } return list; } public List GetOpenSocketGemData(ItemData item) { List list = new List(); ItemData openSocketContainerItem = GetOpenSocketContainerItem(); Inventory openSocketContainerInventory = GetOpenSocketContainerInventory(); if (openSocketContainerItem?.m_shared == null || openSocketContainerInventory == null || !IsSameOpenSocketContainerItem(item, openSocketContainerItem)) { return list; } int num = Math.Max(1, openSocketContainerInventory.m_width); int num2 = Math.Max(0, num * Math.Max(0, openSocketContainerInventory.m_height)); for (int i = 0; i < num2; i++) { list.Add(new JewelcraftingSocketGemData("", null)); } foreach (ItemData item2 in openSocketContainerInventory.m_inventory) { if (item2?.m_shared != null) { int num3 = item2.m_gridPos.x + item2.m_gridPos.y * num; if (num3 >= 0 && num3 < list.Count) { string prefabName = (((Object)(object)item2.m_dropPrefab != (Object)null && !IsUnityNull((Object?)(object)item2.m_dropPrefab)) ? ((Object)item2.m_dropPrefab).name : GetItemPrefabName(item2)); list[num3] = new JewelcraftingSocketGemData(prefabName, GetSocketSeedData(item2)); } } } return list; } private static Dictionary? CopySocketSeeds(object? seedObject) { if (!(seedObject is IDictionary { Count: not 0 } dictionary)) { return null; } Dictionary dictionary2 = new Dictionary(); foreach (DictionaryEntry item in dictionary) { string text = item.Key?.ToString() ?? ""; if (!string.IsNullOrWhiteSpace(text)) { uint result; if (item.Value is uint value) { dictionary2[text] = value; } else if (item.Value != null && uint.TryParse(item.Value.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { dictionary2[text] = result; } } } if (dictionary2.Count <= 0) { return null; } return dictionary2; } private Dictionary? GetSocketSeedData(ItemData gem) { if (_itemDataMethod == null || _itemInfoGetAllSocketSeedsMethod == null || _socketSeedSeedProperty == null) { return null; } try { object obj = _itemDataMethod.Invoke(null, new object[1] { gem }); if (!(((obj != null) ? _itemInfoGetAllSocketSeedsMethod.Invoke(obj, null) : null) is IDictionary { Count: not 0 } dictionary)) { return null; } Dictionary dictionary2 = new Dictionary(); foreach (DictionaryEntry item in dictionary) { string text = item.Key?.ToString() ?? ""; if (!string.IsNullOrWhiteSpace(text) && item.Value != null) { object value = _socketSeedSeedProperty.GetValue(item.Value); uint result; if (value is uint value2) { dictionary2[text] = value2; } else if (value != null && uint.TryParse(value.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { dictionary2[text] = result; } } } return (dictionary2.Count > 0) ? dictionary2 : null; } catch { return null; } } private static bool IsSameOpenSocketContainerItem(ItemData item, ItemData openItem) { if (item == openItem) { return true; } if (item.m_shared != null && openItem.m_shared != null && string.Equals(GetItemPrefabName(item), GetItemPrefabName(openItem), StringComparison.Ordinal) && string.Equals(item.m_shared.m_name, openItem.m_shared.m_name, StringComparison.Ordinal) && item.m_variant == openItem.m_variant && item.m_quality == openItem.m_quality && item.m_gridPos.x == openItem.m_gridPos.x) { return item.m_gridPos.y == openItem.m_gridPos.y; } return false; } private static MemberInfo? FindGemMember(Type type, Type? targetType, params string[] names) { foreach (string name in names) { FieldInfo field = type.GetField(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && (targetType == null || targetType.IsAssignableFrom(field.FieldType) || (targetType == typeof(IDictionary) && typeof(IDictionary).IsAssignableFrom(field.FieldType)))) { return field; } PropertyInfo property = type.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if ((object)property != null && property.GetIndexParameters().Length == 0 && (targetType == null || targetType.IsAssignableFrom(property.PropertyType) || (targetType == typeof(IDictionary) && typeof(IDictionary).IsAssignableFrom(property.PropertyType)))) { return property; } } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (targetType != null && (targetType.IsAssignableFrom(fieldInfo.FieldType) || (targetType == typeof(IDictionary) && typeof(IDictionary).IsAssignableFrom(fieldInfo.FieldType)))) { return fieldInfo; } } return null; } private static object? GetGemMemberValue(MemberInfo? member, object instance) { try { return (member is FieldInfo fieldInfo) ? fieldInfo.GetValue(instance) : ((!(member is PropertyInfo { CanRead: not false } propertyInfo) || propertyInfo.GetIndexParameters().Length != 0) ? null : propertyInfo.GetValue(instance)); } catch { return null; } } } private sealed class JewelcraftingGemCuttingApi { private readonly FieldInfo _gemUpgradeChancesField; private JewelcraftingGemCuttingApi(FieldInfo gemUpgradeChancesField) { _gemUpgradeChancesField = gemUpgradeChancesField; } public static bool TryCreate(Assembly assembly, out JewelcraftingGemCuttingApi? api, out string detail) { api = null; FieldInfo fieldInfo = assembly.GetType("Jewelcrafting.Jewelcrafting")?.GetField("gemUpgradeChances", BindingFlags.Static | BindingFlags.Public); if (fieldInfo == null) { detail = "Jewelcrafting.gemUpgradeChances was not found"; return false; } api = new JewelcraftingGemCuttingApi(fieldInfo); detail = ""; return true; } public bool IsGemCuttingRecipe(Recipe recipe) { string text = (((Object)(object)recipe.m_item != (Object)null) ? (recipe.m_item.m_itemData.m_shared.m_name ?? "") : ""); if (string.IsNullOrWhiteSpace(text)) { return false; } try { return _gemUpgradeChancesField.GetValue(null) is IDictionary dictionary && dictionary.Contains(text); } catch { return false; } } } private readonly struct JewelcraftingGemIconData { public readonly Sprite Sprite; public readonly string DisplayName; public JewelcraftingGemIconData(Sprite sprite, string displayName) { Sprite = sprite; DisplayName = displayName; } } private readonly struct JewelcraftingSocketGemData { public readonly string PrefabName; public readonly Dictionary? Seeds; public bool HasGem => !string.IsNullOrWhiteSpace(PrefabName); public JewelcraftingSocketGemData(string prefabName, Dictionary? seeds) { PrefabName = prefabName ?? ""; Seeds = seeds; } } private sealed class JewelcraftingSlotApi { private readonly FieldInfo _ringSlotField; private readonly FieldInfo _necklaceSlotField; private readonly FieldInfo? _wisplightGemField; private readonly FieldInfo? _wishboneGemField; private readonly MethodInfo? _isJewelryEquippedMethod; private ConfigEntryBase? _ringSlotConfig; private ConfigEntryBase? _necklaceSlotConfig; private ConfigEntryBase? _wisplightGemConfig; private ConfigEntryBase? _wishboneGemConfig; private JewelcraftingSlotApi(FieldInfo ringSlotField, FieldInfo necklaceSlotField, FieldInfo? wisplightGemField, FieldInfo? wishboneGemField, MethodInfo? isJewelryEquippedMethod) { _ringSlotField = ringSlotField; _necklaceSlotField = necklaceSlotField; _wisplightGemField = wisplightGemField; _wishboneGemField = wishboneGemField; _isJewelryEquippedMethod = isJewelryEquippedMethod; } public static bool TryCreate(Assembly assembly, out JewelcraftingSlotApi? api, out string detail) { api = null; Type? type = assembly.GetType("Jewelcrafting.Jewelcrafting"); Type type2 = assembly.GetType("Jewelcrafting.API"); FieldInfo fieldInfo = type?.GetField("ringSlot", BindingFlags.Static | BindingFlags.Public); FieldInfo fieldInfo2 = type?.GetField("necklaceSlot", BindingFlags.Static | BindingFlags.Public); FieldInfo wisplightGemField = type?.GetField("wisplightGem", BindingFlags.Static | BindingFlags.Public); FieldInfo wishboneGemField = type?.GetField("wishboneGem", BindingFlags.Static | BindingFlags.Public); if (fieldInfo == null || fieldInfo2 == null) { detail = "ringSlot or necklaceSlot config field was not found"; return false; } MethodInfo isJewelryEquippedMethod = type2?.GetMethod("IsJewelryEquipped", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Player), typeof(string) }, null); api = new JewelcraftingSlotApi(fieldInfo, fieldInfo2, wisplightGemField, wishboneGemField, isJewelryEquippedMethod); detail = ""; return true; } public bool IsRingEnabled() { return GetCompatConfigEntryToggleOn(_ringSlotField, ref _ringSlotConfig); } public bool IsNecklaceEnabled() { return GetCompatConfigEntryToggleOn(_necklaceSlotField, ref _necklaceSlotConfig); } public bool IsWisplightGemEnabled() { if (_wisplightGemField != null) { return GetCompatConfigEntryToggleOn(_wisplightGemField, ref _wisplightGemConfig); } return false; } public bool IsWishboneGemEnabled() { if (_wishboneGemField != null) { return GetCompatConfigEntryToggleOn(_wishboneGemField, ref _wishboneGemConfig); } return false; } public bool TryGetIsJewelryEquippedMethod(out MethodBase? method) { method = _isJewelryEquippedMethod; return method != null; } } private sealed class JewelcraftingTooltipApi { private readonly MethodInfo _fillItemContainerTooltipMethod; private readonly FieldInfo _socketTooltipField; private readonly FieldInfo? _advancedTooltipKeyField; private JewelcraftingTooltipApi(MethodInfo fillItemContainerTooltipMethod, FieldInfo socketTooltipField, FieldInfo? advancedTooltipKeyField) { _fillItemContainerTooltipMethod = fillItemContainerTooltipMethod; _socketTooltipField = socketTooltipField; _advancedTooltipKeyField = advancedTooltipKeyField; } public static bool TryCreate(Assembly assembly, out JewelcraftingTooltipApi? api, out string detail) { api = null; Type? type = assembly.GetType("Jewelcrafting.API"); Type type2 = assembly.GetType("Jewelcrafting.GemStoneSetup"); Type type3 = assembly.GetType("Jewelcrafting.Jewelcrafting"); MethodInfo methodInfo = type?.GetMethod("FillItemContainerTooltip", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(ItemData), typeof(Transform), typeof(bool) }, null); FieldInfo fieldInfo = type2?.GetField("SocketTooltip", BindingFlags.Static | BindingFlags.Public); if (methodInfo == null || fieldInfo == null) { detail = "required API members were not found"; return false; } api = new JewelcraftingTooltipApi(methodInfo, fieldInfo, type3?.GetField("advancedTooltipKey", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); detail = ""; return true; } public void FillItemContainerTooltip(ItemData item, RectTransform root, bool showInteract) { _fillItemContainerTooltipMethod.Invoke(null, new object[3] { item, root, showInteract }); } public GameObject? GetSocketTooltip() { object? value = _socketTooltipField.GetValue(null); return (GameObject?)((value is GameObject) ? value : null); } public bool TryIsAdvancedTooltipPressed(out bool pressed) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) pressed = false; if (!(_advancedTooltipKeyField?.GetValue(null) is ConfigEntry val)) { return false; } KeyboardShortcut value = val.Value; pressed = ((KeyboardShortcut)(ref value)).IsPressed(); return true; } } private sealed class JewelcraftingVisualApi { private readonly FieldInfo _visualsField; private readonly FieldInfo _equippedFingerItemField; private readonly FieldInfo _equippedNeckItemField; private readonly FieldInfo? _currentFingerItemHashField; private readonly FieldInfo? _currentNeckItemHashField; private readonly MethodInfo? _setFingerItemMethod; private readonly MethodInfo? _setNeckItemMethod; private readonly MethodInfo? _setFingerEquippedMethod; private readonly MethodInfo? _setNeckEquippedMethod; private JewelcraftingVisualApi(FieldInfo visualsField, FieldInfo equippedFingerItemField, FieldInfo equippedNeckItemField, FieldInfo? currentFingerItemHashField, FieldInfo? currentNeckItemHashField, MethodInfo? setFingerItemMethod, MethodInfo? setNeckItemMethod, MethodInfo? setFingerEquippedMethod, MethodInfo? setNeckEquippedMethod) { _visualsField = visualsField; _equippedFingerItemField = equippedFingerItemField; _equippedNeckItemField = equippedNeckItemField; _currentFingerItemHashField = currentFingerItemHashField; _currentNeckItemHashField = currentNeckItemHashField; _setFingerItemMethod = setFingerItemMethod; _setNeckItemMethod = setNeckItemMethod; _setFingerEquippedMethod = setFingerEquippedMethod; _setNeckEquippedMethod = setNeckEquippedMethod; } public static bool TryCreate(Assembly assembly, out JewelcraftingVisualApi? api, out string detail) { api = null; Type type = assembly.GetType("Jewelcrafting.Visual"); FieldInfo fieldInfo = type?.GetField("visuals", BindingFlags.Static | BindingFlags.Public); FieldInfo fieldInfo2 = type?.GetField("equippedFingerItem", BindingFlags.Instance | BindingFlags.Public); FieldInfo fieldInfo3 = type?.GetField("equippedNeckItem", BindingFlags.Instance | BindingFlags.Public); if (fieldInfo == null || fieldInfo2 == null || fieldInfo3 == null) { detail = "Visual fields were not found"; return false; } api = new JewelcraftingVisualApi(fieldInfo, fieldInfo2, fieldInfo3, type?.GetField("currentFingerItemHash", BindingFlags.Instance | BindingFlags.Public), type?.GetField("currentNeckItemHash", BindingFlags.Instance | BindingFlags.Public), type?.GetMethod("setFingerItem", BindingFlags.Instance | BindingFlags.NonPublic), type?.GetMethod("setNeckItem", BindingFlags.Instance | BindingFlags.NonPublic), type?.GetMethod("setFingerEquipped", BindingFlags.Instance | BindingFlags.NonPublic), type?.GetMethod("setNeckEquipped", BindingFlags.Instance | BindingFlags.NonPublic)); detail = ""; return true; } public bool TryGetVisual(VisEquipment visEquipment, out object? visual) { visual = null; if (!(_visualsField.GetValue(null) is IDictionary dictionary) || !dictionary.Contains(visEquipment)) { return false; } visual = dictionary[visEquipment]; return visual != null; } public void ClearSlot(object visual, bool isRing) { FieldInfo fieldInfo = (isRing ? _equippedFingerItemField : _equippedNeckItemField); FieldInfo fieldInfo2 = (isRing ? _currentFingerItemHashField : _currentNeckItemHashField); MethodInfo? obj = (isRing ? _setFingerItemMethod : _setNeckItemMethod); MethodInfo methodInfo = (isRing ? _setFingerEquippedMethod : _setNeckEquippedMethod); fieldInfo.SetValue(visual, null); obj?.Invoke(visual, new object[1] { "" }); if (methodInfo != null) { methodInfo.Invoke(visual, new object[1] { 0 }); } else { fieldInfo2?.SetValue(visual, 0); } } } private sealed class MagicSupremacyApi { private readonly MethodInfo _getMatchingSlotDefinitionMethod; private readonly MethodInfo _getDefinitionBySlotIdMethod; private readonly MethodInfo _getEquippedItemMethod; private readonly MethodInfo _setEquippedItemMethod; private readonly MethodInfo _getOrCreateItemGuidMethod; private readonly MethodInfo _setSavedEquippedGuidMethod; private readonly MethodInfo _clearSavedEquippedGuidMethod; private readonly FieldInfo _slotIdField; private object? _beltDefinition; private MagicSupremacyApi(MethodInfo getMatchingSlotDefinitionMethod, MethodInfo getDefinitionBySlotIdMethod, MethodInfo getEquippedItemMethod, MethodInfo setEquippedItemMethod, MethodInfo getOrCreateItemGuidMethod, MethodInfo setSavedEquippedGuidMethod, MethodInfo clearSavedEquippedGuidMethod, FieldInfo slotIdField) { _getMatchingSlotDefinitionMethod = getMatchingSlotDefinitionMethod; _getDefinitionBySlotIdMethod = getDefinitionBySlotIdMethod; _getEquippedItemMethod = getEquippedItemMethod; _setEquippedItemMethod = setEquippedItemMethod; _getOrCreateItemGuidMethod = getOrCreateItemGuidMethod; _setSavedEquippedGuidMethod = setSavedEquippedGuidMethod; _clearSavedEquippedGuidMethod = clearSavedEquippedGuidMethod; _slotIdField = slotIdField; } public static bool TryCreate(Assembly assembly, out MagicSupremacyApi? api, out string detail) { api = null; Type type = assembly.GetType("Magic_Supremacy.CustomSlotSystem"); Type type2 = type?.GetNestedType("CustomSlotDefinition", BindingFlags.Public | BindingFlags.NonPublic); MethodInfo methodInfo = type?.GetMethod("GetMatchingSlotDefinition", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ItemData) }, null); MethodInfo methodInfo2 = type?.GetMethod("GetDefinitionBySlotId", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); MethodInfo methodInfo3 = type?.GetMethod("GetEquippedItem", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Humanoid), typeof(string) }, null); MethodInfo methodInfo4 = type?.GetMethod("SetEquippedItem", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(Humanoid), typeof(string), typeof(ItemData) }, null); MethodInfo methodInfo5 = type?.GetMethod("GetOrCreateItemGuid", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[1] { typeof(ItemData) }, null); MethodInfo methodInfo6 = FindMethod(type, "SetSavedEquippedGuid", 3); MethodInfo methodInfo7 = FindMethod(type, "ClearSavedEquippedGuid", 2); FieldInfo fieldInfo = type2?.GetField("SlotId", BindingFlags.Instance | BindingFlags.Public); if (type == null || type2 == null || methodInfo == null || methodInfo2 == null || methodInfo3 == null || methodInfo4 == null || methodInfo5 == null || methodInfo6 == null || methodInfo7 == null || fieldInfo == null) { detail = "Magic_Supremacy.CustomSlotSystem belt slot methods were not found"; return false; } api = new MagicSupremacyApi(methodInfo, methodInfo2, methodInfo3, methodInfo4, methodInfo5, methodInfo6, methodInfo7, fieldInfo); detail = ""; return true; } public bool IsBeltItem(ItemData? item) { if (item == null) { return false; } try { object definition = _getMatchingSlotDefinitionMethod.Invoke(null, new object[1] { item }); return IsBeltDefinition(definition); } catch { return false; } } public bool IsBeltEquipped(Player player, ItemData item) { if ((Object)(object)player == (Object)null || item == null) { return false; } try { return _getEquippedItemMethod.Invoke(null, new object[2] { player, "belt" }) == item; } catch { return false; } } public void SyncBelt(Player player, ItemData item) { if ((Object)(object)player == (Object)null || item == null || !IsBeltItem(item)) { return; } try { object beltDefinition = GetBeltDefinition(); if (beltDefinition != null) { if (_getOrCreateItemGuidMethod.Invoke(null, new object[1] { item }) is string text && !string.IsNullOrWhiteSpace(text)) { _setSavedEquippedGuidMethod.Invoke(null, new object[3] { player, beltDefinition, text }); } _setEquippedItemMethod.Invoke(null, new object[3] { player, "belt", item }); } } catch (Exception) { } } public void ClearBeltIfCurrent(Player player, ItemData item) { if ((Object)(object)player == (Object)null || item == null) { return; } try { object obj = _getEquippedItemMethod.Invoke(null, new object[2] { player, "belt" }); if (obj == null || obj == item) { object beltDefinition = GetBeltDefinition(); _setEquippedItemMethod.Invoke(null, new object[3] { player, "belt", null }); if (beltDefinition != null) { _clearSavedEquippedGuidMethod.Invoke(null, new object[2] { player, beltDefinition }); } } } catch (Exception) { } } private object? GetBeltDefinition() { if (_beltDefinition != null) { return _beltDefinition; } _beltDefinition = _getDefinitionBySlotIdMethod.Invoke(null, new object[1] { "belt" }); if (!IsBeltDefinition(_beltDefinition)) { return null; } return _beltDefinition; } private bool IsBeltDefinition(object? definition) { if (definition == null) { return false; } try { return _slotIdField.GetValue(definition) is string a && string.Equals(a, "belt", StringComparison.Ordinal); } catch { return false; } } private static MethodInfo? FindMethod(Type? type, string name, int parameterCount) { if (type == null) { return null; } MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == name && methodInfo.GetParameters().Length == parameterCount) { return methodInfo; } } return null; } } private enum MultiUserContainerBatchKind { TakeAll, PlaceStacks, AreaPlaceStacks, AreaFavoriteRestock } private sealed class MultiUserContainerBatchItem { public Vector2i SourcePosition; public ItemData Identity; public int RemainingAmount; public int ExpectedStack; public bool MovedAny; } private sealed class MultiUserContainerBatchTarget { public Container Container; public ZDOID ContainerId; public bool HasContainerId; public bool MovedAny; } private sealed class MultiUserContainerBatchState { public MultiUserContainerBatchKind Kind; public ZDOID ContainerId; public readonly List Containers = new List(); public readonly List Items = new List(); public int ContainerIndex; public int ItemIndex; public int PendingAmount; public int MovedStacks; public int MovedAmount; public int ChangedContainerVfxCount; public float AreaRangeSquared; public bool WaitingForTransfer; } private enum MultiUserContainerRecoveryMode { InventoryFirst, RegularInventoryFirst, BatchInventoryFirst, ConsumeAfterInventory, WorldFirst } private enum MultiUserContainerLocalPlacementPolicy { AnyUsable, RegularAndHotbar, ContainerBatch } private enum MultiUserContainerWorldDeliveryResult { NotAttempted, Succeeded, DefinitelyNotSpawned, Uncertain } private sealed class PendingMultiUserContainerTransfer { public Container Container; public ZDOID ContainerId; public long RequesterPeerId; public long Owner; public HashSet RequestOwners = new HashSet(); public MultiUserContainerRequest Request; public byte[] RequestBytes; public byte[] RequestDigest; public Inventory? LocalInventory; public ItemData? LocalEscrow; public Vector2i PreferredLocalPosition; public Inventory? Projection; public float StartedAt; public float LastSentAt; public float LastReceiptCheckAt; public int SendAttempts; public bool TimeoutNotified; public bool ResponseApplied; public bool AuthoritativeStateObserved; public float ResponseAppliedAt; public bool AuthorityChangedOrReloaded; public bool TerminalFailureReceived; public bool LocalRecoveryPending; public ItemData? PendingRecoveryItem; public bool AcknowledgementPending; public bool PermanentlyDestroyed; public MultiUserContainerRecoveryMode RecoveryMode; public bool CompletionActionAttempted; public MultiUserContainerWorldDeliveryResult WorldDeliveryResult; } private sealed class PendingMultiUserContainerLocalRecovery { public Inventory? Inventory; public ItemData Item; public Vector2i PreferredPosition; public float NextAttemptAt; public MultiUserContainerLocalPlacementPolicy PlacementPolicy; } private enum MultiUserContainerOperation : byte { Add = 1, Remove, Move, Exchange, Swap } private enum MultiUserContainerFailure : byte { None, Disabled, InvalidRequest, AccessDenied, OwnerChanged, ItemChanged, DestinationChanged } private sealed class MultiUserContainerRequest { public int RequestId; public MultiUserContainerOperation Operation; public long RequesterPlayerId; public Vector2i SourcePosition; public Vector2i TargetPosition; public int ExpectedTargetStack; public int Amount; public ItemData Item; public ItemData? CounterpartItem; } private sealed class MultiUserContainerResponse { public int RequestId; public MultiUserContainerOperation Operation; public bool Success; public MultiUserContainerFailure Failure; public int Amount; public Vector2i SourcePosition; public Vector2i TargetPosition; public ItemData? Item; } private readonly struct MultiUserContainerOwnerRequestKey : IEquatable { public long Sender { get; } public int RequestId { get; } public MultiUserContainerOwnerRequestKey(long sender, int requestId) { Sender = sender; RequestId = requestId; } public bool Equals(MultiUserContainerOwnerRequestKey other) { if (Sender == other.Sender) { return RequestId == other.RequestId; } return false; } public override bool Equals(object? obj) { if (obj is MultiUserContainerOwnerRequestKey other) { return Equals(other); } return false; } public override int GetHashCode() { return (Sender.GetHashCode() * 397) ^ RequestId; } } private sealed class MultiUserContainerOwnerResponse { public float CreatedAt; public byte[] RequestDigest; public byte[] ResponseBytes; } private sealed class MultiUserContainerUncertainRequest { public byte[] RequestDigest; } private sealed class MultiUserContainerDurableReceipt { public bool Acknowledged; public long RequesterPlayerId; public long Sender; public int RequestId; public long CreatedUtcTicks; public byte[] RequestDigest; public byte[] ResponseBytes; } private sealed class MultiUserContainerOwnerState { public readonly Dictionary Responses = new Dictionary(); public readonly Dictionary UncertainRequests = new Dictionary(); public int TotalResponseBytes; } private enum PinnedTooltipContext { None, InventoryContainer, CraftingCraft, CraftingUpgrade } private readonly struct PinnedTooltipVerticalFrame { public readonly float TopY; public readonly float BottomY; public readonly float Height; public PinnedTooltipVerticalFrame(float topY, float bottomY) { TopY = topY; BottomY = bottomY; Height = Mathf.Max(1f, topY - bottomY); } } private readonly struct InventoryPinnedTooltipTarget { public InventoryGrid Grid { get; } public Vector2i Pos { get; } public ItemData Item { get; } public InventoryPinnedTooltipTarget(InventoryGrid grid, Vector2i pos, ItemData item) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Grid = grid; Pos = pos; Item = item; } } public enum Toggle { Off, On } public enum CraftingHoverTooltipMode { Full, TitleOnly, Off } public enum InventoryRowsDisplayMode { Fixed, Expandable } public enum PinnedTooltipSlotMode { One = 1, Two, Three } public enum PlayerStatBarLengthScaling { Linear, Logarithmic } public enum GamepadUiScrollSource { RightStickY, DPadVertical, RightStickYOrDPadVertical } public enum ControllerDPadHotkeyMode { InventoryNavigation, Hotkeys, HotkeysWhileHoldingModifier } public enum ControllerHotkeyAction { Off, JoyButtonA, JoyButtonB, JoyButtonX, JoyButtonY, JoyLBumper, JoyRBumper, JoyLTrigger, JoyRTrigger, JoyBack, JoyStart, JoyLStick, JoyRStick, JoyDPadUp, JoyDPadDown, JoyDPadLeft, JoyDPadRight, JoyHotbarUse, JoyAltKeys, AltPlace, JoyUse } private sealed class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } private sealed class ConfigurationManagerAttributes { public int? Order { get; set; } public bool? Browsable { get; set; } public Action? CustomDrawer { get; set; } } private readonly struct RecycleNReclaimYieldTextEntry { public string Name { get; } public int Amount { get; } public ItemData? Item { get; } public RecycleNReclaimYieldTextEntry(string name, int amount, ItemData? item = null) { Name = name; Amount = amount; Item = item; } } private sealed class RecycleNReclaimApi { private readonly PropertyInfo _recyclingTabButtonHolderProperty; private readonly MethodInfo _inRecycleTabMethod; private readonly MethodInfo? _updateRecipeMethod; private readonly FieldInfo? _recyclingAnalysisContextsField; private readonly PropertyInfo? _recyclingImpedimentsProperty; private readonly PropertyInfo? _entriesProperty; private readonly FieldInfo? _entryRecipeItemDataField; private readonly FieldInfo? _entryAmountField; private RecycleNReclaimApi(PropertyInfo recyclingTabButtonHolderProperty, MethodInfo inRecycleTabMethod, MethodInfo? updateRecipeMethod, FieldInfo? recyclingAnalysisContextsField, PropertyInfo? recyclingImpedimentsProperty, PropertyInfo? entriesProperty, FieldInfo? entryRecipeItemDataField, FieldInfo? entryAmountField) { _recyclingTabButtonHolderProperty = recyclingTabButtonHolderProperty; _inRecycleTabMethod = inRecycleTabMethod; _updateRecipeMethod = updateRecipeMethod; _recyclingAnalysisContextsField = recyclingAnalysisContextsField; _recyclingImpedimentsProperty = recyclingImpedimentsProperty; _entriesProperty = entriesProperty; _entryRecipeItemDataField = entryRecipeItemDataField; _entryAmountField = entryAmountField; } public static bool TryCreate(Assembly assembly, out RecycleNReclaimApi? api, out string detail) { api = null; Type? type = assembly.GetType("Recycle_N_Reclaim.Recycle_N_ReclaimPlugin"); Type type2 = assembly.GetType("Recycle_N_Reclaim.GamePatches.UI.StationRecyclingTabHolder"); PropertyInfo propertyInfo = type?.GetProperty("RecyclingTabButtonHolder", BindingFlags.Static | BindingFlags.Public); MethodInfo methodInfo = type2?.GetMethod("InRecycleTab", BindingFlags.Instance | BindingFlags.Public); if (propertyInfo == null || type2 == null || methodInfo == null) { detail = "Recycle_N_Reclaim tab holder API was not found"; return false; } FieldInfo field = type2.GetField("_recyclingAnalysisContexts", BindingFlags.Instance | BindingFlags.NonPublic); Type? type3 = assembly.GetType("Recycle_N_Reclaim.GamePatches.Recycling.RecyclingAnalysisContext"); Type type4 = type3?.GetNestedType("ReclaimingYieldEntry", BindingFlags.Public); PropertyInfo recyclingImpedimentsProperty = type3?.GetProperty("RecyclingImpediments", BindingFlags.Instance | BindingFlags.Public); PropertyInfo entriesProperty = type3?.GetProperty("Entries", BindingFlags.Instance | BindingFlags.Public); api = new RecycleNReclaimApi(propertyInfo, methodInfo, type2.GetMethod("UpdateRecipe", BindingFlags.Instance | BindingFlags.Public, null, new Type[2] { typeof(Player), typeof(float) }, null), field, recyclingImpedimentsProperty, entriesProperty, type4?.GetField("RecipeItemData", BindingFlags.Instance | BindingFlags.Public), type4?.GetField("Amount", BindingFlags.Instance | BindingFlags.Public)); detail = ""; return true; } public bool IsRecycleTabActive() { object holder = GetHolder(); if (holder == null) { return false; } try { object obj = _inRecycleTabMethod.Invoke(holder, null); return obj is bool && (bool)obj; } catch { return false; } } public bool TryRefreshSelectedRecipeUi() { if (_updateRecipeMethod == null || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } object holder = GetHolder(); if (holder == null) { return false; } try { _updateRecipeMethod.Invoke(holder, new object[2] { Player.m_localPlayer, 0f }); return true; } catch { return false; } } public bool TryGetRecyclingImpedimentCount(int index, out int count) { count = 0; if (_recyclingImpedimentsProperty == null || !TryGetContext(index, out object context)) { return false; } try { if (!(_recyclingImpedimentsProperty.GetValue(context, null) is ICollection collection)) { return false; } count = collection.Count; return true; } catch { count = 0; return false; } } public bool TryGetReclaimSummary(int index, List impediments, List yields) { impediments.Clear(); yields.Clear(); if (!TryGetContext(index, out object context)) { return false; } try { if (_recyclingImpedimentsProperty?.GetValue(context, null) is IEnumerable enumerable) { foreach (object item in enumerable) { string text = item?.ToString() ?? ""; if (!string.IsNullOrWhiteSpace(text)) { impediments.Add(text); } } } if (!(_entriesProperty?.GetValue(context, null) is IEnumerable enumerable2) || _entryRecipeItemDataField == null || _entryAmountField == null) { return true; } foreach (object item2 in enumerable2) { if (item2 == null) { continue; } int num = ((_entryAmountField.GetValue(item2) is int num2) ? num2 : 0); if (num > 0) { object? value = _entryRecipeItemDataField.GetValue(item2); ItemData val = (ItemData)((value is ItemData) ? value : null); if (val != null && val.m_shared != null) { yields.Add(new RecycleNReclaimYieldTextEntry(val.m_shared.m_name ?? "", num, val)); } } } return true; } catch { return false; } } public string GetContextSignature() { object holder = GetHolder(); if (holder == null || _recyclingAnalysisContextsField == null) { return "no-context"; } try { if (!(_recyclingAnalysisContextsField.GetValue(holder) is IList list)) { return "no-list"; } int num = 17; for (int i = 0; i < list.Count; i++) { object obj = list[i]; num = num * 31 + ((obj != null) ? RuntimeHelpers.GetHashCode(obj) : 0); if (_recyclingImpedimentsProperty?.GetValue(obj, null) is ICollection collection) { num = num * 31 + collection.Count; } } return $"{list.Count}:{num}"; } catch { return "error"; } } private object? GetHolder() { try { return _recyclingTabButtonHolderProperty.GetValue(null, null); } catch { return null; } } private bool TryGetContext(int index, out object? context) { context = null; if (index < 0 || _recyclingAnalysisContextsField == null) { return false; } object holder = GetHolder(); if (holder == null) { return false; } try { if (!(_recyclingAnalysisContextsField.GetValue(holder) is IList list) || index >= list.Count) { return false; } context = list[index]; return context != null; } catch { context = null; return false; } } } private sealed class RestockTargetLimitEditorRow { public string Item { get; set; } public string Amount { get; set; } public RestockTargetLimitEditorRow(string item, string amount) { Item = item; Amount = amount; } } private sealed class SlotEquipItemSnapshot { public ItemData Item { get; } public bool WasInInventory { get; } public Vector2i GridPos { get; } public bool Equipped { get; } public Dictionary CustomData { get; } public SlotEquipItemSnapshot(ItemData item, bool wasInInventory) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Item = item; WasInInventory = wasInInventory; GridPos = item.m_gridPos; Equipped = item.m_equipped; CustomData = new Dictionary(item.m_customData); } } private sealed class HumanoidEquipmentSnapshot { public ItemData? RightItem { get; } public ItemData? LeftItem { get; } public ItemData? ChestItem { get; } public ItemData? LegItem { get; } public ItemData? AmmoItem { get; } public ItemData? HelmetItem { get; } public ItemData? ShoulderItem { get; } public ItemData? UtilityItem { get; } public ItemData? TrinketItem { get; } public HumanoidEquipmentSnapshot(Humanoid humanoid) { RightItem = humanoid.m_rightItem; LeftItem = humanoid.m_leftItem; ChestItem = humanoid.m_chestItem; LegItem = humanoid.m_legItem; AmmoItem = humanoid.m_ammoItem; HelmetItem = humanoid.m_helmetItem; ShoulderItem = humanoid.m_shoulderItem; UtilityItem = humanoid.m_utilityItem; TrinketItem = humanoid.m_trinketItem; } } private readonly struct TooltipCanvasGroupVisualSnapshot { public bool HadCanvasGroup { get; } public float Alpha { get; } public bool Interactable { get; } public bool BlocksRaycasts { get; } public bool IgnoreParentGroups { get; } public TooltipCanvasGroupVisualSnapshot(bool hadCanvasGroup, float alpha, bool interactable, bool blocksRaycasts, bool ignoreParentGroups) { HadCanvasGroup = hadCanvasGroup; Alpha = alpha; Interactable = interactable; BlocksRaycasts = blocksRaycasts; IgnoreParentGroups = ignoreParentGroups; } } private sealed class InventoryPinnedTooltipRuntimeState { public readonly RectTransform?[] Panels = (RectTransform?[])(object)new RectTransform[3]; public readonly Image?[] Icons = (Image?[])(object)new Image[3]; public readonly TMP_Text?[] Texts = (TMP_Text?[])(object)new TMP_Text[3]; public readonly RectTransform?[] JewelcraftingTooltipRoots = (RectTransform?[])(object)new RectTransform[3]; public readonly ItemData?[] Items = (ItemData?[])(object)new ItemData[3]; public readonly InventoryGrid?[] Grids = (InventoryGrid?[])(object)new InventoryGrid[3]; public readonly Vector2i[] Positions = Enumerable.Repeat(new Vector2i(-1, -1), 3).ToArray(); public InventoryGrid? HoveredGrid; public Vector2i HoveredPos = new Vector2i(-1, -1); } private sealed class CraftingPinnedTooltipRuntimeState { public readonly RectTransform?[] Panels = (RectTransform?[])(object)new RectTransform[3]; public readonly Image?[] Icons = (Image?[])(object)new Image[3]; public readonly TMP_Text?[] Texts = (TMP_Text?[])(object)new TMP_Text[3]; public readonly RectTransform?[] JewelcraftingTooltipRoots = (RectTransform?[])(object)new RectTransform[3]; public readonly RectTransform?[] GemIconRows = (RectTransform?[])(object)new RectTransform[3]; public readonly int[] RecipeIndices = Enumerable.Repeat(-1, 3).ToArray(); } private sealed class PinnedTooltipRuntimeState { public readonly InventoryPinnedTooltipRuntimeState Inventory = new InventoryPinnedTooltipRuntimeState(); public readonly CraftingPinnedTooltipRuntimeState Crafting = new CraftingPinnedTooltipRuntimeState(); public PinnedTooltipContext ActiveContext; } private sealed class TooltipUiRuntimeState { public RectTransform? HotbarSwitchHudHint; public TMP_Text? HotbarSwitchHudHintText; public RectTransform? InventoryWheelHint; public TMP_Text? InventoryWheelHintText; public TMP_FontAsset? DefaultFontAsset; public Material? DefaultFontMaterial; public Sprite? SolidUiSprite; public Sprite? MouseWheelHintSprite; } private static class TooltipController { public static void SetPinnedContext(PinnedTooltipContext context) { if (PinnedTooltips.ActiveContext != context) { PinnedTooltipContext activeContext = PinnedTooltips.ActiveContext; PinnedTooltips.ActiveContext = context; switch (activeContext) { case PinnedTooltipContext.InventoryContainer: HideInventoryPinnedTooltips(); break; case PinnedTooltipContext.CraftingCraft: case PinnedTooltipContext.CraftingUpgrade: HideCraftingPinnedTooltips(); break; } } } public static void SyncCraftingPinnedContext(PinnedTooltipContext current) { if ((PinnedTooltips.ActiveContext == PinnedTooltipContext.CraftingCraft || PinnedTooltips.ActiveContext == PinnedTooltipContext.CraftingUpgrade) && PinnedTooltips.ActiveContext != current) { HideCraftingPinnedTooltips(); PinnedTooltips.ActiveContext = current; } } public static bool IsCraftingPinnedContext() { if (PinnedTooltips.ActiveContext != PinnedTooltipContext.CraftingCraft) { return PinnedTooltips.ActiveContext == PinnedTooltipContext.CraftingUpgrade; } return true; } public static bool IsInventoryPinnedContext() { return PinnedTooltips.ActiveContext == PinnedTooltipContext.InventoryContainer; } public static void SetInventoryHover(InventoryGrid grid, Vector2i pos) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) PinnedTooltips.Inventory.HoveredGrid = grid; PinnedTooltips.Inventory.HoveredPos = pos; } public static void ClearInventoryHover() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) PinnedTooltips.Inventory.HoveredGrid = null; PinnedTooltips.Inventory.HoveredPos = new Vector2i(-1, -1); } public static bool IsInventoryHover(InventoryGrid grid, Vector2i pos) { //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) if ((Object)(object)PinnedTooltips.Inventory.HoveredGrid == (Object)(object)grid) { return PinnedTooltips.Inventory.HoveredPos == pos; } return false; } public static bool TryGetInventoryHover(out InventoryGrid? grid, out Vector2i pos) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) grid = PinnedTooltips.Inventory.HoveredGrid; pos = PinnedTooltips.Inventory.HoveredPos; if ((Object)(object)grid != (Object)null && pos.x >= 0) { return pos.y >= 0; } return false; } } private enum UiScrollInputMode { Discrete, Continuous } private sealed class VeiledRecipesApi { private delegate bool ShouldMaskRecipePairDelegate(Player player, RecipeDataPair pair); private delegate bool IsUnknownRecipePreviewDelegate(Player player, Recipe recipe); private delegate bool IsMaterialKnownDelegate(Player player, Requirement requirement); private delegate bool KnowsRecipeStationRequirementDelegate(Player player, Recipe recipe, int quality); private readonly ShouldMaskRecipePairDelegate _shouldMaskRecipePair; private readonly IsUnknownRecipePreviewDelegate? _isUnknownRecipePreview; private readonly IsMaterialKnownDelegate _isMaterialKnown; private readonly KnowsRecipeStationRequirementDelegate _knowsRecipeStationRequirement; private readonly PropertyInfo _unknownNameTextProperty; private readonly PropertyInfo _unknownDescriptionTextProperty; private readonly PropertyInfo _unknownRequirementTextProperty; private readonly PropertyInfo? _groupUnknownRecipePreviewsBelowKnownRecipesProperty; public string UnknownNameText => GetStringProperty(_unknownNameTextProperty, "???"); public string UnknownDescriptionText => GetStringProperty(_unknownDescriptionTextProperty, "Not enough info"); public string UnknownRequirementText => GetStringProperty(_unknownRequirementTextProperty, "?"); public bool GroupUnknownRecipePreviewsBelowKnownRecipes => GetBoolProperty(_groupUnknownRecipePreviewsBelowKnownRecipesProperty, fallback: false); public bool HasUnknownRecipePreviewApi => _isUnknownRecipePreview != null; private VeiledRecipesApi(ShouldMaskRecipePairDelegate shouldMaskRecipePair, IsUnknownRecipePreviewDelegate? isUnknownRecipePreview, IsMaterialKnownDelegate isMaterialKnown, KnowsRecipeStationRequirementDelegate knowsRecipeStationRequirement, PropertyInfo unknownNameTextProperty, PropertyInfo unknownDescriptionTextProperty, PropertyInfo unknownRequirementTextProperty, PropertyInfo? groupUnknownRecipePreviewsBelowKnownRecipesProperty) { _shouldMaskRecipePair = shouldMaskRecipePair; _isUnknownRecipePreview = isUnknownRecipePreview; _isMaterialKnown = isMaterialKnown; _knowsRecipeStationRequirement = knowsRecipeStationRequirement; _unknownNameTextProperty = unknownNameTextProperty; _unknownDescriptionTextProperty = unknownDescriptionTextProperty; _unknownRequirementTextProperty = unknownRequirementTextProperty; _groupUnknownRecipePreviewsBelowKnownRecipesProperty = groupUnknownRecipePreviewsBelowKnownRecipesProperty; } public static bool TryCreate(Assembly assembly, out VeiledRecipesApi? api, out string detail) { api = null; Type type = assembly.GetType("VeiledRecipes.VeiledRecipesCompat"); MethodInfo methodInfo = type?.GetMethod("ShouldMaskRecipePair", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Player), typeof(RecipeDataPair) }, null); MethodInfo methodInfo2 = type?.GetMethod("IsUnknownRecipePreview", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Player), typeof(Recipe) }, null); MethodInfo methodInfo3 = type?.GetMethod("IsMaterialKnown", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Player), typeof(Requirement) }, null); MethodInfo methodInfo4 = type?.GetMethod("KnowsRecipeStationRequirement", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(Player), typeof(Recipe), typeof(int) }, null); PropertyInfo propertyInfo = type?.GetProperty("UnknownNameText", BindingFlags.Static | BindingFlags.Public); PropertyInfo propertyInfo2 = type?.GetProperty("UnknownDescriptionText", BindingFlags.Static | BindingFlags.Public); PropertyInfo propertyInfo3 = type?.GetProperty("UnknownRequirementText", BindingFlags.Static | BindingFlags.Public); PropertyInfo groupUnknownRecipePreviewsBelowKnownRecipesProperty = type?.GetProperty("GroupUnknownRecipePreviewsBelowKnownRecipes", BindingFlags.Static | BindingFlags.Public); if (type == null || methodInfo == null || methodInfo3 == null || methodInfo4 == null || propertyInfo == null || propertyInfo2 == null || propertyInfo3 == null) { detail = "VeiledRecipes compatibility API was not found"; return false; } try { api = new VeiledRecipesApi((ShouldMaskRecipePairDelegate)Delegate.CreateDelegate(typeof(ShouldMaskRecipePairDelegate), methodInfo), (methodInfo2 != null) ? ((IsUnknownRecipePreviewDelegate)Delegate.CreateDelegate(typeof(IsUnknownRecipePreviewDelegate), methodInfo2)) : null, (IsMaterialKnownDelegate)Delegate.CreateDelegate(typeof(IsMaterialKnownDelegate), methodInfo3), (KnowsRecipeStationRequirementDelegate)Delegate.CreateDelegate(typeof(KnowsRecipeStationRequirementDelegate), methodInfo4), propertyInfo, propertyInfo2, propertyInfo3, groupUnknownRecipePreviewsBelowKnownRecipesProperty); detail = ""; return true; } catch (Exception ex) { detail = ex.Message; api = null; return false; } } public bool ShouldMaskRecipePair(Player player, RecipeDataPair pair) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) try { return _shouldMaskRecipePair(player, pair); } catch { return false; } } public bool IsUnknownRecipePreview(Player player, Recipe recipe) { if (_isUnknownRecipePreview == null) { return false; } try { return _isUnknownRecipePreview(player, recipe); } catch { return false; } } public bool IsMaterialKnown(Player player, Requirement requirement) { try { return _isMaterialKnown(player, requirement); } catch { return false; } } public bool KnowsRecipeStationRequirement(Player player, Recipe recipe, int quality) { try { return _knowsRecipeStationRequirement(player, recipe, quality); } catch { return false; } } private static string GetStringProperty(PropertyInfo property, string fallback) { try { return (property.GetValue(null, null) as string) ?? fallback; } catch { return fallback; } } private static bool GetBoolProperty(PropertyInfo? property, bool fallback) { if (property == null) { return fallback; } try { return (property.GetValue(null, null) is bool flag) ? flag : fallback; } catch { return fallback; } } } private sealed class YamlApplySnapshot { public YamlRoot Config { get; } public List SlotDefinitions { get; } public Dictionary> PredefinedGroupDefinitions { get; } public List PredefinedGroupOrder { get; } public Dictionary> PredefinedGroupOrders { get; } public YamlApplySnapshot(YamlRoot config, List slotDefinitions, Dictionary> predefinedGroupDefinitions, List predefinedGroupOrder, Dictionary> predefinedGroupOrders) { Config = config; SlotDefinitions = slotDefinitions; PredefinedGroupDefinitions = predefinedGroupDefinitions; PredefinedGroupOrder = predefinedGroupOrder; PredefinedGroupOrders = predefinedGroupOrders; } } [CompilerGenerated] private static class <>O { public static CompatApiFactory <0>__TryCreate; public static Func <1>__IsAdventureBackpackItem; public static Func <2>__IsSmoothbrainBackpackItem; public static Func <3>__IsRustyBagItem; public static Func <4>__IsRustyQuiverItem; public static CompatApiFactory <5>__TryCreate; public static CompatApiFactory <6>__TryCreate; public static CompatApiFactory <7>__TryCreate; public static CompatApiFactory <8>__TryCreate; public static TryGetContainerHoldContext <9>__TryGetContainerQuickStackHotkeyContext; public static Func <10>__TryQuickStackFromHoveredContainer; public static TryGetContainerHoldContext <11>__TryGetContainerRestockHotkeyContext; public static Func <12>__TryRestockFromHoveredContainer; public static Func <13>__GetInventoryItemSortKey; public static Func <14>__IsPendingUpgradeFavoriteItem; public static UnityAction <15>__UpdateCraftingSearchQuery; public static Func <16>__IsDigit; public static UnityAction <17>__OnCraftingRecipeScrollbarChanged; public static Func <18>__IsKeyHintText; public static UnityAction <19>__TryClickInventoryTrashPanel; public static CompatApiFactory <20>__TryCreate; public static Func <21>__IsJewelcraftingNecklaceItem; public static Func <22>__IsJewelcraftingRingItem; public static CompatApiFactory <23>__TryCreate; public static CompatApiFactory <24>__TryCreate; public static CompatApiFactory <25>__TryCreate; public static CompatApiFactory <26>__TryCreate; public static CompatApiFactory <27>__TryCreate; public static CompatApiFactory <28>__TryCreate; public static CompatApiFactory <29>__TryCreate; public static Func <30>__IsMagicSupremacyBeltItem; public static CompatApiFactory <31>__TryCreate; public static Action <32>__HandleInventoryGridTooltipPointerEnter; public static Action <33>__HandleInventoryGridTooltipPointerExit; public static Action <34>__DrawRestockTargetStackLimitsConfig; public static Action <35>__HandleLocalizationComplete; public static Action <36>__DrawControllerHotkeyConfig; public static CompatApiFactory <37>__TryCreate; public static Func <38>__SanitizeRecycleNReclaimHudText; public static CompatApiFactory <39>__TryCreate; public static Func <40>__NormalizeGroupId; public static Func <41>__QuickSlotAcceptsItem; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func <>9__12_0; public static Func <>9__13_0; public static Func <>9__14_0; public static Func <>9__15_0; public static Comparison<(Container Container, float DistanceSq)> <>9__95_0; public static Func <>9__96_0; public static Comparison <>9__157_1; public static Func <>9__159_0; public static Func <>9__159_1; public static Comparison <>9__160_1; public static Comparison <>9__171_1; public static Func <>9__194_0; public static Func <>9__204_0; public static Func <>9__204_1; public static Func <>9__206_0; public static Funcf__AnonymousType0> <>9__206_1; public static Funcf__AnonymousType0, ItemData>, List> <>9__206_2; public static Func <>9__206_3; public static Func <>9__209_0; public static Comparison <>9__209_1; public static Func <>9__211_1; public static Func <>9__211_2; public static UnityAction <>9__260_0; public static Func <>9__292_0; public static Func <>9__292_1; public static EventHandler <>9__303_0; public static EventHandler <>9__303_1; public static EventHandler <>9__303_2; public static EventHandler <>9__303_3; public static Func <>9__366_0; public static Func <>9__369_0; public static Func <>9__370_0; public static Func <>9__370_1; public static Func <>9__371_0; public static Func <>9__371_1; public static Action <>9__400_0; public static Action <>9__400_1; public static Action <>9__400_2; public static Action <>9__400_3; public static Action <>9__419_0; public static Func <>9__442_0; public static Action <>9__453_0; public static Func <>9__471_0; public static Func <>9__536_0; public static Func <>9__537_0; public static Func <>9__539_0; public static Func <>9__570_0; public static Func <>9__644_0; public static Func <>9__831_0; public static Func <>9__832_0; public static Func <>9__840_0; public static Func <>9__842_0; public static Func <>9__842_1; public static Func <>9__861_0; public static Func <>9__861_2; public static UnityAction <>9__983_0; public static UnityAction <>9__983_1; public static UnityAction <>9__985_0; public static UnityAction <>9__992_0; public static Func <>9__1050_0; public static Func <>9__1050_1; public static Func <>9__1050_2; public static Func <>9__1076_0; public static Func <>9__1186_0; public static Func <>9__1278_0; public static Func <>9__1356_0; public static Func <>9__1359_0; public static Func <>9__1367_0; public static Func <>9__1412_0; public static Func <>9__1412_1; public static Func <>9__1412_2; public static Action <>9__1418_0; public static Action <>9__1418_1; public static Action <>9__1519_0; public static Action <>9__1519_1; public static Action <>9__1536_0; public static Action <>9__1536_1; public static Func <>9__1618_0; public static Func <>9__1618_1; public static Func <>9__1760_0; public static Func <>9__1760_1; public static Func <>9__1782_0; public static Func <>9__1782_1; public static Func <>9__1882_0; public static Func <>9__1882_1; public static Func <>9__1882_2; public static Func <>9__1882_3; public static Func <>9__1910_0; public static Func <>9__1923_0; public static Func <>9__1923_1; public static Func <>9__1923_2; public static Comparison <>9__1926_2; public static Comparison <>9__1927_1; public static Func <>9__1948_0; public static Func <>9__1948_1; public static Func <>9__1948_2; public static Func <>9__2026_0; public static Func <>9__2026_1; public static Func <>9__2026_2; public static Converter <>9__2100_0; public static EventHandler <>9__2423_0; public static EventHandler <>9__2423_1; public static EventHandler <>9__2423_2; public static EventHandler <>9__2423_3; public static EventHandler <>9__2423_4; public static EventHandler <>9__2423_5; public static EventHandler <>9__2423_6; public static EventHandler <>9__2423_7; public static EventHandler <>9__2423_8; public static Func <>9__2509_0; public static Func <>9__2510_0; public static Func <>9__2511_0; public static Func <>9__2511_1; public static Func <>9__2512_0; public static Func <>9__2512_1; public static Func <>9__2522_0; public static Func <>9__2522_1; public static Func <>9__2529_0; public static Func <>9__2532_0; public static Action <>9__2674_0; public static Action <>9__2674_1; public static FileSystemEventHandler <>9__2677_0; public static RenamedEventHandler <>9__2677_1; public static ErrorEventHandler <>9__2677_2; public static Func>, string> <>9__2690_0; public static Func>, List> <>9__2690_1; public static Func>, string> <>9__2690_2; public static Func>, List> <>9__2690_3; public static Func <>9__2696_0; public static Func <>9__2696_1; public static Func <>9__2696_2; public static Func <>9__2696_3; public static Func <>9__2701_0; public static Func <>9__2701_1; public static Func <>9__2701_2; public static Func <>9__2701_3; public static Func <>9__2701_4; public static Func <>9__2701_5; public static Func <>9__2706_0; public static Func <>9__2706_1; internal bool b__12_0(ItemData? item) { return IsAdventureBackpackItem(item); } internal bool b__13_0(ItemData? item) { return IsSmoothbrainBackpackItem(item); } internal bool b__14_0(ItemData? item) { return IsRustyBagItem(item); } internal bool b__15_0(ItemData? item) { return IsRustyQuiverItem(item); } internal int b__95_0((Container Container, float DistanceSq) left, (Container Container, float DistanceSq) right) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num = left.DistanceSq.CompareTo(right.DistanceSq); if (num != 0) { return num; } ZNetView nview = left.Container.m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); ZNetView nview2 = right.Container.m_nview; ZDO val2 = ((nview2 != null) ? nview2.GetZDO() : null); if (val == null || val2 == null) { return 0; } return ((ZDOID)(ref val.m_uid)).CompareTo(val2.m_uid); } internal bool b__96_0(Container container) { if (!IsUnityNull((Object?)(object)container)) { return container.m_inventory != null; } return false; } internal int b__157_1(ItemData a, ItemData b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return -CompareGridOrder(a.m_gridPos, b.m_gridPos); } internal bool b__159_0(ItemData item) { return item?.m_shared != null; } internal string b__159_1(ItemData item) { return item.m_shared.m_name; } internal int b__160_1(ItemData a, ItemData b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return CompareGridOrder(a.m_gridPos, b.m_gridPos); } internal int b__171_1(ItemData a, ItemData b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return -CompareGridOrder(a.m_gridPos, b.m_gridPos); } internal bool b__194_0(ItemData item) { return item?.m_shared != null; } internal ItemData b__204_0(ItemData item) { return item; } internal ItemData b__204_1(ItemData item) { return item; } internal bool b__206_0(ItemData item) { if (item?.m_shared != null && item.m_stack < item.m_shared.m_maxStackSize) { return CanUseContainerActionStacking(item); } return false; } internal <>f__AnonymousType0 b__206_1(ItemData item) { return new { item.m_shared.m_name, item.m_quality, item.m_worldLevel }; } internal List b__206_2(IGrouping<<>f__AnonymousType0, ItemData> grouping) { return grouping.ToList(); } internal int b__206_3(ItemData item) { return item.m_stack; } internal bool b__209_0(ItemData item) { return item?.m_shared != null; } internal int b__209_1(ItemData left, ItemData right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return CompareGridOrder(left.m_gridPos, right.m_gridPos); } internal int b__211_1(ItemData target) { return target.m_gridPos.y; } internal int b__211_2(ItemData target) { return target.m_gridPos.x; } internal void b__260_0(string value) { SetCraftingCount(ParseCraftingCount(value)); } internal bool b__292_0(TMP_Text text) { if (!((Object)(object)text == (Object)null)) { return IsUnityNull((Object?)(object)text); } return true; } internal bool b__292_1(Text text) { if (!((Object)(object)text == (Object)null)) { return IsUnityNull((Object?)(object)text); } return true; } internal void b__303_0(object _, EventArgs _) { CraftingController.MarkRecipeGridLayoutDirty(); } internal void b__303_1(object _, EventArgs _) { CraftingController.MarkGroupRailDirty(); } internal void b__303_2(object _, EventArgs _) { CraftingController.ResetSortModeButtonsStamp(); InvalidateCraftingRecipeView(); } internal void b__303_3(object _, EventArgs _) { CraftingController.MarkRecipeGridLayoutDirty(); } internal string b__366_0() { return Guid.NewGuid().ToString("N"); } internal bool b__369_0(ItemData item) { return item?.m_customData != null; } internal bool b__370_0(string recipe) { return !string.IsNullOrWhiteSpace(recipe); } internal bool b__370_1(string itemId) { return !string.IsNullOrWhiteSpace(itemId); } internal string b__371_0(string recipe) { return recipe; } internal string b__371_1(string itemId) { return itemId; } internal void b__400_0(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); SetCraftingRecipeHover(component?.Index ?? (-1), component?.Tooltip); } internal void b__400_1(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); ClearCraftingRecipeHover(component?.Index ?? (-1), component?.Tooltip); } internal void b__400_2(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); int num = component?.Index ?? (-1); ClearCraftingRecipeHover(num, component?.Tooltip); if (!TryToggleCraftingRecipeFavorite(num)) { SelectCraftingRecipeFromGrid(num); } } internal void b__400_3(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); int num = component?.Index ?? (-1); ClearCraftingRecipeHover(num, component?.Tooltip); if (!TryToggleCraftingRecipeFavorite(num)) { SelectCraftingRecipeFromGrid(num); } } internal void b__419_0(UIInputHandler handler) { ShowCraftingRecipeStyleDialog(((Component)handler).GetComponent()); } internal bool b__442_0(CraftingRecipeGroupFilter filter) { return filter.Id != _selectedCraftingGroupId; } internal void b__453_0(UIInputHandler handler) { ToggleCraftingGroupFilter(((Component)handler).GetComponent()?.FilterId ?? ""); } internal string b__471_0(CraftingRecipeGroupFilter filter) { return filter.Id; } internal bool b__536_0(char c) { return !char.IsWhiteSpace(c); } internal bool b__537_0(char c) { return !char.IsWhiteSpace(c); } internal bool b__539_0(ItemData _) { return false; } internal bool b__570_0(CraftingRecipeGroupFilter group) { return group.Id == _selectedCraftingGroupId; } internal Transform b__644_0(Image image) { return ((Component)image).transform; } internal bool b__831_0(SlotDefinition slot) { return slot.Kind == SlotKind.CustomEquipment; } internal bool b__832_0(SlotDefinition slot) { return slot.Kind == SlotKind.CustomEquipment; } internal bool b__840_0(SlotDefinition slot) { return slot.Kind == SlotKind.CustomEquipment; } internal VisEquipment b__842_0(CustomEquipmentVisual visual) { return visual.Owner; } internal bool b__842_1(VisEquipment owner) { return !IsUnityNull((Object?)(object)owner); } internal bool b__861_0(SlotDefinition slot) { return slot.Kind == SlotKind.Quick; } internal bool b__861_2(SlotDefinition slot) { return slot.Kind != SlotKind.Quick; } internal void b__983_0() { StoreAllToCurrentContainer(Player.m_localPlayer); } internal void b__983_1() { RestockFromCurrentContainer(Player.m_localPlayer); } internal void b__985_0() { SortPlayerInventory(Player.m_localPlayer); } internal void b__992_0() { SortCurrentContainer(Player.m_localPlayer); } internal int b__1050_0(Vector2i slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return slot.y; } internal int b__1050_1(Vector2i slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return slot.x; } internal InventorySlotsFavoriteSlot b__1050_2(Vector2i slot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new InventorySlotsFavoriteSlot { X = slot.x, Y = slot.y }; } internal bool b__1076_0(TMP_FontAsset fontAsset) { if ((Object)(object)fontAsset != (Object)null && !IsUnityNull((Object?)(object)fontAsset)) { return (((Object)fontAsset).name ?? "").IndexOf("LiberationSans", StringComparison.OrdinalIgnoreCase) < 0; } return false; } internal bool b__1186_0(UITooltip tooltip, InventoryHoverTooltipItemSource source) { return !IsInventoryHoverTooltipSourceValid(tooltip, source); } internal bool b__1278_0(TMP_Text text) { return !IsKeyHintText(text); } internal bool b__1356_0(int _, int _) { return true; } internal bool b__1359_0(int x, int y) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return !IsExternalReservedForCompat(new Vector2i(x, y)); } internal bool b__1367_0(int _, int _) { return true; } internal bool b__1412_0(AnimationClip c) { if ((Object)(object)c != (Object)null && c.length > 0.05f) { return c.length < 2f; } return false; } internal bool b__1412_1(AnimationClip c) { return IsLikelyInventoryOpenClip(((Object)c).name); } internal float b__1412_2(AnimationClip c) { return Mathf.Abs(c.length - 0.25f); } internal void b__1418_0(UIInputHandler handler) { SelectQuickHudSlot(((Component)handler).GetComponentInParent()); } internal void b__1418_1(UIInputHandler handler) { UseQuickHudSlot(((Component)handler).GetComponentInParent()); } internal void b__1519_0(UIInputHandler handler) { StartInventoryPanelDrag(((Component)handler).GetComponent()); } internal void b__1519_1(UIInputHandler _) { StopInventoryPanelDrag(); } internal void b__1536_0(UIInputHandler handler) { StartInventoryPanelDrag(((Component)handler).GetComponent()); } internal void b__1536_1(UIInputHandler _) { StopInventoryPanelDrag(); } internal int b__1618_0(MovedPlayerStatPanel panel) { return panel.SortOrder; } internal PlayerStatPanelKind b__1618_1(MovedPlayerStatPanel panel) { return panel.Kind; } internal bool b__1760_0(SlotDefinition slot) { return slot.Id != "jewelcrafting.necklace"; } internal bool b__1760_1(SlotDefinition slot) { return slot.Id != "jewelcrafting.ring"; } internal bool b__1782_0(SlotDefinition slot) { if (slot.Id == "jewelcrafting.ring") { return slot.Kind == SlotKind.CustomEquipment; } return false; } internal bool b__1782_1(SlotDefinition slot) { if (slot.Id == "jewelcrafting.necklace") { return slot.Kind == SlotKind.CustomEquipment; } return false; } internal bool b__1882_0(Graphic graphic) { if (!((Object)(object)graphic == (Object)null)) { return IsUnityNull((Object?)(object)graphic); } return true; } internal bool b__1882_1(TMP_Text text) { if (!((Object)(object)text == (Object)null)) { return IsUnityNull((Object?)(object)text); } return true; } internal bool b__1882_2(LayoutGroup group) { if (!((Object)(object)group == (Object)null)) { return IsUnityNull((Object?)(object)group); } return true; } internal bool b__1882_3(ContentSizeFitter fitter) { if (!((Object)(object)fitter == (Object)null)) { return IsUnityNull((Object?)(object)fitter); } return true; } internal bool b__1910_0(SlotDefinition existing) { return existing.Id == "magicsupremacy.belt"; } internal bool b__1923_0(ItemData item) { return item?.m_shared != null; } internal int b__1923_1(ItemData item) { return item.m_gridPos.y; } internal int b__1923_2(ItemData item) { return item.m_gridPos.x; } internal int b__1926_2(ItemData left, ItemData right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return -CompareGridOrder(left.m_gridPos, right.m_gridPos); } internal int b__1927_1(ItemData left, ItemData right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return -CompareGridOrder(left.m_gridPos, right.m_gridPos); } internal bool b__1948_0(ItemData item) { return item?.m_shared != null; } internal int b__1948_1(ItemData item) { return item.m_gridPos.y; } internal int b__1948_2(ItemData item) { return item.m_gridPos.x; } internal bool b__2026_0(ItemData target) { return target?.m_shared != null; } internal int b__2026_1(ItemData target) { return target.m_gridPos.y; } internal int b__2026_2(ItemData target) { return target.m_gridPos.x; } internal ItemData b__2100_0(ItemData item) { return item.Clone(); } internal void b__2423_0(object _, EventArgs _) { RefreshRestockTargetStackLimits(); } internal void b__2423_1(object _, EventArgs _) { InvalidatePinnedTooltipUi(); } internal void b__2423_2(object _, EventArgs _) { RefreshPinnedTooltipBackgrounds(); } internal void b__2423_3(object _, EventArgs _) { OnCraftingHoverTooltipConfigChanged(); } internal void b__2423_4(object _, EventArgs _) { RefreshCraftingHoverTooltipBackground(); } internal void b__2423_5(object _, EventArgs _) { RefreshInventoryContainerHoverTooltipBackground(); } internal void b__2423_6(object _, EventArgs _) { OnInventoryTrashPanelConfigChanged(); } internal void b__2423_7(object _, EventArgs _) { ApplyAutoFavoriteHotbarSwitchRowToLocalPlayer(); } internal void b__2423_8(object _, EventArgs _) { OnQuickSlotHudFollowsPanelChanged(); } internal string b__2509_0(RecycleNReclaimYieldTextEntry entry) { return $"{LocalizeUi(entry.Name, entry.Name)} x{entry.Amount}"; } internal bool b__2510_0(RectTransform slot) { if ((Object)(object)slot != (Object)null && !IsUnityNull((Object?)(object)slot)) { return ((Component)slot).gameObject.activeSelf; } return false; } internal bool b__2511_0(string part) { return !string.IsNullOrWhiteSpace(part); } internal string b__2511_1(string part) { return part.Trim(); } internal string b__2512_0(string line) { return line.Trim(); } internal bool b__2512_1(string line) { return !string.IsNullOrWhiteSpace(line); } internal bool b__2522_0(RestockTargetLimitEditorRow row) { if (string.IsNullOrWhiteSpace(row.Item)) { return !string.IsNullOrWhiteSpace(row.Amount); } return true; } internal string b__2522_1(RestockTargetLimitEditorRow row) { return row.Item.Trim() + ": " + row.Amount.Trim(); } internal bool b__2529_0(ItemData item) { if (item != null) { return item.m_gridPos.y >= GetFixedRegularRows(); } return false; } internal bool b__2532_0(ItemData item) { if (item != null) { return item.m_gridPos.y >= GetFixedRegularRows(); } return false; } internal void b__2674_0() { ApplyYaml(_syncedYaml.Value, fromSync: true); } internal void b__2674_1() { ApplyResourceMapYaml(_syncedResourceMapYaml.Value, fromSync: true); } internal void b__2677_0(object _, FileSystemEventArgs args) { QueueYamlReloadForFile(args.FullPath); } internal void b__2677_1(object _, RenamedEventArgs args) { QueueYamlReloadForFile(args.OldFullPath); QueueYamlReloadForFile(args.FullPath); } internal void b__2677_2(object _, ErrorEventArgs _) { QueueYamlReload(reloadYaml: true, reloadResourceMap: true); } internal string b__2690_0(KeyValuePair> entry) { return entry.Key; } internal List b__2690_1(KeyValuePair> entry) { return entry.Value.ToList(); } internal string b__2690_2(KeyValuePair> entry) { return entry.Key; } internal List b__2690_3(KeyValuePair> entry) { return entry.Value.ToList(); } internal bool b__2696_0(string value) { return !string.IsNullOrWhiteSpace(value); } internal string b__2696_1(string value) { return value.Trim(); } internal bool b__2696_2(string value) { return !string.IsNullOrWhiteSpace(value); } internal bool b__2696_3(string value) { return !string.IsNullOrWhiteSpace(value); } internal bool b__2701_0(ItemData? item) { //IL_001a: 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_002d: Invalid comparison between Unknown and I4 if (item == null) { return false; } return (int)(item.m_shared?.m_itemType).GetValueOrDefault() == 6; } internal bool b__2701_1(ItemData? item) { //IL_001a: 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_002d: Invalid comparison between Unknown and I4 if (item == null) { return false; } return (int)(item.m_shared?.m_itemType).GetValueOrDefault() == 7; } internal bool b__2701_2(ItemData? item) { //IL_001a: 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_002e: Invalid comparison between Unknown and I4 if (item == null) { return false; } return (int)(item.m_shared?.m_itemType).GetValueOrDefault() == 11; } internal bool b__2701_3(ItemData? item) { //IL_001a: 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_002e: Invalid comparison between Unknown and I4 if (item == null) { return false; } return (int)(item.m_shared?.m_itemType).GetValueOrDefault() == 17; } internal bool b__2701_4(ItemData? item) { //IL_0018: 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_002c: Invalid comparison between Unknown and I4 if (item != null && (int)(item.m_shared?.m_itemType).GetValueOrDefault() == 18 && !IsJewelcraftingDedicatedJewelryItem(item)) { return !IsJewelcraftingUtilityGemBlocked(item); } return false; } internal bool b__2701_5(ItemData? item) { //IL_001a: 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_002e: Invalid comparison between Unknown and I4 if (item == null) { return false; } return (int)(item.m_shared?.m_itemType).GetValueOrDefault() == 24; } internal bool b__2706_0(string value) { return !string.IsNullOrWhiteSpace(value); } internal string b__2706_1(string value) { return value.Trim(); } internal bool <.cctor>b__2729_0(ItemData _) { return true; } internal bool <.cctor>b__2729_1(ItemData item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 return (int)item.m_shared.m_itemType == 13; } internal bool <.cctor>b__2729_2(ItemData item) { return item.m_shared.m_value > 0; } } private static bool _adventureBackpacksPatchesApplied; private static ItemData? _lastAdventureBackpackCompatItem; private static ItemData? _lastSmoothbrainBackpackCompatItem; private static ItemData? _lastRustyBagCompatItem; private static ItemData? _lastRustyQuiverCompatItem; private static readonly CompatRuntimeState CompatRuntime = new CompatRuntimeState(); private const string ServerCharactersGuid = "org.bepinex.plugins.servercharacters"; private const string MultiUserChestGuid = "com.maxsch.valheim.MultiUserChest"; private const string BetterArcheryGuid = "ishid4.mods.betterarchery"; private const string AzuCraftyBoxesGuid = "Azumatt.AzuCraftyBoxes"; private const string EpicLootGuid = "randyknapp.mods.epicloot"; private const string TooltipExpansionGuid = "Azumatt.TooltipExpansion"; private const string JewelcraftingGuid = "org.bepinex.plugins.jewelcrafting"; private const string ItemRequiresSkillLevelGuid = "WackyMole.ItemRequiresSkillLevel"; private const string AdventureBackpacksGuid = "vapok.mods.adventurebackpacks"; private const string SmoothbrainBackpacksGuid = "org.bepinex.plugins.backpacks"; private const string RustyBagsGuid = "RustyMods.RustyBags"; private const string MagicSupremacyGuid = "Dreanegade.Magic_Supremacy"; private const string CurrencyPocketGuid = "Azumatt.CurrencyPocket"; private const string MyLittleUIGuid = "shudnal.MyLittleUI"; private const string RecycleNReclaimGuid = "Azumatt.Recycle_N_Reclaim"; private const string VeiledRecipesGuid = "sighsorry.VeiledRecipes"; private const string ContentsWithinGuid = "com.maxsch.valheim.contentswithin"; private const string ContainerActionSuccessFxPrefabName = "fx_HildirChest_Unlock"; private const int ContainerActionSuccessVfxLimit = 10; private const float ContainerActionSuccessSfxLifetime = 5f; private const int ContainerPreviewHiddenFrames = 10; private const float ContainerPreviewFailureLogInterval = 5f; private static readonly Dictionary ContainerPreviewHiddenObjects = new Dictionary(); private static bool _containerPreviewRealGuiVisible; private static bool _containerPreviewFrameOwned; private static bool _containerPreviewActive; private static bool _containerPreviewUiCaptured; private static bool _containerPreviewStandaloneWarningLogged; private static Container? _containerPreviewTarget; private static Inventory? _containerPreviewInventory; private static Inventory? _containerPreviewRenderedInventory; private static int _containerPreviewRenderedWidth = -1; private static int _containerPreviewRenderedHeight = -1; private static float _containerPreviewCloseAt; private static float _containerPreviewLastFailureAt = float.NegativeInfinity; private static string _containerPreviewLastFailure = ""; private const string RpcRequestSort = "InventorySlots_RequestSortV2"; private const string RpcSortResponse = "InventorySlots_SortResponseV2"; private const float ContainerSortRequestTimeout = 2f; private static Container? _pendingSortContainer; private static int _pendingSortRequestId; private static int _nextSortRequestId = 1; private static long _pendingSortOwner; private static float _pendingSortStartedAt = -1f; private const float ControllerHotkeyCaptureSeconds = 8f; private static readonly HashSet ExpandedControllerHotkeyPresetDrawers = new HashSet(); private static string _controllerHotkeyCaptureEntryKey = ""; private static float _controllerHotkeyCaptureEndTime; private static readonly ControllerActionOption[] ControllerActionOptions = new ControllerActionOption[21] { new ControllerActionOption(ControllerHotkeyAction.Off, "Off"), new ControllerActionOption(ControllerHotkeyAction.JoyButtonA, "A"), new ControllerActionOption(ControllerHotkeyAction.JoyButtonB, "B"), new ControllerActionOption(ControllerHotkeyAction.JoyButtonX, "X"), new ControllerActionOption(ControllerHotkeyAction.JoyButtonY, "Y"), new ControllerActionOption(ControllerHotkeyAction.JoyLBumper, "LB"), new ControllerActionOption(ControllerHotkeyAction.JoyRBumper, "RB"), new ControllerActionOption(ControllerHotkeyAction.JoyLTrigger, "LT"), new ControllerActionOption(ControllerHotkeyAction.JoyRTrigger, "RT"), new ControllerActionOption(ControllerHotkeyAction.JoyBack, "Back"), new ControllerActionOption(ControllerHotkeyAction.JoyStart, "Start"), new ControllerActionOption(ControllerHotkeyAction.JoyLStick, "L Stick"), new ControllerActionOption(ControllerHotkeyAction.JoyRStick, "R Stick"), new ControllerActionOption(ControllerHotkeyAction.JoyDPadUp, "DPad Up"), new ControllerActionOption(ControllerHotkeyAction.JoyDPadDown, "DPad Down"), new ControllerActionOption(ControllerHotkeyAction.JoyDPadLeft, "DPad Left"), new ControllerActionOption(ControllerHotkeyAction.JoyDPadRight, "DPad Right"), new ControllerActionOption(ControllerHotkeyAction.JoyHotbarUse, "Hotbar Use"), new ControllerActionOption(ControllerHotkeyAction.JoyAltKeys, "Alt Keys"), new ControllerActionOption(ControllerHotkeyAction.AltPlace, "Alt Place"), new ControllerActionOption(ControllerHotkeyAction.JoyUse, "Use") }; private static readonly Dictionary UnityJoystickButtonToControllerAction = new Dictionary { [0] = ControllerHotkeyAction.JoyButtonA, [1] = ControllerHotkeyAction.JoyButtonB, [2] = ControllerHotkeyAction.JoyButtonX, [3] = ControllerHotkeyAction.JoyButtonY, [4] = ControllerHotkeyAction.JoyLBumper, [5] = ControllerHotkeyAction.JoyRBumper, [6] = ControllerHotkeyAction.JoyBack, [7] = ControllerHotkeyAction.JoyStart, [8] = ControllerHotkeyAction.JoyLStick, [9] = ControllerHotkeyAction.JoyRStick, [10] = ControllerHotkeyAction.JoyDPadLeft, [11] = ControllerHotkeyAction.JoyDPadRight, [12] = ControllerHotkeyAction.JoyDPadUp, [13] = ControllerHotkeyAction.JoyDPadDown, [14] = ControllerHotkeyAction.JoyLTrigger, [15] = ControllerHotkeyAction.JoyRTrigger, [16] = ControllerHotkeyAction.JoyButtonA, [17] = ControllerHotkeyAction.JoyButtonB, [18] = ControllerHotkeyAction.JoyButtonX, [19] = ControllerHotkeyAction.JoyButtonY }; private static ConfigEntry _craftingRecipeGridSize = null; private static ConfigEntry _craftingRecipeGridZoomModifier = null; private static ConfigEntry _craftingClearFavoritesKey = null; private static ConfigEntry _showCraftingRecipeGridZoomHint = null; private static ConfigEntry _craftingRecipeSortMode = null; private static ConfigEntry _craftingRecipeCraftableBackgroundColor = null; private const string CraftingRecipeGridName = "InventorySlots_CraftingRecipeGrid"; private const string CraftingPinnedTooltipNamePrefix = "InventorySlots_CraftingPinnedTooltip_"; private const string CraftingGemIconRowName = "InventorySlots_CraftingGemIconRow"; private const string CraftingTooltipRecipeOverlayName = "InventorySlots_CraftingTooltipRecipeOverlay"; private const string CraftingCountInputName = "InventorySlots_CraftingCountInput"; private const string CraftingUpgradeProgressionName = "InventorySlots_CraftingUpgradeProgression"; private const string CraftingSearchInputName = "InventorySlots_CraftingSearchInput"; private const string CraftingSortModeButtonGroupName = "InventorySlots_CraftingSortModeButtons"; private const string CraftingGroupFirstSortButtonName = "InventorySlots_CraftingGroupFirstSortButton"; private const string CraftingTierFirstSortButtonName = "InventorySlots_CraftingTierFirstSortButton"; private const string CraftingRecipeScrollbarName = "InventorySlots_CraftingRecipeScrollbar"; private const string CraftingControlsBackgroundName = "InventorySlots_CraftingControlsBackground"; private const string CraftingGroupRailName = "InventorySlots_CraftingGroupRail"; private const string CraftingGroupPanelNamePrefix = "InventorySlots_CraftingGroupPanel_"; private const string CraftingGroupButtonNamePrefix = "InventorySlots_CraftingGroupButton_"; private const string CraftingRecipeGridCellNamePrefix = "InventorySlots_CraftingRecipeCell_"; private const string CraftingRecipeStyleButtonName = "InventorySlots_CraftingRecipeStyleButton"; private const string CraftingCountWheelIconName = "InventorySlots_CraftingCountWheelIcon"; private const string CraftingRequirementSlotNamePrefix = "InventorySlots_CraftingRequirementSlot_"; private const string CraftingRequirementHitboxName = "InventorySlots_CraftingRequirementHitbox"; private const string CraftingRequiredStationHitboxName = "InventorySlots_CraftingRequiredStationHitbox"; private const string CraftingRecipeGridZoomHintName = "InventorySlots_CraftingRecipeGridZoomHint"; private const string CraftingFavoriteBorderName = "InventorySlots_CraftingFavoriteBorder"; private const string CraftingPinnedTooltipMarkerName = "InventorySlots_CraftingPinnedTooltipMarker"; private const string CraftingSocketWarningName = "InventorySlots_CraftingSocketWarning"; private const string CraftingBottomControlsHiddenSignature = "hidden"; private const int CraftingRecipeGridMinDimension = 4; private const int CraftingRecipeGridMaxDimension = 8; private const int CraftingRecipeGridColumns = 8; private const int CraftingRecipeGridRows = 9; private const int CraftingRecipeIconRows = 8; private const int CraftingBottomControlRow = 8; private const int CraftingSocketWarningRow = 9; private const int CraftingVisibleRequirementSlots = 4; private const float CraftingRecipeGridCellSize = 64f; private const float CraftingRecipeGridCellSpace = 72f; private const float CraftingSocketWarningHeight = 58f; private const float CraftingRecipeGridZoomHintFixedSize = 16f; private const float CraftingRecipeGridZoomHintFixedTextIconGap = 0f; private const float CraftingSearchInputWidth = 136f; private const int CraftingTooltipRecipeSlotCount = 5; private const int CraftingQueueMaxCount = 99; private static readonly Vector2 CraftingRecipeGridFixedOffset = new Vector2(0f, -100f); private static readonly Vector2 CraftingRecipeGridZoomHintFixedOffset = new Vector2(256f, -16f); private const float CraftingPanelBottomFixedExtension = 84f; private static readonly Vector2 CraftingRecipeScrollbarFixedOffset = new Vector2(4f, 0f); private static readonly Vector2 CraftingGroupRailFixedOffset = new Vector2(-66f, -96f); private const float CraftingGroupIconBlockFixedSize = 60f; private const float CraftingGroupIconFixedPadding = 3f; private static readonly Vector2 CraftingSearchInputFixedOffset = new Vector2(0f, 3f); private const float CraftingSortModeButtonGap = 4f; private static readonly Vector2 CraftingSortModeButtonsFixedOffset = new Vector2(0f, 4f); private static readonly Vector2 CraftingBottomControlsFixedOffset = new Vector2(0f, 8f); private static readonly Vector2 CraftingCraftButtonFixedOffset = new Vector2(0f, -4f); private static readonly Vector2 CraftingCountInputFixedOffset = new Vector2(0f, -4f); private static readonly Color CraftingRecipeUnavailableBackgroundColor = new Color(0.055f, 0.035f, 0.025f, 0.42f); private static readonly Color CraftingRecipeDefaultCraftableBackgroundColor = new Color(1f, 0.58f, 0.16f, 0.44f); private static readonly Color CraftingRecipeSelectedBackgroundColor = new Color(0.42f, 0.68f, 0.92f, 0.62f); private static Sprite? _craftingFavoriteGroupIcon; private const float CraftingRequirementAvailabilityCacheSeconds = 0.25f; private static readonly CraftingRecipeRuntimeState CraftingRecipes = new CraftingRecipeRuntimeState(); private static readonly CraftingRequirementRuntimeState CraftingRequirements = new CraftingRequirementRuntimeState(); private static readonly CraftingGridRuntimeState CraftingGrid = new CraftingGridRuntimeState(); private static readonly CraftingScrollbarRuntimeState CraftingScrollbar = new CraftingScrollbarRuntimeState(); private static readonly CraftingQueueRuntimeState CraftingQueue = new CraftingQueueRuntimeState(); private static readonly CraftingUiRuntimeState CraftingUi = new CraftingUiRuntimeState(); private static readonly CraftingRefreshRuntimeState CraftingRefresh = new CraftingRefreshRuntimeState(); private static readonly Dictionary CraftingVanillaPanelBackgroundStates = new Dictionary(); private static readonly Dictionary CraftingPanelResizeProtectedSnapshots = new Dictionary(); private static readonly List CraftingRecipeGroupFilters = CreateCraftingRecipeGroupFilters(); private static readonly HashSet FavoriteCraftingRecipeKeys = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet FavoriteUpgradeItemKeys = new HashSet(StringComparer.OrdinalIgnoreCase); private static bool _craftingRedesignApplied; private static bool _craftingVanillaRecipeElementsHidden; private static bool _craftingVanillaDetailHidden; private static bool _craftingVanillaRecipeScrollbarsHidden; private static bool _craftingVanillaPanelBackgroundsHidden; private static bool _craftingEnglishLocalizationIndexBuilt; private static int _lastCraftingSelectedVariant = -1; private static int _craftingRecipeVariantVersion; private static int _craftingFavoritesVersion; private static int _craftingGroupAvailabilityVersion; private static int _craftingGroupAvailabilityBuiltVersion = -1; private static int _uiLocalizationVersion; private static string _loadedCraftingFavoritesPlayerId = ""; private static string _selectedCraftingGroupId = ""; private static string _craftingSearchQuery = ""; private static string _craftingGroupAvailabilitySignature = ""; private static string _craftingGroupAvailabilityContextSignature = ""; private static string _craftingSelectableGroupFilterIdsSignature = ""; private static string _craftingPanelExtensionSignature = ""; private static string _pendingUpgradeFavoriteItemId = ""; private static string _pendingUpgradeFavoritePrefab = ""; private static int _pendingUpgradeFavoriteQuality = -1; private static int _pendingUpgradeFavoriteVariant = -1; private static int _visibleRecycleNReclaimTabFrame = -1; private static int _visibleRecycleNReclaimTabGuiId = -1; private static Vector2i _pendingUpgradeFavoriteGridPos = new Vector2i(-1, -1); private static bool _visibleRecycleNReclaimTabValue; private static Recipe? _lastCraftingSelectedRecipe; private static object? _craftingGroupAvailabilityRecipeListRef; private static int _craftingGroupAvailabilityRecipeCount = -1; private const float CraftingHoverTooltipScrollbarWidth = 3f; private const float CraftingHoverTooltipScrollbarOutsideOffset = 2f; private const float CraftingHoverTooltipScrollSensitivity = 96f; private const float CraftingHoverTooltipMinBodyHeight = 80f; private const float CraftingHoverTooltipMaxPanelHeight = 720f; private static readonly List CustomEquippedItemsCache = new List(); private static readonly Dictionary CustomEquipmentSetCountCache = new Dictionary(StringComparer.Ordinal); private static Player? _customEquipmentCachePlayer; private static Inventory? _customEquipmentCacheInventory; private static string _customEquipmentCachePlayerId = ""; private static int _customEquipmentCacheVersion; private static int _customEquipmentCacheBuiltVersion = -1; private static float _customEquipmentCacheWeight; private static float _customEquipmentCacheEitrRegen; private static float _customEquipmentCacheArmor; private static float[]? _customEquipmentModifierValuesCache; private const string CustomEquipmentVisualItemZdoPrefix = "InventorySlots_CustomEquipmentVisual_Item_"; private const string CustomEquipmentVisualVariantZdoPrefix = "InventorySlots_CustomEquipmentVisual_Variant_"; private static bool? _epicLootLoaded; private static int _epicLootInventoryGridTooltipUiPatchScope; private static GameObject? _epicLootSuppressedOnHoverTooltip; private static bool _epicLootComparisonTooltipReflectionResolved; private static FieldInfo? _epicLootComparisonTooltipField; private static FieldInfo? _epicLootComparisonAddedField; private static bool _epicLootEquipmentEffectCacheResetReflectionResolved; private static MethodInfo? _epicLootEquipmentEffectCacheResetMethod; private static bool _epicLootEquipmentEffectCacheResetWarningLogged; private static bool _epicLootRuntimeItemDataReflectionResolved; private static bool _epicLootRuntimeItemDataWarningLogged; private static MethodInfo? _epicLootItemDataMethod; private static MethodInfo? _epicLootItemInfoLoadAllMethod; private static MethodInfo? _epicLootItemInfoGetMethod; private static Type? _epicLootMagicItemComponentType; private static MethodInfo? _epicLootMagicItemComponentLoadMethod; private static int _lastEpicLootRespawnRuntimeReloadFrame = -1; private static float _lastEpicLootRespawnRuntimeReloadTime = -1000f; private const float HudStatBarPixelsPer25 = 32f; private const float HudAdrenalineBarPixelsPer25 = 64f; private const float HudStatBarLogBaseline = 100f; private const float InventoryHoverTooltipWidth = 410f; private const float InventoryHoverTooltipPadding = 8f; private const float InventoryHoverTooltipTopicGap = 6f; private const float InventoryHoverTooltipScrollbarWidth = 3f; private const float InventoryHoverTooltipScrollbarOutsideOffset = 2f; private const float InventoryHoverTooltipScrollSensitivity = 120f; private const float InventoryHoverTooltipMinBodyHeight = 80f; private const float InventoryHoverTooltipMaxPanelHeight = 720f; private const float InventoryHoverTooltipScrollbarThresholdHeight = 600f; private const int InventoryHoverTooltipSourceCacheLimit = 64; private static readonly InventoryHoverTooltipRuntimeState InventoryHoverTooltipRuntime = new InventoryHoverTooltipRuntimeState(); private static string QuickSlotProgressionCachePlayerId = ""; private static int QuickSlotProgressionCachedRows; private static string QuickSlotProgressionResetPendingPlayerId = ""; private static string QuickSlotProgressionResetWarningPlayerId = ""; private static readonly Dictionary PlayerInventoryPanelBackgroundSnapshots = new Dictionary(StringComparer.Ordinal); private static CustomSyncedValue _syncedYaml = null; private static CustomSyncedValue _syncedResourceMapYaml = null; private static FileSystemWatcher? _yamlWatcher; private static readonly object YamlReloadLock = new object(); private static readonly InventoryPanelRuntimeState InventoryPanels = new InventoryPanelRuntimeState(); private static readonly InventorySafetyRuntimeState InventorySafety = new InventorySafetyRuntimeState(); private static readonly InventoryContainerRuntimeState InventoryContainers = new InventoryContainerRuntimeState(); private static readonly InventoryDefinitionRuntimeState InventoryDefinitions = new InventoryDefinitionRuntimeState(); private static readonly InventoryClientRuntimeState InventoryClient = new InventoryClientRuntimeState(); private static readonly EquipmentVisualRuntimeState EquipmentVisuals = new EquipmentVisualRuntimeState(); private static readonly InventorySortRuntimeState InventorySort = new InventorySortRuntimeState(); private static readonly string[] PlayerStatPanelExtraNames = new string[2] { "Jewelcrafting Synergy", "Trash" }; private static readonly string[] QuickStackStoreMiniButtonNames = new string[4] { "sortInventoryButton", "restockAreaButton", "quickStackAreaButton", "favoritingTogglingButton" }; private float _nextRefreshTime; private float _nextLightAuditTime; private float _nextHeavyAuditTime; private static bool _yamlReloadQueued; private static bool _resourceMapReloadQueued; private static DateTime _yamlReloadAfterUtc; private const float InventoryTrashPanelGap = 8f; private const string InventoryTrashButtonName = "InventorySlots_TrashButton"; private const string InventoryTrashIconName = "InventorySlots_TrashIcon"; private const string InventoryTrashConfirmDialogName = "InventorySlots_TrashConfirmDialog"; private static RectTransform? _inventoryTrashPanel; private static Sprite? _inventoryTrashIconSprite; private static GameObject? _inventoryTrashConfirmDialog; private static Inventory? _inventoryTrashPendingInventory; private static ItemData? _inventoryTrashPendingItem; private static int _inventoryTrashPendingAmount; private const int MaxItemClassifierCacheItems = 2048; private static readonly ItemClassifierRuntimeState ItemClassifierRuntime = new ItemClassifierRuntimeState(); private static readonly Dictionary> BuiltInGroupMatchers = new Dictionary>(StringComparer.OrdinalIgnoreCase) { ["all"] = (ItemData _) => true, ["healthfood"] = MatchHealthFoodCategory, ["staminafood"] = MatchStaminaFoodCategory, ["eitrfood"] = MatchEitrFoodCategory, ["consumable"] = MatchConsumableCategory, ["mead"] = MatchMeadCategory, ["potion"] = MatchPotionCategory, ["meadbase"] = MatchMeadBaseCategory, ["feast"] = MatchFeastCategory, ["trophy"] = (ItemData item) => (int)item.m_shared.m_itemType == 13, ["valuable"] = (ItemData item) => item.m_shared.m_value > 0, ["melee"] = MatchMeleeCategory, ["ranged"] = MatchRangedCategory, ["magic"] = MatchMagicCategory, ["armor"] = MatchArmorCategory, ["equipment"] = MatchArmorCategory, ["food"] = MatchFoodCategory, ["misc"] = MatchMiscCategory, ["legs"] = MatchLegsCategory, ["chest"] = MatchChestCategory, ["helmet"] = MatchHelmetCategory, ["cape"] = MatchCapeCategory, ["utility"] = MatchUtilityCategory, ["trinket"] = MatchTrinketCategory, ["shield"] = MatchShieldCategory, ["axe"] = MatchAxeCategory, ["club"] = MatchClubCategory, ["knife"] = MatchKnifeCategory, ["pickaxe"] = MatchPickaxeCategory, ["polearm"] = MatchPolearmCategory, ["spear"] = MatchSpearCategory, ["sword"] = MatchSwordCategory, ["fists"] = MatchFistsCategory, ["bow"] = MatchBowWeaponCategory, ["crossbow"] = MatchCrossbowWeaponCategory, ["elementalmagic"] = MatchElementalMagicCategory, ["bloodmagic"] = MatchBloodMagicCategory, ["tool"] = MatchToolCategory, ["bomb"] = MatchBombCategory, ["arrow"] = MatchArrowAmmo, ["bolt"] = MatchBoltAmmo, ["ammo"] = MatchAmmoCategory }; private const string JewelcraftingGemcutterStationPrefabName = "op_transmution_table"; private static bool _jewelcraftingSlotStateInitialized; private static bool _lastJewelcraftingRingSlotEnabled; private static bool _lastJewelcraftingNecklaceSlotEnabled; private static bool _lastJewelcraftingWisplightGemEnabled; private static bool _lastJewelcraftingWishboneGemEnabled; private const float InventoryPinnedJewelcraftingScrollGap = 12f; private const float InventoryPinnedJewelcraftingRowPadding = 12f; private const float InventoryPinnedJewelcraftingIconGap = 8f; private const float InventoryPinnedJewelcraftingNativeIconSize = 42f; private const float InventoryPinnedJewelcraftingNativeIconInset = 4f; private const float InventoryPinnedJewelcraftingNativeRowGap = 10f; private const float InventoryPinnedJewelcraftingNativeInteractGap = 8f; private const float InventoryPinnedJewelcraftingNativeTextPadding = 4f; private const float InventoryPinnedJewelcraftingNativeBottomPadding = 32f; private static ItemData? _lastMagicSupremacyBeltCompatItem; private static MultiUserContainerBatchState? _multiUserContainerBatch; private const byte MultiUserContainerItemCodecVersion = 1; private const int MultiUserContainerMaxPrefabNameBytes = 1024; private const int MultiUserContainerMaxCrafterNameBytes = 4096; private const int MultiUserContainerMaxCustomDataEntries = 1024; private const int MultiUserContainerMaxCustomDataKeyBytes = 4096; private const int MultiUserContainerMaxCustomDataValueBytes = 40960; private const int MultiUserContainerMaxCustomDataBytes = 40960; private const int MultiUserContainerMaxStack = 1000000; private const int MultiUserContainerMaxQuality = 10000; private const int MultiUserContainerMaxVariant = 10000; private const int MultiUserContainerMaxWorldLevel = 10000; private const int MultiUserContainerMaxGridCoordinate = 4096; private static readonly Encoding MultiUserContainerUtf8 = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); private const float MultiUserContainerRetryInterval = 0.75f; private const float MultiUserContainerRequestTimeout = 5f; private const float MultiUserContainerReceiptPollInterval = 0.25f; private const float MultiUserContainerCommittedProjectionTimeout = 5f; private const float MultiUserContainerLocalRecoveryRetryInterval = 1f; private const int MultiUserContainerMaximumSendAttempts = 5; private static PendingMultiUserContainerTransfer? _pendingMultiUserContainerTransfer; private static readonly List PendingMultiUserContainerLocalRecoveries = new List(); private static int _nextMultiUserContainerRequestId = Math.Max(1, Guid.NewGuid().GetHashCode() & 0x7FFFFFFF); private const string MultiUserContainerRequestRpc = "InventorySlots_MUC_Request_v3"; private const string MultiUserContainerResponseRpc = "InventorySlots_MUC_Response_v3"; private const string MultiUserContainerAcknowledgeRpc = "InventorySlots_MUC_Ack_v3"; private const string MultiUserContainerReceiptZdoKey = "sighsorry.InventorySlots.MUC.Receipts.v3"; private const byte MultiUserContainerProtocolVersion = 3; private const int MultiUserContainerMaxRequestPackageBytes = 98304; private const int MultiUserContainerMaxResponsePackageBytes = 49152; private const int MultiUserContainerMaxDurableReceiptResponseBytes = 49152; private const int MultiUserContainerMaxDurableReceiptBlobBytes = 65536; private const int MultiUserContainerMaxDurableReceiptCount = 128; private const long MultiUserContainerAcknowledgedReceiptLifetimeTicks = 300000000L; private const int MultiUserContainerOwnerResponseCacheLimit = 128; private const int MultiUserContainerOwnerResponseCacheByteLimit = 33554432; private const float MultiUserContainerOwnerResponseCacheLifetime = 30f; private const float MultiUserContainerMaximumInteractionDistance = 10f; private static readonly Dictionary MultiUserContainerOwnerStates = new Dictionary(); private const float MyLittleUICraftingObjectScanInterval = 0.5f; private static readonly string[] MyLittleUIConflictingPatchTypeNames = new string[19] { "MyLittleUI.CraftFilter+StoreGui_Awake_InitializePanel", "MyLittleUI.CraftFilter+InventoryGui_Show_ClearCache", "MyLittleUI.CraftFilter+InventoryGui_OnDestroy_ClearCache", "MyLittleUI.CraftFilter+Chat_HasFocus_FocusOverride", "MyLittleUI.CraftFilter+Player_GetAvailableRecipes_FilterRecipeList", "MyLittleUI.CraftFilter+InventoryGui_UpdateRecipe_HandleFieldFocus", "MyLittleUI.CraftSort+Game_SpawnPlayer_InitializePanel", "MyLittleUI.CraftSort+InventoryGui_Update_SortingPanelVisibility", "MyLittleUI.CraftSort+InventoryGui_UpdateCraftingPanel_HideWithOtherMods", "MyLittleUI.CraftSort+InventoryGui_Update_HideWithOtherMods", "MyLittleUI.CraftSort+InventoryGui_UpdateRecipeList_FilteringAndSorting", "MyLittleUI.CraftSort+InventoryGui_Update_GamepadControls", "MyLittleUI.MultiCraft+InventoryGui_UpdateRecipe_MulticraftShowButtons", "MyLittleUI.MultiCraft+InventoryGui_Awake_MulticraftCreateButtons", "MyLittleUI.MultiCraft+InventoryGui_SetRecipe_ResetMulticraftAfterRecipeChange", "MyLittleUI.Crafting.CraftNew+InventoryGui_UpdateRecipeList_CraftNewRecipeMark", "MyLittleUI.MyLittleUI+InventoryGui_SetupRequirement_AddAvailableAmount", "MyLittleUI.ItemTooltip+ItemDropItemData_GetTooltip_ItemTooltip", "MyLittleUI.ItemTooltip+InventoryGui_Awake_ItemTooltipCraftingFontSize" }; private static readonly string[] MyLittleUICraftingObjectNames = new string[3] { "MLUI_FilterField", "MLUI_SortingPanels", "MLUI_Multicraft" }; private static readonly string[] MyLittleUICraftingObjectPrefixes = new string[2] { "MLUI_SortingPanel_", "selected (MLUI_SortingPanel_" }; private static readonly List CachedMyLittleUICraftingObjects = new List(); private static int _myLittleUICraftingObjectRootSignature; private static float _nextMyLittleUICraftingObjectScanTime; private static bool _myLittleUIInventoryVisibleLastFrame; private static bool _myLittleUIPluginPresenceResolved; private static bool _myLittleUIPluginDetected; private static bool _myLittleUICraftingSuppressionActive; private static bool _myLittleUICraftingCompatibilityApplied; private static string _myLittleUICraftingSuppressionSignature = ""; private const float PinnedTooltipScrollbarWidth = 3f; private const float PinnedTooltipScrollbarOutsideOffset = 2f; private const float PinnedTooltipScrollSensitivity = 240f; private const float CraftingPinnedTooltipTextScrollPadding = 0f; private const float PinnedTooltipScrollOverflowThreshold = 8f; private const float PinnedTooltipTopOffset = -12f; private const float PinnedTooltipBottomOffset = 60f; private const float PinnedTooltipInventoryStartOffset = 6f; private const float PinnedTooltipCraftingStartOffset = -80f; private const int BaseRows = 4; private const int InventoryWidth = 8; private const int MaxSupportedExtraRows = 5; private const string SlotIdKey = "InventorySlotsSlotId"; private const string EquippedByKey = "InventorySlotsEquippedBy"; private const string BackupKey = "InventorySlotsBackup"; private const string UpgradeFavoriteItemIdKey = "InventorySlotsUpgradeFavoriteId"; private const string ExtraSlotsEquippedByKey = "ExtraSlotsEquippedBy"; private const string ExtraSlotsEquippedSlotKey = "ExtraSlotsEquippedSlot"; private const string ExtraSlotsEquippedWeaponShieldKey = "ExtraSlotsEquippedWeaponShield"; private const string JewelcraftingRingSlotId = "jewelcrafting.ring"; private const string JewelcraftingNecklaceSlotId = "jewelcrafting.necklace"; private const string AdventureBackpackSlotId = "adventurebackpacks.backpack"; private const string SmoothbrainBackpackSlotId = "smoothbrainbackpacks.backpack"; private const string RustyBagSlotId = "rustybags.bag"; private const string RustyQuiverSlotId = "rustybags.quiver"; private const string MagicSupremacyBeltSlotId = "magicsupremacy.belt"; private const string MagicSupremacyNativeBeltSlotId = "belt"; private const string MultiUserChestIgnoreZdoKey = "MUC_Ignore"; private const string ConfigDirectoryName = "InventorySlots"; private const string YamlFileName = "InventorySlots.yml"; private const string ResourceMapFileName = "ResourceMap.yml"; private const string ClientStateFileName = "ClientState.yml"; private const string CustomSlotPanelName = "InventorySlots_CustomSlotPanel"; private const string QuickSlotPanelName = "InventorySlots_QuickSlotPanel"; private const string SlotPanelDragBorderName = "InventorySlots_DragBorder"; private const string PlayerStatPanelHostName = "InventorySlots_PlayerStatPanelHost"; private const string InventorySortPanelName = "InventorySlots_InventorySortPanel"; private const string InventoryTrashPanelName = "InventorySlots_TrashPanel"; private const string CurrencyPocketPanelName = "CoinPocketUI"; private const int CurrencyPocketInventoryRow = 4; private const float CurrencyPocketOutsideGap = 6f; private const string QuickSlotsHotkeyBarName = "InventorySlots_QuickSlotsHotKeyBar"; private const string FavoriteKeyHintName = "InventorySlots_FavoriteKeyHint"; private const string PinnedTooltipKeyHintName = "InventorySlots_PinnedTooltipKeyHint"; private const string InventoryPinnedTooltipNamePrefix = "InventorySlots_InventoryPinnedTooltip_"; private const string InventoryPinnedJewelcraftingTooltipRootName = "InventorySlots_JewelcraftingTooltipRoot"; private const string InventoryPinnedTooltipMarkerName = "InventorySlots_PinnedTooltipMarker"; private const string FavoriteBorderName = "InventorySlots_FavoriteBorder"; private const float FavoriteBorderThickness = 2f; private const float QuickSlotsHudSlotBackgroundAlpha = 0.25f; private const int CustomSlotPanelRows = 3; private const int QuickSlotPanelColumns = 3; private const int QuickSlotPanelRows = 3; private const float EquipmentPanelGapRows = 0.35f; private const float SidePanelGapColumns = 1.45f; private const float SidePanelBackgroundPadding = 16f; private const float PlayerStatPanelGap = -8f; private const int HotbarRowsToSwitch = 2; private const int HotbarSwitchFavoriteRow = 1; private const float ContainerActionPairButtonWidthMultiplier = 1f; private const float SortButtonOutsideGap = 1f; private const float QuickSlotPanelIntroFallbackDuration = 0.25f; private const float ContainerHoverHoldDuration = 0.5f; private const int PinnedTooltipSlotCount = 3; private const float PinnedTooltipFixedPanelGap = 15f; private const float InventoryMaintenanceInterval = 1f; private const float LightSafetyAuditInterval = 5f; private const float HeavySafetyAuditInterval = 30f; private const float HeavySafetyAuditActivityDelay = 2f; private const float PendingSlotActionTimeout = 30f; private const float InventoryPinnedJewelcraftingReservedHeight = 190f; private const string ProgressiveSlotsConfigSection = "2 - Progressive Slots"; private const string RestockConfigSection = "3 - Restock"; private const string ClientConfigSection = "4 - Client"; private const string ClientUiConfigSection = "5 - Client UI"; private const string ClientKeysConfigSection = "6 - Client Keys"; private const string ControllerInputConfigSection = "7 - Controller Input"; private static readonly Vector2 HotbarSwitchHintOffset = new Vector2(-50f, -32f); private static readonly Color HotbarSwitchHintColor = new Color(58f / 85f, 0.8784314f, 1f, 1f); private const float HotbarSwitchHintSize = 64f; private const float HotbarSwitchHintFontSize = 16f; private static readonly Vector2 InventoryWheelHintOffset = new Vector2(0f, -32f); private static readonly Color InventoryWheelHintColor = new Color(58f / 85f, 0.8784314f, 1f, 1f); private const float InventoryWheelHintSize = 0f; private static readonly Vector2 PinnedTooltipFixedPanelSize = new Vector2(345f, 600f); private static readonly Vector2 InventoryPinnedTooltipFixedOffset = new Vector2(828f, -384f); private static readonly Vector2 CraftingPinnedTooltipFixedOffset = new Vector2(-900f, 0f); private static readonly Vector2 QuickSlotsPanelFixedOffset = new Vector2(-80f, -552f); private static readonly Vector2 QuickSlotsHudFallbackPosition = new Vector2(64f, -520f); private static readonly Vector2 EquipmentSlotsPanelFixedOffset = new Vector2(-80f, 0f); private static readonly Vector2 PlayerStatPanelsFixedOffset = Vector2.zero; private static readonly Vector2 ArmorPanelFixedOffset = new Vector2(-5f, 15f); private static readonly Vector2 WeightPanelFixedOffset = new Vector2(-5f, -5f); private static readonly Vector2 SynergyPanelFixedOffset = new Vector2(-5f, -25f); private static readonly Vector2 InventorySortButtonFixedOffset = new Vector2(2f, 2f); private static readonly Vector2 ContainerSortButtonFixedOffset = Vector2.zero; private const float ContainerWeightPanelFixedYOffset = 200f; internal static readonly ManualLogSource Log = Logger.CreateLogSource("InventorySlots"); private readonly Harmony _harmony = new Harmony("sighsorry.InventorySlots"); private static InventorySlotsPlugin _instance = null; private static readonly ConfigSync ConfigSync = new ConfigSync("sighsorry.InventorySlots") { DisplayName = "InventorySlots", CurrentVersion = "1.3.3", MinimumRequiredVersion = "1.3.3", ModRequired = true }; private static ConfigEntry _serverConfigLocked = null; private static ConfigEntry _progressiveRowsEnabled = null; private static ConfigEntry _maxExtraRows = null; private static ConfigEntry[] _rowUnlockItems = null; private static ConfigEntry _quickSlotRows = null; private static ConfigEntry _quickSlotProgressionEnabled = null; private static ConfigEntry[] _quickSlotRowUnlockItems = null; private static ConfigEntry _equipmentSlotProgressionEnabled = null; private static ConfigEntry _deathKeepRulesEnabled = null; private static ConfigEntry _areaQuickStackRange = null; private static ConfigEntry _areaRestockRange = null; private static ConfigEntry _restockTargetStackLimitsConfig = null; private static ConfigEntry _hotbarSwitchKey = null; private static ConfigEntry _containerRestockKey = null; private static ConfigEntry _showHotbarSwitchHint = null; private static ConfigEntry _quickSlotHudFollowsPanel = null; private static ConfigEntry _inventoryRowsDisplayMode = null; private static ConfigEntry _showInventoryWheelButton = null; private static ConfigEntry _enableInventoryTrashPanel = null; private static ConfigEntry _pinnedTooltipSlots = null; private static ConfigEntry _pinnedTooltipKey = null; private static ConfigEntry _pinnedTooltipBackgroundAlpha = null; private static ConfigEntry _showCraftingHoverTooltip = null; private static ConfigEntry _craftingHoverTooltipBackgroundAlpha = null; private static ConfigEntry _inventoryContainerHoverTooltipBackgroundAlpha = null; private static ConfigEntry _playerStatBarLengthScaling = null; private static ConfigEntry _containerActionSuccessFx = null; private static ConfigEntry _inventorySortMode = null; private static ConfigEntry _autoFavoriteHotbarSwitchRow = null; private static ConfigEntry _mouseUiScrollMultiplier = null; private static ConfigEntry _enableGamepadUiScroll = null; private static ConfigEntry _gamepadUiScrollSource = null; private static ConfigEntry _gamepadUiScrollSensitivity = null; private static ConfigEntry _gamepadUiScrollRepeatDelay = null; private static ConfigEntry _gamepadUiScrollDeadzone = null; private static ConfigEntry _enableControllerHotkeys = null; private static ConfigEntry _controllerDPadHotkeyMode = null; private static ConfigEntry _controllerDPadModifierButton = null; private static ConfigEntry _controllerCraftingGridZoomModifierButton = null; private static ConfigEntry _controllerPinnedTooltipButton = null; private static ConfigEntry _controllerFavoriteModifierButton = null; private static ConfigEntry _controllerClearCraftingFavoritesButton = null; private static ConfigEntry _controllerHotbarSwitchButton = null; private static ConfigEntry _controllerContainerRestockButton = null; private static ConfigEntry[] _controllerQuickSlotButtons = null; private static ConfigEntry _containerPreviewCloseDelay = null; private static ConfigEntry _favoriteModifierKey = null; private static ConfigEntry[] _quickSlotHotkeys = null; private static ConfigEntry _enableBuiltInMultiUserChest = null; internal const string ModName = "InventorySlots"; internal const string ModVersion = "1.3.3"; internal const string Author = "sighsorry"; internal const string ModGUID = "sighsorry.InventorySlots"; private const string RecycleNReclaimCompatibilityCapability = "Recycle_N_Reclaim reclaim tab"; private const float RecycleNReclaimSignatureCacheSeconds = 0.1f; private static int _recycleNReclaimActiveFrame = -1; private static bool _recycleNReclaimActiveFrameValue; private static float _recycleNReclaimContextSignatureExpiresAt; private static string _recycleNReclaimContextSignature = ""; private const string RecycleNReclaimHudName = "InventorySlots_RecycleNReclaimHud"; private const int RecycleNReclaimYieldColumn = 2; private const int RecycleNReclaimYieldColumns = 6; private static readonly List RecycleNReclaimHudImpediments = new List(); private static readonly List RecycleNReclaimHudYields = new List(); private static RectTransform? _recycleNReclaimHudRect; private static TMP_Text? _recycleNReclaimHudText; private static string _recycleNReclaimHudSignature = ""; private static object? _recycleNReclaimRecipeListSignatureListRef; private static int _recycleNReclaimRecipeListSignatureCount = -1; private static float _recycleNReclaimRecipeListSignatureExpiresAt; private static string _recycleNReclaimRecipeListSignature = ""; private static readonly List RestockTargetLimitEditorRows = new List(); private static string _restockTargetLimitEditorLastValue = ""; private static readonly List StationTokenCookingStations = new List(); private static readonly List StationTokenFermenters = new List(); private static readonly Dictionary VanillaTooltipVisualSnapshots = new Dictionary(); private static readonly Dictionary VanillaTooltipChildCanvasGroupSnapshots = new Dictionary(); private static readonly PinnedTooltipRuntimeState PinnedTooltips = new PinnedTooltipRuntimeState(); private static readonly TooltipUiRuntimeState TooltipUi = new TooltipUiRuntimeState(); private static float _nextGamepadUiScrollStepTime; private static YamlRoot _yamlConfig = new YamlRoot(); private const string DefaultYamlResourceName = "InventorySlots.Default.yml"; private const string DefaultResourceMapYamlResourceName = "InventorySlots.ResourceMap.Default.yml"; private static readonly Lazy DefaultYamlResource = new Lazy(LoadDefaultYaml); private static readonly Lazy DefaultResourceMapYamlResource = new Lazy(LoadDefaultResourceMapYaml); private static bool HasServerCharactersActive { get { if (!ZNet.IsSinglePlayer) { return HasPlugin("org.bepinex.plugins.servercharacters"); } return false; } } private static bool HasExternalMultiUserChestActive => HasPlugin("com.maxsch.valheim.MultiUserChest"); private static bool IsBuiltInMultiUserChestEnabled { get { if (!HasExternalMultiUserChestActive) { ConfigEntry enableBuiltInMultiUserChest = _enableBuiltInMultiUserChest; if (enableBuiltInMultiUserChest == null) { return false; } return enableBuiltInMultiUserChest.Value == Toggle.On; } return false; } } private static bool HasJewelcraftingActive => HasPlugin("org.bepinex.plugins.jewelcrafting"); private static RectTransform? _craftingRecipeGrid { get { return CraftingGrid.RecipeGrid; } set { CraftingGrid.RecipeGrid = value; } } private static RectTransform? _craftingRecipeScrollbar { get { return CraftingScrollbar.RecipeScrollbar; } set { CraftingScrollbar.RecipeScrollbar = value; } } private static RectTransform? _craftingGroupRail { get { return CraftingUi.GroupRail; } set { CraftingUi.GroupRail = value; } } private static TMP_InputField? _craftingCountInput { get { return CraftingUi.CountInput; } set { CraftingUi.CountInput = value; } } private static RectTransform? _craftingCountInputRect { get { return CraftingUi.CountInputRect; } set { CraftingUi.CountInputRect = value; } } private static RectTransform? _craftingUpgradeProgressionRect { get { return CraftingUi.UpgradeProgressionRect; } set { CraftingUi.UpgradeProgressionRect = value; } } private static RectTransform? _craftingSortModeButtonGroup { get { return CraftingUi.SortModeButtonGroup; } set { CraftingUi.SortModeButtonGroup = value; } } private static RectTransform? _craftingControlsBackground { get { return CraftingUi.ControlsBackground; } set { CraftingUi.ControlsBackground = value; } } private static RectTransformSnapshot? _craftingPanelRootSnapshot { get { return CraftingUi.PanelRootSnapshot; } set { CraftingUi.PanelRootSnapshot = value; } } private static Vector2 _craftingPanelOriginalSizeDelta { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return CraftingUi.PanelOriginalSizeDelta; } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) CraftingUi.PanelOriginalSizeDelta = value; } } private static int _craftingRecipePage { get { return CraftingGrid.RecipePage; } set { CraftingGrid.RecipePage = value; } } private static GameObject? _inventoryHoverTooltip { get { return InventoryHoverTooltipRuntime.HoverTooltip; } set { InventoryHoverTooltipRuntime.HoverTooltip = value; } } private static RectTransform? _inventoryHoverTooltipPanel { get { return InventoryHoverTooltipRuntime.HoverTooltipPanel; } set { InventoryHoverTooltipRuntime.HoverTooltipPanel = value; } } private static TMP_Text? _inventoryHoverTooltipTopic { get { return InventoryHoverTooltipRuntime.HoverTooltipTopic; } set { InventoryHoverTooltipRuntime.HoverTooltipTopic = value; } } private static TMP_Text? _inventoryHoverTooltipText { get { return InventoryHoverTooltipRuntime.HoverTooltipText; } set { InventoryHoverTooltipRuntime.HoverTooltipText = value; } } private static ScrollableTooltipBodyState InventoryHoverTooltipTextScroll => InventoryHoverTooltipRuntime.HoverTooltipTextScroll; private static TooltipSourceCacheCore InventoryHoverTooltipItems => InventoryHoverTooltipRuntime.HoverTooltipItems; private static string _inventoryHoverTooltipSignature { get { return InventoryHoverTooltipRuntime.HoverTooltipSignature; } set { InventoryHoverTooltipRuntime.HoverTooltipSignature = value; } } private static string _inventoryHoverTooltipLayoutSignature { get { return InventoryHoverTooltipRuntime.HoverTooltipLayoutSignature; } set { InventoryHoverTooltipRuntime.HoverTooltipLayoutSignature = value; } } private static float _inventoryHoverTooltipScrollOffset { get { return InventoryHoverTooltipRuntime.HoverTooltipScrollOffset; } set { InventoryHoverTooltipRuntime.HoverTooltipScrollOffset = value; } } private static float _inventoryHoverTooltipMaxScroll { get { return InventoryHoverTooltipRuntime.HoverTooltipMaxScroll; } set { InventoryHoverTooltipRuntime.HoverTooltipMaxScroll = value; } } private static bool _inventoryHoverTooltipNeedsScroll { get { return InventoryHoverTooltipRuntime.HoverTooltipNeedsScroll; } set { InventoryHoverTooltipRuntime.HoverTooltipNeedsScroll = value; } } private static RectTransform? _inventoryHoverJewelcraftingTooltipRoot { get { return InventoryHoverTooltipRuntime.HoverJewelcraftingTooltipRoot; } set { InventoryHoverTooltipRuntime.HoverJewelcraftingTooltipRoot = value; } } private static string _inventoryHoverJewelcraftingTooltipSignature { get { return InventoryHoverTooltipRuntime.HoverJewelcraftingTooltipSignature; } set { InventoryHoverTooltipRuntime.HoverJewelcraftingTooltipSignature = value; } } private static int _inventoryHoverJewelcraftingTooltipLayoutRefreshFrames { get { return InventoryHoverTooltipRuntime.HoverJewelcraftingTooltipLayoutRefreshFrames; } set { InventoryHoverTooltipRuntime.HoverJewelcraftingTooltipLayoutRefreshFrames = value; } } private static GameObject? _inventorySimpleNameTooltip { get { return InventoryHoverTooltipRuntime.SimpleNameTooltip; } set { InventoryHoverTooltipRuntime.SimpleNameTooltip = value; } } private static RectTransform? _inventorySimpleNameTooltipRect { get { return InventoryHoverTooltipRuntime.SimpleNameTooltipRect; } set { InventoryHoverTooltipRuntime.SimpleNameTooltipRect = value; } } private static TMP_Text? _inventorySimpleNameTooltipText { get { return InventoryHoverTooltipRuntime.SimpleNameTooltipText; } set { InventoryHoverTooltipRuntime.SimpleNameTooltipText = value; } } private static string _inventorySimpleNameTooltipValue { get { return InventoryHoverTooltipRuntime.SimpleNameTooltipValue; } set { InventoryHoverTooltipRuntime.SimpleNameTooltipValue = value; } } private static SimpleNameTooltipPlacement _inventorySimpleNameTooltipPlacement { get { return InventoryHoverTooltipRuntime.SimpleNameTooltipPlacement; } set { InventoryHoverTooltipRuntime.SimpleNameTooltipPlacement = value; } } private static SimpleTooltipOwnershipCore InventorySimpleNameTooltipOwner => InventoryHoverTooltipRuntime.SimpleNameTooltipOwner; private static object InventorySimpleNameTooltipFallbackOwner => InventoryHoverTooltipRuntime.SimpleNameTooltipFallbackOwner; private static object? _pinnedGemNameTooltipOwner { get { return InventoryHoverTooltipRuntime.PinnedGemNameTooltipOwner; } set { InventoryHoverTooltipRuntime.PinnedGemNameTooltipOwner = value; } } private static float _pinnedGemNameTooltipHoldUntil { get { return InventoryHoverTooltipRuntime.PinnedGemNameTooltipHoldUntil; } set { InventoryHoverTooltipRuntime.PinnedGemNameTooltipHoldUntil = value; } } private static UITooltip? _inventoryContainerHoverTooltipSource { get { return InventoryHoverTooltipRuntime.ContainerHoverTooltipSource; } set { InventoryHoverTooltipRuntime.ContainerHoverTooltipSource = value; } } private static UITooltip? _inventorySlotsOwnedHoverTooltipSource { get { return InventoryHoverTooltipRuntime.OwnedHoverTooltipSource; } set { InventoryHoverTooltipRuntime.OwnedHoverTooltipSource = value; } } private static bool _tooltipLateUpdateExceptionLogged { get { return InventoryHoverTooltipRuntime.LateUpdateExceptionLogged; } set { InventoryHoverTooltipRuntime.LateUpdateExceptionLogged = value; } } private static List SlotDefinitions => InventoryDefinitions.SlotDefinitions; private static Dictionary> PredefinedGroupDefinitions => InventoryDefinitions.PredefinedGroupDefinitions; private static List PredefinedGroupOrder => InventoryDefinitions.PredefinedGroupOrder; private static Dictionary> PredefinedGroupOrders => InventoryDefinitions.PredefinedGroupOrders; private static Dictionary InventoryLimits => InventoryDefinitions.InventoryLimits; private static Dictionary ResourceTierByToken => InventoryDefinitions.ResourceTierByToken; private static HashSet CookingStationInputTokens => InventoryDefinitions.CookingStationInputTokens; private static HashSet CraftingRecipeFoodInputTokens => InventoryDefinitions.CraftingRecipeFoodInputTokens; private static HashSet CookingStationFoodInputTokens => InventoryDefinitions.CookingStationFoodInputTokens; private static HashSet FermenterInputTokens => InventoryDefinitions.FermenterInputTokens; private static HashSet FermenterOutputTokens => InventoryDefinitions.FermenterOutputTokens; private static HashSet FermenterFoodInputTokens => InventoryDefinitions.FermenterFoodInputTokens; private static Dictionary ItemNameTokens => InventoryDefinitions.ItemNameTokens; private static HashSet FavoriteSlots => InventoryClient.FavoriteSlots; internal static bool IsCompletingSlotUnequip => InventorySafety.SlotUnequipInProgress; internal static bool IsHandlingSlotDropOutside => InventorySafety.HandlingSlotDropOutside; internal static IReadOnlyList Slots => SlotDefinitions; internal static bool IsDedicatedServer { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4) { if (Application.isBatchMode) { return string.Equals(Paths.ProcessName, "valheim_server", StringComparison.OrdinalIgnoreCase); } return false; } return true; } } private static string ConfigDirectoryPath => Path.Combine(Paths.ConfigPath, "InventorySlots"); private static string YamlFilePath => Path.Combine(ConfigDirectoryPath, "InventorySlots.yml"); private static string ResourceMapFilePath => Path.Combine(ConfigDirectoryPath, "ResourceMap.yml"); private static string ClientStateFilePath => Path.Combine(ConfigDirectoryPath, "ClientState.yml"); internal static string DefaultYaml => DefaultYamlResource.Value; internal static string DefaultResourceMapYaml => DefaultResourceMapYamlResource.Value; private static int GetAzuCraftyBoxesAvailableCraftingRequirementAmount(Requirement requirement, string sharedName) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)requirement.m_resItem == (Object)null || !TryGetAzuCraftyBoxesApi(out AzuCraftyBoxesApi api) || api == null || api.ShouldPrevent()) { return 0; } try { IEnumerable nearbyContainers = api.GetNearbyContainers(localPlayer, api.GetRange()); if (nearbyContainers == null) { return 0; } string prefabNameForAzuCraftyBoxes = GetPrefabNameForAzuCraftyBoxes(((Object)requirement.m_resItem).name); bool leaveOne = api.GetLeaveOne(); int num = 0; foreach (object item in nearbyContainers) { if (item == null) { continue; } string text = api.InvokeString(item, "GetPrefabName"); if (!string.IsNullOrWhiteSpace(text) && api.CanItemBePulled(text, prefabNameForAzuCraftyBoxes)) { int num2 = api.InvokeInt(item, "ItemCount", sharedName); if (leaveOne && num2 > 0) { num2--; } if (num2 > 0) { num += num2; } } } return num; } catch (Exception) { return 0; } } private static bool TryGetAzuCraftyBoxesApi(out AzuCraftyBoxesApi? api) { return TryGetCompatApi("Azumatt.AzuCraftyBoxes", "AzuCraftyBoxes", CompatRuntime.AzuCraftyBoxes, AzuCraftyBoxesApi.TryCreate, "AzuCraftyBoxes compatibility disabled", out api); } private static bool TryGetAzuCraftyBoxesRequirementFlashColor(out Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) color = default(Color); if (!TryGetAzuCraftyBoxesApi(out AzuCraftyBoxesApi api) || api == null || api.ShouldPrevent()) { return false; } return api.TryGetRequirementFlashColor(out color); } private static string GetPrefabNameForAzuCraftyBoxes(string name) { if (string.IsNullOrWhiteSpace(name)) { return ""; } int num = name.IndexOfAny(new char[2] { '(', ' ' }); if (num < 0) { return name; } return name.Substring(0, num); } private static void InitializeBackpackCompatibility() { if (!_adventureBackpacksPatchesApplied && TryGetAdventureBackpacksApi(out AdventureBackpacksApi api) && api != null) { api.ApplyPatches(_instance._harmony); _adventureBackpacksPatchesApplied = true; } TryGetSmoothbrainBackpacksApi(out SmoothbrainBackpacksApi _); TryGetRustyBagsApi(out RustyBagsApi _); } private static bool TryAddBackpackCompatSlot(YamlSlot slot, string id) { return NormalizeSlotId(id) switch { "adventurebackpacks.backpack" => TryAddAdventureBackpackSlot(slot), "smoothbrainbackpacks.backpack" => TryAddSmoothbrainBackpackSlot(slot), "rustybags.bag" => TryAddRustyBagSlot(slot), "rustybags.quiver" => TryAddRustyQuiverSlot(slot), _ => false, }; } private static bool TryAddAdventureBackpackSlot(YamlSlot slot) { AdventureBackpacksApi api; bool hasApi = TryGetAdventureBackpacksApi(out api) && api != null; return TryAddBackpackCompatSlot(slot, "adventurebackpacks.backpack", "Backpack", hasApi, (ItemData? item) => IsAdventureBackpackItem(item)); } private static bool TryAddSmoothbrainBackpackSlot(YamlSlot slot) { SmoothbrainBackpacksApi api; bool hasApi = TryGetSmoothbrainBackpacksApi(out api) && api != null; return TryAddBackpackCompatSlot(slot, "smoothbrainbackpacks.backpack", "Backpack", hasApi, (ItemData? item) => IsSmoothbrainBackpackItem(item)); } private static bool TryAddRustyBagSlot(YamlSlot slot) { RustyBagsApi api; bool hasApi = TryGetRustyBagsApi(out api) && api != null; return TryAddBackpackCompatSlot(slot, "rustybags.bag", "Bag", hasApi, (ItemData? item) => IsRustyBagItem(item)); } private static bool TryAddRustyQuiverSlot(YamlSlot slot) { RustyBagsApi api; bool hasApi = TryGetRustyBagsApi(out api) && api != null; return TryAddBackpackCompatSlot(slot, "rustybags.quiver", "Quiver", hasApi, (ItemData? item) => IsRustyQuiverItem(item)); } private static bool TryAddBackpackCompatSlot(YamlSlot slot, string id, string fallbackName, bool hasApi, Func accepts) { if (SlotDefinitions.Any((SlotDefinition existing) => existing.Id == id)) { return true; } List items = GetSlotItems(slot); if (!hasApi && items.Count == 0) { return true; } string name = (string.IsNullOrWhiteSpace(slot.Name) ? fallbackName : slot.Name.Trim()); SlotDefinitions.Add(new SlotDefinition(id, name, SlotKind.CustomEquipment, (ItemData? item) => accepts(item) || (items.Count > 0 && ItemMatchesSlotItems(item, items)))); return true; } private static bool IsAdventureBackpackItem(ItemData? item) { if (item != null && TryGetAdventureBackpacksApi(out AdventureBackpacksApi api) && api != null) { return api.IsBackpack(item); } return false; } private static bool IsSmoothbrainBackpackItem(ItemData? item) { if (item != null && TryGetSmoothbrainBackpacksApi(out SmoothbrainBackpacksApi api) && api != null) { return api.IsBackpack(item); } return false; } private static bool IsRustyBagItem(ItemData? item) { if (item != null && TryGetRustyBagsApi(out RustyBagsApi api) && api != null && api.IsBag(item)) { return !api.IsQuiver(item); } return false; } private static bool IsRustyQuiverItem(ItemData? item) { if (item != null && TryGetRustyBagsApi(out RustyBagsApi api) && api != null) { return api.IsQuiver(item); } return false; } private static void SyncBackpackCompatState(Player player) { if (!((Object)(object)player == (Object)null)) { SyncAdventureBackpackCompatState(player); SyncSmoothbrainBackpackCompatState(player); SyncRustyBagsCompatState(player); } } private static void OnCustomEquipmentCompatEquipped(Player player, ItemData item) { if ((Object)(object)player == (Object)null || item == null) { return; } if (IsAdventureBackpackItem(item) && TryGetAdventureBackpacksApi(out AdventureBackpacksApi api) && api != null) { if (_lastAdventureBackpackCompatItem != item || !api.IsBackpackEquippedFlagSet()) { api.OnCustomBackpackEquipped(player, item); } _lastAdventureBackpackCompatItem = item; } if (IsSmoothbrainBackpackItem(item) && TryGetSmoothbrainBackpacksApi(out SmoothbrainBackpacksApi api2) && api2 != null) { api2.SyncEquippedBackpack(player, item); _lastSmoothbrainBackpackCompatItem = item; } if (TryGetRustyBagsApi(out RustyBagsApi api3) && api3 != null) { if (IsRustyBagItem(item)) { api3.SyncBag(player, item); _lastRustyBagCompatItem = item; } else if (IsRustyQuiverItem(item)) { api3.SyncQuiver(player, item); _lastRustyQuiverCompatItem = item; } } OnMagicSupremacyBeltEquipped(player, item); } private static void OnCustomEquipmentCompatUnequipping(Player? player, ItemData item) { if (player == null) { player = Player.m_localPlayer; } if ((Object)(object)player == (Object)null || item == null) { return; } if ((_lastAdventureBackpackCompatItem == item || IsAdventureBackpackItem(item)) && TryGetAdventureBackpacksApi(out AdventureBackpacksApi api) && api != null) { api.OnCustomBackpackUnequipping(player, item); if (_lastAdventureBackpackCompatItem == item) { _lastAdventureBackpackCompatItem = null; } } if ((_lastSmoothbrainBackpackCompatItem == item || IsSmoothbrainBackpackItem(item)) && TryGetSmoothbrainBackpacksApi(out SmoothbrainBackpacksApi api2) && api2 != null) { api2.SyncEquippedBackpack(player, null); if (_lastSmoothbrainBackpackCompatItem == item) { _lastSmoothbrainBackpackCompatItem = null; } } if (TryGetRustyBagsApi(out RustyBagsApi api3) && api3 != null) { if (_lastRustyBagCompatItem == item || IsRustyBagItem(item)) { api3.ClearBagIfCurrent(player, item); if (_lastRustyBagCompatItem == item) { _lastRustyBagCompatItem = null; } } if (_lastRustyQuiverCompatItem == item || IsRustyQuiverItem(item)) { api3.ClearQuiverIfCurrent(player, item); if (_lastRustyQuiverCompatItem == item) { _lastRustyQuiverCompatItem = null; } } } OnMagicSupremacyBeltUnequipping(player, item); } private static void SyncAdventureBackpackCompatState(Player player) { if (!TryGetAdventureBackpacksApi(out AdventureBackpacksApi api) || api == null) { _lastAdventureBackpackCompatItem = null; return; } ItemData val = FindCustomEquippedItem(player, IsAdventureBackpackItem); if (val != _lastAdventureBackpackCompatItem) { if (_lastAdventureBackpackCompatItem != null) { api.OnCustomBackpackUnequipping(player, _lastAdventureBackpackCompatItem); } _lastAdventureBackpackCompatItem = val; if (val != null) { api.OnCustomBackpackEquipped(player, val); } } else if (val != null && !api.IsBackpackEquippedFlagSet()) { api.OnCustomBackpackEquipped(player, val); } } private static void SyncSmoothbrainBackpackCompatState(Player player) { if (!TryGetSmoothbrainBackpacksApi(out SmoothbrainBackpacksApi api) || api == null) { _lastSmoothbrainBackpackCompatItem = null; return; } ItemData val = FindCustomEquippedItem(player, IsSmoothbrainBackpackItem); api.SyncEquippedBackpack(player, val); _lastSmoothbrainBackpackCompatItem = val; } private static void SyncRustyBagsCompatState(Player player) { if (!TryGetRustyBagsApi(out RustyBagsApi api) || api == null) { _lastRustyBagCompatItem = null; _lastRustyQuiverCompatItem = null; return; } ItemData val = FindCustomEquippedItem(player, IsRustyBagItem); ItemData val2 = FindCustomEquippedItem(player, IsRustyQuiverItem); api.SyncBag(player, val); api.SyncQuiver(player, val2); _lastRustyBagCompatItem = val; _lastRustyQuiverCompatItem = val2; } private static ItemData? FindCustomEquippedItem(Player player, Func predicate) { if ((Object)(object)player == (Object)null) { return null; } return ((IEnumerable)GetCustomEquippedItems(player)).FirstOrDefault((Func)((ItemData item) => item != null && predicate(item))); } private static bool TryGetAdventureBackpacksApi(out AdventureBackpacksApi? api) { return TryGetCompatApi("vapok.mods.adventurebackpacks", "AdventureBackpacks", CompatRuntime.AdventureBackpacks, AdventureBackpacksApi.TryCreate, "AdventureBackpacks compatibility disabled", out api); } private static bool TryGetSmoothbrainBackpacksApi(out SmoothbrainBackpacksApi? api) { return TryGetCompatApi("org.bepinex.plugins.backpacks", "Smoothbrain Backpacks", CompatRuntime.SmoothbrainBackpacks, SmoothbrainBackpacksApi.TryCreate, "Smoothbrain Backpacks compatibility disabled", out api); } private static bool TryGetRustyBagsApi(out RustyBagsApi? api) { return TryGetCompatApi("RustyMods.RustyBags", "RustyBags", CompatRuntime.RustyBags, RustyBagsApi.TryCreate, "RustyBags compatibility disabled", out api); } private static void AdventureBackpackIsBackpackEquippedPostfix(Player player, ref bool __result) { if (!__result && (Object)(object)player != (Object)null && FindCustomEquippedItem(player, IsAdventureBackpackItem) != null) { __result = true; } } private static void AdventureBackpackIsThisBackpackEquippedPostfix(Player player, ItemData itemData, ref bool __result) { if (!__result && !((Object)(object)player == (Object)null) && itemData != null && IsAdventureBackpackItem(itemData)) { __result = GetCustomEquippedItems(player).Any((ItemData item) => item == itemData); } } private static void AdventureBackpackGetEquippedBackpackPrefix(Player player, ref ItemData? __state) { if ((Object)(object)player == (Object)null) { return; } __state = ((Humanoid)player).m_shoulderItem; if (!IsAdventureBackpackItem(((Humanoid)player).m_shoulderItem)) { ItemData val = FindCustomEquippedItem(player, IsAdventureBackpackItem); if (val != null) { ((Humanoid)player).m_shoulderItem = val; } } } private static void AdventureBackpackGetEquippedBackpackPostfix(Player player, ItemData? __state) { if ((Object)(object)player != (Object)null) { ((Humanoid)player).m_shoulderItem = __state; } } private static bool IsBetterArcheryQuiverCell(Vector2i pos, bool includeRestockableSlots) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!TryGetBetterArcheryQuiverApi(out BetterArcheryQuiverApi api) || api == null) { return false; } try { return api.IsQuiverCell(pos, includeRestockableSlots); } catch (Exception ex) { return MarkCompatReflectionFailed(CompatRuntime.BetterArcheryQuiver, ex.Message, "BetterArchery quiver compatibility disabled"); } } private static bool TryGetBetterArcheryQuiverApi(out BetterArcheryQuiverApi? api) { return TryGetCompatApi("ishid4.mods.betterarchery", "BetterArchery quiver", CompatRuntime.BetterArcheryQuiver, BetterArcheryQuiverApi.TryCreate, "BetterArchery quiver compatibility disabled", out api); } private static bool TryGetCompatApi(string guid, string capability, CompatApiRuntimeState runtime, CompatApiFactory factory, string warningPrefix, out TApi? api) where TApi : class { api = runtime.Api; if (api != null) { return true; } if (!TryGetCompatAssembly(guid, capability, runtime, out Assembly assembly)) { api = null; return false; } try { if (!factory(assembly, out api, out var detail) || api == null) { runtime.ReflectionFailed = true; Log.LogWarning((object)(warningPrefix + ": " + detail + ".")); return false; } runtime.Api = api; return true; } catch (Exception ex) { api = null; return MarkCompatReflectionFailed(runtime, ex.Message, warningPrefix); } } private static bool TryGetCompatAssembly(string guid, string capability, CompatApiRuntimeState runtime, out Assembly? assembly) where TApi : class { assembly = null; if (!HasPlugin(guid)) { return false; } if (runtime.ReflectionFailed) { return false; } try { assembly = ((object)Chainloader.PluginInfos[guid].Instance).GetType().Assembly; return true; } catch (Exception ex) { return MarkCompatReflectionFailed(runtime, ex.Message, capability + " compatibility disabled"); } } private static bool MarkCompatReflectionFailed(CompatApiRuntimeState runtime, string detail, string warningPrefix) where TApi : class { runtime.ReflectionFailed = true; Log.LogWarning((object)(warningPrefix + ": " + detail)); return false; } private static bool GetCompatConfigEntryToggleOn(FieldInfo field, ref ConfigEntryBase? config) { try { if (config == null) { object? value = field.GetValue(null); config = (ConfigEntryBase?)((value is ConfigEntryBase) ? value : null); } ConfigEntryBase? obj = config; object obj2 = ((obj != null) ? obj.BoxedValue : null); return obj2 != null && (string.Equals(obj2.ToString(), Toggle.On.ToString(), StringComparison.OrdinalIgnoreCase) || string.Equals(obj2.ToString(), bool.TrueString, StringComparison.OrdinalIgnoreCase)); } catch { return false; } } private static bool HasPlugin(string guid) { if (!string.IsNullOrWhiteSpace(guid)) { return Chainloader.PluginInfos.ContainsKey(guid); } return false; } internal static bool TryGetCurrencyPocketOverlapDetectionMethod(out MethodBase? method) { method = null; if (!Chainloader.PluginInfos.TryGetValue("Azumatt.CurrencyPocket", out var value) || (Object)(object)value.Instance == (Object)null) { return false; } MethodInfo methodInfo = ((object)value.Instance).GetType().Assembly.GetType("CurrencyPocket.MiscFunctions")?.GetMethod("IsOverlappingUIModInstalled", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (methodInfo == null || methodInfo.ReturnType != typeof(bool)) { return false; } method = methodInfo; return true; } private static bool CanHandleContainerRestock(Player player, Container container) { if ((Object)(object)player != (Object)null && !player.m_isLoading && (Object)(object)container != (Object)null && container.m_inventory != null && CanHandleContainerAreaAction(player, container)) { return HasContainerPlayerAccess(player, container, flashGuardStone: false); } return false; } private static bool IsAreaContainerAllowed(Player player, Container container, Container? currentContainer, Vector3 playerPosition, float rangeSq, bool includeBuiltInRemote, out float distanceSq) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (!IsAreaContainerCandidate(player, container, currentContainer, playerPosition, rangeSq, out distanceSq) || !HasContainerPlayerAccess(player, container, flashGuardStone: true)) { return false; } ContainerAccessMode containerAccessMode = GetContainerAccessMode(container); bool num = containerAccessMode == ContainerAccessMode.DirectOwner; bool flag = includeBuiltInRemote && containerAccessMode == ContainerAccessMode.MultiUserChestRemote && CanUseBuiltInRemoteAreaContainer(player, container); if (!num && !flag) { return false; } if ((Object)(object)container.m_piece != (Object)null && !container.m_piece.IsPlacedByPlayer()) { return false; } if (flag) { return true; } if (!HasExternalMultiUserChestActive && (!IsBuiltInMultiUserChestEnabled || !IsBuiltInMultiUserContainerEligible(container))) { return !IsContainerInUse(container); } return true; } private static bool IsAreaContainerCandidate(Player player, Container container, Container? currentContainer, Vector3 playerPosition, float rangeSq, out float distanceSq) { //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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) distanceSq = float.MaxValue; if ((Object)(object)player == (Object)null || (Object)(object)container == (Object)null || (Object)(object)container == (Object)(object)currentContainer || container.m_inventory == null || (Object)(object)container.m_nview == (Object)null) { return false; } Vector3 val = ((Component)container).transform.position - playerPosition; distanceSq = ((Vector3)(ref val)).sqrMagnitude; if (distanceSq > rangeSq) { return false; } if ((Object)(object)((Component)container).GetComponent() == (Object)null && (Object)(object)((Component)container).GetComponentInParent() == (Object)null && (Object)(object)((Component)container.m_nview).GetComponent() == (Object)null) { return (Object)(object)((Component)((Component)container).transform.root).GetComponentInChildren() == (Object)null; } return false; } private static bool HasContainerPlayerAccess(Player player, Container container, bool flashGuardStone) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)container == (Object)null) { return false; } if (container.m_checkGuardStone && !PrivateArea.CheckAccess(((Component)container).transform.position, 0f, flashGuardStone, false)) { return false; } return container.CheckAccess(player.GetPlayerID()); } private static bool IsContainerInUse(Container container) { if ((Object)(object)container == (Object)null) { return true; } if (container.IsInUse() || ((Object)(object)container.m_wagon != (Object)null && container.m_wagon.InUse())) { return true; } ZDO val = (((Object)(object)container.m_nview != (Object)null) ? container.m_nview.GetZDO() : null); if (val != null) { return val.GetInt("InUse", 0) == 1; } return false; } private static ContainerAccessMode GetContainerAccessMode(Container container, bool allowLocalWithoutZNetView = false) { if ((Object)(object)container == (Object)null) { return ContainerAccessMode.Unavailable; } if ((Object)(object)container.m_nview == (Object)null || !container.m_nview.IsValid()) { if (!allowLocalWithoutZNetView) { return ContainerAccessMode.Unavailable; } return ContainerAccessMode.DirectOwner; } if (container.m_nview.IsOwner()) { return ContainerAccessMode.DirectOwner; } if (!CanUseMultiUserChestRemote(container)) { return ContainerAccessMode.Unavailable; } return ContainerAccessMode.MultiUserChestRemote; } private static bool CanMutateContainerDirectly(Container container, bool allowLocalWithoutZNetView = false) { return GetContainerAccessMode(container, allowLocalWithoutZNetView) == ContainerAccessMode.DirectOwner; } private static bool CanHandleContainerAreaAction(Player player, Container container) { return GetContainerAccessMode(container, (Object)(object)container.m_nview == (Object)null) switch { ContainerAccessMode.MultiUserChestRemote => CanUseBuiltInRemoteAreaContainer(player, container), ContainerAccessMode.DirectOwner => true, _ => false, }; } private static bool CanUseBuiltInRemoteAreaContainer(Player player, Container container) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)container == (Object)null || !IsBuiltInMultiUserChestEnabled || !IsBuiltInMultiUserContainerEligible(container)) { return false; } float num = 10f; Vector3 val = ((Component)player).transform.position - ((Component)container).transform.position; return ((Vector3)(ref val)).sqrMagnitude <= num * num; } private static bool CanProcessContainerSortRpc(Container container, long sender, long requesterPlayerId) { if (sender != 0L && requesterPlayerId != 0L && CanUseMultiUserChestRemote(container) && IsRpcSenderForPlayer(sender, requesterPlayerId) && CanMutateContainerDirectly(container)) { return container.CheckAccess(requesterPlayerId); } return false; } private static bool CanUseMultiUserChestRemote(Container container) { if ((Object)(object)container == (Object)null || IsMultiUserChestIgnored(container)) { return false; } if (!HasExternalMultiUserChestActive) { if (IsBuiltInMultiUserChestEnabled) { return IsBuiltInMultiUserContainerEligible(container); } return false; } return true; } private static bool IsRpcSenderForPlayer(long sender, long requesterPlayerId) { Player requester; return TryGetRpcSenderPlayer(sender, requesterPlayerId, out requester); } private static bool TryGetRpcSenderPlayer(long sender, long requesterPlayerId, out Player? requester) { requester = null; foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)null) && allPlayer.GetPlayerID() == requesterPlayerId && !((Object)(object)((Character)allPlayer).m_nview == (Object)null) && ((Character)allPlayer).m_nview.IsValid()) { ZDO zDO = ((Character)allPlayer).m_nview.GetZDO(); if (zDO != null && zDO.GetOwner() == sender) { requester = allPlayer; return true; } } } return false; } private static bool IsMultiUserChestIgnored(Container container) { ZDO val = (((Object)(object)container?.m_nview != (Object)null) ? container.m_nview.GetZDO() : null); if (val != null) { return val.GetBool("MUC_Ignore", false); } return false; } private static List GetActionContainers(Player player, Container currentContainer, bool areaForQuickStack, bool includeBuiltInRemote = false) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) List list = new List(); HashSet hashSet = new HashSet(); if ((Object)(object)currentContainer != (Object)null && currentContainer.m_inventory != null && hashSet.Add(currentContainer)) { list.Add(currentContainer); } float num = ((!areaForQuickStack) ? (_areaRestockRange?.Value ?? 0f) : (_areaQuickStackRange?.Value ?? 0f)); if (num <= 0f) { return list; } if ((Object)(object)currentContainer == (Object)null || IsUnityNull((Object?)(object)currentContainer)) { return list; } Vector3 position = ((Component)currentContainer).transform.position; float rangeSq = num * num; List<(Container, float)> list2 = new List<(Container, float)>(); for (int num2 = InventoryContainers.KnownContainers.Count - 1; num2 >= 0; num2--) { Container val = InventoryContainers.KnownContainers[num2]; float distanceSq; if ((Object)(object)val == (Object)null || IsUnityNull((Object?)(object)val)) { InventoryContainers.KnownContainers.RemoveAt(num2); } else if (!hashSet.Contains(val) && IsAreaContainerAllowed(player, val, currentContainer, position, rangeSq, includeBuiltInRemote, out distanceSq)) { list2.Add((val, distanceSq)); hashSet.Add(val); } } list2.Sort(delegate((Container Container, float DistanceSq) left, (Container Container, float DistanceSq) right) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num3 = left.DistanceSq.CompareTo(right.DistanceSq); if (num3 != 0) { return num3; } ZNetView nview = left.Container.m_nview; ZDO val2 = ((nview != null) ? nview.GetZDO() : null); ZNetView nview2 = right.Container.m_nview; ZDO val3 = ((nview2 != null) ? nview2.GetZDO() : null); return (val2 != null && val3 != null) ? ((ZDOID)(ref val2.m_uid)).CompareTo(val3.m_uid) : 0; }); foreach (var item2 in list2) { Container item = item2.Item1; list.Add(item); } return list; } private static int RunContainerTransferAcrossContainers(Player localPlayer, Container anchorContainer, bool includeArea, bool areaForQuickStack, Func transfer, Action onMoved) { if ((Object)(object)localPlayer == (Object)null || (Object)(object)anchorContainer == (Object)null || transfer == null) { return 0; } int vfxLimit = ((includeArea && IsContainerActionSuccessFxEnabled()) ? 10 : 0); int changedContainerVfxCount = 0; return ContainerTransferCore.Run((IEnumerable?)(includeArea ? ((IList)GetActionContainers(localPlayer, anchorContainer, areaForQuickStack)) : ((IList)new List { anchorContainer })), (Container container) => !IsUnityNull((Object?)(object)container) && container.m_inventory != null, transfer, delegate(Container container, int _) { changedContainerVfxCount = TryPlayChangedContainerActionSuccessVfx(container, vfxLimit, changedContainerVfxCount); }, delegate { onMoved?.Invoke(); if (vfxLimit > 0) { PlayContainerActionSuccessSfx(anchorContainer); } }); } private static void ShowContainerActionResult(Player player, string actionToken, string actionFallback, int moved) { if (!((Object)(object)player == (Object)null)) { string newValue = LocalizeUi(actionToken, actionFallback); string text = LocalizeUi("$inventoryslots_action_result_format", "{action}: {count}").Replace("{action}", newValue).Replace("{count}", moved.ToString()); ((Character)player).Message((MessageType)2, text, 0, (Sprite)null); } } private static List GetPlayerActionSlots(Player player, Inventory inventory, bool includeHotbar, bool blockFavorites = false) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) List list = new List(); int num = Math.Min(GetFixedRegularRows(), inventory.GetHeight()); HashSet hashSet = (blockFavorites ? GetFavoriteBlockedSlots(player, inventory) : new HashSet()); Vector2i val = default(Vector2i); for (int i = 0; i < num; i++) { for (int j = 0; j < inventory.GetWidth(); j++) { ((Vector2i)(ref val))..ctor(j, i); if (!hashSet.Contains(val) && InventoryActionCellPolicyCore.CanUseContainerActionSource(GetInventoryCellKind(player, inventory, val), includeHotbar)) { list.Add(val); } } } return list; } private static HashSet GetFavoriteBlockedSlots(Player player, Inventory inventory) { //IL_0036: 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) HashSet hashSet = new HashSet(); EnsureFavoritesLoaded(player); foreach (ItemData item in inventory.m_inventory) { if (item?.m_shared != null && FavoriteSlots.Contains(item.m_gridPos)) { hashSet.Add(item.m_gridPos); } } return hashSet; } private static bool TryGetActionContext(Player? player, out Player localPlayer, out Inventory playerInventory, out Container container, out Inventory containerInventory) { localPlayer = null; playerInventory = null; container = null; containerInventory = null; if ((Object)(object)player == (Object)null || player.m_isLoading || (Object)(object)InventoryGui.instance == (Object)null) { return false; } if (IsMultiUserContainerAreaBatchActive()) { ShowMultiUserContainerNotReady(); return false; } Container currentContainer = InventoryGui.instance.m_currentContainer; if ((Object)(object)currentContainer == (Object)null || currentContainer.m_inventory == null) { return false; } if (!CanMutateContainerDirectly(currentContainer, allowLocalWithoutZNetView: true)) { ((Character)player).Message((MessageType)2, LocalizeUi("$inventoryslots_container_not_ready", "Container is not ready."), 0, (Sprite)null); return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } localPlayer = player; playerInventory = inventory; container = currentContainer; containerInventory = currentContainer.m_inventory; return true; } private static bool HasNoCustomData(ItemData item) { if (item.m_customData != null) { return item.m_customData.Count == 0; } return true; } private static bool CanUseContainerActionStacking(ItemData item) { if (item?.m_shared != null) { if (!HasNoCustomData(item)) { return IsTrustedCustomDataStackingItem(item); } return true; } return false; } private static bool IsTrustedCustomDataStackingItem(ItemData? item) { if (!IsJewelcraftingOrbItem(item)) { return IsEpicLootStackableMaterial(item); } return true; } private static bool IsJewelcraftingOrbItem(ItemData? item) { if (item?.m_shared == null || !HasPlugin("org.bepinex.plugins.jewelcrafting")) { return false; } string itemPrefabName = GetItemPrefabName(item); if (itemPrefabName.StartsWith("JC_Orb_", StringComparison.OrdinalIgnoreCase)) { return true; } string text = item.m_shared.m_name ?? ""; if (!text.StartsWith("$jc_orb_", StringComparison.OrdinalIgnoreCase)) { if (text.IndexOf("orb_of_", StringComparison.OrdinalIgnoreCase) >= 0) { return itemPrefabName.StartsWith("JC_", StringComparison.OrdinalIgnoreCase); } return false; } return true; } private static bool IsEpicLootStackableMaterial(ItemData? item) { if (item?.m_shared == null || !HasPlugin("randyknapp.mods.epicloot")) { return false; } if (IsEpicLootStackableMaterialToken(GetItemPrefabName(item))) { return true; } if (!IsUnityNull((Object?)(object)item.m_dropPrefab) && IsEpicLootStackableMaterialToken(((Object)item.m_dropPrefab).name)) { return true; } return IsEpicLootStackableMaterialToken(item.m_shared.m_name ?? ""); } private static bool IsEpicLootStackableMaterialToken(string token) { if (!token.StartsWith("Shard", StringComparison.OrdinalIgnoreCase) && !token.StartsWith("Essence", StringComparison.OrdinalIgnoreCase) && !token.StartsWith("Dust", StringComparison.OrdinalIgnoreCase)) { return token.StartsWith("Reagent", StringComparison.OrdinalIgnoreCase); } return true; } private static int CountMovedFromContainerSource(Inventory sourceInventory, ItemData sourceItem, int before, int requestedAmount, bool moveSucceeded) { int after = (sourceInventory.m_inventory.Contains(sourceItem) ? sourceItem.m_stack : 0); return ContainerActionCore.CountMovedAmount(before, after, requestedAmount, moveSucceeded, useMoveSucceededFallback: false); } private static void RemoveItemIfStillOwned(Inventory inventory, ItemData item) { if (inventory != null && item != null && inventory.m_inventory.Contains(item)) { inventory.RemoveItem(item); } } private static int CompareGridOrder(Vector2i a, Vector2i b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return ContainerActionCore.CompareGridOrder(a.x, a.y, b.x, b.y); } private static bool IsContainerActionSuccessFxEnabled() { if (_containerActionSuccessFx != null) { return _containerActionSuccessFx.Value == Toggle.On; } return true; } private static void HandleContainerHoldHotkey(Player player, ContainerHoldActionState hold, TryGetContainerHoldContext tryGetContext, Func executeAction) { if (!tryGetContext(player, out var container)) { ResetContainerHold(hold); return; } if (IsUnityNull((Object?)(object)hold.Container) || (Object)(object)hold.Container != (Object)(object)container) { hold.Container = container; hold.StartTime = Time.time; hold.Triggered = false; } if (!hold.Triggered && !(Time.time - hold.StartTime < 0.5f)) { if (executeAction(player, container)) { hold.Triggered = true; } else { ResetContainerHold(hold); } } } private static void ResetContainerHold(ContainerHoldActionState hold) { hold.Container = null; hold.StartTime = -1f; hold.Triggered = false; } private static int TryPlayChangedContainerActionSuccessVfx(Container container, int limit, int played) { if (limit <= 0 || played >= limit) { return played; } PlayContainerActionSuccessVfx(container); return played + 1; } private static void PlayContainerActionSuccessVfx(Container container) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)container == (Object)null || IsUnityNull((Object?)(object)container) || (Object)(object)ZNetScene.instance == (Object)null) { return; } GameObject prefab = ZNetScene.instance.GetPrefab("fx_HildirChest_Unlock"); if ((Object)(object)prefab == (Object)null || IsUnityNull((Object?)(object)prefab)) { return; } Vector3 position = ((Component)container).transform.position; Quaternion rotation = ((Component)container).transform.rotation; bool forceDisableInit = ZNetView.m_forceDisableInit; GameObject val; try { ZNetView.m_forceDisableInit = true; val = Object.Instantiate(prefab, position, rotation); } finally { ZNetView.m_forceDisableInit = forceDisableInit; } Object.Destroy((Object)(object)val, 5f); ZSFX[] componentsInChildren = val.GetComponentsInChildren(true); foreach (ZSFX val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2)) { val2.Stop(); ((Component)val2).gameObject.SetActive(false); } } } private static void PlayContainerActionSuccessSfx(Container container) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)container == (Object)null || IsUnityNull((Object?)(object)container) || (Object)(object)ZNetScene.instance == (Object)null) { return; } GameObject prefab = ZNetScene.instance.GetPrefab("fx_HildirChest_Unlock"); if (!((Object)(object)prefab == (Object)null) && !IsUnityNull((Object?)(object)prefab)) { Transform val = prefab.transform.Find("SFX"); if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val)) { Object.Destroy((Object)(object)Object.Instantiate(((Component)val).gameObject, ((Component)container).transform.position, ((Component)container).transform.rotation), 5f); } } } internal static void OnRealInventoryGuiShown() { _containerPreviewRealGuiVisible = true; RestoreContainerPreviewUi(); EndContainerPreview(InventoryGui.instance, keepRealGuiVisible: true); } internal static void BeforeRealInventoryGuiShown() { RestoreContainerPreviewUi(); } internal static void OnInventoryGuiHidden() { _containerPreviewRealGuiVisible = false; EndContainerPreview(InventoryGui.instance, keepRealGuiVisible: false); } private static void ShutdownContainerPreview() { _containerPreviewRealGuiVisible = false; EndContainerPreview(InventoryGui.instance, keepRealGuiVisible: false); RestoreContainerPreviewUi(); } internal static bool ShouldBlockContainerPreviewInteraction(InventoryGui? gui) { if ((Object)(object)gui != (Object)null && !IsUnityNull((Object?)(object)gui) && (Object)(object)gui == (Object)(object)InventoryGui.instance && !_containerPreviewRealGuiVisible) { if (!_containerPreviewActive && !_containerPreviewFrameOwned) { return _containerPreviewUiCaptured; } return true; } return false; } private static ContainerPreviewPhase GetContainerPreviewPhase() { if (_containerPreviewActive || _containerPreviewFrameOwned || (Object)(object)_containerPreviewTarget != (Object)null || _containerPreviewInventory != null || _containerPreviewRenderedInventory != null) { return ContainerPreviewPhase.PreviewVisible; } if (_containerPreviewRealGuiVisible) { return ContainerPreviewPhase.RealInventoryVisible; } if (!_containerPreviewUiCaptured) { return ContainerPreviewPhase.Hidden; } return ContainerPreviewPhase.RestorePending; } internal static void BeforeContainerPreviewGuiUpdate(InventoryGui gui) { _containerPreviewFrameOwned = false; if (IsDedicatedServer || (Object)(object)gui == (Object)null || IsUnityNull((Object?)(object)gui)) { return; } Player localPlayer = Player.m_localPlayer; bool inputBlocked = (Object)(object)localPlayer == (Object)null || IsUnityNull((Object?)(object)localPlayer) || ShouldBlockGlobalHotkeys(localPlayer); if (_containerPreviewRealGuiVisible) { return; } if (!CanRunContainerPreview(localPlayer, inputBlocked)) { EndContainerPreview(gui, keepRealGuiVisible: false); return; } float unscaledTime = Time.unscaledTime; if (TryGetContainerPreviewTarget(localPlayer, out Container container, out Inventory inventory)) { _containerPreviewTarget = container; _containerPreviewInventory = inventory; _containerPreviewCloseAt = unscaledTime + Mathf.Max(0f, _containerPreviewCloseDelay.Value); } else { if (GetContainerPreviewPhase() == ContainerPreviewPhase.RestorePending) { return; } if (!_containerPreviewActive || _containerPreviewInventory == null || unscaledTime > _containerPreviewCloseAt || !IsContainerPreviewInventoryValid(_containerPreviewInventory, out var _, out var _)) { EndContainerPreview(gui, keepRealGuiVisible: false); return; } } _containerPreviewFrameOwned = _containerPreviewInventory != null; if (_containerPreviewFrameOwned) { if ((Object)(object)gui.m_animator != (Object)null) { gui.m_animator.SetBool("visible", false); } CaptureAndHideContainerPreviewUi(gui); } } internal static void AfterContainerPreviewGuiUpdate(InventoryGui gui) { if (_containerPreviewFrameOwned && !_containerPreviewRealGuiVisible) { RenderContainerPreview(gui); } } private static bool CanRunContainerPreview(Player? player, bool inputBlocked) { if (_containerPreviewCloseDelay.Value <= 0f || inputBlocked || (Object)(object)player == (Object)null || IsUnityNull((Object?)(object)player) || player.m_isLoading || ((Character)player).IsDead() || ((Character)player).InCutscene() || ((Character)player).IsTeleporting()) { return false; } if (!HasPlugin("com.maxsch.valheim.contentswithin")) { return true; } if (!_containerPreviewStandaloneWarningLogged) { _containerPreviewStandaloneWarningLogged = true; Log.LogWarning((object)"InventorySlots container preview is disabled because standalone ContentsWithin is installed."); } return false; } private static bool TryGetContainerPreviewTarget(Player player, out Container? container, out Inventory? inventory) { container = GetHoveredContainer(player); inventory = null; if ((Object)(object)container == (Object)null || IsUnityNull((Object?)(object)container) || !HasContainerPlayerAccess(player, container, flashGuardStone: false)) { return false; } inventory = container.GetInventory(); if (inventory == null || !IsContainerPreviewInventoryValid(inventory, out var _, out var _)) { inventory = null; return false; } return true; } private static bool IsContainerPreviewInventoryValid(Inventory inventory, out int width, out int height) { width = ((inventory != null) ? inventory.GetWidth() : 0); height = ((inventory != null) ? inventory.GetHeight() : 0); if (inventory == null || width <= 0 || height <= 0 || (long)width * (long)height > int.MaxValue) { return false; } foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem == null || allItem.m_gridPos.x < 0 || allItem.m_gridPos.y < 0 || allItem.m_gridPos.x >= width || allItem.m_gridPos.y >= height) { return false; } } return true; } private static void RenderContainerPreview(InventoryGui gui) { Inventory containerPreviewInventory = _containerPreviewInventory; if (containerPreviewInventory == null || !IsContainerPreviewInventoryValid(containerPreviewInventory, out var width, out var height) || (Object)(object)gui.m_containerGrid == (Object)null || (Object)(object)gui.m_container == (Object)null) { EndContainerPreview(gui, keepRealGuiVisible: false); return; } try { CaptureAndHideContainerPreviewUi(gui); gui.m_animator.SetBool("visible", true); gui.m_hiddenFrames = 10; ((Component)gui.m_container).gameObject.SetActive(true); InventoryGrid containerGrid = gui.m_containerGrid; containerGrid.m_inventory = containerPreviewInventory; containerGrid.m_selected.x = Mathf.Clamp(containerGrid.m_selected.x, 0, width - 1); containerGrid.m_selected.y = Mathf.Clamp(containerGrid.m_selected.y, 0, height - 1); int num = width * height; if (containerGrid.m_elements == null || containerGrid.m_elements.Count != num) { containerGrid.m_width = -1; containerGrid.m_height = -1; } containerGrid.UpdateGui((Player)null, (ItemData)null); if (_containerPreviewRenderedInventory != containerPreviewInventory || _containerPreviewRenderedWidth != width || _containerPreviewRenderedHeight != height) { containerGrid.ResetView(); _containerPreviewRenderedInventory = containerPreviewInventory; _containerPreviewRenderedWidth = width; _containerPreviewRenderedHeight = height; } string name = containerPreviewInventory.GetName(); gui.m_containerName.text = ((Localization.instance != null) ? Localization.instance.Localize(name) : name); gui.m_containerWeight.text = Mathf.CeilToInt(containerPreviewInventory.GetTotalWeight()).ToString(); _containerPreviewActive = true; } catch (Exception exception) { LogContainerPreviewFailure(exception); EndContainerPreview(gui, keepRealGuiVisible: false); } } private static void CaptureAndHideContainerPreviewUi(InventoryGui gui) { if (!_containerPreviewUiCaptured) { ContainerPreviewHiddenObjects.Clear(); _containerPreviewUiCaptured = true; RestoreContainerUiState(); HideInventoryPinnedTooltips(); HideInventoryOwnedHoverTooltips(); ClearInventoryHoverTooltipSources(); } CaptureAndHideContainerPreviewObject(((Object)(object)gui.m_player != (Object)null) ? ((Component)gui.m_player).gameObject : null); CaptureAndHideContainerPreviewObject(((Object)(object)gui.m_crafting != (Object)null) ? ((Component)gui.m_crafting).gameObject : null); CaptureAndHideContainerPreviewObject(((Object)(object)gui.m_info != (Object)null) ? ((Component)gui.m_info).gameObject : null); CaptureAndHideContainerPreviewObject(((Object)(object)gui.m_infoPanel != (Object)null) ? ((Component)gui.m_infoPanel).gameObject : null); CaptureAndHideContainerPreviewObject(((Object)(object)gui.m_takeAllButton != (Object)null) ? ((Component)gui.m_takeAllButton).gameObject : null); CaptureAndHideContainerPreviewObject(((Object)(object)gui.m_stackAllButton != (Object)null) ? ((Component)gui.m_stackAllButton).gameObject : null); Transform inventoryRoot = gui.m_inventoryRoot; object target; if (inventoryRoot == null) { target = null; } else { Transform obj = inventoryRoot.Find("Crafting"); target = ((obj != null) ? ((Component)obj).gameObject : null); } CaptureAndHideContainerPreviewObject((GameObject?)target); Transform inventoryRoot2 = gui.m_inventoryRoot; object target2; if (inventoryRoot2 == null) { target2 = null; } else { Transform obj2 = inventoryRoot2.Find("RightPanel"); target2 = ((obj2 != null) ? ((Component)obj2).gameObject : null); } CaptureAndHideContainerPreviewObject((GameObject?)target2); HideInventoryActionPanels(); } private static void CaptureAndHideContainerPreviewObject(GameObject? target) { if (!((Object)(object)target == (Object)null) && !IsUnityNull((Object?)(object)target)) { if (!ContainerPreviewHiddenObjects.ContainsKey(target)) { ContainerPreviewHiddenObjects.Add(target, target.activeSelf); } if (target.activeSelf) { target.SetActive(false); } } } private static void EndContainerPreview(InventoryGui? gui, bool keepRealGuiVisible) { if (GetContainerPreviewPhase() != ContainerPreviewPhase.PreviewVisible) { return; } _containerPreviewFrameOwned = false; _containerPreviewActive = false; _containerPreviewTarget = null; _containerPreviewInventory = null; _containerPreviewRenderedInventory = null; _containerPreviewRenderedWidth = -1; _containerPreviewRenderedHeight = -1; _containerPreviewCloseAt = 0f; if (!((Object)(object)gui == (Object)null) && !IsUnityNull((Object?)(object)gui)) { if (!keepRealGuiVisible && (Object)(object)gui.m_animator != (Object)null) { gui.m_animator.SetBool("visible", false); } if (keepRealGuiVisible && (Object)(object)gui.m_currentContainer == (Object)null && (Object)(object)gui.m_container != (Object)null) { ((Component)gui.m_container).gameObject.SetActive(false); } } } private static void RestoreContainerPreviewUi() { if (!_containerPreviewUiCaptured) { return; } foreach (KeyValuePair containerPreviewHiddenObject in ContainerPreviewHiddenObjects) { if ((Object)(object)containerPreviewHiddenObject.Key != (Object)null && !IsUnityNull((Object?)(object)containerPreviewHiddenObject.Key)) { containerPreviewHiddenObject.Key.SetActive(containerPreviewHiddenObject.Value); } } ContainerPreviewHiddenObjects.Clear(); _containerPreviewUiCaptured = false; } private static void LogContainerPreviewFailure(Exception exception) { string text = exception.GetType().Name + ": " + exception.Message; float unscaledTime = Time.unscaledTime; if (!string.Equals(text, _containerPreviewLastFailure, StringComparison.Ordinal) || !(unscaledTime - _containerPreviewLastFailureAt < 5f)) { _containerPreviewLastFailure = text; _containerPreviewLastFailureAt = unscaledTime; Log.LogWarning((object)("Container preview was closed after a UI update failed: " + text)); } } internal static bool TryHandleVanillaPlaceStacks(InventoryGui gui) { if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_currentContainer == (Object)null) { return false; } if (IsMultiUserContainerAreaBatchActive()) { ShowMultiUserContainerNotReady(); return true; } ContainerAccessMode containerAccessMode = GetContainerAccessMode(gui.m_currentContainer, allowLocalWithoutZNetView: true); if (containerAccessMode == ContainerAccessMode.MultiUserChestRemote && IsBuiltInMultiUserChestEnabled) { if (!TryStartMultiUserContainerPlaceStacksBatch(gui.m_currentContainer)) { ShowMultiUserContainerNotReady(); } return true; } if (containerAccessMode != ContainerAccessMode.DirectOwner) { return false; } QuickStackCurrentContainer(Player.m_localPlayer); return true; } internal static bool TryHandleContainerStackAll(Container container) { if (ShouldSuppressContainerStackAllForRestock(container)) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_isLoading || (Object)(object)container == (Object)null || container.m_inventory == null) { return false; } ContainerAccessMode containerAccessMode = GetContainerAccessMode(container, allowLocalWithoutZNetView: true); if (IsBuiltInMultiUserChestEnabled && TryHandleMultiUserContainerAreaQuickStack(container)) { return true; } if (containerAccessMode == ContainerAccessMode.MultiUserChestRemote && IsBuiltInMultiUserChestEnabled) { ShowMultiUserContainerNotReady(); return true; } if (containerAccessMode != ContainerAccessMode.DirectOwner) { return false; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { return false; } QuickStackIntoContainers(localPlayer, inventory, container, includeArea: true); return true; } private static void HandleContainerQuickStackHotkey(Player player) { HandleContainerHoldHotkey(player, InventoryPanels.ContainerQuickStackHold, TryGetContainerQuickStackHotkeyContext, TryQuickStackFromHoveredContainer); } private static bool TryGetContainerQuickStackHotkeyContext(Player player, out Container container) { container = null; if ((Object)(object)player == (Object)null || InventoryGui.IsVisible() || ShouldBlockGlobalHotkeys(player) || IsContainerRestockShortcutHeld() || !IsContainerQuickStackShortcutHeld()) { return false; } Container hoveredContainer = GetHoveredContainer(player); if ((Object)(object)hoveredContainer == (Object)null || player.m_isLoading || hoveredContainer.m_inventory == null || !CanHandleContainerAreaAction(player, hoveredContainer)) { return false; } container = hoveredContainer; return true; } private static bool IsContainerQuickStackShortcutHeld() { if (!ZInput.GetButton("Use")) { return ZInput.GetButton("JoyUse"); } return true; } private static bool TryQuickStackFromHoveredContainer(Player player, Container container) { if ((Object)(object)container == (Object)null || container.m_inventory == null || !CanHandleContainerAreaAction(player, container)) { return false; } if (TryHandleMultiUserContainerAreaQuickStack(container)) { return true; } if (!CanMutateContainerDirectly(container, allowLocalWithoutZNetView: true)) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } QuickStackIntoContainers(player, inventory, container, includeArea: true); return true; } internal static void QuickStackCurrentContainer(Player? player) { if (TryGetActionContext(player, out Player localPlayer, out Inventory playerInventory, out Container container, out Inventory _)) { QuickStackIntoContainers(localPlayer, playerInventory, container, includeArea: false); } } private static void QuickStackIntoContainers(Player localPlayer, Inventory playerInventory, Container container, bool includeArea) { List candidates = playerInventory.m_inventory.Where((ItemData item) => ShouldQuickStackItem(localPlayer, playerInventory, item, includeHotbar: false)).ToList(); candidates.Sort((ItemData a, ItemData b) => -CompareGridOrder(a.m_gridPos, b.m_gridPos)); InventoryGui instance = InventoryGui.instance; if (instance != null) { instance.SetupDragItem((ItemData)null, (Inventory)null, 0); } int moved = RunContainerTransferAcrossContainers(localPlayer, container, includeArea, areaForQuickStack: true, (Container targetContainer) => QuickStackItemsIntoContainer(playerInventory, targetContainer.m_inventory, candidates), delegate { playerInventory.Changed(); ClearCraftingRequirementAvailabilityCache(); }); ShowContainerActionResult(localPlayer, "$inventoryslots_action_stack", "Stack", moved); } private static bool ShouldQuickStackItem(Player player, Inventory inventory, ItemData item, bool includeHotbar) { if (item?.m_shared != null && item.m_shared.m_maxStackSize > 1 && IsRegularActionItem(player, inventory, item, includeHotbar) && !IsFavoriteProtected(player, inventory, item)) { return CanUseContainerActionStacking(item); } return false; } private static int QuickStackItemsIntoContainer(Inventory playerInventory, Inventory containerInventory, List candidates) { if (containerInventory == null || candidates.Count == 0) { return 0; } HashSet hashSet = new HashSet(from item in containerInventory.m_inventory where item?.m_shared != null select item.m_shared.m_name, StringComparer.OrdinalIgnoreCase); if (hashSet.Count == 0) { return 0; } int num = 0; foreach (ItemData candidate in candidates) { if (playerInventory.m_inventory.Contains(candidate) && candidate?.m_shared != null && hashSet.Contains(candidate.m_shared.m_name) && containerInventory.AddItem(candidate)) { RemoveItemIfStillOwned(playerInventory, candidate); num++; } } if (num > 0) { containerInventory.Changed(); } return num; } private static void StoreAllToCurrentContainer(Player? player) { if (!TryGetActionContext(player, out Player localPlayer, out Inventory playerInventory, out Container _, out Inventory containerInventory)) { return; } List list = playerInventory.m_inventory.Where((ItemData item) => ShouldStoreAllItem(localPlayer, playerInventory, item, includeHotbar: false, includeEquipped: false)).ToList(); list.Sort((ItemData a, ItemData b) => CompareGridOrder(a.m_gridPos, b.m_gridPos)); InventoryGui.instance.SetupDragItem((ItemData)null, (Inventory)null, 0); int num = 0; foreach (ItemData item in list) { if (playerInventory.m_inventory.Contains(item) && containerInventory.AddItem(item)) { RemoveItemIfStillOwned(playerInventory, item); num++; if (item.m_equipped) { ((Humanoid)localPlayer).RemoveEquipAction(item); ((Humanoid)localPlayer).UnequipItem(item, false); } } } if (num > 0) { playerInventory.Changed(); containerInventory.Changed(); ClearCraftingRequirementAvailabilityCache(); } } private static bool ShouldStoreAllItem(Player player, Inventory inventory, ItemData item, bool includeHotbar, bool includeEquipped) { if (item?.m_shared != null && IsRegularActionItem(player, inventory, item, includeHotbar) && !IsFavoriteProtected(player, inventory, item)) { if (!includeEquipped) { return !item.m_equipped; } return true; } return false; } private static void RefreshRestockTargetStackLimits() { InventoryDefinitions.RestockTargetStackLimits = RestockTargetLimitCore.Parse(_restockTargetStackLimitsConfig?.Value); } private static void RestockFromCurrentContainer(Player? player) { if (TryGetActionContext(player, out Player localPlayer, out Inventory playerInventory, out Container container, out Inventory _)) { RestockFromContainer(localPlayer, playerInventory, container, ContainerTakeStacksMode.CurrentContainerMatchingStacks); } } private static void HandleContainerRestockHotkey(Player player) { HandleContainerHoldHotkey(player, InventoryPanels.ContainerRestockHold, TryGetContainerRestockHotkeyContext, TryRestockFromHoveredContainer); } internal static bool ShouldSuppressContainerInteractForRestock(Container container, Humanoid character) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)character != (Object)(object)localPlayer || InventoryGui.IsVisible() || !IsContainerRestockShortcutHeld()) { return false; } if ((Object)(object)GetHoveredContainer(localPlayer) == (Object)(object)container) { return CanHandleContainerRestock(localPlayer, container); } return false; } private static bool ShouldSuppressContainerStackAllForRestock(Container container) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_isLoading || InventoryGui.IsVisible() || !IsContainerRestockShortcutHeld()) { return false; } return (Object)(object)GetHoveredContainer(localPlayer) == (Object)(object)container; } internal static void AppendContainerRestockHoverText(Container container, ref string text) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_isLoading || string.IsNullOrWhiteSpace(text) || !IsContainerRestockKeyConfigured() || !CanHandleContainerRestock(localPlayer, container)) { return; } string text2 = LocalizeUi("$inventoryslots_hold_to_restock", "Hold to restock"); if (text.IndexOf("Hold to restock", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf(text2, StringComparison.OrdinalIgnoreCase) < 0) { string containerRestockKeyDisplayText = GetContainerRestockKeyDisplayText(); if (!string.IsNullOrWhiteSpace(containerRestockKeyDisplayText)) { text = text + "\n[" + containerRestockKeyDisplayText + "] (" + text2 + ")"; } } } private static bool TryGetContainerRestockHotkeyContext(Player player, out Container container) { container = null; if ((Object)(object)player == (Object)null || InventoryGui.IsVisible() || ShouldBlockGlobalHotkeys(player) || !IsContainerRestockShortcutHeld()) { return false; } Container hoveredContainer = GetHoveredContainer(player); if ((Object)(object)hoveredContainer == (Object)null || !CanHandleContainerRestock(player, hoveredContainer)) { return false; } container = hoveredContainer; return true; } private static bool TryRestockFromHoveredContainer(Player player, Container container) { if (!CanHandleContainerRestock(player, container)) { return false; } if (TryHandleMultiUserContainerAreaRestock(container)) { return true; } if (!CanMutateContainerDirectly(container, allowLocalWithoutZNetView: true)) { return false; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return false; } RestockFromContainer(player, inventory, container, ContainerTakeStacksMode.AreaFavoriteRestock); return true; } private static void RestockFromContainer(Player localPlayer, Inventory playerInventory, Container container, ContainerTakeStacksMode mode) { if (!((Object)(object)localPlayer == (Object)null) && playerInventory != null && !((Object)(object)container == (Object)null) && container.m_inventory != null) { bool includeArea = mode == ContainerTakeStacksMode.AreaFavoriteRestock; List targets = playerInventory.m_inventory.Where((ItemData item) => ShouldTakeStacksTarget(localPlayer, playerInventory, item, includeHotbar: false, mode)).ToList(); targets.Sort((ItemData a, ItemData b) => -CompareGridOrder(a.m_gridPos, b.m_gridPos)); InventoryGui instance = InventoryGui.instance; if (instance != null) { instance.SetupDragItem((ItemData)null, (Inventory)null, 0); } int moved = RunContainerTransferAcrossContainers(localPlayer, container, includeArea, areaForQuickStack: false, (Container sourceContainer) => RestockTargetsFromContainer(playerInventory, sourceContainer.m_inventory, targets, mode), delegate { playerInventory.Changed(); ClearCraftingRequirementAvailabilityCache(); }); ShowContainerActionResult(localPlayer, "$inventoryslots_action_take_stacks", "Take stacks", moved); } } private static Container? GetHoveredContainer(Player player) { GameObject val = (((Object)(object)player != (Object)null) ? ((Humanoid)player).GetHoverObject() : null); if (!IsUnityNull((Object?)(object)val)) { return val.GetComponentInParent(); } return null; } private static bool IsContainerRestockKeyConfigured() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (_containerRestockKey != null) { KeyboardShortcut value = _containerRestockKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { return true; } } return IsControllerHotkeyConfigured(_controllerContainerRestockButton); } private static bool IsContainerRestockShortcutHeld() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) if (_containerRestockKey != null) { KeyboardShortcut value = _containerRestockKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0 && IsShortcutHeldAllowingAltPair(_containerRestockKey.Value)) { return true; } } return IsControllerHotkeyHeld(_controllerContainerRestockButton); } private static string GetContainerRestockKeyDisplayText() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return JoinShortcutDisplayTexts((_containerRestockKey != null) ? _containerRestockKey.Value.GetCompactDisplayText() : "", GetControllerHotkeyDisplayText(_controllerContainerRestockButton)); } private static bool ShouldTakeStacksTarget(Player player, Inventory inventory, ItemData item, bool includeHotbar, ContainerTakeStacksMode mode) { if (mode != ContainerTakeStacksMode.AreaFavoriteRestock) { return ShouldTakeMatchingStackItem(player, inventory, item, includeHotbar); } return ShouldRestockItem(player, inventory, item); } private static bool ShouldRestockItem(Player player, Inventory inventory, ItemData item) { if (item?.m_shared == null || !IsFavoriteRestockActionItem(player, inventory, item) || !IsFavoriteRestockTarget(player, item) || !CanUseContainerActionStacking(item)) { return false; } int maxStackSize = item.m_shared.m_maxStackSize; int restockTargetStack = GetRestockTargetStack(item); if (maxStackSize > 1) { return item.m_stack < restockTargetStack; } return false; } private static bool ShouldTakeMatchingStackItem(Player player, Inventory inventory, ItemData item, bool includeHotbar) { if (item?.m_shared != null && IsRegularActionItem(player, inventory, item, includeHotbar) && !IsFavoriteRestockTarget(player, item) && CanUseContainerActionStacking(item) && item.m_shared.m_maxStackSize > 1) { return item.m_stack < item.m_shared.m_maxStackSize; } return false; } private static bool IsFavoriteRestockActionItem(Player player, Inventory inventory, ItemData item) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return InventoryActionCellPolicyCore.CanUseFavoriteRestockTarget(GetInventoryCellKind(player, inventory, item.m_gridPos)); } private static bool IsFavoriteRestockTarget(Player player, ItemData item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return IsFavoriteSlot(player, item.m_gridPos); } private static int GetRestockTargetStack(ItemData item) { if (item?.m_shared != null) { return RestockTargetLimitCore.ResolveTargetStackLimit(InventoryDefinitions.RestockTargetStackLimits, GetRestockTargetLookupTokens(item), item.m_shared.m_maxStackSize); } return 0; } private static IEnumerable GetRestockTargetLookupTokens(ItemData item) { if (item != null) { yield return GetItemPrefabName(item); if (!IsUnityNull((Object?)(object)item.m_dropPrefab)) { yield return ((Object)item.m_dropPrefab).name; } string sharedName = item.m_shared?.m_name ?? ""; yield return sharedName; yield return StripLocalizationToken(sharedName); if (Localization.instance != null && !string.IsNullOrWhiteSpace(sharedName)) { yield return Localization.instance.Localize(sharedName); } } } private static bool CanRestockFromContainerItem(ItemData target, ItemData source) { if (target?.m_shared != null && source?.m_shared != null && CanUseContainerActionStacking(target) && CanUseContainerActionStacking(source)) { return CanShareInventoryStack(target, source); } return false; } private static int RestockTargetsFromContainer(Inventory playerInventory, Inventory containerInventory, List targets, ContainerTakeStacksMode mode) { if (containerInventory == null || targets.Count == 0) { return 0; } int num = 0; foreach (ItemData target in targets) { if (!playerInventory.m_inventory.Contains(target)) { continue; } int num2 = ((mode == ContainerTakeStacksMode.AreaFavoriteRestock) ? GetRestockTargetStack(target) : target.m_shared.m_maxStackSize); int num3 = target.m_stack; int num4 = containerInventory.m_inventory.Count - 1; while (num4 >= 0 && num3 < num2) { ItemData val = containerInventory.m_inventory[num4]; if (CanRestockFromContainerItem(target, val)) { int num5 = Math.Min(num2 - num3, val.m_stack); if (num5 > 0) { int stack = val.m_stack; bool moveSucceeded = playerInventory.MoveItemToThis(containerInventory, val, num5, target.m_gridPos.x, target.m_gridPos.y); int num6 = CountMovedFromContainerSource(containerInventory, val, stack, num5, moveSucceeded); num3 += num6; num += num6; } } num4--; } } if (num > 0) { containerInventory.Changed(); } return num; } private static void SortCurrentContainer(Player? player) { if ((Object)(object)player == (Object)null || player.m_isLoading || (Object)(object)InventoryGui.instance == (Object)null) { return; } if (IsMultiUserContainerAreaBatchActive()) { ShowMultiUserContainerNotReady(); return; } Container currentContainer = InventoryGui.instance.m_currentContainer; if ((Object)(object)currentContainer == (Object)null || currentContainer.m_inventory == null) { return; } switch (GetContainerAccessMode(currentContainer, allowLocalWithoutZNetView: true)) { case ContainerAccessMode.DirectOwner: SortContainerInventory(currentContainer); break; case ContainerAccessMode.MultiUserChestRemote: if (!IsContainerSortRequestPending(currentContainer)) { ZDO zDO = currentContainer.m_nview.GetZDO(); long num = ((zDO != null) ? zDO.GetOwner() : 0); if (num != 0L) { int nextContainerSortRequestId = GetNextContainerSortRequestId(); _pendingSortContainer = currentContainer; _pendingSortRequestId = nextContainerSortRequestId; _pendingSortOwner = num; _pendingSortStartedAt = Time.unscaledTime; currentContainer.m_nview.InvokeRPC("InventorySlots_RequestSortV2", new object[2] { nextContainerSortRequestId, player.GetPlayerID() }); } } break; } } private static int SortContainerInventory(Container container) { if ((Object)(object)container == (Object)null || container.m_inventory == null) { return 0; } List allInventorySlots = GetAllInventorySlots(container.m_inventory); return SortInventoryInternal(container.m_inventory, allInventorySlots, (ItemData item) => item?.m_shared != null); } internal static void RegisterContainer(Container container) { if (!((Object)(object)container == (Object)null)) { if (!InventoryContainers.KnownContainers.Contains(container)) { InventoryContainers.KnownContainers.Add(container); } RegisterContainerRpcs(container); RegisterMultiUserContainerRpcs(container); } } internal static void UnregisterContainer(Container container) { if ((Object)(object)container != (Object)null) { UnregisterMultiUserContainerRpcs(container); ClearPendingContainerSortRequest(container); InventoryContainers.KnownContainers.Remove(container); } } private static void RegisterContainerRpcs(Container container) { if ((Object)(object)container == (Object)null) { return; } if ((Object)(object)container.m_nview == (Object)null) { container.m_nview = (((Object)(object)container.m_rootObjectOverride != (Object)null) ? ((Component)container.m_rootObjectOverride).GetComponent() : ((Component)container).GetComponent()); } if (!((Object)(object)container.m_nview == (Object)null)) { container.m_nview.Unregister("InventorySlots_RequestSortV2"); container.m_nview.Unregister("InventorySlots_SortResponseV2"); container.m_nview.Register("InventorySlots_RequestSortV2", (Action)delegate(long sender, int requestId, long requesterPlayerId) { RPC_RequestSort(container, sender, requestId, requesterPlayerId); }); container.m_nview.Register("InventorySlots_SortResponseV2", (Action)delegate(long sender, int requestId, bool success) { RPC_SortResponse(container, sender, requestId, success); }); } } private static void RPC_RequestSort(Container container, long sender, int requestId, long requesterPlayerId) { bool flag = CanProcessContainerSortRpc(container, sender, requesterPlayerId); if (flag) { SortContainerInventory(container); } if (sender != 0L && (Object)(object)container?.m_nview != (Object)null && container.m_nview.IsValid()) { container.m_nview.InvokeRPC(sender, "InventorySlots_SortResponseV2", new object[2] { requestId, flag }); } } private static void RPC_SortResponse(Container container, long sender, int requestId, bool success) { if (!((Object)(object)container == (Object)null) && !((Object)(object)_pendingSortContainer != (Object)(object)container) && _pendingSortRequestId == requestId && _pendingSortOwner == sender) { ClearPendingContainerSortRequest(); if (!success && !IsUnityNull((Object?)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, LocalizeUi("$inventoryslots_container_not_ready", "Container is not ready."), 0, (Sprite)null); } } } private static bool IsContainerSortRequestPending(Container container) { if ((Object)(object)_pendingSortContainer == (Object)null) { ClearPendingContainerSortRequest(); return false; } if (Time.unscaledTime - _pendingSortStartedAt >= 2f) { ClearPendingContainerSortRequest(); return false; } return (Object)(object)_pendingSortContainer == (Object)(object)container; } private static int GetNextContainerSortRequestId() { if (_nextSortRequestId <= 0) { _nextSortRequestId = 1; } return _nextSortRequestId++; } private static void ClearPendingContainerSortRequest(Container? container = null) { if (!((Object)(object)container != (Object)null) || !((Object)(object)_pendingSortContainer != (Object)(object)container)) { _pendingSortContainer = null; _pendingSortRequestId = 0; _pendingSortOwner = 0L; _pendingSortStartedAt = -1f; } } private static void SortPlayerInventory(Player? player) { if ((Object)(object)player == (Object)null || player.m_isLoading) { return; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory != null) { List playerActionSlots = GetPlayerActionSlots(player, inventory, includeHotbar: false, blockFavorites: true); HashSet allowedSet = new HashSet(playerActionSlots); InventoryGui.instance.SetupDragItem((ItemData)null, (Inventory)null, 0); SortInventoryInternal(inventory, playerActionSlots, (ItemData item) => item?.m_shared != null && allowedSet.Contains(item.m_gridPos) && !IsFavoriteProtected(player, inventory, item)); } } private static int SortInventoryInternal(Inventory inventory, List allowedSlots, Func shouldSort) { //IL_00fa: 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) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if (inventory == null || allowedSlots.Count == 0) { return 0; } List list = inventory.m_inventory.Where(shouldSort).ToList(); if (list.Count == 0) { return 0; } bool flag = MergeSortableStacks(list, inventory); Dictionary sortKeys = list.ToDictionary((ItemData item) => item, GetInventoryItemSortKey); int inventoryWidth = Mathf.Max(1, inventory.GetWidth()); Dictionary originalIndices = list.ToDictionary((ItemData item) => item, (ItemData item) => GetInventoryOriginalSortIndex(item, inventoryWidth)); list.Sort((ItemData a, ItemData b) => CompareItemsForSort(a, b, sortKeys[a], sortKeys[b], originalIndices[a], originalIndices[b])); int num = 0; int num2 = Math.Min(list.Count, allowedSlots.Count); for (int num3 = 0; num3 < num2; num3++) { if (list[num3].m_gridPos != allowedSlots[num3]) { num++; flag = true; list[num3].m_gridPos = allowedSlots[num3]; } } if (flag) { inventory.Changed(); } return num; } private static int GetInventoryOriginalSortIndex(ItemData item, int inventoryWidth) { return item.m_gridPos.y * inventoryWidth + item.m_gridPos.x; } private static bool MergeSortableStacks(List toMerge, Inventory inventory) { bool result = false; foreach (List item in (from item in toMerge where item?.m_shared != null && item.m_stack < item.m_shared.m_maxStackSize && CanUseContainerActionStacking(item) group item by new { item.m_shared.m_name, item.m_quality, item.m_worldLevel } into grouping select grouping.ToList()).ToList()) { if (item.Count <= 1) { continue; } int num = item.Sum((ItemData item) => item.m_stack); int maxStackSize = item[0].m_shared.m_maxStackSize; foreach (ItemData item2 in item) { if (num <= 0) { if (item2.m_stack != 0) { item2.m_stack = 0; result = true; } inventory.RemoveItem(item2); toMerge.Remove(item2); result = true; } else { int num2 = Math.Min(maxStackSize, num); if (item2.m_stack != num2) { item2.m_stack = num2; result = true; } num -= item2.m_stack; } } } return result; } private static List GetAllInventorySlots(Inventory inventory) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < inventory.GetHeight(); i++) { for (int j = 0; j < inventory.GetWidth(); j++) { list.Add(new Vector2i(j, i)); } } return list; } internal static bool TryHandleSafeTakeAll(InventoryGui gui) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.m_isLoading || (Object)(object)gui == (Object)null || (Object)(object)gui.m_currentContainer == (Object)null || gui.m_currentContainer.m_inventory == null) { return false; } if (IsMultiUserContainerAreaBatchActive()) { ShowMultiUserContainerNotReady(); return true; } Container currentContainer = gui.m_currentContainer; switch (GetContainerAccessMode(currentContainer, allowLocalWithoutZNetView: true)) { case ContainerAccessMode.MultiUserChestRemote: if (IsBuiltInMultiUserChestEnabled) { if (!TryStartMultiUserContainerTakeAllBatch(currentContainer)) { ShowMultiUserContainerNotReady(); } return true; } return false; default: ((Character)localPlayer).Message((MessageType)2, LocalizeUi("$inventoryslots_container_not_ready", "Container is not ready."), 0, (Sprite)null); return true; case ContainerAccessMode.DirectOwner: { Inventory inventory = ((Humanoid)localPlayer).GetInventory(); Inventory inventory2 = currentContainer.m_inventory; if (inventory == null || inventory2 == null) { return false; } TombStone component = ((Component)currentContainer).GetComponent(); bool num = (Object)(object)component != (Object)null; gui.SetupDragItem((ItemData)null, (Inventory)null, 0); if (SafeTakeAllItems(localPlayer, inventory, inventory2, includeHotbar: false) > 0) { inventory.Changed(); inventory2.Changed(); ClearCraftingRequirementAvailabilityCache(); } if (num && inventory2.NrOfItems() == 0) { component.OnTakeAllSuccess(); } return true; } } } private static int SafeTakeAllItems(Player player, Inventory playerInventory, Inventory containerInventory, bool includeHotbar) { List playerActionSlots = GetPlayerActionSlots(player, playerInventory, includeHotbar, blockFavorites: true); HashSet allowedSlots = new HashSet(playerActionSlots); List safeTakeAllEmptySlots = GetSafeTakeAllEmptySlots(playerInventory, playerActionSlots); List list = containerInventory.m_inventory.Where((ItemData item) => item?.m_shared != null).ToList(); list.Sort((ItemData left, ItemData right) => CompareGridOrder(left.m_gridPos, right.m_gridPos)); int num = 0; foreach (ItemData item in list) { if (containerInventory.m_inventory.Contains(item)) { int stack = item.m_stack; if (MoveContainerItemSafelyToPlayer(playerInventory, containerInventory, item, safeTakeAllEmptySlots, allowedSlots) > 0 && (!containerInventory.m_inventory.Contains(item) || item.m_stack < stack)) { num++; } } } return num; } private static int MoveContainerItemSafelyToPlayer(Inventory playerInventory, Inventory containerInventory, ItemData source, List emptySlots, HashSet allowedSlots) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) int num = 0; if (source.m_shared != null && source.m_shared.m_maxStackSize > 1 && CanUseContainerActionStacking(source)) { foreach (ItemData safeTakeAllStackTarget in GetSafeTakeAllStackTargets(playerInventory, source, allowedSlots)) { if (!containerInventory.m_inventory.Contains(source) || source.m_stack <= 0) { break; } int num2 = Math.Min(safeTakeAllStackTarget.m_shared.m_maxStackSize - safeTakeAllStackTarget.m_stack, source.m_stack); if (num2 > 0) { int stack = source.m_stack; bool moveSucceeded = playerInventory.MoveItemToThis(containerInventory, source, num2, safeTakeAllStackTarget.m_gridPos.x, safeTakeAllStackTarget.m_gridPos.y); int num3 = CountMovedFromContainerSource(containerInventory, source, stack, num2, moveSucceeded); num += num3; } } } while (containerInventory.m_inventory.Contains(source) && source.m_stack > 0 && emptySlots.Count > 0) { Vector2i val = emptySlots[0]; emptySlots.RemoveAt(0); int stack2 = source.m_stack; int stack3 = source.m_stack; bool moveSucceeded2 = playerInventory.MoveItemToThis(containerInventory, source, stack3, val.x, val.y); int num4 = CountMovedFromContainerSource(containerInventory, source, stack2, stack3, moveSucceeded2); num += num4; if (num4 == 0) { break; } } return num; } private static List GetSafeTakeAllStackTargets(Inventory playerInventory, ItemData source, HashSet allowedSlots) { return (from target in playerInventory.m_inventory where target?.m_shared != null && allowedSlots.Contains(target.m_gridPos) && target.m_shared.m_maxStackSize > 1 && CanUseContainerActionStacking(target) && CanShareInventoryStack(target, source) && target.m_stack < target.m_shared.m_maxStackSize orderby target.m_gridPos.y, target.m_gridPos.x select target).ToList(); } private static List GetSafeTakeAllEmptySlots(Inventory playerInventory, List actionSlots) { return actionSlots.Where((Vector2i slot) => playerInventory.GetItemAt(slot.x, slot.y) == null).ToList(); } private static void DrawControllerHotkeyConfig(ConfigEntryBase entry) { string configDrawerEntryKey = GetConfigDrawerEntryKey(entry); ControllerHotkeyAction controllerHotkeyAction = GetControllerHotkeyConfigValue(entry); bool flag = IsCapturingControllerHotkey(configDrawerEntryKey); GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); string controllerHotkeyDisplayText = GetControllerHotkeyDisplayText(controllerHotkeyAction); GUILayout.Label("Current: " + (string.IsNullOrWhiteSpace(controllerHotkeyDisplayText) ? "Off" : controllerHotkeyDisplayText), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button(flag ? "Stop" : "Capture", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) })) { if (flag) { StopControllerHotkeyCapture(); } else { StartControllerHotkeyCapture(configDrawerEntryKey); } } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(48f) })) { SetControllerHotkeyConfigValue(entry, ControllerHotkeyAction.Off); controllerHotkeyAction = ControllerHotkeyAction.Off; } GUILayout.EndHorizontal(); DrawControllerHotkeyStatus(entry, controllerHotkeyAction, flag); if (GUILayout.Button(ExpandedControllerHotkeyPresetDrawers.Contains(configDrawerEntryKey) ? "Hide Presets" : "Presets", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }) && !ExpandedControllerHotkeyPresetDrawers.Add(configDrawerEntryKey)) { ExpandedControllerHotkeyPresetDrawers.Remove(configDrawerEntryKey); } if (ExpandedControllerHotkeyPresetDrawers.Contains(configDrawerEntryKey)) { DrawControllerHotkeyPresetButtons(entry, controllerHotkeyAction); } GUILayout.EndVertical(); } private static void DrawControllerHotkeyStatus(ConfigEntryBase entry, ControllerHotkeyAction currentValue, bool isCapturing) { if (IsControllerDPadAction(currentValue)) { ConfigEntry controllerDPadHotkeyMode = _controllerDPadHotkeyMode; if (controllerDPadHotkeyMode == null || controllerDPadHotkeyMode.Value == ControllerDPadHotkeyMode.InventoryNavigation) { GUILayout.Label("DPad actions are ignored until Controller DPad Hotkey Mode allows hotkeys.", Array.Empty()); } } if (isCapturing) { ControllerHotkeyAction controllerHotkeyAction = TryCaptureControllerHotkeyAction(); if (controllerHotkeyAction != ControllerHotkeyAction.Off) { SetControllerHotkeyConfigValue(entry, controllerHotkeyAction); StopControllerHotkeyCapture(); } else { float num = Mathf.Max(0f, _controllerHotkeyCaptureEndTime - Time.unscaledTime); GUILayout.Label($"Listening for controller input... {num:0.0}s", Array.Empty()); } } } private static void DrawControllerHotkeyPresetButtons(ConfigEntryBase entry, ControllerHotkeyAction currentValue) { for (int i = 0; i < ControllerActionOptions.Length; i++) { if (i % 4 == 0) { GUILayout.BeginHorizontal(Array.Empty()); } ControllerActionOption controllerActionOption = ControllerActionOptions[i]; if (GUILayout.Button((currentValue == controllerActionOption.Action) ? ("* " + controllerActionOption.Label) : controllerActionOption.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(88f) })) { SetControllerHotkeyConfigValue(entry, controllerActionOption.Action); } if (i % 4 == 3 || i == ControllerActionOptions.Length - 1) { GUILayout.EndHorizontal(); } } } private static ControllerHotkeyAction TryCaptureControllerHotkeyAction() { for (int i = 0; i < ControllerActionOptions.Length; i++) { ControllerHotkeyAction action = ControllerActionOptions[i].Action; if (action == ControllerHotkeyAction.Off) { continue; } try { if (ZInput.GetButtonDown(GetControllerHotkeyActionName(action))) { return action; } } catch { } } for (int j = 0; j <= 19; j++) { try { if (Input.GetKeyDown((KeyCode)(330 + j)) && UnityJoystickButtonToControllerAction.TryGetValue(j, out var value)) { return value; } } catch { return ControllerHotkeyAction.Off; } } return ControllerHotkeyAction.Off; } private static ControllerHotkeyAction GetControllerHotkeyConfigValue(ConfigEntryBase entry) { object boxedValue = entry.BoxedValue; if (boxedValue is ControllerHotkeyAction) { return (ControllerHotkeyAction)boxedValue; } return ControllerHotkeyAction.Off; } private static void SetControllerHotkeyConfigValue(ConfigEntryBase entry, ControllerHotkeyAction value) { if (!object.Equals(entry.BoxedValue, value)) { entry.BoxedValue = value; } } private static bool IsCapturingControllerHotkey(string entryKey) { if (!string.Equals(_controllerHotkeyCaptureEntryKey, entryKey, StringComparison.Ordinal)) { return false; } if (Time.unscaledTime <= _controllerHotkeyCaptureEndTime) { return true; } StopControllerHotkeyCapture(); return false; } private static void StartControllerHotkeyCapture(string entryKey) { _controllerHotkeyCaptureEntryKey = entryKey; _controllerHotkeyCaptureEndTime = Time.unscaledTime + 8f; } private static void StopControllerHotkeyCapture() { _controllerHotkeyCaptureEntryKey = ""; _controllerHotkeyCaptureEndTime = 0f; } private static string GetConfigDrawerEntryKey(ConfigEntryBase entry) { return entry.Definition.Section + "\n" + entry.Definition.Key; } private static bool IsControllerHotkeyDown(ConfigEntry? entry) { return IsControllerHotkeyActive(entry, down: true, respectDPadMode: true); } private static bool IsControllerHotkeyHeld(ConfigEntry? entry) { return IsControllerHotkeyActive(entry, down: false, respectDPadMode: true); } private static bool IsControllerHotkeyConfigured(ConfigEntry? entry) { if (entry != null && entry.Value != ControllerHotkeyAction.Off) { return IsControllerActionAllowedByDPadMode(entry.Value, forDisplay: true); } return false; } private static bool IsControllerHotkeyActive(ConfigEntry? entry, bool down, bool respectDPadMode) { if (_enableControllerHotkeys == null || _enableControllerHotkeys.Value.IsOff() || entry == null || entry.Value == ControllerHotkeyAction.Off || !IsGamepadActiveSafe()) { return false; } ControllerHotkeyAction value = entry.Value; if (respectDPadMode && !IsControllerActionAllowedByDPadMode(value, forDisplay: false)) { return false; } string controllerHotkeyActionName = GetControllerHotkeyActionName(value); if (string.IsNullOrWhiteSpace(controllerHotkeyActionName)) { return false; } try { return down ? ZInput.GetButtonDown(controllerHotkeyActionName) : ZInput.GetButton(controllerHotkeyActionName); } catch { return false; } } private static string GetControllerHotkeyDisplayText(ConfigEntry? entry) { return GetControllerHotkeyDisplayText(entry, respectDPadMode: true); } private static string GetControllerHotkeyDisplayText(ConfigEntry? entry, bool respectDPadMode) { if (entry == null || entry.Value == ControllerHotkeyAction.Off) { return ""; } ControllerHotkeyAction value = entry.Value; if (respectDPadMode && !IsControllerActionAllowedByDPadMode(value, forDisplay: true)) { return ""; } string text = GetControllerHotkeyDisplayText(value); if (respectDPadMode && IsControllerDPadAction(value) && (_controllerDPadHotkeyMode?.Value ?? ControllerDPadHotkeyMode.InventoryNavigation) == ControllerDPadHotkeyMode.HotkeysWhileHoldingModifier) { string controllerHotkeyDisplayText = GetControllerHotkeyDisplayText(_controllerDPadModifierButton, respectDPadMode: false); if (!string.IsNullOrWhiteSpace(controllerHotkeyDisplayText)) { text = controllerHotkeyDisplayText + " + " + text; } } return text; } private static string GetControllerHotkeyDisplayText(ControllerHotkeyAction action) { if (action != ControllerHotkeyAction.Off) { return GetControllerActionDisplayText(GetControllerHotkeyActionName(action)); } return ""; } private static string GetControllerActionDisplayText(string action) { if (string.IsNullOrWhiteSpace(action)) { return ""; } try { string text = ((ZInput.instance != null) ? ZInput.instance.GetBoundKeyString(action, true) : ""); if (!string.IsNullOrWhiteSpace(text)) { return text; } } catch { } return action; } private static string GetControllerHotkeyActionName(ControllerHotkeyAction action) { if (action != ControllerHotkeyAction.Off) { return action.ToString(); } return ""; } private static bool IsControllerActionAllowedByDPadMode(ControllerHotkeyAction action, bool forDisplay) { if (!IsControllerDPadAction(action)) { return true; } return (_controllerDPadHotkeyMode?.Value ?? ControllerDPadHotkeyMode.InventoryNavigation) switch { ControllerDPadHotkeyMode.Hotkeys => true, ControllerDPadHotkeyMode.HotkeysWhileHoldingModifier => forDisplay ? IsControllerHotkeyConfiguredIgnoringDPadMode(_controllerDPadModifierButton) : IsControllerHotkeyActive(_controllerDPadModifierButton, down: false, respectDPadMode: false), _ => false, }; } private static bool IsControllerHotkeyConfiguredIgnoringDPadMode(ConfigEntry? entry) { if (entry != null) { return entry.Value != ControllerHotkeyAction.Off; } return false; } private static bool IsControllerDPadAction(ControllerHotkeyAction action) { if ((uint)(action - 13) <= 3u) { return true; } return false; } private static void UpdateCraftingActionControls(InventoryGui gui, RectTransform? countRect, RectTransform? upgradeProgressionRect, Vector2 craftPosition, Vector2 countPosition, Vector2 craftButtonSize, Vector2 countInputSize, bool updateLayout) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_craftingCountInputRect != (Object)null && (Object)(object)countRect == (Object)null) { ((Component)_craftingCountInputRect).gameObject.SetActive(false); } if ((Object)(object)_craftingUpgradeProgressionRect != (Object)null && (Object)(object)upgradeProgressionRect == (Object)null) { ((Component)_craftingUpgradeProgressionRect).gameObject.SetActive(false); } if ((Object)(object)gui.m_craftButton != (Object)null) { ((Component)gui.m_craftButton).gameObject.SetActive((Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe != (Object)null && gui.m_craftTimer < 0f); if (updateLayout) { RectTransform rect = (RectTransform)((Component)gui.m_craftButton).transform; SetCraftingTopLeftRect(gui.m_crafting, rect, craftPosition, craftButtonSize); } } Transform craftProgressPanel = gui.m_craftProgressPanel; RectTransform val = (RectTransform)(object)((craftProgressPanel is RectTransform) ? craftProgressPanel : null); if (val != null && updateLayout) { SetCraftingTopLeftRect(gui.m_crafting, val, craftPosition, craftButtonSize); GuiBar craftProgressBar = gui.m_craftProgressBar; if (craftProgressBar != null) { craftProgressBar.SetWidth(craftButtonSize.x); } } if ((Object)(object)countRect != (Object)null) { if (updateLayout) { SetCraftingTopLeftRect(gui.m_crafting, countRect, countPosition, countInputSize); } ((Component)countRect).gameObject.SetActive((Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe != (Object)null && ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData == null); UpdateCraftingCountInputState(gui); } if ((Object)(object)upgradeProgressionRect != (Object)null) { if (updateLayout) { SetCraftingTopLeftRect(gui.m_crafting, upgradeProgressionRect, countPosition, countInputSize); } UpdateCraftingUpgradeProgression(gui); } UpdateCraftingCraftButtonLabel(gui); UpdateJewelcraftingSocketCraftButtonState(gui); UpdateCraftingProgressLabel(gui); } private static void UpdateCraftingStationAndWarningControls(InventoryGui gui, RectTransform grid, Vector2 requiredStationPosition, bool updateLayout) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (ShouldShowCraftingStatusHud(gui)) { LayoutCraftingStatusHud(gui, grid, updateLayout); } else { HideCraftingSocketWarning(); } UpdateCraftingRequiredStationLevel(gui, requiredStationPosition, updateLayout); } private static void UpdateCraftingRequirementStrip(InventoryGui gui, Vector2 requirementPosition, List visibleRequirements, bool updateLayout) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00d7: Unknown result type (might be due to invalid IL or missing references) int selectedCraftingQuality = GetSelectedCraftingQuality(gui); int effectiveCraftingCount = GetEffectiveCraftingCount(gui); HideCraftingVanillaRequirementSlots(gui); int num = Mathf.Max(4, CraftingRequirements.OwnedSlots.Count); for (int i = 0; i < num; i++) { if (i >= 4 || i >= visibleRequirements.Count) { if (i < CraftingRequirements.OwnedSlots.Count) { RectTransform val = CraftingRequirements.OwnedSlots[i]; if (val != null && !IsUnityNull((Object?)(object)val)) { ((Component)val).gameObject.SetActive(false); } } } else { RectTransform val2 = EnsureOwnedCraftingRequirementSlot(gui, i); if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2)) { ((Component)val2).gameObject.SetActive(true); SetCraftingTopLeftRect(gui.m_crafting, val2, requirementPosition + new Vector2((float)i * 72f, 0f), new Vector2(64f, 64f)); ConfigureCompactCraftingRequirement(gui, val2, visibleRequirements[i], selectedCraftingQuality, effectiveCraftingCount); } } } } private static void LayoutCraftingBottomControls(InventoryGui gui, RectTransform grid) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d5: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) HideRecycleNReclaimHud(); if (CraftingRecipes.View.Count == 0 || FindCraftingRecipeViewIndex(gui.GetSelectedRecipeIndex(false)) < 0) { HideCraftingRedesignBottomControls(gui); HideCraftingSocketWarning(); if ((Object)(object)_craftingCountInputRect != (Object)null) { ((Component)_craftingCountInputRect).gameObject.SetActive(false); } CraftingController.StoreBottomControlsSignature("hidden"); return; } bool num = IsJewelcraftingSocketTabActive(gui); Vector2 craftingBottomControlsFixedOffset = CraftingBottomControlsFixedOffset; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(136f, 42f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(64f, 42f); Vector2 craftPosition = GetCraftingGridCenteredPosition(grid, 0, 8, val, 2) + craftingBottomControlsFixedOffset + CraftingCraftButtonFixedOffset; Vector2 countPosition = GetCraftingGridCenteredPosition(grid, 2, 8, val2) + craftingBottomControlsFixedOffset + CraftingCountInputFixedOffset; Vector2 requirementPosition = GetCraftingGridCellPosition(grid, 3, 8) + craftingBottomControlsFixedOffset; Vector2 requiredStationPosition = GetCraftingGridCellPosition(grid, 7, 8) + craftingBottomControlsFixedOffset; RectTransform countRect = (num ? null : EnsureCraftingCountInput(gui)); RectTransform upgradeProgressionRect = (num ? null : EnsureCraftingUpgradeProgression(gui)); List visibleCraftingRequirements = GetVisibleCraftingRequirements(gui); string craftingBottomControlsLayoutSignature = GetCraftingBottomControlsLayoutSignature(gui, grid, countRect, upgradeProgressionRect, visibleCraftingRequirements.Count); bool updateLayout = CraftingController.NeedsBottomControlsLayout(craftingBottomControlsLayoutSignature); UpdateCraftingActionControls(gui, countRect, upgradeProgressionRect, craftPosition, countPosition, val, val2, updateLayout); UpdateCraftingStationAndWarningControls(gui, grid, requiredStationPosition, updateLayout); UpdateCraftingRequirementStrip(gui, requirementPosition, visibleCraftingRequirements, updateLayout); CraftingController.StoreBottomControlsSignature(craftingBottomControlsLayoutSignature); } private static void HideCraftingRedesignBottomControls(InventoryGui gui) { SuppressCraftingRequiredStationLevelOriginalBackground(gui); if ((Object)(object)gui.m_craftButton != (Object)null) { ((Component)gui.m_craftButton).gameObject.SetActive(false); } Transform craftProgressPanel = gui.m_craftProgressPanel; RectTransform val = (RectTransform)(object)((craftProgressPanel is RectTransform) ? craftProgressPanel : null); if (val != null) { ((Component)val).gameObject.SetActive(false); } if ((Object)(object)gui.m_minStationLevelIcon != (Object)null) { ((Component)gui.m_minStationLevelIcon).gameObject.SetActive(false); } if ((Object)(object)gui.m_minStationLevelText != (Object)null) { ((Component)gui.m_minStationLevelText).gameObject.SetActive(false); } HideCraftingRequiredStationLevelTooltip(); if ((Object)(object)gui.m_itemCraftType != (Object)null) { ((Component)gui.m_itemCraftType).gameObject.SetActive(false); } HideCraftingSocketWarning(); if ((Object)(object)_craftingUpgradeProgressionRect != (Object)null) { ((Component)_craftingUpgradeProgressionRect).gameObject.SetActive(false); } HideCraftingVanillaRequirementSlots(gui); HideOwnedCraftingRequirementSlots(); CraftingController.MarkBottomControlsDirty(); } private static string GetCraftingBottomControlsLayoutSignature(InventoryGui gui, RectTransform grid, RectTransform? countRect, RectTransform? upgradeProgressionRect, int visibleRequirementCount) { //IL_0030: 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) return $"{((Object)gui.m_crafting).GetInstanceID()}|{((Object)grid).GetInstanceID()}|{grid.anchoredPosition.x:0.###}|{grid.anchoredPosition.y:0.###}|{GetUnityObjectId((Object?)(object)gui.m_craftButton)}|{GetUnityObjectId((Object?)(object)gui.m_craftProgressPanel)}|{GetUnityObjectId((Object?)(object)countRect)}|{GetUnityObjectId((Object?)(object)upgradeProgressionRect)}|{GetUnityObjectId((Object?)(object)gui.m_minStationLevelIcon)}|{GetUnityObjectId((Object?)(object)gui.m_minStationLevelText)}|{visibleRequirementCount}|ownedReq={CraftingRequirements.OwnedSlots.Count}|{64f:0.###}|{72f:0.###}|socket={IsJewelcraftingSocketTabActive(gui)}"; } private static List GetVisibleCraftingRequirements(InventoryGui gui) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) CraftingRequirements.VisibleRequirements.Clear(); CraftingRequirements.VisibleRequirementCandidates.Clear(); Recipe recipe = ((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe; int selectedCraftingQuality = GetSelectedCraftingQuality(gui); if ((Object)(object)recipe == (Object)null || recipe.m_resources == null) { return CraftingRequirements.VisibleRequirements; } if (IsJewelcraftingSocketTabActive(gui) && ShouldHideJewelcraftingSocketRequirements(gui.m_selectedRecipe)) { return CraftingRequirements.VisibleRequirements; } Player localPlayer = Player.m_localPlayer; Requirement[] resources = recipe.m_resources; foreach (Requirement val in resources) { if (val != null && !((Object)(object)val.m_resItem == (Object)null) && val.GetAmount(selectedCraftingQuality) > 0 && (!recipe.m_requireOnlyOneIngredient || !((Object)(object)localPlayer != (Object)null) || val.m_resItem.m_itemData?.m_shared == null || localPlayer.IsKnownMaterial(val.m_resItem.m_itemData.m_shared.m_name))) { CraftingRequirements.VisibleRequirementCandidates.Add(val); } } int num = 0; if (CraftingRequirements.VisibleRequirementCandidates.Count > 4) { int num2 = Mathf.CeilToInt((float)CraftingRequirements.VisibleRequirementCandidates.Count / 4f); num = (int)Time.fixedTime % Mathf.Max(1, num2) * 4; } for (int j = num; j < CraftingRequirements.VisibleRequirementCandidates.Count; j++) { if (CraftingRequirements.VisibleRequirements.Count >= 4) { break; } CraftingRequirements.VisibleRequirements.Add(CraftingRequirements.VisibleRequirementCandidates[j]); } return CraftingRequirements.VisibleRequirements; } private static bool ShouldShowCraftingStatusHud(InventoryGui gui) { if (ShouldShowUpgradeCraftingStatusHud(gui)) { return true; } if (IsJewelcraftingSocketTabActive(gui)) { return true; } if (IsJewelcraftingGemcutterStationActive() && IsCraftingCraftTabSelected(gui)) { return IsJewelcraftingGemCuttingRecipe(((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe); } return false; } private static bool ShouldShowUpgradeCraftingStatusHud(InventoryGui gui) { if (gui.InUpradeTab() && !IsJewelcraftingSocketTabActive(gui) && !IsRecycleNReclaimReclaimTabActive(gui) && ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData?.m_shared != null) { return (Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe != (Object)null; } return false; } private static void LayoutCraftingStatusHud(InventoryGui gui, RectTransform grid, bool updateLayout) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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) string craftingStatusHudText = GetCraftingStatusHudText(gui); if (string.IsNullOrWhiteSpace(craftingStatusHudText)) { HideCraftingSocketWarning(); return; } RectTransform val = EnsureCraftingSocketWarning(gui); if (!((Object)(object)val == (Object)null) && !((Object)(object)CraftingUi.SocketWarningText == (Object)null)) { Vector2 val2 = GetCraftingGridCellPosition(grid, 0, 9) + CraftingBottomControlsFixedOffset; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(568f, 58f); CraftingStatusHudStamp stamp = new CraftingStatusHudStamp(((Object)gui.m_crafting).GetInstanceID(), ((Object)grid).GetInstanceID(), val2.x, val2.y, val3.x, val3.y, craftingStatusHudText); if (updateLayout || !CraftingController.CanReuseSocketWarning(stamp)) { SetCraftingTopLeftRect(gui.m_crafting, val, val2, val3); ConfigureCraftingSocketWarningText(CraftingUi.SocketWarningText, craftingStatusHudText); CraftingController.StoreSocketWarningStamp(stamp); } ((Transform)val).SetAsLastSibling(); ((Component)val).gameObject.SetActive(true); } } private static string GetCraftingStatusHudText(InventoryGui gui) { if (ShouldShowUpgradeCraftingStatusHud(gui)) { return GetUpgradeCraftingStatusText(gui); } return StripRichText(((Object)(object)gui.m_itemCraftType != (Object)null && !IsUnityNull((Object?)(object)gui.m_itemCraftType)) ? (gui.m_itemCraftType.text ?? "") : "").Trim(); } private static string GetUpgradeCraftingStatusText(InventoryGui gui) { ItemData itemData = ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData; if (itemData?.m_shared == null) { return ""; } int num = Mathf.Max(1, itemData.m_quality); int num2 = Mathf.Max(num, itemData.m_shared.m_maxQuality); if (num >= num2) { if (Localization.instance == null) { return "Max quality"; } return Localization.instance.Localize("$inventory_maxquality"); } string localizedItemName = GetLocalizedItemName(itemData); string text = (num + 1).ToString(); if (Localization.instance == null) { return "Upgrade " + localizedItemName + " quality to " + text; } return Localization.instance.Localize("$inventory_upgrade", new string[2] { localizedItemName, text }); } private static RectTransform? EnsureCraftingSocketWarning(InventoryGui gui) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown if ((Object)(object)gui.m_crafting == (Object)null) { return null; } if ((Object)(object)CraftingUi.SocketWarningRect != (Object)null && !IsUnityNull((Object?)(object)CraftingUi.SocketWarningRect) && (Object)(object)((Transform)CraftingUi.SocketWarningRect).parent == (Object)(object)gui.m_crafting) { return CraftingUi.SocketWarningRect; } Transform val = ((Transform)gui.m_crafting).Find("InventorySlots_CraftingSocketWarning"); CraftingUi.SocketWarningRect = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)CraftingUi.SocketWarningRect == (Object)null) { CraftingUi.SocketWarningRect = new GameObject("InventorySlots_CraftingSocketWarning", new Type[1] { typeof(RectTransform) }).GetComponent(); } ((Transform)CraftingUi.SocketWarningRect).SetParent((Transform)(object)gui.m_crafting, false); Image val2 = default(Image); if (((Component)CraftingUi.SocketWarningRect).TryGetComponent(ref val2)) { ((Behaviour)val2).enabled = false; ((Graphic)val2).raycastTarget = false; } Transform val3 = ((Transform)CraftingUi.SocketWarningRect).Find("Text"); RectTransform rect; if ((Object)(object)val3 != (Object)null) { TMP_Text component = ((Component)val3).GetComponent(); if (component != null) { rect = (RectTransform)val3; CraftingUi.SocketWarningText = component; goto IL_015f; } } rect = CreateTextRect("Text", (Transform)(object)CraftingUi.SocketWarningRect, out TMP_Text text); CraftingUi.SocketWarningText = text; goto IL_015f; IL_015f: SetStretchRectLayout(rect, new Vector2(12f, 5f), new Vector2(-12f, -5f)); TMP_Text? socketWarningText = CraftingUi.SocketWarningText; ConfigureCraftingSocketWarningText(socketWarningText, socketWarningText.text); return CraftingUi.SocketWarningRect; } private static void ConfigureCraftingSocketWarningText(TMP_Text text, string warning) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)text == (Object)null) && !IsUnityNull((Object?)(object)text)) { ApplyDefaultFontAsset(text); text.text = warning; ((Graphic)text).color = new Color(1f, 0.72f, 0.28f, 1f); text.alignment = (TextAlignmentOptions)514; text.textWrappingMode = (TextWrappingModes)1; text.overflowMode = (TextOverflowModes)3; text.enableAutoSizing = true; text.fontSizeMin = 12f; text.fontSizeMax = 18f; ((Graphic)text).raycastTarget = false; } } private static void HideCraftingSocketWarning() { if ((Object)(object)CraftingUi.SocketWarningRect != (Object)null && !IsUnityNull((Object?)(object)CraftingUi.SocketWarningRect)) { ((Component)CraftingUi.SocketWarningRect).gameObject.SetActive(false); } CraftingController.ResetSocketWarningStamp(); } private static int GetSelectedCraftingQuality(InventoryGui gui) { if (IsJewelcraftingSocketTabActive(gui)) { return 1; } if (((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData != null) { return ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData.m_quality + 1; } return 1; } private static Vector2 GetCraftingGridCellPosition(RectTransform grid, int column, int row) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return grid.anchoredPosition + new Vector2((float)column * 72f, (float)(-row) * 72f); } private static Vector2 GetCraftingGridCenteredPosition(RectTransform grid, int column, int row, Vector2 size, int columnSpan = 1) { //IL_001b: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) float num = (float)(Mathf.Max(1, columnSpan) - 1) * 72f + 64f; return GetCraftingGridCellPosition(grid, column, row) + new Vector2((num - size.x) * 0.5f, (0f - (64f - size.y)) * 0.5f); } private static RectTransform? EnsureCraftingCountInput(InventoryGui gui) { //IL_00a0: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_craftingCountInputRect != (Object)null && !IsUnityNull((Object?)(object)_craftingCountInputRect) && (Object)(object)((Transform)_craftingCountInputRect).parent == (Object)(object)gui.m_crafting) { return _craftingCountInputRect; } Transform val = ((Transform)gui.m_crafting).Find("InventorySlots_CraftingCountInput"); _craftingCountInputRect = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)_craftingCountInputRect == (Object)null) { _craftingCountInputRect = new GameObject("InventorySlots_CraftingCountInput", new Type[3] { typeof(RectTransform), typeof(Image), typeof(TMP_InputField) }).GetComponent(); ((Transform)_craftingCountInputRect).SetParent((Transform)(object)gui.m_crafting, false); Image component = ((Component)_craftingCountInputRect).GetComponent(); component.sprite = GetSolidUiSprite(); ((Graphic)component).color = new Color(0f, 0f, 0f, 0.46f); ((Graphic)component).raycastTarget = true; RectTransform component2 = new GameObject("Text Area", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }).GetComponent(); ((Transform)component2).SetParent((Transform)(object)_craftingCountInputRect, false); SetStretchRectLayout(component2, new Vector2(22f, 3f), new Vector2(-4f, -3f)); CraftingUi.CountInputViewport = component2; SetStretchRectLayout(CreateTextRect("Text", (Transform)(object)component2, out TMP_Text text), Vector2.zero, Vector2.zero); text.fontSize = 22f; text.alignment = (TextAlignmentOptions)514; ((Graphic)text).color = Color.white; text.textWrappingMode = (TextWrappingModes)0; _craftingCountInput = ((Component)_craftingCountInputRect).GetComponent(); _craftingCountInput.textViewport = component2; _craftingCountInput.textComponent = text; ((Selectable)_craftingCountInput).targetGraphic = (Graphic)(object)component; _craftingCountInput.contentType = (ContentType)2; _craftingCountInput.characterValidation = (CharacterValidation)2; _craftingCountInput.lineType = (LineType)0; _craftingCountInput.characterLimit = 2; _craftingCountInput.SetTextWithoutNotify("1"); ((UnityEvent)(object)_craftingCountInput.onEndEdit).AddListener((UnityAction)delegate(string value) { SetCraftingCount(ParseCraftingCount(value)); }); } else { _craftingCountInput = ((Component)_craftingCountInputRect).GetComponent(); CraftingUiRuntimeState craftingUi = CraftingUi; TMP_InputField? craftingCountInput = _craftingCountInput; craftingUi.CountInputViewport = ((craftingCountInput != null) ? craftingCountInput.textViewport : null); if ((Object)(object)CraftingUi.CountInputViewport == (Object)null || IsUnityNull((Object?)(object)CraftingUi.CountInputViewport)) { ref RectTransform? countInputViewport = ref CraftingUi.CountInputViewport; Transform obj = ((Transform)_craftingCountInputRect).Find("Text Area"); countInputViewport = (RectTransform?)(object)((obj is RectTransform) ? obj : null); } } EnsureCraftingCountWheelIcon(_craftingCountInputRect, locked: false); return _craftingCountInputRect; } private static RectTransform? EnsureCraftingUpgradeProgression(InventoryGui gui) { //IL_00a0: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_craftingUpgradeProgressionRect != (Object)null && !IsUnityNull((Object?)(object)_craftingUpgradeProgressionRect) && (Object)(object)((Transform)_craftingUpgradeProgressionRect).parent == (Object)(object)gui.m_crafting) { return _craftingUpgradeProgressionRect; } Transform val = ((Transform)gui.m_crafting).Find("InventorySlots_CraftingUpgradeProgression"); _craftingUpgradeProgressionRect = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)_craftingUpgradeProgressionRect == (Object)null) { _craftingUpgradeProgressionRect = new GameObject("InventorySlots_CraftingUpgradeProgression", new Type[3] { typeof(RectTransform), typeof(Image), typeof(UITooltip) }).GetComponent(); ((Transform)_craftingUpgradeProgressionRect).SetParent((Transform)(object)gui.m_crafting, false); Image component = ((Component)_craftingUpgradeProgressionRect).GetComponent(); component.sprite = GetSolidUiSprite(); ((Graphic)component).color = new Color(0f, 0f, 0f, 0.42f); ((Graphic)component).raycastTarget = true; TMP_Text text; RectTransform rect = CreateTextRect("Text", (Transform)(object)_craftingUpgradeProgressionRect, out text); CraftingUi.UpgradeProgressionText = text; SetStretchRectLayout(rect, new Vector2(4f, 3f), new Vector2(-4f, -3f)); text.fontSize = 20f; text.alignment = (TextAlignmentOptions)514; ((Graphic)text).color = new Color(1f, 0.84f, 0.42f, 1f); text.textWrappingMode = (TextWrappingModes)0; text.overflowMode = (TextOverflowModes)0; ((Graphic)text).raycastTarget = false; } else { CraftingUiRuntimeState craftingUi = CraftingUi; Transform obj = ((Transform)_craftingUpgradeProgressionRect).Find("Text"); craftingUi.UpgradeProgressionText = ((obj != null) ? ((Component)obj).GetComponent() : null); } return _craftingUpgradeProgressionRect; } private static void UpdateCraftingUpgradeProgression(InventoryGui gui) { if ((Object)(object)_craftingUpgradeProgressionRect == (Object)null) { return; } ItemData itemData = ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData; Recipe recipe = ((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe; bool flag = itemData?.m_shared != null && (Object)(object)recipe != (Object)null; ((Component)_craftingUpgradeProgressionRect).gameObject.SetActive(flag); if (!flag) { return; } int num = Mathf.Max(1, itemData.m_quality); int num2 = Mathf.Max(num, itemData.m_shared.m_maxQuality); int num3 = Mathf.Min(num + 1, num2); string text = ((num < num2) ? $"{num} > {num3}" : LocalizeUi("$inventoryslots_max", "Max")); if ((Object)(object)CraftingUi.UpgradeProgressionText != (Object)null) { CraftingTextCacheState craftingTextCache = GetCraftingTextCache(((Component)_craftingUpgradeProgressionRect).gameObject); CraftingTextStamp craftingTextStamp = new CraftingTextStamp("upgrade", text, "", 20f); if (!craftingTextCache.LastTextStamp.Equals(craftingTextStamp)) { ApplyDefaultFontAsset(CraftingUi.UpgradeProgressionText); CraftingUi.UpgradeProgressionText.text = text; CraftingUi.UpgradeProgressionText.enableAutoSizing = true; CraftingUi.UpgradeProgressionText.fontSizeMin = 10f; CraftingUi.UpgradeProgressionText.fontSizeMax = 20f; craftingTextCache.LastTextStamp = craftingTextStamp; } } ConfigureSimpleTooltip(((Component)_craftingUpgradeProgressionRect).gameObject, GetLocalizedItemName(itemData) + " " + text, enabled: true); } private static void EnsureCraftingCountWheelIcon(RectTransform countRect, bool locked) { //IL_0016: 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_0040: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = EnsureHintImage(countRect, "InventorySlots_CraftingCountWheelIcon"); obj.anchorMin = new Vector2(0f, 0.5f); obj.anchorMax = new Vector2(0f, 0.5f); obj.pivot = new Vector2(0f, 0.5f); obj.anchoredPosition = new Vector2(5f, 0f); obj.sizeDelta = new Vector2(13f, 19f); ((Transform)obj).localScale = Vector3.one; ((Transform)obj).localRotation = Quaternion.identity; ((Transform)obj).SetAsLastSibling(); Image component = ((Component)obj).GetComponent(); component.sprite = GetMouseWheelHintSprite(); component.type = (Type)0; component.preserveAspect = true; ((Graphic)component).raycastTarget = false; ((Graphic)component).color = (locked ? new Color(0.68f, 0.88f, 1f, 0.32f) : new Color(0.68f, 0.88f, 1f, 0.82f)); RectTransform val = CraftingUi.CountInputViewport; if ((Object)(object)val == (Object)null || IsUnityNull((Object?)(object)val) || (Object)(object)((Transform)val).parent != (Object)(object)countRect) { Transform obj2 = ((Transform)countRect).Find("Text Area"); val = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); CraftingUi.CountInputViewport = val; } if ((Object)(object)val != (Object)null && !IsUnityNull((Object?)(object)val)) { SetStretchRectLayout(val, new Vector2(22f, 3f), new Vector2(-4f, -3f)); } } private static void UpdateCraftingRequiredStationLevel(InventoryGui gui, Vector2 anchoredPosition, bool updateLayout) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0146: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) Recipe recipe = ((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe; if ((Object)(object)gui.m_minStationLevelIcon == (Object)null || (Object)(object)gui.m_minStationLevelText == (Object)null) { return; } RectTransform val = (RectTransform)((Component)gui.m_minStationLevelIcon).transform; RectTransform val2 = (RectTransform)gui.m_minStationLevelText.transform; SuppressCraftingRequiredStationLevelOriginalBackground(gui, val, val2); if ((Object)(object)recipe == (Object)null) { ((Component)gui.m_minStationLevelIcon).gameObject.SetActive(false); ((Component)gui.m_minStationLevelText).gameObject.SetActive(false); HideCraftingRequiredStationLevelTooltip(); return; } int num = ((((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData == null) ? 1 : (((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData.m_quality + 1)); bool flag = num <= recipe.m_item.m_itemData.m_shared.m_maxQuality; CraftingStation requiredStation = recipe.GetRequiredStation(num); if ((Object)(object)requiredStation == (Object)null || !flag) { ((Component)gui.m_minStationLevelIcon).gameObject.SetActive(false); ((Component)gui.m_minStationLevelText).gameObject.SetActive(false); HideCraftingRequiredStationLevelTooltip(); return; } int requiredStationLevel = recipe.GetRequiredStationLevel(num); bool flag2 = !IsVeiledRecipeMasked(gui.m_selectedRecipe) || KnowsVeiledRecipeStationRequirement(recipe, num); Vector2 val3 = anchoredPosition + new Vector2(10f, -10f); if (updateLayout) { SetCraftingTopLeftRect(gui.m_crafting, val, val3, new Vector2(44f, 44f)); SetCraftingTopLeftRect(gui.m_crafting, val2, val3 + new Vector2(0f, -24f), new Vector2(44f, 20f)); } if ((Object)(object)requiredStation.m_icon != (Object)null) { gui.m_minStationLevelIcon.sprite = requiredStation.m_icon; gui.m_minStationLevelIcon.overrideSprite = requiredStation.m_icon; } ((Graphic)gui.m_minStationLevelIcon).color = Color.white; ((Component)gui.m_minStationLevelIcon).gameObject.SetActive(true); ApplyDefaultFontAsset(gui.m_minStationLevelText); gui.m_minStationLevelText.text = (flag2 ? requiredStationLevel.ToString() : GetVeiledRecipeUnknownRequirementText()); gui.m_minStationLevelText.alignment = (TextAlignmentOptions)1028; gui.m_minStationLevelText.enableAutoSizing = true; gui.m_minStationLevelText.fontSizeMin = 12f; gui.m_minStationLevelText.fontSizeMax = 18f; CraftingStation val4 = (((Object)(object)Player.m_localPlayer != (Object)null) ? Player.m_localPlayer.GetCurrentCraftingStation() : null); bool flag3 = flag2 && ((Object)(object)val4 == (Object)null || val4.GetLevel(true) < requiredStationLevel); ((Graphic)gui.m_minStationLevelText).color = ((flag3 && !ZoneSystem.instance.GetGlobalKey((GlobalKeys)20) && Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : gui.m_minStationLevelBasecolor); ((Component)gui.m_minStationLevelText).gameObject.SetActive(true); RectTransform val5 = EnsureCraftingRequiredStationLevelHitbox(gui, val3, 44f); if ((Object)(object)val5 != (Object)null) { ConfigureSimpleTooltip(((Component)val5).gameObject, flag2 ? GetCraftingStationDisplayName(requiredStation) : GetVeiledRecipeUnknownNameText(), enabled: true); } } private static RectTransform? EnsureCraftingRequiredStationLevelHitbox(InventoryGui gui, Vector2 iconPosition, float iconSize) { //IL_008b: 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_00ab: 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) if ((Object)(object)gui.m_crafting == (Object)null) { return null; } RectTransform val = CraftingUi.RequiredStationLevelHitbox; if ((Object)(object)val == (Object)null || IsUnityNull((Object?)(object)val) || (Object)(object)((Transform)val).parent != (Object)(object)gui.m_crafting) { Transform obj = ((Transform)gui.m_crafting).Find("InventorySlots_CraftingRequiredStationHitbox"); val = (RectTransform)(object)((obj is RectTransform) ? obj : null); if ((Object)(object)val == (Object)null || IsUnityNull((Object?)(object)val)) { val = new GameObject("InventorySlots_CraftingRequiredStationHitbox", new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent(); } CraftingUi.RequiredStationLevelHitbox = val; } SetCraftingTopLeftRect(gui.m_crafting, val, iconPosition, new Vector2(iconSize, iconSize)); ((Component)val).gameObject.SetActive(true); Image obj2 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj2.sprite = GetSolidUiSprite(); ((Graphic)obj2).color = new Color(0f, 0f, 0f, 0f); ((Graphic)obj2).raycastTarget = true; if ((Object)(object)((Transform)val).parent != (Object)null && ((Transform)val).GetSiblingIndex() != ((Transform)val).parent.childCount - 1) { ((Transform)val).SetAsLastSibling(); } return val; } private static void HideCraftingRequiredStationLevelTooltip() { RectTransform requiredStationLevelHitbox = CraftingUi.RequiredStationLevelHitbox; if ((Object)(object)requiredStationLevelHitbox == (Object)null || IsUnityNull((Object?)(object)requiredStationLevelHitbox)) { CraftingUi.RequiredStationLevelHitbox = null; return; } ConfigureSimpleTooltip(((Component)requiredStationLevelHitbox).gameObject, "", enabled: false); ((Component)requiredStationLevelHitbox).gameObject.SetActive(false); } private static void SuppressCraftingRequiredStationLevelOriginalBackground(InventoryGui gui) { //IL_0029: 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_0043: Expected O, but got Unknown //IL_0043: Expected O, but got Unknown if (!((Object)(object)gui.m_minStationLevelIcon == (Object)null) && !((Object)(object)gui.m_minStationLevelText == (Object)null)) { SuppressCraftingRequiredStationLevelOriginalBackground(gui, (RectTransform)((Component)gui.m_minStationLevelIcon).transform, (RectTransform)gui.m_minStationLevelText.transform); } } private static void SuppressCraftingRequiredStationLevelOriginalBackground(InventoryGui gui, RectTransform iconRect, RectTransform textRect) { HideCraftingRequiredStationLevelOriginalBackground(gui, iconRect, textRect); } private static void HideCraftingRequiredStationLevelOriginalBackground(InventoryGui gui, RectTransform iconRect, RectTransform textRect) { if ((Object)(object)gui.m_crafting == (Object)null) { return; } if ((Object)(object)CraftingUi.RequiredStationLevelOriginalRoot == (Object)null || IsUnityNull((Object?)(object)CraftingUi.RequiredStationLevelOriginalRoot)) { CraftingUi.RequiredStationLevelOriginalRoot = FindCraftingRequiredStationLevelOriginalRoot(gui, iconRect, textRect); } Transform requiredStationLevelOriginalRoot = CraftingUi.RequiredStationLevelOriginalRoot; if ((Object)(object)requiredStationLevelOriginalRoot == (Object)null || IsUnityNull((Object?)(object)requiredStationLevelOriginalRoot) || (Object)(object)requiredStationLevelOriginalRoot == (Object)(object)gui.m_crafting || !requiredStationLevelOriginalRoot.IsChildOf((Transform)(object)gui.m_crafting)) { CraftingUi.RequiredStationLevelOriginalRoot = FindCraftingRequiredStationLevelOriginalRoot(gui, iconRect, textRect); requiredStationLevelOriginalRoot = CraftingUi.RequiredStationLevelOriginalRoot; if ((Object)(object)requiredStationLevelOriginalRoot == (Object)null || IsUnityNull((Object?)(object)requiredStationLevelOriginalRoot) || (Object)(object)requiredStationLevelOriginalRoot == (Object)(object)gui.m_crafting || !requiredStationLevelOriginalRoot.IsChildOf((Transform)(object)gui.m_crafting)) { CraftingUi.RequiredStationLevelOriginalRoot = null; return; } } Image[] componentsInChildren = ((Component)requiredStationLevelOriginalRoot).GetComponentsInChildren(true); foreach (Image val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val) && !((Object)(object)val == (Object)(object)gui.m_minStationLevelIcon) && !IsOwnedCraftingUiTransform(((Component)val).transform)) { if (!CraftingVanillaPanelBackgroundStates.ContainsKey(val)) { CraftingVanillaPanelBackgroundStates[val] = ((Behaviour)val).enabled; } ((Behaviour)val).enabled = false; ((Graphic)val).raycastTarget = false; } } } private static Transform? FindCraftingRequiredStationLevelOriginalRoot(InventoryGui gui, RectTransform iconRect, RectTransform textRect) { Transform parent = ((Transform)iconRect).parent; Transform parent2 = ((Transform)textRect).parent; if ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)gui.m_crafting && (Object)(object)parent2 != (Object)null && ((Object)(object)parent2 == (Object)(object)parent || parent2.IsChildOf(parent))) { return parent; } if ((Object)(object)parent2 != (Object)null && (Object)(object)parent2 != (Object)(object)gui.m_crafting && (Object)(object)parent != (Object)null && parent.IsChildOf(parent2)) { return parent2; } if (!((Object)(object)parent != (Object)null) || !((Object)(object)parent != (Object)(object)gui.m_crafting)) { return null; } return parent; } private static void UpdateCraftingCountInputState(InventoryGui gui) { //IL_007c: 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) if (!((Object)(object)_craftingCountInput == (Object)null) && !((Object)(object)_craftingCountInputRect == (Object)null)) { bool flag = IsCraftingCountInputLocked(gui); ((Selectable)_craftingCountInput).interactable = !flag; _craftingCountInput.readOnly = flag; Image val = default(Image); if (((Component)_craftingCountInputRect).TryGetComponent(ref val)) { ((Graphic)val).color = (flag ? new Color(0f, 0f, 0f, 0.28f) : new Color(0f, 0f, 0f, 0.46f)); } EnsureCraftingCountWheelIcon(_craftingCountInputRect, flag); } } private static void UpdateCraftingCraftButtonLabel(InventoryGui gui) { if ((Object)(object)gui.m_craftButton == (Object)null || (Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe == (Object)null) { return; } string text = (IsJewelcraftingSocketTabActive(gui) ? LocalizeUi("$jc_add_socket_button", "Socket") : ((((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData != null) ? LocalizeUi("$inventory_upgradebutton", "Upgrade") : LocalizeUi("$inventory_craftbutton", "Craft"))); int effectiveCraftingCount = GetEffectiveCraftingCount(gui); if (((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData == null && effectiveCraftingCount > 1) { text = FormatCraftingCountLabel("$inventoryslots_craft_button_count_format", "{label} x{count}", text, effectiveCraftingCount); } CraftingTextCacheState craftingTextCache = GetCraftingTextCache(((Component)gui.m_craftButton).gameObject); CraftingTextStamp craftingTextStamp = new CraftingTextStamp("craft", text, craftingTextCache.ChildSignature); if (craftingTextCache.LastTextStamp.Equals(craftingTextStamp) && TextCacheMatches(craftingTextCache, text)) { ApplyCraftingActionButtonTextStateColor(gui.m_craftButton, ((Selectable)gui.m_craftButton).interactable); return; } TMP_Text[] tmpTexts = craftingTextCache.TmpTexts; foreach (TMP_Text val in tmpTexts) { if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val)) { ApplyDefaultFontAsset(val); if (val.text != text) { val.text = text; } } } Text[] legacyTexts = craftingTextCache.LegacyTexts; foreach (Text val2 in legacyTexts) { if ((Object)(object)val2 != (Object)null && !IsUnityNull((Object?)(object)val2) && val2.text != text) { val2.text = text; } } craftingTextCache.LastTextStamp = craftingTextStamp; SetActionButtonTextAutoSize(gui.m_craftButton); ApplyCraftingActionButtonTextStateColor(gui.m_craftButton, ((Selectable)gui.m_craftButton).interactable); } private static void UpdateJewelcraftingSocketCraftButtonState(InventoryGui gui) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (IsJewelcraftingSocketTabActive(gui) && !((Object)(object)gui.m_craftButton == (Object)null)) { bool flag = CanAffordJewelcraftingSocketAttempt(gui.m_selectedRecipe); bool flag2 = CanAttemptJewelcraftingSocket(gui.m_selectedRecipe); ((Selectable)gui.m_craftButton).interactable = flag2; ApplyCraftingActionButtonTextStateColor(gui.m_craftButton, flag2); UITooltip component = ((Component)gui.m_craftButton).GetComponent(); if (!((Object)(object)component == (Object)null) && !IsUnityNull((Object?)(object)component)) { component.m_text = ((flag2 || flag) ? "" : LocalizeUi("$msg_missingrequirement", "Missing requirement")); } } } private static void ApplyCraftingActionButtonTextStateColor(Button button, bool interactable) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00cf: 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) Color craftingActionButtonTextStateColor = GetCraftingActionButtonTextStateColor(button, interactable); CraftingTextCacheState craftingTextCache = GetCraftingTextCache(((Component)button).gameObject); CraftingTextColorStamp craftingTextColorStamp = new CraftingTextColorStamp(interactable, craftingActionButtonTextStateColor.r, craftingActionButtonTextStateColor.g, craftingActionButtonTextStateColor.b, craftingActionButtonTextStateColor.a, craftingTextCache.ChildSignature); if (craftingTextCache.LastColorStamp.Equals(craftingTextColorStamp) && TextColorCacheMatches(craftingTextCache, craftingActionButtonTextStateColor)) { return; } TMP_Text[] tmpTexts = craftingTextCache.TmpTexts; foreach (TMP_Text val in tmpTexts) { if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val) && !ColorsApproximatelyEqual(((Graphic)val).color, craftingActionButtonTextStateColor)) { ((Graphic)val).color = craftingActionButtonTextStateColor; } } Text[] legacyTexts = craftingTextCache.LegacyTexts; foreach (Text val2 in legacyTexts) { if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2) && !ColorsApproximatelyEqual(((Graphic)val2).color, craftingActionButtonTextStateColor)) { ((Graphic)val2).color = craftingActionButtonTextStateColor; } } craftingTextCache.LastColorStamp = craftingTextColorStamp; } private static Color GetCraftingActionButtonTextStateColor(Button button, bool interactable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004b: 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) ColorBlock colors = ((Selectable)button).colors; Color val = (interactable ? ((ColorBlock)(ref colors)).normalColor : ((ColorBlock)(ref colors)).disabledColor); if (interactable && Mathf.Max(new float[3] { val.r, val.g, val.b }) < 0.65f) { val = Color.white; } if (val.a < 0.25f) { val.a = 1f; } return val; } private static bool TextCacheMatches(CraftingTextCacheState cache, string label) { bool result = false; TMP_Text[] tmpTexts = cache.TmpTexts; foreach (TMP_Text val in tmpTexts) { if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val)) { result = true; if (!string.Equals(val.text, label, StringComparison.Ordinal)) { return false; } } } Text[] legacyTexts = cache.LegacyTexts; foreach (Text val2 in legacyTexts) { if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2)) { result = true; if (!string.Equals(val2.text, label, StringComparison.Ordinal)) { return false; } } } return result; } private static bool TextColorCacheMatches(CraftingTextCacheState cache, Color color) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) bool result = false; TMP_Text[] tmpTexts = cache.TmpTexts; foreach (TMP_Text val in tmpTexts) { if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val)) { result = true; if (!ColorsApproximatelyEqual(((Graphic)val).color, color)) { return false; } } } Text[] legacyTexts = cache.LegacyTexts; foreach (Text val2 in legacyTexts) { if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2)) { result = true; if (!ColorsApproximatelyEqual(((Graphic)val2).color, color)) { return false; } } } return result; } private static void UpdateCraftingProgressLabel(InventoryGui gui) { Transform craftProgressPanel = gui.m_craftProgressPanel; RectTransform val = (RectTransform)(object)((craftProgressPanel is RectTransform) ? craftProgressPanel : null); if (val == null || !((Component)val).gameObject.activeInHierarchy) { return; } CraftingTextCacheState craftingProgressTextCache = GetCraftingProgressTextCache(val); string text = GetCraftingProgressBaseLabel(craftingProgressTextCache); if (TryGetCraftingProgressLabelCount(gui, out var count)) { text = FormatCraftingCountLabel("$inventoryslots_crafting_progress_count_format", "{label} x{count}", text, count); } CraftingTextStamp craftingTextStamp = new CraftingTextStamp("progress", text, craftingProgressTextCache.ChildSignature); if (craftingProgressTextCache.LastTextStamp.Equals(craftingTextStamp) && TextCacheMatches(craftingProgressTextCache, text)) { return; } TMP_Text[] tmpTexts = craftingProgressTextCache.TmpTexts; foreach (TMP_Text val2 in tmpTexts) { if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2)) { ApplyDefaultFontAsset(val2); if (val2.text != text) { val2.text = text; } val2.enableAutoSizing = true; val2.fontSizeMin = 10f; val2.fontSizeMax = Mathf.Min(Mathf.Max(val2.fontSizeMax, 14f), 18f); val2.alignment = (TextAlignmentOptions)514; } } Text[] legacyTexts = craftingProgressTextCache.LegacyTexts; foreach (Text val3 in legacyTexts) { if ((Object)(object)val3 != (Object)null && !IsUnityNull((Object?)(object)val3) && val3.text != text) { val3.text = text; } } craftingProgressTextCache.LastTextStamp = craftingTextStamp; } private static bool TryGetCraftingProgressLabelCount(InventoryGui gui, out int count) { count = 0; if (gui.m_craftTimer < 0f || (Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe == (Object)null || ((RecipeDataPair)(ref gui.m_selectedRecipe)).ItemData != null) { return false; } if (CraftingQueue.QueueTotal > 1 && (Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe == (Object)(object)CraftingQueue.QueueRecipe && gui.m_selectedVariant == CraftingQueue.QueueVariant) { int num = ((gui.m_craftTimer >= 0f) ? 1 : 0); count = Mathf.Clamp(CraftingQueue.QueueRemaining + num, 1, CraftingQueue.QueueTotal); return true; } if (gui.m_multiCrafting && gui.m_multiCraftAmount > 1) { count = Mathf.Clamp(gui.m_multiCraftAmount, 1, 99); return true; } if (CraftingQueue.ProgressLabelCount > 1 && (Object)(object)((RecipeDataPair)(ref gui.m_selectedRecipe)).Recipe == (Object)(object)CraftingQueue.ProgressLabelRecipe && gui.m_selectedVariant == CraftingQueue.ProgressLabelVariant) { count = Mathf.Clamp(CraftingQueue.ProgressLabelCount, 1, 99); return true; } int craftingCount = GetCraftingCount(); if (craftingCount <= 1) { return false; } count = craftingCount; return true; } private static CraftingTextCacheState GetCraftingProgressTextCache(RectTransform progressPanel) { CraftingTextCacheState craftingTextCache = GetCraftingTextCache(((Component)progressPanel).gameObject); Transform obj = ((Transform)progressPanel).Find("Text"); TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent() : null); Transform obj2 = ((Transform)progressPanel).Find("Text"); Text val2 = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); bool flag = false; if ((Object)(object)val != (Object)null && !IsUnityNull((Object?)(object)val) && !craftingTextCache.TmpTexts.Contains(val)) { craftingTextCache.TmpTexts = craftingTextCache.TmpTexts.Concat((IEnumerable)(object)new TMP_Text[1] { val }).ToArray(); flag = true; } if ((Object)(object)val2 != (Object)null && !IsUnityNull((Object?)(object)val2) && !craftingTextCache.LegacyTexts.Contains(val2)) { craftingTextCache.LegacyTexts = craftingTextCache.LegacyTexts.Concat((IEnumerable)(object)new Text[1] { val2 }).ToArray(); flag = true; } if (craftingTextCache.TmpTexts.Length == 0 && craftingTextCache.LegacyTexts.Length == 0) { TMP_Text val3 = EnsureCraftingProgressLabel(progressPanel); if ((Object)(object)val3 != (Object)null && !IsUnityNull((Object?)(object)val3)) { craftingTextCache.TmpTexts = (TMP_Text[])(object)new TMP_Text[1] { val3 }; flag = true; } } if (flag) { craftingTextCache.LastTextStamp = default(CraftingTextStamp); craftingTextCache.ProgressBaseLabel = ""; } return craftingTextCache; } private static TMP_Text? EnsureCraftingProgressLabel(RectTransform progressPanel) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Transform)progressPanel).Find("Text"); if ((Object)(object)val != (Object)null) { TMP_Text component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && !IsUnityNull((Object?)(object)component)) { return component; } } RectTransform val2 = (RectTransform)(((object)((val is RectTransform) ? val : null)) ?? ((object)new GameObject("Text", new Type[1] { typeof(RectTransform) }).GetComponent())); ((Transform)val2).SetParent((Transform)(object)progressPanel, false); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; ((Transform)val2).localScale = Vector3.one; object obj = ((object)((Component)val2).GetComponent()) ?? ((object)((Component)val2).gameObject.AddComponent()); ApplyDefaultFontAsset((TMP_Text?)obj); ((TMP_Text)obj).text = LocalizeUi("$inventory_crafting", "Crafting"); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).fontSizeMin = 10f; ((TMP_Text)obj).fontSizeMax = 18f; ((Graphic)obj).raycastTarget = false; return (TMP_Text?)obj; } private static string GetCraftingProgressBaseLabel(CraftingTextCacheState cache) { if (!string.IsNullOrWhiteSpace(cache.ProgressBaseLabel)) { return cache.ProgressBaseLabel; } TMP_Text[] tmpTexts = cache.TmpTexts; foreach (TMP_Text val in tmpTexts) { if (!((Object)(object)val == (Object)null) && !IsUnityNull((Object?)(object)val)) { string text = StripCraftingProgressCounter(val.text); if (!string.IsNullOrWhiteSpace(text)) { cache.ProgressBaseLabel = text; return cache.ProgressBaseLabel; } } } Text[] legacyTexts = cache.LegacyTexts; foreach (Text val2 in legacyTexts) { if (!((Object)(object)val2 == (Object)null) && !IsUnityNull((Object?)(object)val2)) { string text2 = StripCraftingProgressCounter(val2.text); if (!string.IsNullOrWhiteSpace(text2)) { cache.ProgressBaseLabel = text2; return cache.ProgressBaseLabel; } } } cache.ProgressBaseLabel = LocalizeUi("$inventory_crafting", "Crafting"); return cache.ProgressBaseLabel; } private static string FormatCraftingCountLabel(string token, string fallback, string label, int count) { return LocalizeUi(token, fallback).Replace("{label}", label).Replace("{count}", count.ToString()); } private static string StripCraftingProgressCounter(string value) { value = value.Trim(); int num = value.LastIndexOf(' '); if (num <= 0) { return value; } if (IsCraftingProgressCounterSuffix(value.Substring(num + 1))) { return value.Substring(0, num); } return value; } private static bool IsCraftingProgressCounterSuffix(string suffix) { int num = suffix.IndexOf('/'); int result; if (num > 0 && num < suffix.Length - 1) { if (int.TryParse(suffix.Substring(0, num), out result)) { return int.TryParse(suffix.Substring(num + 1), out result); } return false; } if (suffix.Length > 1 && (suffix[0] == 'x' || suffix[0] == 'X')) { return int.TryParse(suffix.Substring(1), out result); } return false; } private static string LocalizeUi(string token, string fallback) { string text = ((Localization.instance != null) ? Localization.instance.Localize(token) : token); if (!string.IsNullOrWhiteSpace(text) && !(text == token)) { return text; } return fallback; } private static string GetRequirementDisplayName(Requirement requirement) { if ((Object)(object)requirement.m_resItem == (Object)null) { return ""; } ItemData itemData = requirement.m_resItem.m_itemData; return LocalizeUi(itemData.m_shared.m_name, itemData.m_shared.m_name); } private static string GetCraftingStationDisplayName(CraftingStation station) { if (!((Object)(object)station == (Object)null)) { return LocalizeUi(station.m_name, station.m_name); } return ""; } private static void ConfigureSimpleTooltip(GameObject target, string topic, bool enabled) { ConfigureSimpleTooltip(target, topic, "", enabled); } private static void ConfigureSimpleTooltip(GameObject target, string topic, string text, bool enabled) { if ((Object)(object)target == (Object)null || IsUnityNull((Object?)(object)target)) { return; } UITooltip component = target.GetComponent(); CraftingTooltipState craftingTooltipState = target.GetComponent() ?? target.AddComponent(); if (!enabled || string.IsNullOrWhiteSpace(topic)) { if (craftingTooltipState.Stamp.IsValid || !((Object)(object)component == (Object)null)) { if ((Object)(object)component != (Object)null) { component.m_topic = ""; component.m_text = ""; ((Behaviour)component).enabled = false; } InventorySlotsSimpleTooltipHover component2 = target.GetComponent(); if ((Object)(object)component2 != (Object)null && !IsUnityNull((Object?)(object)component2)) { component2.Configure("", ""); } craftingTooltipState.Stamp = default(CraftingSimpleTooltipStamp); } } else { if ((Object)(object)component != (Object)null) { component.m_topic = ""; component.m_text = ""; ((Behaviour)component).enabled = false; } CraftingSimpleTooltipStamp craftingSimpleTooltipStamp = new CraftingSimpleTooltipStamp(topic, text); if (!craftingTooltipState.Stamp.Equals(craftingSimpleTooltipStamp)) { (target.GetComponent() ?? target.AddComponent()).Configure(topic, text); craftingTooltipState.Stamp = craftingSimpleTooltipStamp; } } } private static CraftingTextCacheState GetCraftingTextCache(GameObject root) { CraftingTextCacheState craftingTextCacheState = root.GetComponent() ?? root.AddComponent(); string text = root.transform.childCount.ToString(); if (string.Equals(craftingTextCacheState.ChildSignature, text, StringComparison.Ordinal) && !HasInvalidTextCache(craftingTextCacheState)) { return craftingTextCacheState; } craftingTextCacheState.ChildSignature = text; craftingTextCacheState.LastTextStamp = default(CraftingTextStamp); craftingTextCacheState.LastColorStamp = default(CraftingTextColorStamp); craftingTextCacheState.ProgressBaseLabel = ""; craftingTextCacheState.TmpTexts = root.GetComponentsInChildren(true); craftingTextCacheState.LegacyTexts = root.GetComponentsInChildren(true); return craftingTextCacheState; } private static bool HasInvalidTextCache(CraftingTextCacheState cache) { if (!cache.TmpTexts.Any((TMP_Text text) => (Object)(object)text == (Object)null || IsUnityNull((Object?)(object)text))) { return cache.LegacyTexts.Any((Text text) => (Object)(object)text == (Object)null || IsUnityNull((Object?)(object)text)); } return true; } private static bool IsCraftingCountInputLocked(InventoryGui? gui) { if (CraftingQueue.QueueRemaining <= 0) { if ((Object)(object)gui != (Object)null) { return gui.m_craftTimer >= 0f; } return false; } return true; } private static int GetUnityObjectId(Object? obj) { if (!(obj != (Object)null) || IsUnityNull(obj)) { return 0; } return obj.GetInstanceID(); } private static void SetCraftingTopLeftRect(RectTransform parent, RectTransform rect, Vector2 anchoredPosition, Vector2 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) SetTopLeftRectLayout(parent, rect, anchoredPosition, size); } private static void ConfigureCompactCraftingRequirement(InventoryGui gui, RectTransform rect, Requirement requirement, int quality, int craftMultiplier) { //IL_0034: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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_021e: 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: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: 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_0309: Unknown result type (might be due to invalid IL or missing references) CraftingRequirementUiMarker craftingRequirementUiMarker = GetCraftingRequirementUiMarker(rect); HideCraftingRequirementSlotBackground(craftingRequirementUiMarker); string text = $"{64f:0.###}"; bool flag = !string.Equals(craftingRequirementUiMarker.LayoutSignature, text, StringComparison.Ordinal); bool flag2 = !IsVeiledRecipeMasked(gui.m_selectedRecipe) || IsVeiledRecipeRequirementKnown(requirement); if ((Object)(object)craftingRequirementUiMarker.Name != (Object)null && !IsUnityNull((Object?)(object)craftingRequirementUiMarker.Name)) { ((Component)craftingRequirementUiMarker.Name).gameObject.SetActive(false); } if ((Object)(object)craftingRequirementUiMarker.Icon != (Object)null && !IsUnityNull((Object?)(object)craftingRequirementUiMarker.Icon)) { RectTransform icon = craftingRequirementUiMarker.Icon; ((Component)icon).gameObject.SetActive(true); if (flag) { icon.anchorMin = new Vector2(0f, 1f); icon.anchorMax = new Vector2(0f, 1f); icon.pivot = new Vector2(0f, 1f); icon.anchoredPosition = new Vector2(10f, -10f); icon.sizeDelta = new Vector2(44f, 44f); ((Transform)icon).localScale = Vector3.one; } if ((Object)(object)craftingRequirementUiMarker.IconImage != (Object)null && !IsUnityNull((Object?)(object)craftingRequirementUiMarker.IconImage)) { craftingRequirementUiMarker.IconImage.sprite = requirement.m_resItem.m_itemData.GetIcon(); ((Graphic)craftingRequirementUiMarker.IconImage).color = (flag2 ? Color.white : Color.black); ((Graphic)craftingRequirementUiMarker.IconImage).raycastTarget = false; } ConfigureSimpleTooltip(((Component)icon).gameObject, "", enabled: false); } if ((Object)(object)craftingRequirementUiMarker.Amount != (Object)null && !IsUnityNull((Object?)(object)craftingRequirementUiMarker.Amount)) { RectTransform amount = craftingRequirementUiMarker.Amount; ((Component)amount).gameObject.SetActive(true); if (flag) { amount.anchorMin = new Vector2(0.5f, 0f); amount.anchorMax = new Vector2(0.5f, 0f); amount.pivot = new Vector2(0.5f, 0f); amount.anchoredPosition = new Vector2(0f, 4f); amount.sizeDelta = new Vector2(60f, 20f); ((Transform)amount).localScale = Vector3.one; } if ((Object)(object)craftingRequirementUiMarker.AmountText != (Object)null && !IsUnityNull((Object?)(object)craftingRequirementUiMarker.AmountText)) { TMP_Text amountText = craftingRequirementUiMarker.AmountText; int num = Mathf.Max(0, requirement.GetAmount(quality) * Mathf.Max(1, craftMultiplier)); int num2 = (flag2 ? GetAvailableCraftingRequirementAmount(requirement) : 0); bool flag3 = HasNoCraftCost(); bool availableEnough = flag2 && (flag3 || num2 >= num); string text2 = (flag2 ? FormatCompactRequirementAmount(num2, num) : GetVeiledRecipeUnknownRequirementText()); Color val = (flag2 ? GetCompactRequirementAmountColor(availableEnough) : Color.white); string text3 = $"{text2}|{val}"; if (!string.Equals(craftingRequirementUiMarker.AmountSignature, text3, StringComparison.Ordinal) || !RequirementAmountTextMatches(amountText, text2, val)) { ApplyDefaultFontAsset(amountText); amountText.text = text2; ((Graphic)amountText).color = val; craftingRequirementUiMarker.AmountSignature = text3; } if (flag) { amountText.alignment = (TextAlignmentOptions)1026; amountText.enableAutoSizing = true; amountText.fontSizeMin = 10f; amountText.fontSizeMax = 16f; amountText.textWrappingMode = (TextWrappingModes)0; amountText.overflowMode = (TextOverflowModes)0; } } } RectTransform val2 = EnsureCraftingRequirementHitbox(rect, craftingRequirementUiMarker); DisableCompetingCraftingRequirementTooltips(rect, val2, craftingRequirementUiMarker); ConfigureCraftingRequirementTooltip(gui, ((Component)val2).gameObject, requirement, quality, craftMultiplier); craftingRequirementUiMarker.LayoutSignature = text; } private static void BindCraftingClientConfigs() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0055: 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_0079: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) _craftingRecipeGridSize = ConfigEntry("4 - Client", "Crafting Recipe Grid Size", 6, new ConfigDescription("Recipe icon grid size inside the fixed 8x8 recipe area. Changed with the crafting grid zoom controls.", (AcceptableValueBase)(object)new AcceptableValueRange(4, 8), new object[1] { new ConfigurationManagerAttributes { Browsable = false } }), synchronizedSetting: false); _craftingRecipeGridZoomModifier = OrderedConfigEntry("6 - Client Keys", "Crafting Recipe Grid Zoom Modifier", new KeyboardShortcut((KeyCode)308, Array.Empty()), new ConfigDescription("Hold this key while using the mouse wheel over the crafting recipe grid to zoom between 8x8 and 4x4. Plain mouse wheel changes pages. Alt accepts both LeftAlt and RightAlt.", (AcceptableValueBase)(object)new AcceptableShortcuts(), Array.Empty()), 748, synchronizedSetting: false); _craftingClearFavoritesKey = OrderedConfigEntry("6 - Client Keys", "Clear Crafting Favorites Key", new KeyboardShortcut((KeyCode)325, Array.Empty()), new ConfigDescription("Key used while hovering the favorite group icon to clear crafting or upgrade favorites for the current crafting tab.", (AcceptableValueBase)(object)new AcceptableShortcuts(), Array.Empty()), 740, synchronizedSetting: false); _showCraftingRecipeGridZoomHint = OrderedConfigEntry("5 - Client UI", "Show Crafting Recipe Grid Zoom Hint", Toggle.On, "Show the Alt + mouse wheel hint above the crafting recipe grid. Not synced with server.", 880, synchronizedSetting: false); _craftingRecipeGridSize.SettingChanged += delegate { CraftingController.MarkRecipeGridLayoutDirty(); }; _craftingClearFavoritesKey.SettingChanged += delegate { CraftingController.MarkGroupRailDirty(); }; _craftingRecipeSortMode = ConfigEntry("4 - Client", "Crafting Recipe Sort Mode", CraftingRecipeSortMode.TierThenGroup, new ConfigDescription("Sorting mode selected by the crafting station recipe grid buttons.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false } }), synchronizedSetting: false); _craftingRecipeSortMode.SettingChanged += delegate { CraftingController.ResetSortModeButtonsStamp(); InvalidateCraftingRecipeView(); }; _craftingRecipeCraftableBackgroundColor = OrderedConfigEntry("4 - Client", "Craftable Recipe Background Color", CraftingRecipeDefaultCraftableBackgroundColor, "Advanced color for recipe grid cells that can currently be crafted. Not synced with server.", 780, synchronizedSetting: false); _craftingRecipeCraftableBackgroundColor.SettingChanged += delegate { CraftingController.MarkRecipeGridLayoutDirty(); }; } private static bool TryToggleCraftingRecipeFavorite(int originalIndex) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (IsRecycleNReclaimReclaimTabActive(InventoryGui.instance)) { return false; } if (!IsFavoriteModifierHeld()) { return false; } InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null || !TryGetCraftingRecipePair(instance, originalIndex, out var pair)) { return true; } ToggleCraftingRecipeFavorite(localPlayer, pair); InvalidateCraftingRecipeView(); UpdateCraftingPanelRedesign(instance, CraftingPanelUpdateReason.StateChanged); return true; } private static void ToggleCraftingRecipeFavorite(Player player, RecipeDataPair pair) { //IL_0006: 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) EnsureCraftingFavoritesLoaded(player); bool flag = IsUpgradeFavoritePair(pair); string text = (flag ? GetOrCreateUpgradeFavoriteItemKey(((RecipeDataPair)(ref pair)).ItemData) : GetCraftingRecipeFavoriteKey(pair)); if (string.IsNullOrWhiteSpace(text)) { return; } HashSet hashSet = (flag ? FavoriteUpgradeItemKeys : FavoriteCraftingRecipeKeys); if (!hashSet.Add(text)) { hashSet.Remove(text); if (flag && ((RecipeDataPair)(ref pair)).ItemData != null) { RemoveUpgradeFavoriteItemKey(((RecipeDataPair)(ref pair)).ItemData); Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory != null) { inventory.Changed(); } } } else if (flag) { Inventory inventory2 = ((Humanoid)player).GetInventory(); if (inventory2 != null) { inventory2.Changed(); } } _craftingFavoritesVersion++; ClearCraftingGroupAvailabilityCache(); SaveCraftingFavorites(player); } private static bool ClearCraftingFavorites(Player? player, bool upgradeFavorites) { if ((Object)(object)player == (Object)null) { return false; } EnsureCraftingFavoritesLoaded(player); HashSet hashSet = (upgradeFavorites ? FavoriteUpgradeItemKeys : FavoriteCraftingRecipeKeys); if (hashSet.Count == 0) { return false; } if (upgradeFavorites) { RemoveUpgradeFavoriteItemKeysFromInventory(player, hashSet); } hashSet.Clear(); _craftingFavoritesVersion++; ClearCraftingGroupAvailabilityCache(); SaveCraftingFavorites(player); return true; } private static bool IsFavoriteCraftingRecipe(RecipeDataPair pair) { //IL_0018: 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) if (IsRecycleNReclaimReclaimTabActive(InventoryGui.instance)) { return false; } EnsureCraftingFavoritesLoaded(Player.m_localPlayer); if (IsUpgradeFavoritePair(pair)) { string upgradeFavoriteItemKey = GetUpgradeFavoriteItemKey(((RecipeDataPair)(ref pair)).ItemData); if (!string.IsNullOrWhiteSpace(upgradeFavoriteItemKey)) { return FavoriteUpgradeItemKeys.Contains(upgradeFavoriteItemKey); } return false; } string craftingRecipeFavoriteKey = GetCraftingRecipeFavoriteKey(pair); if (!string.IsNullOrWhiteSpace(craftingRecipeFavoriteKey)) { return FavoriteCraftingRecipeKeys.Contains(craftingRecipeFavoriteKey); } return false; } private static bool IsUpgradeFavoritePair(RecipeDataPair pair) { return ((RecipeDataPair)(ref pair)).ItemData != null; } private static string GetCraftingRecipeFavoriteKey(RecipeDataPair pair) { ItemDrop val = (((Object)(object)((RecipeDataPair)(ref pair)).Recipe != (Object)null) ? ((RecipeDataPair)(ref pair)).Recipe.m_item : null); if ((Object)(object)val == (Object)null) { return ""; } string text = (((Object)(object)val.m_itemData.m_dropPrefab != (Object)null) ? ((Object)val.m_itemData.m_dropPrefab).name : ((Object)val).name); return CleanPrefabName((!string.IsNullOrWhiteSpace(text)) ? text : val.m_itemData.m_shared.m_name); } private static string GetUpgradeFavoriteItemKey(ItemData? item) { return UpgradeFavoriteCore.GetItemId(item?.m_customData, "InventorySlotsUpgradeFavoriteId"); } private static string GetOrCreateUpgradeFavoriteItemKey(ItemData? item) { if (item == null) { return ""; } if (item.m_customData == null) { item.m_customData = new Dictionary(); } return UpgradeFavoriteCore.GetOrCreateItemId(item.m_customData, "InventorySlotsUpgradeFavoriteId", FavoriteUpgradeItemKeys, () => Guid.NewGuid().ToString("N")); } private static void SetUpgradeFavoriteItemKey(ItemData? item, string id) { if (item != null && !string.IsNullOrWhiteSpace(id)) { if (item.m_customData == null) { item.m_customData = new Dictionary(); } UpgradeFavoriteCore.SetItemId(item.m_customData, "InventorySlotsUpgradeFavoriteId", id); } } private static void RemoveUpgradeFavoriteItemKey(ItemData? item) { UpgradeFavoriteCore.RemoveItemId(item?.m_customData, "InventorySlotsUpgradeFavoriteId"); } private static void RemoveUpgradeFavoriteItemKeysFromInventory(Player player, HashSet favoriteKeys) { Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return; } bool flag = false; foreach (ItemData item in inventory.m_inventory.Where((ItemData item) => item?.m_customData != null)) { string upgradeFavoriteItemKey = GetUpgradeFavoriteItemKey(item); if (!string.IsNullOrWhiteSpace(upgradeFavoriteItemKey) && favoriteKeys.Contains(upgradeFavoriteItemKey)) { UpgradeFavoriteCore.RemoveItemId(item.m_customData, "InventorySlotsUpgradeFavoriteId"); flag = true; } } if (flag) { inventory.Changed(); } } private static void EnsureCraftingFavoritesLoaded(Player? player) { if ((Object)(object)player == (Object)null) { return; } string playerId = GetPlayerId(player); if (string.Equals(_loadedCraftingFavoritesPlayerId, playerId, StringComparison.Ordinal)) { return; } FavoriteCraftingRecipeKeys.Clear(); FavoriteUpgradeItemKeys.Clear(); _loadedCraftingFavoritesPlayerId = playerId; _craftingFavoritesVersion++; ClearCraftingGroupAvailabilityCache(); try { InventorySlotsClientPlayerState clientPlayerState = GetClientPlayerState(playerId, create: false); if (clientPlayerState == null) { return; } foreach (string item in clientPlayerState.CraftingFavorites.Where((string recipe) => !string.IsNullOrWhiteSpace(recipe))) { FavoriteCraftingRecipeKeys.Add(item.Trim()); } foreach (string item2 in clientPlayerState.UpgradeFavorites.Where((string itemId) => !string.IsNullOrWhiteSpace(itemId))) { FavoriteUpgradeItemKeys.Add(item2.Trim()); } _craftingFavoritesVersion++; ClearCraftingGroupAvailabilityCache(); } catch (Exception ex) { Log.LogWarning((object)("Failed to load InventorySlots crafting favorites from " + ClientStateFilePath + ": " + ex.Message)); } } private static void SaveCraftingFavorites(Player player) { if ((Object)(object)player == (Object)null) { return; } string playerId = (_loadedCraftingFavoritesPlayerId = GetPlayerId(player)); try { InventorySlotsClientPlayerState? clientPlayerState = GetClientPlayerState(playerId, create: true); clientPlayerState.CraftingFavorites = FavoriteCraftingRecipeKeys.OrderBy((string recipe) => recipe, StringComparer.OrdinalIgnoreCase).ToList(); clientPlayerState.UpgradeFavorites = FavoriteUpgradeItemKeys.OrderBy((string itemId) => itemId, StringComparer.OrdinalIgnoreCase).ToList(); SaveClientState(); } catch (Exception ex) { Log.LogWarning((object)("Failed to save InventorySlots crafting favorites: " + ex.Message)); } } internal static void CaptureUpgradeFavoriteBeforeCrafting(InventoryGui gui) { //IL_0022: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) _pendingUpgradeFavoriteItemId = ""; _pendingUpgradeFavoritePrefab = ""; _pendingUpgradeFavoriteQuality = -1; _pendingUpgradeFavoriteVariant = -1; _pendingUpgradeFavoriteGridPos = new Vector2i(-1, -1); ItemData val = gui?.m_craftUpgradeItem; string upgradeFavoriteItemKey = GetUpgradeFavoriteItemKey(val); if (val?.m_shared != null && !string.IsNullOrWhiteSpace(upgradeFavoriteItemKey)) { _pendingUpgradeFavoriteItemId = upgradeFavoriteItemKey; _pendingUpgradeFavoritePrefab = GetItemPrefabName(val); _pendingUpgradeFavoriteQuality = val.m_quality + 1; _pendingUpgradeFavoriteVariant = val.m_variant; _pendingUpgradeFavoriteGridPos = val.m_gridPos; } } internal static void RestoreUpgradeFavoriteAfterCrafting(InventoryGui gui, Player player) { string pendingUpgradeFavoriteItemId = _pendingUpgradeFavoriteItemId; if (string.IsNullOrWhiteSpace(pendingUpgradeFavoriteItemId)) { return; } _pendingUpgradeFavoriteItemId = ""; Inventory val = ((player != null) ? ((Humanoid)player).GetInventory() : null); ItemData val2 = ((val != null) ? val.GetItemAt(_pendingUpgradeFavoriteGridPos.x, _pendingUpgradeFavoriteGridPos.y) : null); if (!IsPendingUpgradeFavoriteItem(val2)) { val2 = ((IEnumerable)val?.m_inventory).FirstOrDefault((Func)IsPendingUpgradeFavoriteItem); } if (val2 != null) { SetUpgradeFavoriteItemKey(val2, pendingUpgradeFavoriteItemId); if (val != null) { val.Changed(); } _craftingFavoritesVersion++; ClearCraftingGroupAvailabilityCache(); InvalidateCraftingRecipeView(); if ((Object)(object)gui != (Object)null) { UpdateCraftingPanelRedesign(gui, CraftingPanelUpdateReason.StateChanged); } } } private static bool IsPendingUpgradeFavoriteItem(ItemData? item) { if (item?.m_shared != null && item.m_quality == _pendingUpgradeFavoriteQuality && item.m_variant == _pendingUpgradeFavoriteVariant) { return string.Equals(GetItemPrefabName(item), _pendingUpgradeFavoritePrefab, StringComparison.OrdinalIgnoreCase); } return false; } private static bool TryRunCraftingPanelFrameFastPath(InventoryGui gui, CraftingTabAdapterState adapter) { if (!CanRunCraftingPanelFrameFastPath()) { return false; } CraftingFrameFastPathStamp stamp = CreateCraftingFrameFastPathStamp(gui, adapter); if (!CraftingController.CanReuseFrameFastPath(stamp)) { CraftingController.StoreFrameFastPathStamp(stamp); return false; } RectTransform craftingRecipeGrid = _craftingRecipeGrid; if ((Object)(object)craftingRecipeGrid == (Object)null || IsUnityNull((Object?)(object)craftingRecipeGrid)) { return false; } if (HandleCraftingPanelFastPathInput(gui, craftingRecipeGrid)) { return false; } RefreshCraftingPanelDynamicFrameUi(gui, craftingRecipeGrid, adapter); return true; } private static bool CanRunCraftingPanelFrameFastPath() { if (_craftingRedesignApplied && (Object)(object)_craftingRecipeGrid != (Object)null && !IsUnityNull((Object?)(object)_craftingRecipeGrid) && !CraftingController.HasFrameRebuildWork() && !CraftingController.IsSearchInputDirty && (Object)(object)CraftingQueue.QueueRecipe == (Object)null) { return !CraftingQueue.ContinuingQueue; } return false; } private static bool HandleCraftingPanelFastPathInput(InventoryGui gui, RectTransform grid) { if (HandleCraftingCountWheel()) { CraftingController.MarkBottomControlsDirty(); return true; } HandleCraftingGroupFavoriteClearShortcut(); if (CraftingController.HasFrameRebuildWork()) { return true; } if (!HandleCraftingPinnedTooltipWheel() && !HandleCraftingHoverTooltipWheel() && !HandleCraftingRecipeGridZoomWheel(gui, grid) && !HandleCraftingRecipeGridWheel(gui, grid)) { return CraftingController.HasFrameRebuildWork(); } return true; } private static void RefreshCraftingPanelDynamicFrameUi(InventoryGui gui, RectTransform grid, CraftingTabAdapterState adapter) { SuppressCraftingTabAdapterFrameResidue(gui, adapter); LayoutCraftingTabAdapterBottomControls(gui, grid, adapter); UpdateCraftingRecipeGridZoomHint(gui, grid); UpdateCraftingTooltipRecipeOverlay(gui); if (HasActiveCraftingPinnedTooltip()) { RepairCraftingPinnedTooltipTextVisibility(); } } private static void StoreCraftingFrameFastPathSignature(InventoryGui gui, CraftingTabAdapterState adapter) { if (!_craftingRedesignApplied || (Object)(object)_craftingRecipeGrid == (Object)null || IsUnityNull((Object?)(object)_craftingRecipeGrid) || CraftingController.HasFrameRebuildWork() || CraftingController.IsSearchInputDirty || (Object)(object)CraftingQueue.QueueRecipe != (Object)null || CraftingQueue.ContinuingQueue) { ResetCraftingFrameFastPathStamp(); } else { CraftingController.StoreFrameFastPathStamp(CreateCraftingFrameFastPathStamp(gui, adapter)); } } private static void ResetCraftingFrameFastPathStamp() { CraftingController.ResetFrameFastPathStamp(); } private static CraftingFrameFastPathStamp CreateCraftingFrameFastPathStamp(InventoryGui gui, CraftingTabAdapterState adapter) { RectTransform craftingRecipeGrid = _craftingRecipeGrid; return new CraftingFrameFastPathStamp(((Object)gui).GetInstanceID(), ((Object)(object)gui.m_crafting != (Object)null && !IsUnityNull((Object?)(object)gui.m_crafting)) ? ((Object)gui.m_crafting).GetInstanceID() : 0, ((Object)(object)craftingRecipeGrid != (Object)null && !IsUnityNull((Object?)(object)craftingRecipeGrid)) ? ((Object)craftingRecipeGrid).GetInstanceID() : 0, adapter.Kind, GetSelectedCraftingRecipeIndexSafe(gui), GetCraftingRecipeViewSignature(gui, adapter), _craftingRecipePage, GetCraftingRecipeGridDimension(), CraftingRequirements.AvailabilityVersion, HasNoCraftCost(), GetCraftingPinnedTooltipGridSignature(), _craftingRecipeVariantVersion, CraftingController.HoveredRecipeIndex, Screen.width, Screen.height); } private static bool HasActiveCraftingPinnedTooltip() { for (int i = 0; i < PinnedTooltips.Crafting.Panels.Length; i++) { RectTransform val = PinnedTooltips.Crafting.Panels[i]; if ((Object)(object)val != (Object)null && !IsUnityNull((Object?)(object)val) && ((Component)val).gameObject.activeInHierarchy) { return true; } } return false; } private static bool HandleCraftingRecipeGridWheel(InventoryGui gui, RectTransform grid) { //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) //IL_0006: 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) Vector2 uiMousePosition = GetUiMousePosition(); bool flag = IsCraftingRecipeScrollbarScrollTargetActive(uiMousePosition); if (IsCraftingRecipeGridZoomModifierHeld() && !flag) { return false; } int craftingRecipePageCount = GetCraftingRecipePageCount(gui); bool flag2 = IsCraftingRecipePageScrollTargetActive(grid, uiMousePosition, flag); float uiScrollDelta = GetUiScrollDelta(UiScrollInputMode.Discrete); if (craftingRecipePageCount <= 1 || !flag2) { return false; } if (Mathf.Abs(uiScrollDelta) < 0.01f) { return false; } int num = ((uiScrollDelta < 0f) ? 1 : (-1)); int craftingRecipePage = _craftingRecipePage; _craftingRecipePage = Mathf.Clamp(_craftingRecipePage + num, 0, craftingRecipePageCount - 1); if (_craftingRecipePage == craftingRecipePage) { return false; } CraftingController.ClearHoveredRecipeAndRequestMouseSync(); CraftingController.MarkRecipeGridLayoutDirty(); int num2 = _craftingRecipePage * GetCraftingRecipeGridCapacity(); if (num2 >= 0 && num2 < CraftingRecipes.View.Count) { SetCraftingRecipeWithStoredVariant(gui, CraftingRecipes.View[num2].OriginalIndex, center: false); } return true; } private static bool HandleCraftingRecipeGridZoomWheel(InventoryGui gui, RectTransform grid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) bool num = IsCraftingRecipeGridZoomScrollTargetActive(grid, GetUiMousePosition()); bool flag = IsCraftingRecipeGridZoomModifierHeld(); float uiScrollDelta = GetUiScrollDelta(UiScrollInputMode.Discrete); if (!num) { return false; } if (!flag || Mathf.Abs(uiScrollDelta) < 0.01f) { return false; } int craftingRecipeGridDimension = GetCraftingRecipeGridDimension(); int num2 = Mathf.Clamp(craftingRecipeGridDimension + ((!(uiScrollDelta > 0f)) ? 1 : (-1)), 4, 8); if (num2 == craftingRecipeGridDimension) { return true; } if (_craftingRecipeGridSize != null) { _craftingRecipeGridSize.Value = num2; } int num3 = FindCraftingRecipeViewIndex(gui.GetSelectedRecipeIndex(false)); if (num3 >= 0) { _craftingRecipePage = Mathf.Clamp(num3 / GetCraftingRecipeGridCapacity(), 0, Mathf.Max(0, GetCraftingRecipePageCount(gui) - 1)); } else { ClampCraftingRecipePage(gui); } EnsureCraftingRecipeCells(gui, grid); CraftingController.MarkRecipeGridLayoutDirty(); CraftingController.ClearHoveredRecipeAndRequestMouseSync(); return true; } private static bool IsCraftingRecipePageScrollTargetActive(RectTransform grid, Vector2 mouse, bool scrollbarTargetActive) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!(RectContainsCraftingRecipeIconArea(grid, mouse) || scrollbarTargetActive)) { return IsGamepadUiScrollActive(); } return true; } private static bool IsCraftingRecipeGridZoomScrollTargetActive(RectTransform grid, Vector2 mouse) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!RectContainsCraftingRecipeIconArea(grid, mouse)) { return IsGamepadUiScrollActive(); } return true; } private static bool IsCraftingRecipeScrollbarScrollTargetActive(Vector2 mouse) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_craftingRecipeScrollbar != (Object)null && !IsUnityNull((Object?)(object)_craftingRecipeScrollbar) && ((Component)_craftingRecipeScrollbar).gameObject.activeInHierarchy) { return RectContainsScreenPoint(_craftingRecipeScrollbar, mouse); } return false; } private static bool IsCraftingRecipeGridZoomModifierHeld() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (_craftingRecipeGridZoomModifier == null || !IsShortcutHeldAllowingAltPair(_craftingRecipeGridZoomModifier.Value)) { return IsGamepadCraftingRecipeGridZoomModifierHeld(); } return true; } private static bool IsGamepadCraftingRecipeGridZoomModifierHeld() { if (!IsGamepadActiveSafe()) { return false; } try { return IsControllerHotkeyHeld(_controllerCraftingGridZoomModifierButton); } catch { return false; } } private static void UpdateCraftingRecipeGridZoomHint(InventoryGui gui, RectTransform grid) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_0235: 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_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: 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_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0304: 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_031a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gui?.m_crafting == (Object)null) && !((Object)(object)grid == (Object)null) && _showCraftingRecipeGridZoomHint != null && !_showCraftingRecipeGridZoomHint.Value.IsOff() && _craftingRecipeGridZoomModifier != null) { KeyboardShortcut value = _craftingRecipeGridZoomModifier.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { string craftingRecipeGridZoomModifierDisplayText = GetCraftingRecipeGridZoomModifierDisplayText(); if (string.IsNullOrWhiteSpace(craftingRecipeGridZoomModifierDisplayText)) { SetHintActive(CraftingUi.RecipeGridZoomHint, active: false); return; } TMP_Text text = null; CraftingUi.RecipeGridZoomHint = EnsureInventoryHintLabel(gui.m_crafting, "InventorySlots_CraftingRecipeGridZoomHint", ref text); if (!((Object)(object)CraftingUi.RecipeGridZoomHint == (Object)null) && !((Object)(object)text == (Object)null)) { float num = 16f; float num2 = Mathf.Clamp(num * 1.35f, 14f, 42f); float num3 = Mathf.Max(10f, num2 * 0.72f); float num4 = 0f; string text2 = craftingRecipeGridZoomModifierDisplayText + "+"; float num5 = Mathf.Max(num2, num * 1.45f); text.text = ""; ((Behaviour)text).enabled = false; ((Graphic)text).raycastTarget = false; TMP_Text val = EnsureHintText(CraftingUi.RecipeGridZoomHint, "Label", text2); ((Behaviour)val).enabled = true; val.fontSize = num; val.alignment = (TextAlignmentOptions)513; val.textWrappingMode = (TextWrappingModes)0; val.overflowMode = (TextOverflowModes)0; ((Graphic)val).color = InventoryWheelHintColor; ((Graphic)val).raycastTarget = false; float num6 = Mathf.Ceil(Mathf.Max(num * 1.4f, val.GetPreferredValues(text2, 1000f, num2).x + 1f)); float num7 = num6 + num4 + num3; Vector2 size = default(Vector2); ((Vector2)(ref size))..ctor(num7, num5); Vector2 craftingRecipeGridZoomHintFixedOffset = CraftingRecipeGridZoomHintFixedOffset; if ((Object)(object)((Transform)CraftingUi.RecipeGridZoomHint).parent != (Object)(object)gui.m_crafting) { ((Transform)CraftingUi.RecipeGridZoomHint).SetParent((Transform)(object)gui.m_crafting, false); } SetCenteredRectLayout(CraftingUi.RecipeGridZoomHint, craftingRecipeGridZoomHintFixedOffset, size); ((Transform)CraftingUi.RecipeGridZoomHint).SetAsLastSibling(); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0f, 0.5f); val2.anchorMax = new Vector2(0f, 0.5f); val2.pivot = new Vector2(0f, 0.5f); val2.anchoredPosition = Vector2.zero; val2.sizeDelta = new Vector2(num6, num5); ((Transform)val2).localScale = Vector3.one; ((Transform)val2).localRotation = Quaternion.identity; RectTransform obj = EnsureHintImage(CraftingUi.RecipeGridZoomHint, "MouseWheelIcon"); obj.anchorMin = new Vector2(0f, 0.5f); obj.anchorMax = new Vector2(0f, 0.5f); obj.pivot = new Vector2(0f, 0.5f); obj.anchoredPosition = new Vector2(num6 + num4, 0f); obj.sizeDelta = new Vector2(num3, num2); ((Transform)obj).localScale = Vector3.one; ((Transform)obj).localRotation = Quaternion.identity; ((Transform)obj).SetAsLastSibling(); Image component = ((Component)obj).GetComponent(); component.sprite = GetMouseWheelHintSprite(); component.type = (Type)0; component.preserveAspect = true; ((Graphic)component).raycastTarget = false; ((Graphic)component).color = InventoryWheelHintColor; SetHintActive(CraftingUi.RecipeGridZoomHint, active: true); } return; } } SetHintActive(CraftingUi.RecipeGridZoomHint, active: false); } private static string GetCraftingRecipeGridZoomModifierDisplayText() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_craftingRecipeGridZoomModifier == null) { return ""; } string displayText = _craftingRecipeGridZoomModifier.Value.GetDisplayText(); if (string.IsNullOrWhiteSpace(displayText)) { return ""; } return displayText; } private static void SyncCraftingRecipePageToSelected(InventoryGui gui) { int selectedRecipeIndex = gui.GetSelectedRecipeIndex(false); if (selectedRecipeIndex < 0) { int craftingRecipePage = _craftingRecipePage; _craftingRecipePage = 0; if (_craftingRecipePage != craftingRecipePage) { CraftingController.MarkRecipeGridLayoutDirty(); } return; } int num = FindCraftingRecipeViewIndex(selectedRecipeIndex); int craftingRecipePage2 = _craftingRecipePage; _craftingRecipePage = ((num >= 0) ? Mathf.Clamp(num / GetCraftingRecipeGridCapacity(), 0, Mathf.Max(0, GetCraftingRecipePageCount(gui) - 1)) : 0); if (_craftingRecipePage != craftingRecipePage2) { CraftingController.MarkRecipeGridLayoutDirty(); } } private static void ClampCraftingRecipePage(InventoryGui gui) { int craftingRecipePage = _craftingRecipePage; _craftingRecipePage = Mathf.Clamp(_craftingRecipePage, 0, Mathf.Max(0, GetCraftingRecipePageCount(gui) - 1)); if (_craftingRecipePage != craftingRecipePage) { CraftingController.MarkRecipeGridLayoutDirty(); } } private static int GetCraftingRecipePageCount(InventoryGui gui) { int count = CraftingRecipes.View.Count; if (count > 0) { return Mathf.CeilToInt((float)count / (float)GetCraftingRecipeGridCapacity()); } return 1; } private static void LayoutCraftingRecipeGrid(InventoryGui gui, RectTransform grid) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) int craftingRecipeGridDimension = GetCraftingRecipeGridDimension(); int num = _craftingRecipePage * GetCraftingRecipeGridCapacity(); int selectedRecipeIndex = gui.GetSelectedRecipeIndex(false); int craftingRecipeGridAvailabilityHash = GetCraftingRecipeGridAvailabilityHash(gui, num); CraftingRecipeGridStamp stamp = new CraftingRecipeGridStamp(craftingRecipeGridDimension, num, selectedRecipeIndex, craftingRecipeGridAvailabilityHash, GetCraftingPinnedTooltipGridSignature(), CraftingRecipes.View.Count, _craftingRecipeVariantVersion); if (CraftingController.CanReuseRecipeGrid(stamp)) { return; } EnsureCraftingRecipeCells(gui, grid); for (int i = 0; i < CraftingRecipes.GridCells.Count; i++) { CraftingRecipeGridCell cell = CraftingRecipes.GridCells[i]; int num2 = num + i; if (num2 < 0 || num2 >= CraftingRecipes.View.Count) { SetCraftingRecipeCellVisible(cell, visible: false); continue; } CraftingRecipeViewEntry craftingRecipeViewEntry = CraftingRecipes.View[num2]; ConfigureCraftingRecipeCell(gui, cell, craftingRecipeViewEntry.Pair, craftingRecipeViewEntry.OriginalIndex, i, IsCraftingRecipeTooltipPinned(craftingRecipeViewEntry.OriginalIndex), craftingRecipeViewEntry.OriginalIndex == selectedRecipeIndex); } CraftingController.StoreRecipeGridStamp(stamp); } private static void SetCraftingRecipeCellVisible(CraftingRecipeGridCell cell, bool visible) { if (!visible) { ClearCurrentCraftingRecipeTooltip(cell.Tooltip); } if ((Object)(object)cell.Go != (Object)null && !IsUnityNull((Object?)(object)cell.Go)) { cell.Go.SetActive(visible); } } private static void ConfigureCraftingRecipeCell(InventoryGui gui, CraftingRecipeGridCell cell, RecipeDataPair pair, int index, int slotIndex, bool tooltipPinned, bool craftingSelected) { //IL_0057: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0106: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cell.Go == (Object)null || IsUnityNull((Object?)(object)cell.Go)) { return; } cell.Go.SetActive(true); RectTransform rect = cell.Rect; int craftingRecipeGridDimension = GetCraftingRecipeGridDimension(); float craftingRecipeDynamicCellSpace = GetCraftingRecipeDynamicCellSpace(); float craftingRecipeDynamicCellSize = GetCraftingRecipeDynamicCellSize(craftingRecipeDynamicCellSpace); int num = slotIndex % craftingRecipeGridDimension; int num2 = slotIndex / craftingRecipeGridDimension; rect.anchorMin = new Vector2(0f, 1f); rect.anchorMax = new Vector2(0f, 1f); rect.pivot = new Vector2(0f, 1f); rect.sizeDelta = new Vector2(craftingRecipeDynamicCellSize, craftingRecipeDynamicCellSize); rect.anchoredPosition = new Vector2((float)num * craftingRecipeDynamicCellSpace, (float)(-num2) * craftingRecipeDynamicCellSpace); ((Transform)rect).localScale = Vector3.one; ((Transform)rect).localRotation = Quaternion.identity; ConfigureCraftingRecipeCellOverlays(cell, craftingRecipeDynamicCellSize); if ((Object)(object)cell.Background != (Object)null) { bool flag = !IsVeiledRecipeMasked(pair) && IsCraftingRecipeActionAvailable(gui, pair, index); ((Graphic)cell.Background).raycastTarget = true; ((Graphic)cell.Background).color = (craftingSelected ? CraftingRecipeSelectedBackgroundColor : (flag ? GetCraftingRecipeCraftableBackgroundColor() : CraftingRecipeUnavailableBackgroundColor)); } ConfigureCraftingRecipeCellIcon(cell.Icon, pair, craftingRecipeDynamicCellSize); ConfigureCraftingRecipeFoodIcon(gui, cell.Food, pair, craftingRecipeDynamicCellSize); ConfigureCraftingRecipeCellAmountText(cell.Amount, GetCraftingRecipeCellAmountText(gui, pair), craftingRecipeDynamicCellSize); ConfigureCraftingRecipeCellQualityText(cell.Quality, (!IsVeiledRecipeMasked(pair) && ((RecipeDataPair)(ref pair)).ItemData != null) ? ((RecipeDataPair)(ref pair)).ItemData.m_quality.ToString() : "", craftingRecipeDynamicCellSize); ConfigureCraftingRecipeStyleButton(gui, cell, pair, index, craftingRecipeDynamicCellSize); SetCraftingRecipeCellChild(cell.Selected, active: false); SetCraftingRecipeCellChild(cell.Equipped, active: false); SetCraftingRecipeCellChild(cell.Queued, active: false); SetCraftingRecipeCellChild(cell.NoTeleport, active: false); SetCraftingRecipeCellChild(cell.Durability, active: false); SetCraftingRecipeFavoriteBorder(cell, IsFavoriteCraftingRecipe(pair), IsUpgradeFavoritePair(pair)); SetCraftingRecipePinnedTooltipMarker(cell, tooltipPinned, craftingRecipeDynamicCellSize); ConfigureCraftingRecipeVneiTooltip(cell.Tooltip, pair); CraftingRecipeGridMarker marker = cell.Marker; marker.Index = index; marker.Tooltip = cell.Tooltip; if (!marker.Initialized) { UIInputHandler input = cell.Input; input.m_onPointerEnter = (Action)Delegate.Combine(input.m_onPointerEnter, (Action)delegate(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); SetCraftingRecipeHover(component?.Index ?? (-1), component?.Tooltip); }); input.m_onPointerExit = (Action)Delegate.Combine(input.m_onPointerExit, (Action)delegate(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); ClearCraftingRecipeHover(component?.Index ?? (-1), component?.Tooltip); }); input.m_onLeftClick = (Action)Delegate.Combine(input.m_onLeftClick, (Action)delegate(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); int num3 = component?.Index ?? (-1); ClearCraftingRecipeHover(num3, component?.Tooltip); if (!TryToggleCraftingRecipeFavorite(num3)) { SelectCraftingRecipeFromGrid(num3); } }); input.m_onRightClick = (Action)Delegate.Combine(input.m_onRightClick, (Action)delegate(UIInputHandler handler) { CraftingRecipeGridMarker component = ((Component)handler).GetComponent(); int num3 = component?.Index ?? (-1); ClearCraftingRecipeHover(num3, component?.Tooltip); if (!TryToggleCraftingRecipeFavorite(num3)) { SelectCraftingRecipeFromGrid(num3); } }); marker.Initialized = true; } ((Behaviour)cell.Tooltip).enabled = false; } private static string GetCraftingRecipeCellAmountText(InventoryGui gui, RecipeDataPair pair) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (IsVeiledRecipeMasked(pair)) { return ""; } string recycleNReclaimRecipeCellAmountText = GetRecycleNReclaimRecipeCellAmountText(gui, pair); if (!string.IsNullOrEmpty(recycleNReclaimRecipeCellAmountText)) { return recycleNReclaimRecipeCellAmountText; } if (!((Object)(object)((RecipeDataPair)(ref pair)).Recipe != (Object)null) || ((RecipeDataPair)(ref pair)).Recipe.m_amount <= 1) { return ""; } return ((RecipeDataPair)(ref pair)).Recipe.m_amount.ToString(); } private static Color GetCraftingRecipeCraftableBackgroundColor() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return _craftingRecipeCraftableBackgroundColor?.Value ?? CraftingRecipeDefaultCraftableBackgroundColor; } private static void SelectCraftingRecipeFromGrid(int index) { InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance == (Object)null) && TryGetCraftingRecipePair(instance, index, out var _)) { SetCraftingRecipeWithStoredVariant(instance, index, center: false); } } private static void SetCraftingRecipeHover(int index, UITooltip? tooltip) { if (CraftingController.IsHoveredRecipe(index)) { SetCurrentCraftingRecipeTooltip(tooltip); return; } CraftingController.SetHoveredRecipe(index); SetCurrentCraftingRecipeTooltip(tooltip); } private static void SyncCraftingRecipeHoverWithMouseIfRequested() { if (CraftingController.ConsumeRecipeHoverMouseSync() && TryGetCraftingRecipeCellUnderMouse(out int index, out UITooltip tooltip)) { SetCraftingRecipeHover(index, tooltip); } } private static bool TryGetCraftingRecipeCellUnderMouse(out int index, out UITooltip? tooltip) { //IL_002c: 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) //IL_008c: Unknown result type (might be due to invalid IL or missing references) index = -1; tooltip = null; RectTransform craftingRecipeGrid = _craftingRecipeGrid; if ((Object)(object)craftingRecipeGrid == (Object)null || IsUnityNull((Object?)(object)craftingRecipeGrid) || !((Component)craftingRecipeGrid).gameObject.activeInHierarchy) { return false; } Vector2 uiMousePosition = GetUiMousePosition(); int num = _craftingRecipePage * GetCraftingRecipeGridCapacity(); for (int i = 0; i < CraftingRecipes.GridCells.Count; i++) { CraftingRecipeGridCell craftingRecipeGridCell = CraftingRecipes.GridCells[i]; if (!((Object)(object)craftingRecipeGridCell.Go == (Object)null) && !IsUnityNull((Object?)(object)craftingRecipeGridCell.Go) && craftingRecipeGridCell.Go.activeInHierarchy && RectContainsScreenPoint(craftingRecipeGridCell.Rect, uiMousePosition)) { int num2 = num + i; index = ((num2 >= 0 && num2 < CraftingRecipes.View.Count) ? CraftingRecipes.View[num2].OriginalIndex : craftingRecipeGridCell.Marker.Index); tooltip = craftingRecipeGridCell.Tooltip; return index >= 0; } } return false; } private static void ClearCraftingRecipeHover(int index, UITooltip? tooltip) { if (!CraftingController.IsHoveredRecipe(index)) { ClearCurrentCraftingRecipeTooltip(tooltip); return; } CraftingController.ClearHoveredRecipe(); ClearCurrentCraftingRecipeTooltip(tooltip); HideCraftingTooltipRecipeOverlay(); } private static void SetCurrentCraftingRecipeTooltip(UITooltip? tooltip) { if (!((Object)(object)tooltip == (Object)null) && !IsUnityNull((Object?)(object)tooltip) && !string.IsNullOrWhiteSpace(tooltip.m_topic)) { UITooltip.m_current = tooltip; } } private static void ClearCurrentCraftingRecipeTooltip(UITooltip? tooltip) { if ((Object)(object)tooltip != (Object)null && !IsUnityNull((Object?)(object)tooltip) && (Object)(object)UITooltip.m_current == (Object)(object)tooltip) { UITooltip.m_current = null; } } private static void ConfigureCraftingRecipeVneiTooltip(UITooltip tooltip, RecipeDataPair pair) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (IsVeiledRecipeMasked(pair)) { string veiledRecipeUnknownNameText = GetVeiledRecipeUnknownNameText(); string veiledRecipeUnknownDescriptionText = GetVeiledRecipeUnknownDescriptionText(); tooltip.m_topic = veiledRecipeUnknownNameText; tooltip.m_text = veiledRecipeUnknownDescriptionText; (((Component)tooltip).GetComponent() ?? ((Component)tooltip).gameObject.AddComponent()).Configure(veiledRecipeUnknownNameText, veiledRecipeUnknownDescriptionText, ""); } else { string craftingRecipeVneiItemToken = GetCraftingRecipeVneiItemToken(pair); string craftingRecipeVneiDisplayText = GetCraftingRecipeVneiDisplayText(pair, craftingRecipeVneiItemToken); tooltip.m_topic = craftingRecipeVneiItemToken; tooltip.m_text = craftingRecipeVneiDisplayText; (((Component)tooltip).GetComponent() ?? ((Component)tooltip).gameObject.AddComponent()).Configure(craftingRecipeVneiItemToken, craftingRecipeVneiDisplayText, ""); } } private static string GetCraftingRecipeVneiItemToken(RecipeDataPair pair) { if (((RecipeDataPair)(ref pair)).ItemData != null) { string itemPrefabName = GetItemPrefabName(((RecipeDataPair)(ref pair)).ItemData); object obj; if (string.IsNullOrWhiteSpace(itemPrefabName)) { obj = ((RecipeDataPair)(ref pair)).ItemData.m_shared?.m_name; if (obj == null) { return ""; } } else { obj = itemPrefabName; } return (string)obj; } ItemDrop val = ((RecipeDataPair)(ref pair)).Recipe?.m_item; if ((Object)(object)val == (Object)null) { return ""; } string text = (((Object)(object)val.m_itemData.m_dropPrefab != (Object)null) ? ((Object)val.m_itemData.m_dropPrefab).name : ((Object)val).name); object obj2; if (string.IsNullOrWhiteSpace(text)) { obj2 = val.m_itemData.m_shared?.m_name; if (obj2 == null) { return ""; } } else { obj2 = CleanPrefabName(text); } return (string)obj2; } private static string GetCraftingRecipeVneiDisplayText(RecipeDataPair pair, string fallback) { string text = ((RecipeDataPair)(ref pair)).ItemData?.m_shared?.m_name ?? ((RecipeDataPair)(ref pair)).Recipe?.m_item?.m_itemData.m_shared?.m_name ?? ""; if (string.IsNullOrWhiteSpace(text)) { return fallback; } if (Localization.instance == null) { return text; } return Localization.instance.Localize(text); } private static string StripRichText(string text) { if (string.IsNullOrEmpty(text)) { return ""; } int num = 0; char[] array = new char[text.Length]; int length = 0; foreach (char c in text) { switch (c) { case '<': num++; continue; case '>': if (num > 0) { num--; continue; } break; } if (num == 0) { array[length++] = c; } } return new string(array, 0, length); } private static void ConfigureCraftingRecipeCellOverlays(CraftingRecipeGridCell cell, float cellSize) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_00d0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in (Transform)cell.Rect) { Transform val = item; string text = ((Object)val).name.ToLowerInvariant(); bool flag = !text.Contains("bkg") && !text.Contains("background") && !text.Contains("border") && !text.Contains("frame"); if (flag) { bool flag2; switch (text) { case "selected": case "equiped": case "queued": case "noteleport": case "durability": flag2 = true; break; default: flag2 = false; break; } flag = !flag2; } if (!flag) { RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null); if (val2 != null) { val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(0f, 1f); val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = Vector2.zero; val2.sizeDelta = new Vector2(cellSize, cellSize); ((Transform)val2).localScale = Vector3.one; ((Transform)val2).localRotation = Quaternion.identity; } } } } private static void ConfigureCraftingRecipeCellIcon(Image? icon, RecipeDataPair pair, float cellSize) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00ea: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)icon == (Object)null)) { ItemDrop val = (((Object)(object)((RecipeDataPair)(ref pair)).Recipe != (Object)null) ? ((RecipeDataPair)(ref pair)).Recipe.m_item : null); ((Component)icon).gameObject.SetActive((Object)(object)val != (Object)null); if (((Component)icon).gameObject.activeSelf) { RectTransform rectTransform = ((Graphic)icon).rectTransform; float num = Mathf.Clamp(cellSize * 0.08f, 5f, 12f); float num2 = Mathf.Max(16f, cellSize - num * 2f); rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.anchoredPosition = new Vector2(num, 0f - num); rectTransform.sizeDelta = new Vector2(num2, num2); ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; icon.sprite = GetCraftingRecipeIcon(pair); ((Graphic)icon).color = (Color)(IsVeiledRecipeMasked(pair) ? Color.black : (((RecipeDataPair)(ref pair)).CanCraft ? Color.white : new Color(0.68f, 0.68f, 0.68f, 0.72f))); ((Graphic)icon).raycastTarget = false; } } } private static void ConfigureCraftingRecipeFoodIcon(InventoryGui gui, Image? foodIcon, RecipeDataPair pair, float cellSize) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00eb: 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_00fd: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)foodIcon == (Object)null)) { ItemData val = ((RecipeDataPair)(ref pair)).ItemData ?? ((RecipeDataPair)(ref pair)).Recipe?.m_item?.m_itemData; Image inventoryFoodIconSource = GetInventoryFoodIconSource(gui); FoodStat stat = FoodStat.None; bool flag = !IsVeiledRecipeMasked(pair) && val != null && (Object)(object)inventoryFoodIconSource != (Object)null && (Object)(object)inventoryFoodIconSource.sprite != (Object)null && TryGetDominantFoodStat(val, out stat); ((Component)foodIcon).gameObject.SetActive(flag); if (flag) { foodIcon.sprite = inventoryFoodIconSource.sprite; ((Graphic)foodIcon).material = ((Graphic)inventoryFoodIconSource).material; foodIcon.type = inventoryFoodIconSource.type; foodIcon.preserveAspect = true; ((Graphic)foodIcon).raycastTarget = false; ((Graphic)foodIcon).color = (Color)(stat switch { FoodStat.Health => gui.m_playerGrid.m_foodHealthColor, FoodStat.Stamina => gui.m_playerGrid.m_foodStaminaColor, FoodStat.Eitr => gui.m_playerGrid.m_foodEitrColor, _ => Color.white, }); RectTransform rectTransform = ((Graphic)foodIcon).rectTransform; float num = Mathf.Clamp(cellSize * 0.3f, 16f, 30f); float num2 = Mathf.Clamp(cellSize * 0.035f, 2f, 5f); rectTransform.anchorMin = Vector2.one; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = Vector2.one; rectTransform.anchoredPosition = new Vector2(num2, 0f - num2); rectTransform.sizeDelta = new Vector2(num, num); ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; ((Transform)rectTransform).SetAsLastSibling(); } } } private static Image? GetInventoryFoodIconSource(InventoryGui gui) { InventoryGrid playerGrid = gui.m_playerGrid; if ((Object)(object)playerGrid == (Object)null) { return null; } if (playerGrid.m_elements != null) { foreach (Element element in playerGrid.m_elements) { if ((Object)(object)element?.m_food != (Object)null && (Object)(object)element.m_food.sprite != (Object)null) { return element.m_food; } } } Transform val = (((Object)(object)playerGrid.m_elementPrefab != (Object)null) ? playerGrid.m_elementPrefab.transform.Find("foodicon") : null); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent(); } private static void ConfigureCraftingRecipeStyleButton(InventoryGui gui, CraftingRecipeGridCell cell, RecipeDataPair pair, int originalIndex, float cellSize) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) RectTransform val = EnsureCraftingRecipeStyleButton(gui, cell); if ((Object)(object)val == (Object)null) { return; } bool flag = GetCraftingRecipeVariantCount(pair) > 1 && ((RecipeDataPair)(ref pair)).ItemData == null && !IsVeiledRecipeMasked(pair); ((Component)val).gameObject.SetActive(flag); if (flag) { float num = Mathf.Clamp(cellSize * 0.224f, 14f, 21f); float num2 = Mathf.Clamp(cellSize * 0.476f, 31f, 50f); val.anchorMin = new Vector2(0f, 1f); val.anchorMax = new Vector2(0f, 1f); val.pivot = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(cellSize - num2 - 2f, -2f); val.sizeDelta = new Vector2(num2, num); ((Transform)val).localScale = Vector3.one; ((Transform)val).localRotation = Quaternion.identity; ((Transform)val).SetAsLastSibling(); Image component = ((Component)val).GetComponent(); if (component != null) { ApplyVanillaButtonImage(gui.m_variantButton, component); ((Graphic)component).raycastTarget = true; } Transform obj = ((Transform)val).Find("Label"); TMP_Text val2 = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { ApplyDefaultFontAsset(val2); val2.text = LocalizeUi("$inventoryslots_style", "Style"); val2.alignment = (TextAlignmentOptions)514; val2.enableAutoSizing = true; val2.fontSizeMin = 7f; val2.fontSizeMax = Mathf.Clamp(num * 0.66f, 9f, 12f); val2.textWrappingMode = (TextWrappingModes)0; val2.overflowMode = (TextOverflowModes)3; ((Graphic)val2).color = GetVanillaButtonTextColor(gui.m_variantButton); ((Graphic)val2).raycastTarget = false; RectTransform rectTransform = val2.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; } CraftingRecipeStyleButtonMarker obj2 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj2.Index = originalIndex; obj2.Gui = gui; } } private static RectTransform? EnsureCraftingRecipeStyleButton(InventoryGui gui, CraftingRecipeGridCell cell) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cell.Rect == (Object)null || IsUnityNull((Object?)(object)cell.Rect)) { return null; } Transform val = ((Transform)cell.Rect).Find("InventorySlots_CraftingRecipeStyleButton"); RectTransform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null) { val2 = new GameObject("InventorySlots_CraftingRecipeStyleButton", new Type[4] { typeof(RectTransform), typeof(Image), typeof(UIInputHandler), typeof(CraftingRecipeStyleButtonMarker) }).GetComponent(); ((Transform)val2).SetParent((Transform)(object)cell.Rect, false); CreateTextRect("Label", (Transform)(object)val2); UIInputHandler component = ((Component)val2).GetComponent(); component.m_onLeftClick = (Action)Delegate.Combine(component.m_onLeftClick, (Action)delegate(UIInputHandler handler) { ShowCraftingRecipeStyleDialog(((Component)handler).GetComponent()); }); } return val2; } private static void ApplyVanillaButtonImage(Button? source, Image target) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Image val = (((Object)(object)source != (Object)null && !IsUnityNull((Object?)(object)source)) ? ((Selectable)source).image : null); if ((Object)(object)val != (Object)null) { target.sprite = val.sprite; target.type = val.type; ((Graphic)target).material = ((Graphic)val).material; target.pixelsPerUnitMultiplier = val.pixelsPerUnitMultiplier; ((Graphic)target).color = ((Graphic)val).color; } else { target.sprite = GetSolidUiSprite(); target.type = (Type)1; ((Graphic)target).color = new Color(0.02f, 0.015f, 0.01f, 0.76f); } } private static Color GetVanillaButtonTextColor(Button? button) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)button != (Object)null && !IsUnityNull((Object?)(object)button)) { TMP_Text componentInChildren = ((Component)button).GetComponentInChildren(true); if (componentInChildren != null) { return ((Graphic)componentInChildren).color; } } return new Color(1f, 0.84f, 0.32f, 1f); } private static void ShowCraftingRecipeStyleDialog(CraftingRecipeStyleButtonMarker? marker) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) InventoryGui val = (InventoryGui)(((Object)(object)marker != (Object)null && (Object)(object)marker.Gui != (Object)null && !IsUnityNull((Object?)(object)marker.Gui)) ? ((object)marker.Gui) : ((object)InventoryGui.instance)); if (!((Object)(object)val == (Object)null) && TryGetCraftingRecipePair(val, marker?.Index ?? (-1), out var pair) && !((Object)(object)((RecipeDataPair)(ref pair)).Recipe == (Object)null) && GetCraftingRecipeVariantCount(pair) > 1) { SetCraftingRecipeWithStoredVariant(val, marker.Index, center: false); val.OnShowVariantSelection(); } } internal static void OnCraftingRecipeVariantSelected(InventoryGui gui, int variant) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gui == (Object)null) && ShouldShowCraftingPanelRedesign(gui)) { RecipeDataPair selectedRecipe = gui.m_selectedRecipe; Recipe recipe = ((RecipeDataPair)(ref selectedRecipe)).Recipe; if (!((Object)(object)recipe == (Object)null) && ((RecipeDataPair)(ref selectedRecipe)).ItemData == null && GetCraftingRecipeVariantCount(selectedRecipe) > 1) { SetCraftingRecipeVariant(recipe, variant); CraftingController.MarkRecipeGridLayoutDirty(); UpdateCraftingPanelRedesign(gui, CraftingPanelUpdateReason.StateChanged); } } } private static void SetCraftingRecipeWithStoredVariant(InventoryGui gui, int index, bool center) { gui.SetRecipe(index, center); ApplyCraftingRecipeVariantToGui(gui, index); } private static void ApplyCraftingRecipeVariantToGui(InventoryGui gui, int index) { //IL_002d: 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) if (!((Object)(object)gui == (Object)null) && TryGetCraftingRecipePair(gui, index, out var pair) && !((Object)(object)((RecipeDataPair)(ref pair)).Recipe == (Object)null) && ((RecipeDataPair)(ref pair)).ItemData == null) { if (GetCraftingRecipeVariantCount(pair) <= 1) { gui.m_selectedVariant = 0; } else { gui.m_selectedVariant = GetCraftingRecipeVariant(pair); } } } private static int GetCraftingRecipeVariant(RecipeDataPair pair) { //IL_0017: 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_0063: Unknown result type (might be due to invalid IL or missing references) if (((RecipeDataPair)(ref pair)).ItemData != null) { return Mathf.Clamp(((RecipeDataPair)(ref pair)).ItemData.m_variant, 0, Mathf.Max(0, GetCraftingRecipeVariantCount(pair) - 1)); } if ((Object)(object)((RecipeDataPair)(ref pair)).Recipe == (Object)null || GetCraftingRecipeVariantCount(pair) <= 1) { return 0; } int value; return Mathf.Clamp(CraftingRecipes.Variants.TryGetValue(((RecipeDataPair)(ref pair)).Recipe, out value) ? value : 0, 0, GetCraftingRecipeVariantCount(pair) - 1); } private static void SetCraftingRecipeVariant(Recipe recipe, int variant) { if (!((Object)(object)recipe == (Object)null)) { int recipeVariantCount = GetRecipeVariantCount(recipe); int num = Mathf.Clamp(variant, 0, Mathf.Max(0, recipeVariantCount - 1)); if (!CraftingRecipes.Variants.TryGetValue(recipe, out var value) || value != num) { CraftingRecipes.Variants[recipe] = num; _craftingRecipeVariantVersion++; } } } private static int GetCraftingRecipeVariantCount(RecipeDataPair pair) { if (!((Object)(object)((RecipeDataPair)(ref pair)).Recipe != (Object)null)) { return 1; } return GetRecipeVariantCount(((RecipeDataPair)(ref pair)).Recipe); } private static int GetRecipeVariantCount(Recipe recipe) { ItemData val = (((Object)(object)recipe?.m_item != (Object)null) ? recipe.m_item.m_itemData : null); if (val?.m_shared == null || val.m_shared.m_icons == null) { return 1; } int num = Mathf.Max(1, val.m_shared.m_icons.Length); int num2 = Mathf.Max(1, val.m_shared.m_variants); return Mathf.Min(num, num2); } private static Sprite? GetCraftingRecipeIcon(RecipeDataPair pair) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (((RecipeDataPair)(ref pair)).ItemData != null) { return ((RecipeDataPair)(ref pair)).ItemData.GetIcon(); } if ((Object)(object)((RecipeDataPair)(ref pair)).Recipe?.m_item == (Object)null) { return null; } ItemData itemData = ((RecipeDataPair)(ref pair)).Recipe.m_item.m_itemData; int craftingRecipeVariant = GetCraftingRecipeVariant(pair); if (itemData.m_shared?.m_icons != null && craftingRecipeVariant >= 0 && craftingRecipeVariant < itemData.m_shared.m_icons.Length) { return itemData.m_shared.m_icons[craftingRecipeVariant]; } return itemData.GetIcon(); } private static void ConfigureCraftingRecipeCellAmountText(TMP_Text? text, string value, float cellSize) { //IL_0012: 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_0030: Unknown result type (might be due to invalid IL or missing references) ConfigureCraftingRecipeCellText(text, value, cellSize, (TextAlignmentOptions)1026, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 1f)); } private static void ConfigureCraftingRecipeCellQualityText(TMP_Text? text, string value, float cellSize) { //IL_0012: 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_0030: Unknown result type (might be due to invalid IL or missing references) ConfigureCraftingRecipeCellText(text, value, cellSize, (TextAlignmentOptions)260, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-1f, -1f)); } private static void ConfigureCraftingRecipeCellText(TMP_Text? text, string value, float cellSize, TextAlignmentOptions alignment, Vector2 anchor, Vector2 pivot, Vector2 direction) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00b2: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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) if (!((Object)(object)text == (Object)null)) { ApplyDefaultFontAsset(text); text.text = value; ((Component)text).gameObject.SetActive(!string.IsNullOrEmpty(value)); text.alignment = alignment; text.textWrappingMode = (TextWrappingModes)0; ((Graphic)text).raycastTarget = false; text.fontSize = Mathf.Clamp(cellSize * 0.28f, 16f, 34f); RectTransform rectTransform = text.rectTransform; rectTransform.anchorMin = anchor; rectTransform.anchorMax = anchor; rectTransform.pivot = pivot; float num = Mathf.Clamp(cellSize * 0.06f, 4f, 10f); float num2 = Mathf.Clamp(cellSize * 0.32f, 20f, 42f); rectTransform.anchoredPosition = new Vector2(direction.x * num, direction.y * num); rectTransform.sizeDelta = new Vector2(cellSize - num * 2f, num2); ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; } } private static void SetCraftingRecipeCellChild(GameObject? child, bool active) { //IL_003e: 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_0050: 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) if ((Object)(object)child == (Object)null) { return; } Image val = default(Image); if (string.Equals(((Object)child).name, "selected", StringComparison.OrdinalIgnoreCase) && child.TryGetComponent(ref val)) { if (!child.activeSelf) { child.SetActive(true); } ((Behaviour)val).enabled = true; Color color = ((Graphic)val).color; color.a = (active ? Mathf.Max(color.a, 0.38f) : 0f); ((Graphic)val).color = color; } else if (child.activeSelf != active) { child.SetActive(active); } } private static void SetCraftingRecipeFavoriteBorder(CraftingRecipeGridCell cell, bool active, bool upgradeFavorite) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) RectTransform val = EnsureCraftingRecipeFavoriteBorder(cell); if (!((Object)(object)val == (Object)null)) { Image[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Graphic)componentsInChildren[i]).color = (upgradeFavorite ? new Color(0.2f, 0.95f, 0.38f, 0.96f) : new Color(1f, 0.82f, 0.1f, 0.96f)); } ((Component)val).gameObject.SetActive(active); if (active) { ((Transform)val).SetAsLastSibling(); } } } private static void SetCraftingRecipePinnedTooltipMarker(CraftingRecipeGridCell cell, bool active, float cellSize) { RectTransform val = EnsureCraftingRecipePinnedTooltipMarker(cell); if (!((Object)(object)val == (Object)null)) { ConfigureCraftingRecipePinnedTooltipMarker(val, cellSize); ((Component)val).gameObject.SetActive(active); if (active) { ((Transform)val).SetAsLastSibling(); } } } private static RectTransform? EnsureCraftingRecipePinnedTooltipMarker(CraftingRecipeGridCell cell) { if ((Object)(object)cell.Rect == (Object)null || IsUnityNull((Object?)(object)cell.Rect)) { return null; } Transform val = ((Transform)cell.Rect).Find("InventorySlots_CraftingPinnedTooltipMarker"); RectTransform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null) { val2 = CreateTextRect("InventorySlots_CraftingPinnedTooltipMarker", (Transform)(object)cell.Rect, out TMP_Text text, active: false); text.text = "T"; } return val2; } private static void ConfigureCraftingRecipePinnedTooltipMarker(RectTransform marker, float cellSize) { //IL_00a7: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)marker == (Object)null || IsUnityNull((Object?)(object)marker)) { return; } float num = Mathf.Clamp(cellSize * 0.06f, 4f, 8f); float num2 = Mathf.Clamp(cellSize * 0.34f, 20f, 28f); float num3 = Mathf.Clamp(cellSize * 0.28f, 16f, 24f); string text = $"{num:0.###}|{num2:0.###}|{num3:0.###}"; CraftingPinnedTooltipMarkerState craftingPinnedTooltipMarkerState = ((Component)marker).GetComponent() ?? ((Component)marker).gameObject.AddComponent(); if (!string.Equals(craftingPinnedTooltipMarkerState.LayoutSignature, text, StringComparison.Ordinal)) { SetRectLayout(marker, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(0f - num, num), new Vector2(num2, num2)); TMP_Text component = ((Component)marker).GetComponent(); if ((Object)(object)component == (Object)null) { craftingPinnedTooltipMarkerState.LayoutSignature = text; return; } ApplyDefaultFontAsset(component); component.text = "T"; component.alignment = (TextAlignmentOptions)1028; component.textWrappingMode = (TextWrappingModes)0; component.fontSize = num3; ((Graphic)component).color = Color.white; component.outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)230); component.outlineWidth = 0.18f; ((Graphic)component).raycastTarget = false; craftingPinnedTooltipMarkerState.LayoutSignature = text; } } private static RectTransform? EnsureCraftingRecipeFavoriteBorder(CraftingRecipeGridCell cell) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ca: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cell.Rect == (Object)null || IsUnityNull((Object?)(object)cell.Rect)) { return null; } Transform obj = ((Transform)cell.Rect).Find("InventorySlots_CraftingFavoriteBorder"); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (val != null) { return val; } GameObject val2 = new GameObject("InventorySlots_CraftingFavoriteBorder", new Type[1] { typeof(RectTransform) }); RectTransform component = val2.GetComponent(); ((Transform)component).SetParent((Transform)(object)cell.Rect, false); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((Transform)component).localScale = Vector3.one; ((Transform)component).localRotation = Quaternion.identity; CreateFavoriteBorderSide(component, "Top", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, 2f), Vector2.zero); CreateFavoriteBorderSide(component, "Bottom", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 2f), Vector2.zero); CreateFavoriteBorderSide(component, "Left", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, 0.5f), new Vector2(2f, 0f), Vector2.zero); CreateFavoriteBorderSide(component, "Right", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(1f, 0.5f), new Vector2(2f, 0f), Vector2.zero); val2.SetActive(false); return component; } private static bool RectContainsCraftingRecipeIconArea(RectTransform grid, Vector2 screenPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Vector2.op_Implicit(((Transform)grid).InverseTransformPoint(Vector2.op_Implicit(screenPoint))); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, -576f, 576f, 576f); return ((Rect)(ref val2)).Contains(val); } private static void UpdateCraftingGroupRail(InventoryGui gui, RectTransform grid) { //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) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_0113: 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_0149: 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_016f: 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_0191: 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_02c2: Unknown result type (might be due to invalid IL or missing references) RectTransform val = EnsureCraftingGroupRail(gui); if ((Object)(object)val == (Object)null) { return; } IReadOnlyList selectableCraftingGroupFilters = GetSelectableCraftingGroupFilters(gui); CraftingGroupRailStamp craftingGroupRailStamp = GetCraftingGroupRailStamp(gui, grid); if (CraftingController.CanReuseGroupRail(craftingGroupRailStamp)) { return; } if (!string.IsNullOrEmpty(_selectedCraftingGroupId) && selectableCraftingGroupFilters.All((CraftingRecipeGroupFilter craftingRecipeGroupFilter) => craftingRecipeGroupFilter.Id != _selectedCraftingGroupId)) { _selectedCraftingGroupId = ""; _craftingRecipePage = 0; CraftingController.ClearHoveredRecipe(); InvalidateCraftingRecipeView(); selectableCraftingGroupFilters = GetSelectableCraftingGroupFilters(gui); craftingGroupRailStamp = GetCraftingGroupRailStamp(gui, grid); } if (selectableCraftingGroupFilters.Count == 0) { ((Component)val).gameObject.SetActive(false); CraftingController.StoreGroupRailStamp(craftingGroupRailStamp); return; } ((Component)val).gameObject.SetActive(true); Vector2 craftingGroupBlockSize = GetCraftingGroupBlockSize(selectableCraftingGroupFilters); val.anchoredPosition = grid.anchoredPosition + CraftingGroupRailFixedOffset; ((Transform)val).SetAsLastSibling(); float x = craftingGroupBlockSize.x; float x2 = craftingGroupBlockSize.x; float y = craftingGroupBlockSize.y; CraftingRecipeGroupPanel craftingRecipeGroupPanel = EnsureCraftingGroupPanel(val, 0); ((Component)craftingRecipeGroupPanel.Rect).gameObject.SetActive(true); craftingRecipeGroupPanel.Rect.anchorMin = new Vector2(0f, 1f); craftingRecipeGroupPanel.Rect.anchorMax = new Vector2(0f, 1f); craftingRecipeGroupPanel.Rect.pivot = new Vector2(0f, 1f); craftingRecipeGroupPanel.Rect.sizeDelta = new Vector2(x, y); craftingRecipeGroupPanel.Rect.anchoredPosition = Vector2.zero; ((Transform)craftingRecipeGroupPanel.Rect).localScale = Vector3.one; ((Transform)craftingRecipeGroupPanel.Rect).localRotation = Quaternion.identity; if ((Object)(object)craftingRecipeGroupPanel.Background != (Object)null) { craftingRecipeGroupPanel.Background.sprite = GetSolidUiSprite(); ((Graphic)craftingRecipeGroupPanel.Background).color = Color.clear; ((Graphic)craftingRecipeGroupPanel.Background).raycastTarget = false; } for (int num = 0; num < selectableCraftingGroupFilters.Count; num++) { CraftingRecipeGroupFilter filter = selectableCraftingGroupFilters[num]; CraftingRecipeGroupButton button = EnsureCraftingGroupButton(gui, craftingRecipeGroupPanel.Rect, num); bool hasRecipes = CraftingGroupHasRecipes(gui, filter); ConfigureCraftingGroupButton(gui, button, filter, num, x, x2, hasRecipes); } for (int num2 = 1; num2 < CraftingRecipes.GroupPanels.Count; num2++) { RectTransform rect = CraftingRecipes.GroupPanels[num2].Rect; if (!IsUnityNull((Object?)(object)rect)) { ((Component)rect).gameObject.SetActive(false); } } for (int num3 = selectableCraftingGroupFilters.Count; num3 < CraftingRecipes.GroupButtons.Count; num3++) { GameObject go = CraftingRecipes.GroupButtons[num3].Go; if (!IsUnityNull((Object?)(object)go)) { go.SetActive(false); } } val.sizeDelta = new Vector2(x, y); CraftingController.StoreGroupRailStamp(craftingGroupRailStamp); } private static void HideCraftingGroupRail() { if ((Object)(object)_craftingGroupRail != (Object)null && !IsUnityNull((Object?)(object)_craftingGroupRail)) { ((Component)_craftingGroupRail).gameObject.SetActive(false); } CraftingController.StoreGroupRailStamp(default(CraftingGroupRailStamp)); } private static CraftingGroupRailStamp GetCraftingGroupRailStamp(InventoryGui gui, RectTransform grid) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) return new CraftingGroupRailStamp(((Object)gui.m_crafting).GetInstanceID(), ((Object)grid).GetInstanceID(), grid.anchoredPosition.x, grid.anchoredPosition.y, _selectedCraftingGroupId, _craftingFavoritesVersion, GetCraftingGroupIconBackgroundAlpha(), _craftingGroupAvailabilitySignature, _craftingSelectableGroupFilterIdsSignature); } private static RectTransform? EnsureCraftingGroupRail(InventoryGui gui) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gui.m_crafting == (Object)null) { return null; } if ((Object)(object)_craftingGroupRail != (Object)null && !IsUnityNull((Object?)(object)_craftingGroupRail) && (Object)(object)((Transform)_craftingGroupRail).parent == (Object)(object)gui.m_crafting) { ConfigureCraftingGroupRail(_craftingGroupRail); return _craftingGroupRail; } Transform val = ((Transform)gui.m_crafting).Find("InventorySlots_CraftingGroupRail"); _craftingGroupRail = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)_craftingGroupRail == (Object)null) { _craftingGroupRail = new GameObject("InventorySlots_CraftingGroupRail", new Type[1] { typeof(RectTransform) }).GetComponent(); ((Transform)_craftingGroupRail).SetParent((Transform)(object)gui.m_crafting, false); } ConfigureCraftingGroupRail(_craftingGroupRail); return _craftingGroupRail; } private static void ConfigureCraftingGroupRail(RectTransform rail) { //IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) rail.anchorMin = new Vector2(0f, 1f); rail.anchorMax = new Vector2(0f, 1f); rail.pivot = new Vector2(0f, 1f); ((Transform)rail).localScale = Vector3.one; ((Transform)rail).localRotation = Quaternion.identity; } private static Vector2 GetCraftingGroupBlockSize(IReadOnlyList filters) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, filters.Count); return new Vector2(60f, 60f * (float)num); } private static CraftingRecipeGroupPanel EnsureCraftingGroupPanel(RectTransform rail, int index) { while (CraftingRecipes.GroupPanels.Count <= index) { CraftingRecipes.GroupPanels.Add(CreateCraftingGroupPanel(rail, CraftingRecipes.GroupPanels.Count)); } CraftingRecipeGroupPanel craftingRecipeGroupPanel = CraftingRecipes.GroupPanels[index]; if (IsUnityNull((Object?)(object)craftingRecipeGroupPanel.Rect)) { craftingRecipeGroupPanel = CreateCraftingGroupPanel(rail, index); CraftingRecipes.GroupPanels[index] = craftingRecipeGroupPanel; } if ((Object)(object)((Transform)craftingRecipeGroupPanel.Rect).parent != (Object)(object)rail) { ((Transform)craftingRecipeGroupPanel.Rect).SetParent((Transform)(object)rail, false); } return craftingRecipeGroupPanel; } private static CraftingRecipeGroupPanel CreateCraftingGroupPanel(RectTransform rail, int index) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) RectTransform component = new GameObject("InventorySlots_CraftingGroupPanel_" + index, new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent(); ((Transform)component).SetParent((Transform)(object)rail, false); return new CraftingRecipeGroupPanel(component); } private static CraftingRecipeGroupButton EnsureCraftingGroupButton(InventoryGui gui, RectTransform panel, int index) { while (CraftingRecipes.GroupButtons.Count <= index) { CraftingRecipes.GroupButtons.Add(CreateCraftingGroupButton(panel, CraftingRecipes.GroupButtons.Count)); } CraftingRecipeGroupButton craftingRecipeGroupButton = CraftingRecipes.GroupButtons[index]; if (IsUnityNull((Object?)(object)craftingRecipeGroupButton.Go) || IsUnityNull((Object?)(object)craftingRecipeGroupButton.Rect)) { craftingRecipeGroupButton = CreateCraftingGroupButton(panel, index); CraftingRecipes.GroupButtons[index] = craftingRecipeGroupButton; } if ((Object)(object)((Transform)craftingRecipeGroupButton.Rect).parent != (Object)(object)panel) { ((Transform)craftingRecipeGroupButton.Rect).SetParent((Transform)(object)panel, false); } return craftingRecipeGroupButton; } private static CraftingRecipeGroupButton CreateCraftingGroupButton(RectTransform panel, int index) { GameObject obj = CreateFallbackCraftingGroupButton(panel); ((Object)obj).name = "InventorySlots_CraftingGroupButton_" + index; obj.SetActive(true); Button component = obj.GetComponent