package ru.dbotthepony.kstarbound.defs

import ru.dbotthepony.kommons.vector.Vector2d
import ru.dbotthepony.kstarbound.io.readVector2d
import ru.dbotthepony.kstarbound.io.writeStruct2d
import java.io.DataInputStream
import java.io.DataOutputStream

data class InteractRequest(val source: Int, val sourcePos: Vector2d, val target: Int, val targetPos: Vector2d) {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(
		stream.readInt(),
		stream.readVector2d(isLegacy),
		stream.readInt(),
		stream.readVector2d(isLegacy),
	)

	fun write(stream: DataOutputStream, isLegacy: Boolean) {
		stream.writeInt(source)
		stream.writeStruct2d(sourcePos, isLegacy)
		stream.writeInt(target)
		stream.writeStruct2d(targetPos, isLegacy)
	}
}
