Ejemplo n.º 1
0
        public static void OnMoveItem(WorldClient client, INetPacketStream packet)
        {
            var moveItemPacket = new MoveItemPacket(packet);
            var inventoryEvent = new InventoryMoveEventArgs(moveItemPacket.SourceSlot, moveItemPacket.DestinationSlot);

            client.Player.NotifySystem <InventorySystem>(inventoryEvent);
        }
        protected override void OnHandle(IPacket packet, NetState netState, ServerWorldState worldState)
        {
            MoveItemPacket incomingPacket = (MoveItemPacket)packet;
            //if (incomingPacket.MobileId != netState.WorldId)
            //{
            //    netState.SendError(0, string.Format("Invalid CMD: '{0},{1},{2}'.", incomingPacket.PacketId, incomingPacket.MobileId, incomingPacket.ItemId));
            //    return;
            //}

            ServerCharacter serverCharacter = (ServerCharacter)worldState.GetCharacter(netState.WorldId);
            Item            item            = (Item)worldState.GetItem(incomingPacket.ItemID);

            if (serverCharacter != null && item != null)
            {
                if (incomingPacket.MoveToID.HasValue) //item.Data.IsWorldItem &&
                {
                    int           containerID = incomingPacket.MoveToID.Value;
                    ContainerItem moveTo      = (ContainerItem)worldState.GetItem(containerID);
                    if (moveTo != null)
                    {
                        if (serverCharacter.MoveItem(item, moveTo))
                        {
                            worldState.SaveItemPosition(item);
                            this.OnSuccessfulChange(serverCharacter.CurrentMapId, serverCharacter.Id, containerID, incomingPacket.ItemID, worldState);
                        }
                    }
                }
                else if (incomingPacket.MoveToPosition.HasValue)
                {
                    Point moveToPostion = incomingPacket.MoveToPosition.Value;
                    if (serverCharacter.MoveItem(item, moveToPostion))
                    {
                        worldState.SaveItemPosition(item);
                        this.OnSuccessfulChange(serverCharacter.CurrentMapId, serverCharacter.Id, moveToPostion, incomingPacket.ItemID, worldState);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void OnMoveItem(IWorldClient client, MoveItemPacket packet)
 {
     _inventorySystem.MoveItem(client.Player, packet.SourceSlot, packet.DestinationSlot);
 }
Ejemplo n.º 4
0
        internal void MoveItem(IItem itemToMove, Point worldPosition)
        {
            MoveItemPacket useItemPacket = new MoveItemPacket(itemToMove.Id, worldPosition);

            worldServerClient.Send(useItemPacket);
        }
Ejemplo n.º 5
0
        internal void MoveItem(IItem itemToMove, IItem toContainer)
        {
            MoveItemPacket useItemPacket = new MoveItemPacket(itemToMove.Id, toContainer.Id);

            worldServerClient.Send(useItemPacket);
        }
Ejemplo n.º 6
0
        internal void DropItem(ClientCharacter playerCharacter, IItem item)
        {
            MoveItemPacket packet = new MoveItemPacket(item.Id, playerCharacter.Position);

            worldServerClient.Send(packet);
        }