package ru.dbotthepony.kstarbound.world.terrain

import ru.dbotthepony.kstarbound.defs.world.TerrainSelectorParameters
import ru.dbotthepony.kstarbound.json.builder.JsonFactory

class FlatSurfaceTerrainSelector(data: Data, parameters: TerrainSelectorParameters) : AbstractTerrainSelector<FlatSurfaceTerrainSelector.Data>(data, parameters) {
	@JsonFactory
	data class Data(val adjustment: Double = 0.0, val flip: Boolean = false)

	private val flip = if (data.flip) -1.0 else 1.0

	override fun get(x: Int, y: Int): Double {
		return flip * (parameters.baseHeight - (y - data.adjustment))
	}

	override val type: TerrainSelectorType
		get() = TerrainSelectorType.FLAT_SURFACE
}
