Terrain fixes
This commit is contained in:
parent
46900554c3
commit
dbef69d6e6
src/main/kotlin/ru/dbotthepony/kstarbound
defs
world/terrain
@ -214,7 +214,7 @@ data class ItemDescriptor(
|
|||||||
|
|
||||||
return ref.type.factory(ref, jConfig, jParameters, count)
|
return ref.type.factory(ref, jConfig, jParameters, count)
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
LOGGER.error("Error while generating randomized item '$name' using script $builder", err)
|
LOGGER.error("Error while building item '$name' using script $builder", err)
|
||||||
return ref.type.factory(ref, ref.json, parameters.deepCopy(), count)
|
return ref.type.factory(ref, ref.json, parameters.deepCopy(), count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ data class TileDefinition(
|
|||||||
val cascading: Boolean = false,
|
val cascading: Boolean = false,
|
||||||
val falling: Boolean = false,
|
val falling: Boolean = false,
|
||||||
val foregroundOnly: Boolean = collisionKind != CollisionType.BLOCK,
|
val foregroundOnly: Boolean = collisionKind != CollisionType.BLOCK,
|
||||||
val supportsMods: Boolean = !(falling || !cascading || collisionKind != CollisionType.BLOCK),
|
val supportsMods: Boolean = !(falling || cascading || collisionKind != CollisionType.BLOCK),
|
||||||
val blocksLiquidFlow: Boolean = collisionKind.isSolidCollision,
|
val blocksLiquidFlow: Boolean = collisionKind.isSolidCollision,
|
||||||
) : IRenderableTile, IThingWithDescription by descriptionData {
|
) : IRenderableTile, IThingWithDescription by descriptionData {
|
||||||
init {
|
init {
|
||||||
|
@ -12,7 +12,7 @@ data class TerrainSelectorParameters(
|
|||||||
val baseHeight: Double,
|
val baseHeight: Double,
|
||||||
val worldHeight: Int = 0,
|
val worldHeight: Int = 0,
|
||||||
val seed: Long = 0L,
|
val seed: Long = 0L,
|
||||||
val commonality: Double = 0.0
|
val commonality: Double = 1.0
|
||||||
) {
|
) {
|
||||||
fun withSeed(seed: Long) = copy(seed = seed)
|
fun withSeed(seed: Long) = copy(seed = seed)
|
||||||
fun withCommonality(commonality: Double) = copy(commonality = commonality)
|
fun withCommonality(commonality: Double) = copy(commonality = commonality)
|
||||||
|
@ -74,8 +74,8 @@ class RidgeBlocksTerrainSelector(data: Data, parameters: TerrainSelectorParamete
|
|||||||
if (parameters.commonality <= 0.0) {
|
if (parameters.commonality <= 0.0) {
|
||||||
return 0.0
|
return 0.0
|
||||||
} else {
|
} else {
|
||||||
val x = perlin[x.toDouble(), y.toDouble()]
|
val x = x + perlin[x.toDouble(), y.toDouble()]
|
||||||
val y = perlin[y.toDouble(), x]
|
val y = y + perlin[y.toDouble(), x]
|
||||||
return (ridge1[x, y] - ridge2[x, y]) * parameters.commonality + data.bias
|
return (ridge1[x, y] - ridge2[x, y]) * parameters.commonality + data.bias
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,31 +96,34 @@ class WormCaveTerrainSelector(data: Data, parameters: TerrainSelectorParameters)
|
|||||||
else
|
else
|
||||||
1.0
|
1.0
|
||||||
|
|
||||||
wormRadius *= taperFactor
|
//wormRadius *= taperFactor
|
||||||
|
|
||||||
// carve out worm area
|
// carve out worm area
|
||||||
val size = ceil(wormRadius)
|
if (wormRadius >= 1.0) {
|
||||||
var dx = -size
|
val size = ceil(wormRadius)
|
||||||
var dy = -size
|
var dx = -size
|
||||||
|
var dy = -size
|
||||||
|
|
||||||
while (dx <= size) {
|
while (dx <= size) {
|
||||||
while (dy <= size) {
|
while (dy <= size) {
|
||||||
val m = sqrt(dx * dx + dy * dy)
|
val m = sqrt(dx * dx + dy * dy)
|
||||||
|
|
||||||
if (m <= wormRadius) {
|
if (m < wormRadius) {
|
||||||
// TODO: maybe roundToInt()?
|
// TODO: maybe roundToInt()?
|
||||||
val x = (dx + worm.pos.x).toInt()
|
val x = (dx + worm.pos.x).toInt()
|
||||||
val y = (dy + worm.pos.y).toInt()
|
val y = (dy + worm.pos.y).toInt()
|
||||||
|
|
||||||
if (isInside(x, y)) {
|
if (isInside(x, y)) {
|
||||||
this[x, y] = this[x, y].coerceAtLeast(wormRadius - m)
|
this[x, y] = this[x, y].coerceAtLeast(wormRadius - m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dy += 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
dy += 1.0
|
dy = -size
|
||||||
|
dx += 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
dx += 1.0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the worm, slowing down a bit as we
|
// move the worm, slowing down a bit as we
|
||||||
|
Loading…
Reference in New Issue
Block a user