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

import ru.dbotthepony.kstarbound.defs.WarpAction
import ru.dbotthepony.kstarbound.network.IServerPacket
import ru.dbotthepony.kstarbound.server.ServerConnection
import java.io.DataInputStream
import java.io.DataOutputStream

class PlayerWarpPacket(val action: WarpAction, val deploy: Boolean) : IServerPacket {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(WarpAction.read(stream, isLegacy), stream.readBoolean())

	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		action.write(stream, isLegacy)
		stream.writeBoolean(deploy)
	}

	override fun play(connection: ServerConnection) {
		connection.enqueueWarp(action, deploy)
	}
}
