package ru.dbotthepony.kstarbound.network.packets.serverbound

import ru.dbotthepony.kommons.io.readVector3i
import ru.dbotthepony.kommons.io.writeStruct3i
import ru.dbotthepony.kommons.vector.Vector3i
import ru.dbotthepony.kstarbound.network.IServerPacket
import ru.dbotthepony.kstarbound.server.ServerConnection
import ru.dbotthepony.kstarbound.world.SystemWorldLocation
import java.io.DataInputStream
import java.io.DataOutputStream

class FlyShipPacket(val system: Vector3i, val location: SystemWorldLocation = SystemWorldLocation.Transit) : IServerPacket {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(stream.readVector3i(), SystemWorldLocation.read(stream, isLegacy))

	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		stream.writeStruct3i(system)
		location.write(stream, isLegacy)
	}

	override fun play(connection: ServerConnection) {
		connection.flyShip(system, location)
	}
}
