package ru.dbotthepony.kstarbound.math

import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import ru.dbotthepony.kstarbound.math.vector.Vector4i

object Vector4iTypeAdapter : TypeAdapter<Vector4i>() {
	override fun write(out: JsonWriter, value: Vector4i) {
		`out`.beginArray()
		`out`.value(value.x)
		`out`.value(value.y)
		`out`.value(value.z)
		`out`.value(value.w)
		`out`.endArray()
	}

	override fun read(`in`: JsonReader): Vector4i {
		`in`.beginArray()

		val x = `in`.nextInt()
		val y = `in`.nextInt()
		val z = `in`.nextInt()
		val w = `in`.nextInt()

		`in`.endArray()

		return Vector4i(x, y, z, w)
	}
}