Пример #1
0
        public static bool Prefix(ItemDrop.ItemData item, Inventory ___m_inventory)
        {
            if (!EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value)
            {
                return(true);
            }

            if (_dropping)
            {
                return(false);
            }

            _shouldDrop = false;
            if (item != null && EquipmentAndQuickSlots.IsSlotEquippable(item) && EquipmentAndQuickSlots.IsEquipmentSlot(item.m_gridPos))
            {
                if (___m_inventory.HaveEmptySlot())
                {
                    var correctInventorySlot = ___m_inventory.FindEmptySlot(false);
                    EquipUtil.MoveItemToSlot(___m_inventory, item, correctInventorySlot);
                }
                else
                {
                    _shouldDrop = true;
                }
            }

            return(true);
        }
Пример #2
0
        public static bool Prefix(InventoryGui __instance, InventoryGrid grid, ItemDrop.ItemData item, Vector2i pos, InventoryGrid.Modifier mod, GameObject ___m_dragGo, ItemDrop.ItemData ___m_dragItem)
        {
            if (EquipmentAndQuickSlots.EquipmentSlotsEnabled.Value && EquipmentAndQuickSlots.IsEquipmentSlot(pos))
            {
                if (___m_dragItem != null && EquipmentAndQuickSlots.IsSlotEquippable(___m_dragItem) && EquipmentAndQuickSlots.GetEquipmentTypeForSlot(pos) == ___m_dragItem.m_shared.m_itemType)
                {
                    var player = Player.m_localPlayer;
                    player.UseItem(player.GetInventory(), ___m_dragItem, true);
                    __instance.SetupDragItem(null, null, 1);
                }
                return(false);
            }

            return(true);
        }
Пример #3
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);
        }