예제 #1
0
        /// <summary>
        /// Adds an item to the inventory.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <param name="pos">The position in the inventory.</param>
        /// <returns>Returns true if the item was added.</returns>
        public bool AddItem(ItemInfo item, byte pos)
        {
            if (Count >= 40)
            {
                using (var fmsg = Packets.Message.MessageCore.CreateSystem2(Owner.Name, Core.MessageConst.INVENTORY_FULL))
                    Owner.Send(fmsg);
                return(false);
            }

            if (InventoryItems.TryAdd(pos, item))
            {
                item.OwnerUID = Owner.EntityUID;
                item.Location = Enums.ItemLocation.Inventory;
                Database.CharacterDatabase.SaveInventory(Owner, item, pos);
                SendItemToClient(item);
                return(true);
            }
            return(false);
        }