using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ExtraSlots; using ExtraSlots.Compatibility; using ExtraSlots.HotBars; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using Splatform; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.LowLevel; using UnityEngine.UI; using YamlDotNet.Serialization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ExtraSlots")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ExtraSlots")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7e559c9a-ba1c-45b5-a260-ec3a1455248b")] [assembly: AssemblyFileVersion("1.1.15")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.15.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LocalizationManager { [PublicAPI] public class Localizer { [CompilerGenerated] private sealed class d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil((Func)(() => PlatformManager.DistributionPlatform != null && PlatformInitializer.PreferencesInitialized)); <>1__state = 1; return true; case 1: <>1__state = -1; if (string.IsNullOrEmpty(PlatformPrefs.GetString("language", ""))) { PlatformPrefs.SetString("language", "English"); } LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string defaultLanguage = "English"; private static readonly Dictionary>> PlaceholderProcessors; private static readonly Dictionary> loadedTexts; private static readonly ConditionalWeakTable localizationLanguage; private static readonly List> localizationObjects; private static BaseUnityPlugin? _plugin; private static readonly List fileExtensions; private static BaseUnityPlugin Plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out string value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out Dictionary> value2)) { text = value2.Aggregate(text, (string current, KeyValuePair> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder(string key, string placeholder, ConfigEntry config, Func? convertConfigValue = null) where T : notnull { string key2 = key; string placeholder2 = placeholder; Func convertConfigValue2 = convertConfigValue; ConfigEntry config2 = config; if (convertConfigValue2 == null) { convertConfigValue2 = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key2)) { PlaceholderProcessors[key2] = new Dictionary>(); } config2.SettingChanged += delegate { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key2][placeholder2] = () => convertConfigValue2(config2.Value); UpdatePlaceholderText(Localization.instance, key2); } } public static void AddText(string key, string text) { List> list = new List>(); foreach (WeakReference localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference item in list) { localizationObjects.Remove(item); } } [IteratorStateMachine(typeof(d__12))] public static IEnumerator Load() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0); } private static void LoadLocalization(Localization __instance, string language) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference(__instance)); } localizationLanguage.Add(__instance, language); Dictionary localizationFiles = new Dictionary(); string[] prefixes = new string[2] { Plugin.Info.Metadata.Name + ".", Plugin.Info.Metadata.Name.Replace(" ", "") + "." }; Scan(Paths.ConfigPath, warn: true); Scan(Paths.PluginPath, warn: false); byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + Plugin.Info.Metadata.Name + ". Expected an embedded resource Translations/English.json or Translations/English.yml."); } Dictionary dictionary = ((BuilderSkeleton)new DeserializerBuilder()).IgnoreFields().Build().Deserialize>(Encoding.UTF8.GetString(array)); if (dictionary == null) { throw new Exception("Localization for mod " + Plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text = null; if (language != "English") { if (localizationFiles.ContainsKey(language)) { text = File.ReadAllText(localizationFiles[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text = Encoding.UTF8.GetString(array2); } } } if (text == null && localizationFiles.ContainsKey("English")) { text = File.ReadAllText(localizationFiles["English"]); } if (text != null) { Dictionary dictionary2; try { dictionary2 = ((BuilderSkeleton)new DeserializerBuilder()).IgnoreFields().Build().Deserialize>(text) ?? new Dictionary(); } catch (Exception arg) { global::ExtraSlots.ExtraSlots.LogWarning($"Failed to deserialize localization for language '{language}'. Using base localization only.\n{arg}"); dictionary2 = new Dictionary(); } foreach (KeyValuePair item in dictionary2) { dictionary[item.Key] = item.Value; } } loadedTexts[language] = dictionary; foreach (KeyValuePair item2 in dictionary) { UpdatePlaceholderText(__instance, item2.Key); } void Scan(string root, bool warn) { foreach (string item3 in from f in Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) where fileExtensions.Contains(Path.GetExtension(f)) select f) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item3); string[] array3 = prefixes; foreach (string text2 in array3) { if (fileNameWithoutExtension.StartsWith(text2)) { string text3 = fileNameWithoutExtension.Substring(text2.Length); if (!string.IsNullOrWhiteSpace(text3)) { if (localizationFiles.ContainsKey(text3)) { if (warn) { global::ExtraSlots.ExtraSlots.LogWarning("Duplicate localization '" + text3 + "' for " + Plugin.Info.Metadata.Name + ". Skipping " + item3); } } else { localizationFiles[text3] = item3; } } break; } } } } } static Localizer() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown PlaceholderProcessors = new Dictionary>>(); loadedTexts = new Dictionary>(); localizationLanguage = new ConditionalWeakTable(); localizationObjects = new List>(); fileExtensions = new List { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static byte[]? LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("Translations." + language + fileExtension); if (array != null) { return array; } } return null; } public static byte[]? ReadEmbeddedFileBytes(string resourceFileName, Assembly? containingAssembly = null) { string resourceFileName2 = resourceFileName; using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName2, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace ExtraSlots { internal static class DebugLogging { [HarmonyPatch(typeof(Player), "CreateTombStone")] internal static class Player_CreateTombstone_LoggingItems { [HarmonyPriority(800)] private static void Prefix(Player __instance) { if (IsDebugEnabled && Slots.IsValidPlayer((Character)(object)__instance)) { ExtraSlots.LogDebug("Player.CreateTombStone:Prefix Player Item List:"); ((Humanoid)__instance).GetInventory().LogInventory(); } } [HarmonyPriority(0)] private static void Finalizer(Player __instance) { if (IsDebugEnabled && Slots.IsValidPlayer((Character)(object)__instance)) { ExtraSlots.LogDebug("Player.CreateTombStone:Finalizer Player Item List:"); ((Humanoid)__instance).GetInventory().LogInventory(); } } } [HarmonyPatch(typeof(Inventory), "MoveInventoryToGrave")] internal static class Inventory_MoveInventoryToGrave_LoggingItems { [HarmonyPriority(800)] private static void Prefix(Inventory __instance, Inventory original) { if (IsDebugEnabled) { ExtraSlots.LogDebug("Inventory.MoveInventoryToGrave:Prefix"); ExtraSlots.LogDebug("From inventory " + GetInventoryState(original)); original.LogInventory(); ExtraSlots.LogDebug("To inventory " + GetInventoryState(__instance)); __instance.LogInventory(); } } [HarmonyPriority(0)] private static void Finalizer(Inventory __instance, Inventory original) { if (IsDebugEnabled) { ExtraSlots.LogDebug("Inventory.MoveInventoryToGrave:Finalizer"); ExtraSlots.LogDebug("From inventory " + GetInventoryState(original)); original.LogInventory(); ExtraSlots.LogDebug("To inventory " + GetInventoryState(__instance)); __instance.LogInventory(); } } } internal static bool IsDebugEnabled => ExtraSlots.loggingEnabled.Value && ExtraSlots.loggingDebugEnabled.Value; internal static void LogItem(ItemData item) { //IL_0012: 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) string text = $"{item.m_shared.m_name} {item.m_gridPos} "; Slots.Slot itemSlot = Slots.GetItemSlot(item); ExtraSlots.LogDebug(text + ((itemSlot != null) ? $"slot: {itemSlot} {itemSlot.GridPosition}" : "")); } internal static string GetInventoryState(Inventory inventory) { object[] obj = new object[6] { inventory.m_name, null, null, null, null, null }; Player localPlayer = Player.m_localPlayer; obj[1] = ((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null) == inventory; obj[2] = inventory.m_width; obj[3] = inventory.m_height; obj[4] = inventory.m_totalWeight; obj[5] = inventory.m_inventory.Count; return string.Format("name:{0} isPlayer:{1} size:{2}x{3} weight:{4} items:{5}", obj); } internal static void LogInventory(this Inventory inventory) { CollectionExtensions.Do((IEnumerable)inventory.GetAllItemsInGridOrder(), (Action)LogItem); } } public static class ItemNameTokens { [HarmonyPatch(typeof(Player), "Load")] private static class Player_Load_UpdateRegisters { private static void Prefix() { UpdateRegisters(); } } public static readonly Dictionary itemNames = new Dictionary(StringComparer.OrdinalIgnoreCase); public static void UpdateRegisters() { if (!Object.op_Implicit((Object)(object)ObjectDB.instance)) { return; } foreach (GameObject item in ObjectDB.instance.m_items) { if ((Object)(object)item == (Object)null) { continue; } ItemDrop component = item.GetComponent(); if (component == null) { continue; } ItemData itemData = component.m_itemData; if (itemData != null) { SharedData shared = itemData.m_shared; if (shared != null && shared.m_name.StartsWith("$")) { itemNames[((Object)item).name] = shared.m_name; itemNames[shared.m_name] = shared.m_name; } } } Slots.UpdateCustomItemLists(); ExtraUtilitySlots.UpdateUniqueEquipped(); TombStoneInteraction.UpdateItemLists(); } public static string GetItemName(this string input) { return CollectionExtensions.GetValueOrDefault((IReadOnlyDictionary)itemNames, input.Trim(), input); } } public static class LightenedSlots { private static readonly List m_affectedRows = new List(); public static bool IsEnabled => ExtraSlots.lightenedSlotsStartIndex.Value != 0; public static float WeightFactor => ExtraSlots.lightenedSlotsWeightFactor.Value; public static bool IsRowAffected(int row) { return IsEnabled && m_affectedRows.Contains(row); } public static void UpdateState() { UpdateAffectedRows(); InventoryInteraction.UpdateTotalWeight(); } public static void UpdateAffectedRows() { m_affectedRows.Clear(); if (!IsEnabled || !SlotsProgression.IsPlayerKeyItemConditionMet(ExtraSlots.lightenedSlotsPlayerKey.Value, ExtraSlots.lightenedSlotsItemDiscovered.Value)) { return; } for (int i = 0; i < Slots.InventoryHeightPlayer; i++) { if (!ExtraSlots.lightenedSlotsOnlyExtraRows.Value || i >= 4) { if (ExtraSlots.lightenedSlotsStartIndex.Value < 0 && i >= ExtraSlots.lightenedSlotsStartIndex.Value + Slots.InventoryHeightPlayer) { m_affectedRows.Add(i); } else if (ExtraSlots.lightenedSlotsStartIndex.Value > 0 && i >= ExtraSlots.lightenedSlotsStartIndex.Value - 1) { m_affectedRows.Add(i); } } } } } internal class CustomConfigs { internal class ConfigurationManagerAttributes { [UsedImplicitly] public Action? CustomDrawer; } internal static object? configManager; internal static Type? configManagerStyles; internal static GUIStyle GetStyle(GUIStyle other) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (configManagerStyles == null) { return other; } FieldInfo fieldInfo = AccessTools.Field(configManagerStyles, "fontSize"); if (fieldInfo == null) { return other; } return new GUIStyle(other) { fontSize = (int)fieldInfo.GetValue(configManagerStyles) }; } internal static void Awake() { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager"); Type type = assembly?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); configManagerStyles = assembly?.GetType("ConfigurationManager.ConfigurationManagerStyles"); } internal static Action DrawSeparatedStrings(string splitString) { string splitString2 = splitString; return delegate(ConfigEntryBase cfg) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select((object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); bool flag = false; GUILayout.BeginVertical(Array.Empty()); List list = new List(); List list2 = ((string)cfg.BoxedValue).Split(new string[1] { splitString2 }, StringSplitOptions.None).ToList(); for (int i = 0; i < list2.Count; i++) { GUILayout.BeginHorizontal(Array.Empty()); string text = list2[i]; string text2 = GUILayout.TextField(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (text2 != text && !valueOrDefault) { flag = true; } if (GUILayout.Button("x", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; } else { list.Add(text2); } if (GUILayout.Button("+", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; list.Add(""); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString2, list); } }; } internal static Action DrawOrderedFixedStrings(string splitString) { string splitString2 = splitString; return delegate(ConfigEntryBase cfg) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select((object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); bool flag = false; GUILayout.BeginVertical(Array.Empty()); string[] array = ((string)cfg.BoxedValue).Split(new string[1] { splitString2 }, StringSplitOptions.None).ToArray(); for (int i = 0; i < array.Length; i++) { GUILayout.BeginHorizontal(Array.Empty()); string text = array[i]; GUILayout.Label(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("ʌ", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault && (flag = i > 0)) { ref string reference = ref array[i]; ref string reference2 = ref array[i - 1]; string text2 = array[i - 1]; string text3 = array[i]; reference = text2; reference2 = text3; } if (GUILayout.Button("v", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault && (flag = i < array.Length - 1)) { ref string reference = ref array[i]; ref string reference3 = ref array[i + 1]; string text3 = array[i + 1]; string text2 = array[i]; reference = text3; reference3 = text2; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString2, array); } }; } } public static class EquipmentPanel { public class SidePanelDefaults { public bool active; public Vector2 anchoredPosition = Vector2.zero; public Vector2 anchorMin = Vector2.zero; public Vector2 anchorMax = Vector2.zero; } private static class SlotPositions { private static int Column(int i) { return i / 3; } private static int Row(int i) { return i % 3; } private static int LastEquipmentRow() { return Row(equipmentSlotsCount - 1); } internal static int LastEquipmentColumn() { return Column(equipmentSlotsCount - 1); } internal static Vector2 GetEquipmentTileOffset(int i) { //IL_0079: 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_0081: Unknown result type (might be due to invalid IL or missing references) int x = Column(i) * 4 + ((ExtraSlots.equipmentSlotsAlignment.Value == ExtraSlots.SlotsAlignment.VerticalTopHorizontalMiddle && Row(i) > LastEquipmentRow()) ? 1 : 0) * 2 + Math.Max(quickSlotsCount - 1 - LastEquipmentColumn(), 0) * 2; int y = Row(i) * 4 + Math.Max((ExtraSlots.equipmentSlotsAlignment.Value == ExtraSlots.SlotsAlignment.VerticalMiddleHorizontalLeft && Column(i) == LastEquipmentColumn()) ? (2 - LastEquipmentRow()) : 0, 0) * 2; return GetSlotPosition(x, y); } internal static Vector2 GetQuickSlotTileOffset(int i) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) int x = i * 4 + Math.Max(ExtraSlots.quickSlotsAlignmentCenter.Value ? (LastEquipmentColumn() + 1 - quickSlotsCount) : 0, 0); int y = EquipmentHeight * 4 + 1; return GetSlotPosition(x, y); } internal static Vector2 GetFoodSlotTileOffset(int i) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) int x = Math.Max(LastEquipmentColumn() + 1, quickSlotsCount) * 4 + 1; int y = i * 4; return GetSlotPosition(x, y); } internal static Vector2 GetAmmoSlotTileOffset(int i) { //IL_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references) int x = Math.Max(LastEquipmentColumn() + 1, quickSlotsCount) * 4 + 1 + (Slots.IsFoodSlotAvailable() ? 4 : 0); int y = i * 4; return GetSlotPosition(x, y); } internal static Vector2 GetMiscSlotTileOffset(int i) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) int x = Math.Max(LastEquipmentColumn() + 1, quickSlotsCount) * 4 + i * 4 + 1; int y = EquipmentHeight * 4 + 1; return GetSlotPosition(x, y); } private static Vector2 GetSlotPosition(int x, int y) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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) return PanelPosition + new Vector2((float)x * 70f / 4f, (float)(-y) * 70f / 4f); } } [HarmonyPatch(typeof(InventoryGui), "Show")] private static class InventoryGui_Show_UpdatePanel { private static void Postfix() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { UpdatePanel(); } } } [HarmonyPatch(typeof(InventoryGui), "OnDestroy")] private static class InventoryGui_OnDestroy_ClearObjects { private static void Postfix() { ClearPanel(); } } [HarmonyPatch(typeof(InventoryGui), "Update")] private static class InventoryGui_Update_UpdateEquipmentPanel { private static void Postfix() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && InventoryGui.IsVisible()) { UpdateEquipmentBackground(); } } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui")] internal static class InventoryGrid_UpdateGui_UpdateSlotsOnDirty { private static void Prefix(InventoryGrid __instance, ref int __state) { if (!((Object)(object)__instance != (Object)(object)InventoryGui.instance.m_playerGrid)) { __state = __instance.m_elements.Count; } } private static void Postfix(InventoryGrid __instance, int __state) { if (!((Object)(object)__instance != (Object)(object)InventoryGui.instance.m_playerGrid)) { if (__state != __instance.m_elements.Count) { MarkDirty(); } UpdateInventorySlots(); } } } [HarmonyPatch(typeof(InventoryGui), "SetupDragItem")] private static class InventoryGui_SetupDragItem_UpdateSlotsOnItemDrag { private static void Prefix(InventoryGui __instance, ref bool __state) { __state = Object.op_Implicit((Object)(object)__instance.m_dragGo); } private static void Postfix(InventoryGui __instance, bool __state) { MarkDirty(); if (!Object.op_Implicit((Object)(object)__instance.m_dragGo) && __state) { UpdateSidePanels(); } } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGamepad")] public static class InventoryGrid_UpdateGamepad_GamepadSupport { public static Vector2i FindEquipmentSlot(int row = -1, Slots.Slot slotRow = null, int col = -1, Slots.Slot slotCol = null, bool right = false, Slots.Slot before = null, Slots.Slot after = null) { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) Slots.Slot[] equipmentSlots = Slots.GetEquipmentSlots(); if (row == -1 && slotRow != null) { row = Array.IndexOf(equipmentSlots, slotRow) % 3; } if (col == -1 && slotCol != null) { col = Array.IndexOf(equipmentSlots, slotCol) / 3; } int num = ((before == null) ? (-1) : Array.IndexOf(equipmentSlots, before)); int num2 = ((after == null) ? (-1) : Array.IndexOf(equipmentSlots, after)); int num3 = (right ? equipmentSlots.Length : (-1)); while (true) { num3 = ((!right) ? (num3 + 1) : (num3 - 1)); if (num3 < 0 || num3 == equipmentSlots.Length) { break; } if ((num <= -1 || num3 < num) && (num2 <= -1 || num3 > num2)) { if (row == -1 && col == -1) { return equipmentSlots[num3].GridPosition; } if ((row != -1 && row == num3 % 3) || (col != -1 && col == num3 / 3)) { return equipmentSlots[num3].GridPosition; } } } return Slots.emptyPosition; } private static bool Prefix(InventoryGrid __instance) { //IL_0034: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0157: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_055d: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_09de: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0982: Unknown result type (might be due to invalid IL or missing references) //IL_0987: Unknown result type (might be due to invalid IL or missing references) //IL_0919: Unknown result type (might be due to invalid IL or missing references) //IL_091e: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0649: 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_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0bd1: Unknown result type (might be due to invalid IL or missing references) //IL_09a2: Unknown result type (might be due to invalid IL or missing references) //IL_09a7: Unknown result type (might be due to invalid IL or missing references) //IL_093f: Unknown result type (might be due to invalid IL or missing references) //IL_0944: Unknown result type (might be due to invalid IL or missing references) //IL_08b9: Unknown result type (might be due to invalid IL or missing references) //IL_08ae: Unknown result type (might be due to invalid IL or missing references) //IL_08b3: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0964: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_0a3d: Unknown result type (might be due to invalid IL or missing references) //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_0b51: Unknown result type (might be due to invalid IL or missing references) //IL_0b1e: Unknown result type (might be due to invalid IL or missing references) //IL_0b23: Unknown result type (might be due to invalid IL or missing references) //IL_0aeb: Unknown result type (might be due to invalid IL or missing references) //IL_0af0: Unknown result type (might be due to invalid IL or missing references) //IL_0b45: Unknown result type (might be due to invalid IL or missing references) //IL_0b4a: Unknown result type (might be due to invalid IL or missing references) //IL_0aa2: Unknown result type (might be due to invalid IL or missing references) //IL_0aa7: Unknown result type (might be due to invalid IL or missing references) //IL_0b95: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)InventoryGui.instance.m_playerGrid || !__instance.m_uiGroup.IsActive || Console.IsVisible()) { return true; } Slots.Slot slotInGrid = Slots.GetSlotInGrid(__instance.m_selected); if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyLStickLeft")) { ExtraSlots.LogDebug($"From {__instance.m_selected} {slotInGrid} left"); if (slotInGrid != null) { if (slotInGrid.IsAmmoSlot) { __instance.m_selected.x += 3; Slots.Slot slotInGrid2 = Slots.GetSlotInGrid(__instance.m_selected); if (slotInGrid2 == null || !slotInGrid2.IsActive) { int num = __instance.m_selected.x % 3; __instance.m_selected = FindEquipmentSlot(num, null, -1, null, right: true); if (__instance.m_selected == Slots.emptyPosition) { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, num); } } } else if (slotInGrid.IsFoodSlot) { int num2 = __instance.m_selected.x % 3; __instance.m_selected = FindEquipmentSlot(num2, null, -1, null, right: true); if (__instance.m_selected == Slots.emptyPosition) { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, num2); } } else if (slotInGrid.IsQuickSlot) { __instance.m_selected.x--; if (__instance.m_selected.x < 0) { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, 3); } } else if (slotInGrid.IsMiscSlot) { __instance.m_selected.x--; Slots.Slot slotInGrid3 = Slots.GetSlotInGrid(__instance.m_selected); if (slotInGrid3 == null) { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, 3); } else if (!slotInGrid3.IsActive) { if (slotInGrid3.IsQuickSlot) { IEnumerable source = from slot in Slots.GetQuickSlots() where slot.IsActive select slot; if (source.Any()) { __instance.m_selected = source.Last().GridPosition; } else { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, 3); } } else if (slotInGrid3.IsMiscSlot && quickSlotsCount == 0) { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, 3); } else { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, 3); } } } else { __instance.m_selected = FindEquipmentSlot(-1, slotInGrid, -1, null, right: true, slotInGrid); if (__instance.m_selected.x < 0) { __instance.m_selected = new Vector2i(Slots.InventoryWidth - 1, Array.IndexOf(Slots.GetEquipmentSlots(), slotInGrid) % 3); } } return false; } } if (ZInput.GetButtonDown("JoyDPadRight") || ZInput.GetButtonDown("JoyLStickRight")) { ExtraSlots.LogDebug($"From {__instance.m_selected} {slotInGrid} right"); if (slotInGrid != null) { if (slotInGrid.IsFoodSlot) { Slots.Slot slotInGrid4 = Slots.GetSlotInGrid(new Vector2i(__instance.m_selected.x - 3, __instance.m_selected.y)); if (slotInGrid4 != null && slotInGrid4.IsActive) { __instance.m_selected = slotInGrid4.GridPosition; } } else { if (slotInGrid.IsAmmoSlot) { return false; } if (slotInGrid.IsMiscSlot) { Slots.Slot slotInGrid5 = Slots.GetSlotInGrid(new Vector2i(__instance.m_selected.x + 1, __instance.m_selected.y)); if (slotInGrid5 != null && slotInGrid5.IsActive) { __instance.m_selected = slotInGrid5.GridPosition; } } else if (slotInGrid.IsQuickSlot) { if (__instance.m_selected.x < quickSlotsCount - 1) { Slots.Slot slotInGrid6 = Slots.GetSlotInGrid(new Vector2i(__instance.m_selected.x + 1, __instance.m_selected.y)); if (slotInGrid6 != null && slotInGrid6.IsActive) { __instance.m_selected = slotInGrid6.GridPosition; } } else { IEnumerable source2 = from slot in Slots.GetMiscSlots() where slot.IsActive select slot; if (source2.Any()) { __instance.m_selected = source2.First().GridPosition; } } } else { __instance.m_selected = FindEquipmentSlot(-1, slotInGrid, -1, null, right: false, null, slotInGrid); if (__instance.m_selected.x < 0) { Slots.Slot[] array = (from slot in Slots.GetFoodSlots() where slot.IsActive select slot).ToArray(); if (array.Length == 3) { __instance.m_selected = array[Array.IndexOf(Slots.GetEquipmentSlots(), slotInGrid) % 3].GridPosition; return false; } Slots.Slot[] array2 = (from slot in Slots.GetAmmoSlots() where slot.IsActive select slot).ToArray(); if (array2.Length == 3) { __instance.m_selected = array2[Array.IndexOf(Slots.GetEquipmentSlots(), slotInGrid) % 3].GridPosition; return false; } } if (__instance.m_selected.x < 0) { __instance.m_selected = slotInGrid.GridPosition; } } } return false; } if (__instance.m_selected.x >= Slots.InventoryWidth - 1) { if (__instance.m_selected.y > 2) { IEnumerable source3 = from slot in Slots.GetQuickSlots() where slot.IsActive select slot; if (source3.Any()) { __instance.m_selected = source3.First().GridPosition; return false; } IEnumerable source4 = from slot in Slots.GetMiscSlots() where slot.IsActive select slot; if (source4.Any()) { __instance.m_selected = source4.First().GridPosition; return false; } __instance.m_selected = new Vector2i(0, Slots.InventoryHeightPlayer); } else { Vector2i val = FindEquipmentSlot(Math.Min(__instance.m_selected.y, equipmentSlotsCount - 1)); if (val != Slots.emptyPosition) { __instance.m_selected = val; } } return false; } } if (ZInput.GetButtonDown("JoyDPadUp") || ZInput.GetButtonDown("JoyLStickUp")) { ExtraSlots.LogDebug($"From {__instance.m_selected} {slotInGrid} up"); if (slotInGrid != null) { if (slotInGrid.IsFoodSlot) { __instance.m_selected.x--; if (__instance.m_selected.x < 3) { __instance.m_selected = slotInGrid.GridPosition; } } else if (slotInGrid.IsAmmoSlot) { __instance.m_selected.x--; if (__instance.m_selected.x < 0) { __instance.m_selected = slotInGrid.GridPosition; } } else if (slotInGrid.IsMiscSlot) { if (slotInGrid.Index == 6) { Slots.Slot slot2 = Slots.GetFoodSlots().Last(); __instance.m_selected = ((slot2 != null && slot2.IsActive) ? slot2 : Slots.GetAmmoSlots().Last()).GridPosition; } else if (slotInGrid.Index == 7) { __instance.m_selected = Slots.GetAmmoSlots().Last().GridPosition; } Slots.Slot slotInGrid7 = Slots.GetSlotInGrid(__instance.m_selected); if (slotInGrid7 == null || !slotInGrid7.IsActive) { __instance.m_selected = slotInGrid.GridPosition; } } else if (slotInGrid.IsQuickSlot) { __instance.m_selected = FindEquipmentSlot(-1, null, Math.Min(__instance.m_selected.x, equipmentSlotsCount / 3), null, right: true); if (__instance.m_selected.x < 0) { __instance.m_selected = FindEquipmentSlot(-1, null, -1, null, right: true); } if (__instance.m_selected.x < 0) { __instance.m_selected = slotInGrid.GridPosition; } } else { __instance.m_selected = FindEquipmentSlot(-1, null, Array.IndexOf(Slots.GetEquipmentSlots(), slotInGrid) / 3, null, right: true, slotInGrid); if (__instance.m_selected.x < 0) { __instance.m_selected = slotInGrid.GridPosition; } } return false; } } if (ZInput.GetButtonDown("JoyDPadDown") || ZInput.GetButtonDown("JoyLStickDown")) { ExtraSlots.LogDebug($"From {__instance.m_selected} {slotInGrid} down"); if (slotInGrid != null) { if (slotInGrid.IsQuickSlot || slotInGrid.IsMiscSlot) { if (!__instance.jumpToNextContainer) { return false; } __instance.OnMoveToLowerInventoryGrid?.Invoke(__instance.m_selected); return false; } if (slotInGrid.IsAmmoSlot) { __instance.m_selected.x++; if (__instance.m_selected.x > 2) { Slots.Slot slot3 = Slots.GetMiscSlots()[1]; __instance.m_selected = ((slot3 != null && slot3.IsActive) ? slot3 : Slots.GetMiscSlots()[0]).GridPosition; } } else if (slotInGrid.IsFoodSlot) { __instance.m_selected.x++; if (__instance.m_selected.x > 5) { __instance.m_selected = Slots.GetMiscSlots()[0].GridPosition; } } else if (slotInGrid.IsEquipmentSlot) { int num3 = Array.IndexOf(Slots.GetEquipmentSlots(), slotInGrid) / 3; __instance.m_selected = FindEquipmentSlot(-1, null, num3, null, right: false, null, slotInGrid); if (__instance.m_selected.x < 0) { __instance.m_selected = Slots.GetQuickSlots()[num3].GridPosition; } } Slots.Slot slotInGrid8 = Slots.GetSlotInGrid(__instance.m_selected); if (slotInGrid8 == null || !slotInGrid8.IsActive) { if (!__instance.jumpToNextContainer) { return false; } __instance.OnMoveToLowerInventoryGrid?.Invoke(__instance.m_selected); } return false; } if (__instance.m_selected.y >= Slots.InventoryHeightPlayer - 1) { __instance.OnMoveToLowerInventoryGrid?.Invoke(__instance.m_selected); return false; } } return true; } private static void Postfix(InventoryGrid __instance, bool __runOriginal) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!__runOriginal) { ExtraSlots.LogDebug($"Selected {__instance.m_selected}"); } } } [HarmonyPatch(typeof(InventoryGrid), "SetSelection")] public static class InventoryGrid_SetSelection_GamepadSupport { private static void Postfix(Vector2i pos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) pos.y = Math.Min(pos.y, Slots.InventoryHeightPlayer - 1); ExtraSlots.LogDebug($"SetSelection {pos}"); } } [HarmonyPatch(typeof(RectTransformUtility), "RectangleContainsScreenPoint", new Type[] { typeof(RectTransform), typeof(Vector2) })] public static class RectTransformUtility_RectangleContainsScreenPoint_BackpacksCompat { private static void Postfix(RectTransform rect, Vector2 screenPoint, ref bool __result) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)InventoryGui.instance) || (Object)(object)rect != (Object)(object)InventoryGui.instance.m_playerGrid.m_gridRoot) { return; } for (int i = 0; i < Math.Min(Slots.slots.Length, InventoryGui.instance.m_playerGrid.m_elements.Count - Slots.InventorySizePlayer); i++) { Transform transform = InventoryGui.instance.m_playerGrid.m_elements[Slots.InventorySizePlayer + i].m_go.transform; if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)(object)((transform is RectTransform) ? transform : null), screenPoint)) { __result = true; break; } } } } private const string BackgroundName = "ExtraSlotsEquipmentPanel"; private const float tileSpace = 6f; private const float tileSize = 70f; private const float interslotSpaceInTiles = 0.25f; private const float inventoryPanelOffset = 100f; private static int equipmentSlotsCount = 0; internal static int quickSlotsCount = 0; public static RectTransform inventoryDarken = null; public static RectTransform inventoryBackground = null; public static Image inventoryBackgroundImage = null; public static RectTransform equipmentBackground = null; public static Image equipmentBackgroundImage = null; public static RectTransform selectedFrame = null; public static RectTransform inventorySelectedFrame = null; private static bool isDirty = true; private static int updateSidePanelsInFrames; private static int updateSidePanelsPreviousExtraRows = -10; private static Color normalColor = Color.clear; private static Color highlightedColor = Color.clear; private static Color normalColorUnfit = Color.clear; private static Color highlightedColorUnfit = Color.clear; private static Material iconMaterial; private static Vector3 originalScale = Vector3.zero; private static Vector2 originalTooltipPosition = Vector2.zero; internal static Sprite ammoSlot; internal static Sprite miscSlot; internal static Sprite quickSlot; internal static Sprite lightenedSlot; internal static Sprite background; private static readonly Dictionary defaultPositionsSidePanels = new Dictionary(); private static float InventoryPanelWidth { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) float result; if (!Object.op_Implicit((Object)(object)InventoryGui.instance)) { result = 0f; } else { Rect rect = InventoryGui.instance.m_player.rect; result = ((Rect)(ref rect)).width; } return result; } } private static float PanelWidth => ((float)Math.Max(quickSlotsCount, SlotPositions.LastEquipmentColumn() + 1) + FoodAmmoSlotsWidthInTiles) * 70f + 3f; private static float PanelHeight => (((quickSlotsCount > 0 || Slots.IsFirstMiscSlotAvailable()) ? 1.25f : 0f) + (float)EquipmentHeight) * 70f + 3f; private static Vector2 PanelOffset => new Vector2(ExtraSlots.equipmentPanelOffset.Value.x, 0f - ExtraSlots.equipmentPanelOffset.Value.y); private static Vector2 PanelPosition => new Vector2(InventoryPanelWidth + 100f, 0f) + PanelOffset; private static float FoodAmmoSlotsWidthInTiles => ((Slots.IsFoodSlotAvailable() || Slots.IsAmmoSlotAvailable()) ? 0.25f : 0f) + (Slots.IsFoodSlotAvailable() ? 1f : 0f) + (Slots.IsAmmoSlotAvailable() ? 1f : 0f); private static int EquipmentHeight => (equipmentSlotsCount > 3 || Slots.IsFoodSlotAvailable() || Slots.IsAmmoSlotAvailable()) ? 3 : equipmentSlotsCount; private static RectTransform SelectedFrameArmor { get { Transform obj = ((Transform)InventoryGui.instance.m_player).Find("selected_frame/selected (2)"); return (RectTransform)(object)((obj is RectTransform) ? obj : null); } } private static RectTransform SelectedFrameWeight { get { Transform obj = ((Transform)InventoryGui.instance.m_player).Find("selected_frame/selected (3)"); return (RectTransform)(object)((obj is RectTransform) ? obj : null); } } public static void MarkDirty() { isDirty = true; } public static void UpdateSidePanels() { updateSidePanelsInFrames = 3; } internal static void UpdateSlotsCount() { equipmentSlotsCount = Slots.GetEquipmentSlotsCount(); quickSlotsCount = Slots.GetQuickSlotsCount(); } internal static void ReorderVanillaSlots() { List list = Slots.VanillaOrder.Split(',').ToList(); List list2 = (from s in ExtraSlots.vanillaSlotsOrder.Value.Split(',') select s.Trim() into s where Slots.Slot.IsVanillaSlotID(s) select s).Distinct().ToList(); foreach (string item in list) { if (!list2.Contains(item)) { list2.Add(item); } } List list3 = Slots.slots.Where((Slots.Slot s) => s?.IsVanillaEquipment() ?? false).ToList(); CollectionExtensions.Do((IEnumerable)list3, (Action)delegate(Slots.Slot slot) { slot.CacheItem(); }); List list4 = new List(); foreach (string id in list2) { Slots.Slot slot2 = list3.FirstOrDefault((Slots.Slot s) => s.ID == id); if (slot2 != null) { list4.Add(slot2); } } list4.AddRange(list3.Except(list4)); int num = 0; for (int i = 0; i < Slots.slots.Length; i++) { if (Slots.slots[i] != null && Slots.slots[i].IsVanillaEquipment()) { Slots.slots[i] = list4[num++]; } } for (int j = 0; j < Slots.slots.Length; j++) { if (Slots.slots[j] != null && Slots.slots[j].IsVanillaEquipment()) { Slots.slots[j].SetSlotIndex(j); Slots.slots[j].UpdateGridPosition(); } } SetSlotsPositions(); Inventory playerInventory = Slots.PlayerInventory; if (playerInventory != null) { playerInventory.Changed(); } if (ExtraSlots.vanillaSlotsOrder.Value != Slots.VanillaOrder) { ExtraSlots.LogInfo("Vanilla slots reordered: " + GeneralExtensions.Join((IEnumerable)list2, (Func)null, ", ")); } } internal static void UpdatePanel() { UpdateSlotsCount(); UpdateBackground(); SetSlotsPositions(); MarkDirty(); UpdateSidePanels(); } internal static void UpdateInventorySlots() { //IL_002d: 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_008c: 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_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) InventoryGui.instance.m_playerGrid.m_gridRoot.SetSizeWithCurrentAnchors((Axis)1, (float)Slots.InventoryHeightPlayer * InventoryGui.instance.m_playerGrid.m_elementSpace); if (originalScale == Vector3.zero && InventoryGui.instance.m_playerGrid.m_elements.Count > 0) { Image icon = InventoryGui.instance.m_playerGrid.m_elements[0].m_icon; if (icon != null && (Object)(object)((Graphic)icon).material != (Object)null) { originalScale = ((Component)icon).transform.localScale; } } int inventorySizePlayer = Slots.InventorySizePlayer; for (int i = 0; i < Math.Min(Slots.slots.Length, InventoryGui.instance.m_playerGrid.m_elements.Count - inventorySizePlayer); i++) { SetSlotBackgroundImage(InventoryGui.instance.m_playerGrid.m_elements[inventorySizePlayer + i], Slots.slots[i]); } for (int j = 0; j < Math.Min(inventorySizePlayer, InventoryGui.instance.m_playerGrid.m_elements.Count); j++) { SetInventorySlotBackgroundImage(InventoryGui.instance.m_playerGrid.m_elements[j], LightenedSlots.IsRowAffected(j / Slots.InventoryWidth)); } if (!isDirty || Slots.PlayerInventory == null || !Object.op_Implicit((Object)(object)InventoryGui.instance.m_playerGrid)) { return; } bool flag = InventoryGui.instance.m_dragItem != null && ((Humanoid)Slots.CurrentPlayer).IsItemEquiped(InventoryGui.instance.m_dragItem) && Slots.IsItemInEquipmentSlot(InventoryGui.instance.m_dragItem); for (int k = 0; k < Math.Min(InventoryGui.instance.m_playerGrid.m_elements.Count, inventorySizePlayer); k++) { Element obj = InventoryGui.instance.m_playerGrid.m_elements[k]; object button; if (obj == null) { button = null; } else { GameObject go = obj.m_go; button = ((go != null) ? go.GetComponent