Пример #1
0
        public static bool Prefix(Inventory __instance, ref Vector2i __result, bool topFirst, int ___m_height, int ___m_width)
        {
            if (__instance.GetName() != "Inventory")
            {
                return(true);
            }

            if (topFirst)
            {
                for (int index1 = 0; index1 < ___m_height; ++index1)
                {
                    if (!EquipmentAndQuickSlots.QuickSlotsEnabled.Value && index1 == ___m_height - 1)
                    {
                        continue;
                    }

                    for (int index2 = 0; index2 < ___m_width; ++index2)
                    {
                        if (EquipmentAndQuickSlots.IsEquipmentSlot(index2, index1))
                        {
                            continue;
                        }

                        if (__instance.GetItemAt(index2, index1) == null)
                        {
                            __result = new Vector2i(index2, index1);
                            return(false);
                        }
                    }
                }
            }
            else
            {
                // Skip the last row
                for (int index1 = ___m_height - 2; index1 >= 0; --index1)
                {
                    for (int index2 = 0; index2 < ___m_width; ++index2)
                    {
                        if (__instance.GetItemAt(index2, index1) == null)
                        {
                            __result = new Vector2i(index2, index1);
                            return(false);
                        }
                    }
                }

                if (EquipmentAndQuickSlots.QuickSlotsEnabled.Value)
                {
                    // Then do the bonus quick slots last
                    for (int index = 0; index < EquipmentAndQuickSlots.QuickUseSlotCount; ++index)
                    {
                        var slotPosition = EquipmentAndQuickSlots.GetQuickSlotPosition(index);
                        if (__instance.GetItemAt(slotPosition.x, slotPosition.y) == null)
                        {
                            __result = slotPosition;
                            return(false);
                        }
                    }
                }
            }
            __result = new Vector2i(-1, -1);

            return(false);
        }