42 lines
1010 B
Kotlin
42 lines
1010 B
Kotlin
package ru.dbotthepony.kstarbound.defs
|
|
|
|
import ru.dbotthepony.kstarbound.json.builder.IStringSerializable
|
|
import ru.dbotthepony.kstarbound.json.builder.JsonAlias
|
|
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
|
|
|
@JsonFactory
|
|
data class PerlinNoiseParameters(
|
|
val type: Type = Type.PERLIN,
|
|
val seed: Long? = null,
|
|
val scale: Int = DEFAULT_SCALE,
|
|
val octaves: Int = 1,
|
|
val gain: Double = 2.0,
|
|
val offset: Double = 1.0,
|
|
val beta: Double = 1.0,
|
|
val alpha: Double = 2.0,
|
|
val frequency: Double = 1.0,
|
|
val amplitude: Double = 1.0,
|
|
val bias: Double = 0.0,
|
|
) {
|
|
init {
|
|
require(scale >= 16) { "Too little perlin noise scale" }
|
|
}
|
|
|
|
enum class Type(override val jsonName: String) : IStringSerializable {
|
|
UNITIALIZED("uninitialized"),
|
|
PERLIN("perlin"),
|
|
BILLOW("billow"),
|
|
RIDGED_MULTI("ridgedMulti");
|
|
|
|
private val lower = jsonName.lowercase()
|
|
|
|
override fun match(name: String): Boolean {
|
|
return name.lowercase() == lower
|
|
}
|
|
}
|
|
|
|
companion object {
|
|
const val DEFAULT_SCALE = 512
|
|
}
|
|
}
|