package ru.dbotthepony.kstarbound.defs.world

import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
import com.google.common.collect.ImmutableSet
import ru.dbotthepony.kommons.math.RGBAColor
import ru.dbotthepony.kommons.vector.Vector2d
import ru.dbotthepony.kommons.vector.Vector2i
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
import ru.dbotthepony.kstarbound.util.random.AbstractPerlinNoise

@JsonFactory
data class AsteroidWorldsConfig(
	val biome: String,
	val gravityRange: Vector2d,
	val worldSize: Vector2i,
	val threatRange: Vector2d,
	val environmentStatusEffects: ImmutableSet<String> = ImmutableSet.of(),
	val overrideTech: ImmutableSet<String>? = null,
	val globalDirectives: ImmutableSet<String>? = null,
	val beamUpRule: BeamUpRule = BeamUpRule.SURFACE, // TODO: ??? why surface? in asteroid field.
	val disableDeathDrops: Boolean = false,
	val worldEdgeForceRegions: WorldEdgeForceRegion = WorldEdgeForceRegion.TOP_AND_BOTTOM,
	val asteroidsTop: Int,
	val asteroidsBottom: Int,
	val ambientLightLevel: RGBAColor,
	val blendSize: Double,

	val blockNoise: BlockNoiseConfig? = null,
	val terrains: ImmutableList<Terrain>,
	val emptyTerrain: Terrain,
) {
	@JsonFactory
	data class Terrain(
		val terrainSelector: String,
		val caveSelector: String,
		val bgCaveSelector: String,
		val oreSelector: String,
		val subBlockSelector: String,
	)

	init {
		require(worldSize.x > 0) { "Invalid asteroid worlds width: ${worldSize.x}" }
		require(worldSize.y > 0) { "Invalid asteroid worlds height: ${worldSize.y}" }
	}
}
