コード例 #1
0
        public bool DragItem(uint itemId, int count = 0)
        {
            int rescount = count;

            if (_charStatsService.Dead)
            {
                throw new InvalidOperationException("Error: " + MethodBase.GetCurrentMethod().ToString() + " [Character is dead]");
            }

            if (PickedUpItem != 0 && _gameObjectService.IsObjectExists(PickedUpItem))
            {
                throw new InvalidOperationException("Error: " + MethodBase.GetCurrentMethod().ToString() + " [Must drop current item before dragging a new one]");
            }

            int quantity = _gameObjectService.GetQuantity(itemId);

            if (!_gameObjectService.IsObjectExists(itemId))
            {
                throw new InvalidOperationException("Error: " + MethodBase.GetCurrentMethod().ToString() + " [Object not found]");
            }

            if (count <= 0 || count > quantity)
            {
                rescount = quantity;
            }

            _client.SendPacket(PacketType.SCDragItem, itemId, rescount);

            return(PickedUpItem == itemId);
        }