package ru.dbotthepony.kstarbound.defs.world

import ru.dbotthepony.kommons.io.readVector2i
import ru.dbotthepony.kommons.io.writeStruct2i
import ru.dbotthepony.kommons.vector.Vector2i
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
import java.io.DataInputStream
import java.io.DataOutputStream

@JsonFactory
data class CelestialBaseInformation(
	val planetOrbitalLevels: Int = 1,
	val satelliteOrbitalLevels: Int = 1,
	val chunkSize: Int = 1,
	val xyCoordRange: Vector2i = Vector2i.ZERO,
	val zCoordRange: Vector2i = Vector2i.ZERO,
) {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(
		stream.readInt(),
		stream.readInt(),
		stream.readInt(),
		stream.readVector2i(),
		stream.readVector2i(),
	)

	fun write(stream: DataOutputStream, isLegacy: Boolean) {
		stream.writeInt(planetOrbitalLevels)
		stream.writeInt(satelliteOrbitalLevels)
		stream.writeInt(chunkSize)
		stream.writeStruct2i(xyCoordRange)
		stream.writeStruct2i(zCoordRange)
	}
}