Esempio n. 1
0
        /// <summary> Fills the designated slot with the items of the same time. </summary>
        /// <param name="slotNumber"> Zero-based index of the slot to fill. </param>
        /// <param name="stack"> The stack to add to the storage. </param>
        /// <returns> The remaining items which could not be added. </returns>
        private InventoryStack Fill(int slotNumber, InventoryStack stack)
        {
            var slot = _slots[slotNumber];

            int numberToAdd = Math.Min(slot.ExtraCapacity, stack.Quantity);

            // add that much to the current slot
            Write(slotNumber, slot.Plus(numberToAdd));

            // reduce the current stack by that much
            return(stack.Plus(-numberToAdd));
        }
Esempio n. 2
0
        /// <summary> Puts items of the designated into the designated empty slot. </summary>
        /// <param name="slotNumber"> The position in which to put the stack. </param>
        /// <param name="stack"> The stack to add to the storage. </param>
        /// <returns> The remaining items that could not be placed in the designated slot. </returns>
        private InventoryStack Put(int slotNumber, InventoryStack stack)
        {
            if (!_slots[slotNumber].IsEmpty)
            {
                return(stack);
            }

            int numberToAdd = Math.Min(stack.Model.StackAmount, stack.Quantity);

            // add that much to the current slot
            Write(slotNumber, new InventoryStack(stack.Model, numberToAdd));

            // reduce the current stack by that much
            stack = stack.Plus(-numberToAdd);
            return(stack);
        }