mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fix: missing params that caused backwards incompatibility
This commit is contained in:
@@ -2,7 +2,6 @@ package net.torvald.terrarum.modulebasegame.worldgenerator
|
||||
|
||||
import com.sudoplay.joise.Joise
|
||||
import com.sudoplay.joise.module.*
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.LoadScreenBase
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
@@ -19,7 +18,7 @@ import kotlin.math.sin
|
||||
*/
|
||||
class Aquagen(world: GameWorld, isFinal: Boolean, val groundScalingCached: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) {
|
||||
|
||||
private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004)
|
||||
private val isAlpha2 = ((params as TerragenParams).versionSince >= 0x0000_000004_000004)
|
||||
|
||||
private val FLUID_FILL = 1.2f
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import kotlin.math.sin
|
||||
*/
|
||||
class Cavegen(world: GameWorld, isFinal: Boolean, val highlandLowlandSelectCache: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) {
|
||||
|
||||
private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004)
|
||||
private val isAlpha2 = ((params as TerragenParams).versionSince >= 0x0000_000004_000004)
|
||||
|
||||
override fun getDone(loadscreen: LoadScreenBase?) {
|
||||
loadscreen?.let {
|
||||
|
||||
@@ -13,9 +13,9 @@ import kotlin.math.sqrt
|
||||
/**
|
||||
* Created by minjaesong on 2023-10-25.
|
||||
*/
|
||||
class Oregen(world: GameWorld, isFinal: Boolean, private val caveAttenuateBiasScaledCache: ModuleCache, seed: Long, private val ores: List<OregenParams>) : Gen(world, isFinal, seed) {
|
||||
class Oregen(world: GameWorld, isFinal: Boolean, private val caveAttenuateBiasScaledCache: ModuleCache, seed: Long, private val ores: List<OregenParams>, terragenParams: TerragenParams) : Gen(world, isFinal, seed, terragenParams) {
|
||||
|
||||
private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004)
|
||||
private val isAlpha2 = (terragenParams.versionSince >= 0x0000_000004_000004)
|
||||
|
||||
override fun getDone(loadscreen: LoadScreenBase?) {
|
||||
loadscreen?.let {
|
||||
|
||||
@@ -18,7 +18,7 @@ import kotlin.math.sin
|
||||
*/
|
||||
class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) {
|
||||
|
||||
private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004)
|
||||
private val isAlpha2 = ((params as TerragenParams).versionSince >= 0x0000_000004_000004)
|
||||
|
||||
override fun getDone(loadscreen: LoadScreenBase?) {
|
||||
loadscreen?.let {
|
||||
@@ -223,7 +223,7 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu
|
||||
abstract class TerragenParams {
|
||||
val LANDBLOCK_VAR_COUNTS = 16
|
||||
|
||||
abstract val version: Long
|
||||
abstract val versionSince: Long
|
||||
abstract val strata: List<Stratum>
|
||||
abstract val featureSize: Double
|
||||
abstract val lowlandScaleOffset: Double // linearly alters the height
|
||||
@@ -297,12 +297,15 @@ abstract class TerragenParams {
|
||||
* @param h: STARTING height of the strata relative to the ground select gradient
|
||||
* @param v: linear ± to the `h`
|
||||
*/
|
||||
data class Hv(val h: Double, val v: Double)
|
||||
data class Hv(val h: Double, val v: Double) { init {
|
||||
if (h.isNaN() || h.isInfinite() || h < 0.0) throw IllegalArgumentException("h-value must be zero or positive (got $h)")
|
||||
if (v.isNaN() || v.isInfinite() || v < 0.0) throw IllegalArgumentException("v-value must be zero or positive (got $v)")
|
||||
} }
|
||||
class Stratum(val yheight: Hv, vararg val tiles: ItemID)
|
||||
class StratumObj(val yheight: Double, val tiles: ItemID)
|
||||
|
||||
data class TerragenParamsAlpha1(
|
||||
override val version: Long = 0L,
|
||||
override val versionSince: Long = 0L,
|
||||
|
||||
// 0. randomiser gets two-element buffer
|
||||
// 1. randomiser consults the buffer and removes matching elements from the random pool
|
||||
@@ -340,7 +343,7 @@ data class TerragenParamsAlpha1(
|
||||
) : TerragenParams()
|
||||
|
||||
data class TerragenParamsAlpha2(
|
||||
override val version: Long = 0x0000_000004_000004,
|
||||
override val versionSince: Long = 0x0000_000004_000004,
|
||||
|
||||
override val strata: List<Stratum> = listOf(
|
||||
Stratum(Hv(.0, .0), Block.AIR),
|
||||
@@ -396,4 +399,4 @@ data class TerragenParamsAlpha2(
|
||||
|
||||
override val landBlockScale: Double = 0.5,
|
||||
|
||||
) : TerragenParams()
|
||||
) : TerragenParams()
|
||||
@@ -98,7 +98,7 @@ object Worldgen {
|
||||
Work(Lang["MENU_IO_WORLDGEN_RETICULATING_SPLINES"], Terragen(world, false, groundScalingCached, params.seed, params.terragenParams), listOf("TERRAIN")), // also generates marble veins
|
||||
Work(Lang["MENU_IO_WORLDGEN_CARVING_EARTH"], Cavegen(world, false, highlandLowlandSelectCache, params.seed, params.terragenParams), listOf("TERRAIN", "CAVE")),
|
||||
Work(Lang["MENU_IO_WORLDGEN_FLOODING_UNDERGROUND"], Aquagen(world, false, groundScalingCached, params.seed, params.terragenParams), listOf("WATER")),
|
||||
Work(Lang["MENU_IO_WORLDGEN_GROWING_MINERALS"], Oregen(world, false, caveAttenuateBiasScaledForOresCache, params.seed, oreRegistry), listOf("ORES")),
|
||||
Work(Lang["MENU_IO_WORLDGEN_GROWING_MINERALS"], Oregen(world, false, caveAttenuateBiasScaledForOresCache, params.seed, oreRegistry, params.terragenParams), listOf("ORES")),
|
||||
Work(Lang["MENU_IO_WORLDGEN_POSITIONING_ROCKS"], OregenAutotiling(world, false, params.seed, oreTilingModes), listOf("ORES")),
|
||||
// TODO generate gemstones
|
||||
Work(Lang["MENU_IO_WORLDGEN_PAINTING_GREEN"], Biomegen(world, false, params.seed, params.biomegenParams, biomeMap), listOf("BIOME")),
|
||||
|
||||
Reference in New Issue
Block a user