Ejemplo n.º 1
0
        public override void Add(ItemSlot itemsToAdd)
        {
            base.Add(itemsToAdd);

            if (itemsToAdd.IsEmpty == false)
            {
                Resize(Capacity + 1);
                var lastSlot = itemSlots[Capacity - 1];
                ItemSlot.SwapItems(lastSlot, itemsToAdd);
            }
            onItemsUpdated.Invoke();
        }
Ejemplo n.º 2
0
        public void HandleSize()
        {
            for (int i = 0; i < Capacity - 1; i++)
            {
                var current = itemSlots[i];
                var next    = itemSlots[i + 1];
                if (current.IsEmpty && next.IsEmpty == false)
                {
                    ItemSlot.SwapItems(current, next);
                }
            }

            var occupied = itemSlots.Count(slot => !slot.IsEmpty);

            Resize(occupied + 1);
        }
Ejemplo n.º 3
0
        public void Combine(ItemSlot itemsToAdd, ItemSlot target)
        {
            if (itemsToAdd == target)
            {
                return;
            }

            if (ItemInstance.CanStack(itemsToAdd.ItemInstance, target.ItemInstance))
            {
                var quantity = target.Quantity + itemsToAdd.Quantity;
                quantity            = Mathf.Min(quantity, target.ItemInstance.Data.MaxStack);
                itemsToAdd.Quantity = itemsToAdd.Quantity - (quantity - target.Quantity);
                target.Quantity     = quantity;
            }
            else
            {
                ItemSlot.SwapItems(itemsToAdd, target);
            }

            onItemsUpdated.Invoke();
        }