示例#1
0
        /// <summary>
        /// Updates a slot in the Inventory
        /// </summary>
        /// <param name="slot">Slot to update</param>
        /// <param name="graphic">New graphic index</param>
        /// <param name="amount">New item amount</param>
        /// <param name="time">Current time</param>
        public void Update(InventorySlot slot, GrhIndex graphic, byte amount, TickCount time)
        {
            // If we get an amount of 0, just use UpdateEmpty()
            if (amount == 0)
            {
                UpdateEmpty(slot);
                return;
            }

            if (this[slot] == null)
            {
                // Add a new item
                this[slot] = new ItemEntity(graphic, amount, time);
            }
            else
            {
                // Update an existing item
                var item = this[slot];
                item.GraphicIndex = graphic;
                item.Amount       = amount;
            }
        }
示例#2
0
        /// <summary>
        /// Updates a slot in the Inventory
        /// </summary>
        /// <param name="slot">Slot to update</param>
        /// <param name="graphic">New graphic index</param>
        /// <param name="amount">New item amount</param>
        /// <param name="time">Current time</param>
        public void Update(InventorySlot slot, GrhIndex graphic, byte amount, TickCount time)
        {
            // If we get an amount of 0, just use UpdateEmpty()
            if (amount == 0)
            {
                UpdateEmpty(slot);
                return;
            }

            if (this[slot] == null)
            {
                // Add a new item
                this[slot] = new ItemEntity(graphic, amount, time);
            }
            else
            {
                // Update an existing item
                var item = this[slot];
                item.GraphicIndex = graphic;
                item.Amount = amount;
            }
        }