예제 #1
0
        private static void HandleReplaceCube(GameSession session, PacketReader packet)
        {
            CoordB coord = packet.Read <CoordB>();

            packet.Skip(1);
            int    replacementItemId  = packet.ReadInt();
            long   replacementItemUid = packet.ReadLong();
            byte   unk       = packet.ReadByte();
            long   unk2      = packet.ReadLong(); // maybe part of rotation?
            float  zRotation = packet.ReadFloat();
            CoordF rotation  = new CoordF();

            rotation.Z = zRotation;

            int plotNumber = MapMetadataStorage.GetPlotNumber(session.Player.MapId, coord);

            if (plotNumber < 0)
            {
                return;
            }
            //TODO: Add and remove appropriate items to warehouse inventory and furnishing inventory

            //TODO: If itemUid is not found, send player to purchase the item
            Item item = new Item(replacementItemId);

            Cube cube = new Cube(item, plotNumber);

            IFieldObject <Cube> fieldCube = session.FieldManager.RequestFieldObject(cube);

            fieldCube.Coord    = coord.ToFloat();
            fieldCube.Rotation = rotation;

            session.FieldManager.BroadcastPacket(ResponseCubePacket.ReplaceCube(session.FieldPlayer, fieldCube));
            session.FieldManager.AddCube(fieldCube, session.FieldPlayer);
        }