package ru.dbotthepony.kstarbound.world

import ru.dbotthepony.kommons.io.StreamCodec
import ru.dbotthepony.kommons.vector.Vector2d
import ru.dbotthepony.kstarbound.json.builder.IStringSerializable

enum class RayDirection(val normal: Vector2d, override val jsonName: String) : IStringSerializable {
	LEFT(Vector2d.NEGATIVE_X, "left"),
	RIGHT(Vector2d.POSITIVE_X, "right"),

	UP(Vector2d.POSITIVE_Y, "up"),
	DOWN(Vector2d.NEGATIVE_Y, "down"),
	NONE(Vector2d.ZERO, "any");

	override fun match(name: String): Boolean {
		return name.lowercase() == jsonName
	}

	companion object {
		val CODEC = StreamCodec.Enum(RayDirection::class.java)
	}
}
