Little more terrain
This commit is contained in:
parent
dbef69d6e6
commit
edf33ca224
@ -17,7 +17,6 @@ import ru.dbotthepony.kommons.gson.set
|
||||
import ru.dbotthepony.kommons.gson.value
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.kommons.util.AABBi
|
||||
import ru.dbotthepony.kommons.util.Either
|
||||
import ru.dbotthepony.kommons.vector.Vector2d
|
||||
import ru.dbotthepony.kommons.vector.Vector2i
|
||||
import ru.dbotthepony.kstarbound.Globals
|
||||
@ -26,12 +25,12 @@ import ru.dbotthepony.kstarbound.Registry
|
||||
import ru.dbotthepony.kstarbound.Starbound
|
||||
import ru.dbotthepony.kstarbound.defs.tile.BuiltinMetaMaterials
|
||||
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
||||
import ru.dbotthepony.kstarbound.world.terrain.AbstractTerrainSelector
|
||||
import ru.dbotthepony.kstarbound.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kstarbound.util.ListInterner
|
||||
import ru.dbotthepony.kstarbound.util.random.AbstractPerlinNoise
|
||||
import ru.dbotthepony.kstarbound.util.random.nextRange
|
||||
import ru.dbotthepony.kstarbound.world.WorldGeometry
|
||||
import ru.dbotthepony.kstarbound.world.terrain.AbstractTerrainSelector
|
||||
import ru.dbotthepony.kstarbound.world.terrain.TerrainSelectorType
|
||||
import java.util.random.RandomGenerator
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -20,6 +20,12 @@ abstract class AbstractTerrainSelector<D : Any>(val data: D, val parameters: Ter
|
||||
return result
|
||||
}
|
||||
|
||||
fun toJsonPlain(): JsonObject {
|
||||
val result = Starbound.gson.toJsonTree(data) as JsonObject
|
||||
result["type"] = type.jsonName
|
||||
return result
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other)
|
||||
return true
|
||||
|
@ -21,6 +21,11 @@ sealed class ComparingTerrainSelector(data: Data, parameters: TerrainSelectorPar
|
||||
}
|
||||
|
||||
class Max(data: Data, parameters: TerrainSelectorParameters) : ComparingTerrainSelector(data, parameters) {
|
||||
constructor(parameters: TerrainSelectorParameters, vararg sources: AbstractTerrainSelector<*>) : this(
|
||||
Data(ImmutableList.copyOf(sources.map { it.toJsonPlain() })),
|
||||
parameters
|
||||
)
|
||||
|
||||
override fun get(x: Int, y: Int): Double {
|
||||
return sources.maxOf { it[x, y] }
|
||||
}
|
||||
@ -30,6 +35,11 @@ sealed class ComparingTerrainSelector(data: Data, parameters: TerrainSelectorPar
|
||||
}
|
||||
|
||||
class Min(data: Data, parameters: TerrainSelectorParameters) : ComparingTerrainSelector(data, parameters) {
|
||||
constructor(parameters: TerrainSelectorParameters, vararg sources: AbstractTerrainSelector<*>) : this(
|
||||
Data(ImmutableList.copyOf(sources.map { it.toJsonPlain() })),
|
||||
parameters
|
||||
)
|
||||
|
||||
override fun get(x: Int, y: Int): Double {
|
||||
return sources.minOf { it[x, y] }
|
||||
}
|
||||
@ -39,6 +49,11 @@ sealed class ComparingTerrainSelector(data: Data, parameters: TerrainSelectorPar
|
||||
}
|
||||
|
||||
class MinMax(data: Data, parameters: TerrainSelectorParameters) : ComparingTerrainSelector(data, parameters) {
|
||||
constructor(parameters: TerrainSelectorParameters, vararg sources: AbstractTerrainSelector<*>) : this(
|
||||
Data(ImmutableList.copyOf(sources.map { it.toJsonPlain() })),
|
||||
parameters
|
||||
)
|
||||
|
||||
override fun get(x: Int, y: Int): Double {
|
||||
var value = 0.0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user