package ru.dbotthepony.kstarbound.defs.tile

import com.google.common.collect.ImmutableList
import ru.dbotthepony.kommons.math.RGBAColor
import ru.dbotthepony.kstarbound.Registry
import ru.dbotthepony.kstarbound.defs.StatusEffectDefinition
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
import ru.dbotthepony.kstarbound.json.builder.JsonIgnore

@JsonFactory
data class LiquidDefinition(
	val name: String,
	val liquidId: Int,
	val description: String = "...",
	val tickDelta: Int = 1,
	val color: RGBAColor,
	val itemDrop: String? = null,
	val statusEffects: ImmutableList<Registry.Ref<StatusEffectDefinition>> = ImmutableList.of(),
	val interactions: ImmutableList<Interaction> = ImmutableList.of(),
	val texture: String,
	val bottomLightMix: RGBAColor,
	val textureMovementFactor: Double,
	@JsonIgnore
	val isMeta: Boolean = false,
) {
	@JsonFactory
	data class Interaction(val liquid: Int, val liquidResult: Int? = null, val materialResult: String? = null) {
		init {
			require(liquidResult != null || materialResult != null) { "Both liquidResult and materialResult are missing" }
		}
	}
}
