package ru.dbotthepony.kstarbound.defs.world

import com.google.common.collect.ImmutableSet
import ru.dbotthepony.kommons.math.RGBAColor
import ru.dbotthepony.kommons.util.Either
import ru.dbotthepony.kommons.vector.Vector2d
import ru.dbotthepony.kommons.vector.Vector2i
import ru.dbotthepony.kstarbound.Registry
import ru.dbotthepony.kstarbound.collect.WeightedList
import ru.dbotthepony.kstarbound.defs.AssetPath
import ru.dbotthepony.kstarbound.defs.dungeon.DungeonDefinition
import ru.dbotthepony.kstarbound.json.builder.JsonFactory

@JsonFactory
data class DungeonWorldsConfig(
	val threatLevel: Double,
	val worldSize: Vector2i,
	val gravity: Either<Double, Vector2d>,
	val airless: Boolean = false,
	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 floating dungeon.
	val disableDeathDrops: Boolean = false,
	val worldEdgeForceRegions: WorldEdgeForceRegion = WorldEdgeForceRegion.TOP,
	val weatherPool: WeightedList<String>? = null,
	val dungeonBaseHeight: Int,
	val dungeonSurfaceHeight: Int = dungeonBaseHeight,
	val dungeonUndergroundLevel: Int = 0,
	val primaryDungeon: Registry.Ref<DungeonDefinition>,
	val biome: String? = null,
	val ambientLightLevel: RGBAColor,

	val musicTrack: AssetPath? = null,
	val dayMusicTrack: AssetPath? = null,
	val nightMusicTrack: AssetPath? = null,

	val ambientNoises: AssetPath? = null,
	val dayAmbientNoises: AssetPath? = null,
	val nightAmbientNoises: AssetPath? = null,
) {
	init {
		require(worldSize.x > 0) { "Invalid asteroid worlds width: ${worldSize.x}" }
		require(worldSize.y > 0) { "Invalid asteroid worlds height: ${worldSize.y}" }
	}
}
