mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
more treegen wip
This commit is contained in:
@@ -28,16 +28,16 @@
|
|||||||
"51";"51";"51";"BLOCK_PLANK_ROSEWOOD";"0.1252";"0.1252";"0.1252";"0.1252";"17";"900";"WOOD";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"WOOD,NORANDTILE"
|
"51";"51";"51";"BLOCK_PLANK_ROSEWOOD";"0.1252";"0.1252";"0.1252";"0.1252";"17";"900";"WOOD";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"WOOD,NORANDTILE"
|
||||||
|
|
||||||
# small punchable trees
|
# small punchable trees
|
||||||
"64";"64";"64";"BLOCK_TRUNK_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"16";"740";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREESMALL,NATURAL"
|
"64";"64";"64";"BLOCK_TRUNK_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"16";"740";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREESMALL,NATURAL"
|
||||||
"65";"65";"65";"BLOCK_TRUNK_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"19";"1200";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREESMALL,NATURAL"
|
"65";"65";"65";"BLOCK_TRUNK_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"19";"1200";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREESMALL,NATURAL"
|
||||||
"66";"66";"66";"BLOCK_TRUNK_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"15";"670";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREESMALL,NATURAL"
|
"66";"66";"66";"BLOCK_TRUNK_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"15";"670";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREESMALL,NATURAL"
|
||||||
"67";"67";"67";"BLOCK_TRUNK_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"17";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREESMALL,NATURAL"
|
"67";"67";"67";"BLOCK_TRUNK_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"17";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREESMALL,NATURAL"
|
||||||
|
|
||||||
# large non-punchable trees
|
# large non-punchable trees
|
||||||
"72";"72";"72";"BLOCK_TRUNK_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"16";"740";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREELARGE,NATURAL"
|
"72";"72";"72";"BLOCK_TRUNK_NORMAL";"0.0312";"0.0312";"0.0312";"0.0312";"16";"740";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREELARGE,NATURAL"
|
||||||
"73";"73";"73";"BLOCK_TRUNK_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"19";"1200";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREELARGE,NATURAL"
|
"73";"73";"73";"BLOCK_TRUNK_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"19";"1200";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREELARGE,NATURAL"
|
||||||
"74";"74";"74";"BLOCK_TRUNK_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"15";"670";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREELARGE,NATURAL"
|
"74";"74";"74";"BLOCK_TRUNK_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"15";"670";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREELARGE,NATURAL"
|
||||||
"75";"75";"75";"BLOCK_TRUNK_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"17";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREELARGE,NATURAL"
|
"75";"75";"75";"BLOCK_TRUNK_ROSEWOOD";"0.0312";"0.0312";"0.0312";"0.0312";"17";"900";"WOOD";"0";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0";"TREE,TREETRUNK,TREELARGE,NATURAL"
|
||||||
|
|
||||||
# sabulous
|
# sabulous
|
||||||
"80";"80";"80";"BLOCK_SAND";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.06";"SAND,NATURAL,WARM"
|
"80";"80";"80";"BLOCK_SAND";"0.1252";"0.1252";"0.1252";"0.1252";"24";"2400";"SAND";"1";"0";"0";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.06";"SAND,NATURAL,WARM"
|
||||||
|
|||||||
|
Can't render this file because it contains an unexpected character in line 17 and column 2.
|
@@ -53,7 +53,9 @@ internal object ExportMap : ConsoleCommand {
|
|||||||
val colFore = (App.tileMaker.terrainTileColourMap.get(terr) ?: throw NullPointerException("nullterr $terr")).toByteArray()
|
val colFore = (App.tileMaker.terrainTileColourMap.get(terr) ?: throw NullPointerException("nullterr $terr")).toByteArray()
|
||||||
val colWall = (App.tileMaker.terrainTileColourMap.get(wall) ?: throw NullPointerException("nullwall $wall")).cpy().mul(WALL_OVERLAY).toByteArray()
|
val colWall = (App.tileMaker.terrainTileColourMap.get(wall) ?: throw NullPointerException("nullwall $wall")).cpy().mul(WALL_OVERLAY).toByteArray()
|
||||||
|
|
||||||
val colArray = if (ore != Block.AIR) colOre else if (BlockCodex[terr].isSolid) colFore else colWall
|
val terrProp = BlockCodex[terr]
|
||||||
|
|
||||||
|
val colArray = if (ore != Block.AIR) colOre else if (terrProp.isSolid || terrProp.hasTag("TREE")) colFore else colWall
|
||||||
|
|
||||||
|
|
||||||
for (i in 0..2) {
|
for (i in 0..2) {
|
||||||
|
|||||||
@@ -46,40 +46,27 @@ class Treegen(world: GameWorld, seed: Long, params: TreegenParams, val biomeMap:
|
|||||||
|
|
||||||
|
|
||||||
private fun makeGrassMap(xs: IntProgression): Array<List<Int>> {
|
private fun makeGrassMap(xs: IntProgression): Array<List<Int>> {
|
||||||
val STRIDE = 4
|
|
||||||
val r = Array<List<Int>>(xs.last - xs.first + 1) { emptyList() }
|
val r = Array<List<Int>>(xs.last - xs.first + 1) { emptyList() }
|
||||||
|
|
||||||
|
|
||||||
for (x in xs) {
|
for (x in xs) {
|
||||||
val ys = ArrayList<Int>()
|
val ys = ArrayList<Int>()
|
||||||
var y = 0
|
var y = 1
|
||||||
|
var tileUp = world.getTileFromTerrain(x, y - 1)
|
||||||
|
var tile = world.getTileFromTerrain(x, y)
|
||||||
|
var tileProp = BlockCodex[tile]
|
||||||
while (y < 800) {
|
while (y < 800) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
|
||||||
val tileProp = BlockCodex[tile]
|
|
||||||
|
|
||||||
if (tileProp.hasAnyTagOf("ROCK", "STONE")) break
|
if (tileProp.hasAnyTagOf("ROCK", "STONE")) break
|
||||||
|
|
||||||
if (tile == Block.GRASS) {
|
if (tile == Block.GRASS && tileUp == Block.AIR) {
|
||||||
ys.add(y)
|
ys.add(y)
|
||||||
}
|
}
|
||||||
// if dirt was hit, climb back up until a grass is seen
|
|
||||||
else if (tile == Block.DIRT) {
|
|
||||||
var yi = 1
|
|
||||||
var tile0 = world.getTileFromTerrain(x, y - yi)
|
|
||||||
var found = false
|
|
||||||
while (tile0 == Block.DIRT || yi < STRIDE) {
|
|
||||||
tile0 = world.getTileFromTerrain(x, y - yi)
|
|
||||||
if (tile0 == Block.GRASS) found = true
|
|
||||||
yi += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// filter duplicates
|
y += 1
|
||||||
if (found && (ys.isEmpty() || ys.last() != y - yi)) {
|
|
||||||
ys.add(y - yi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
y += STRIDE
|
tileUp = tile
|
||||||
|
tile = world.getTileFromTerrain(x, y)
|
||||||
|
tileProp = BlockCodex[tile]
|
||||||
}
|
}
|
||||||
|
|
||||||
r[x - xs.first] = ys
|
r[x - xs.first] = ys
|
||||||
@@ -98,7 +85,7 @@ class Treegen(world: GameWorld, seed: Long, params: TreegenParams, val biomeMap:
|
|||||||
val grad2 = yRight - y
|
val grad2 = yRight - y
|
||||||
|
|
||||||
if ((grad1 * grad2).absoluteValue <= 1) {
|
if ((grad1 * grad2).absoluteValue <= 1) {
|
||||||
printdbg(this, "Trying to plant tree at $x, $y")
|
// printdbg(this, "Trying to plant tree at $x, $y")
|
||||||
|
|
||||||
val rnd = Math.random()
|
val rnd = Math.random()
|
||||||
val biome = biomeMap[LandUtil.getBlockAddr(world, x, y)] ?: 0
|
val biome = biomeMap[LandUtil.getBlockAddr(world, x, y)] ?: 0
|
||||||
@@ -123,10 +110,14 @@ class Treegen(world: GameWorld, seed: Long, params: TreegenParams, val biomeMap:
|
|||||||
|
|
||||||
var growCnt = 1
|
var growCnt = 1
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
var heightSum = 5+3+2+1
|
var heightSum = 5+3+2
|
||||||
// check for minimum height
|
// check for minimum height
|
||||||
if ((1..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }) {
|
val chkM1 = (2..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }
|
||||||
printdbg(this, "Ceiling not tall enough, aborting")
|
val chk0 = (1..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }
|
||||||
|
val chkP1 = (2..heightSum).any { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid }
|
||||||
|
|
||||||
|
if (chkM1 || chk0 || chkP1) {
|
||||||
|
printdbg(this, "Ceiling not tall enough at $x, $y, aborting")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,38 +132,53 @@ class Treegen(world: GameWorld, seed: Long, params: TreegenParams, val biomeMap:
|
|||||||
// }
|
// }
|
||||||
// while ((1..heightSum).none { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid })
|
// while ((1..heightSum).none { BlockCodex[world.getTileFromTerrain(x, y - it)].isSolid })
|
||||||
|
|
||||||
printdbg(this, "Planting tree; params: $stem, $bulb1, $bulb2, $bulb3")
|
printdbg(this, "Planting tree at $x, $y; params: $stem, $bulb1, $bulb2, $bulb3")
|
||||||
|
|
||||||
// trunk
|
// trunk
|
||||||
for (i in 0 until stem) {
|
for (i in 0 until stem) {
|
||||||
for (xi in -1..+1) {
|
for (xi in -1..+1) {
|
||||||
world.setTileTerrain(x + xi, y - growCnt, if (xi == 0) trunk else Block.AIR, true)
|
if (xi != 0) {
|
||||||
|
val tileHere = world.getTileFromTerrain(x + xi, y - growCnt)
|
||||||
|
if (BlockCodex[tileHere].hasTag("TREETRUNK"))
|
||||||
|
world.setTileTerrain(x + xi, y - growCnt, Block.AIR, true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
world.setTileTerrain(x + xi, y - growCnt, trunk, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
growCnt += 1
|
growCnt += 1
|
||||||
}
|
}
|
||||||
// bulb base
|
// bulb base
|
||||||
for (x in x-2..x+2) {
|
for (x in x-2..x+2) {
|
||||||
world.setTileTerrain(x, y - growCnt, foliage, true)
|
val tileHere = world.getTileFromTerrain(x, y - growCnt)
|
||||||
|
if (BlockCodex[tileHere].hasTag("INCONSEQUENTIAL"))
|
||||||
|
world.setTileTerrain(x, y - growCnt, foliage, true)
|
||||||
}
|
}
|
||||||
growCnt += 1
|
growCnt += 1
|
||||||
// bulb 1
|
// bulb 1
|
||||||
for (i in 0 until bulb1) {
|
for (i in 0 until bulb1) {
|
||||||
for (x in x-3..x+3) {
|
for (x in x-3..x+3) {
|
||||||
world.setTileTerrain(x, y - growCnt, foliage, true)
|
val tileHere = world.getTileFromTerrain(x, y - growCnt)
|
||||||
|
if (BlockCodex[tileHere].hasTag("INCONSEQUENTIAL"))
|
||||||
|
world.setTileTerrain(x, y - growCnt, foliage, true)
|
||||||
}
|
}
|
||||||
growCnt += 1
|
growCnt += 1
|
||||||
}
|
}
|
||||||
// bulb 2
|
// bulb 2
|
||||||
for (i in 0 until bulb2) {
|
for (i in 0 until bulb2) {
|
||||||
for (x in x-2..x+2) {
|
for (x in x-2..x+2) {
|
||||||
world.setTileTerrain(x, y - growCnt, foliage, true)
|
val tileHere = world.getTileFromTerrain(x, y - growCnt)
|
||||||
|
if (BlockCodex[tileHere].hasTag("INCONSEQUENTIAL"))
|
||||||
|
world.setTileTerrain(x, y - growCnt, foliage, true)
|
||||||
}
|
}
|
||||||
growCnt += 1
|
growCnt += 1
|
||||||
}
|
}
|
||||||
// bulb 3
|
// bulb 3
|
||||||
for (i in 0 until bulb3) {
|
for (i in 0 until bulb3) {
|
||||||
for (x in x-1..x+1) {
|
for (x in x-1..x+1) {
|
||||||
world.setTileTerrain(x, y - growCnt, foliage, true)
|
val tileHere = world.getTileFromTerrain(x, y - growCnt)
|
||||||
|
if (BlockCodex[tileHere].hasTag("INCONSEQUENTIAL"))
|
||||||
|
world.setTileTerrain(x, y - growCnt, foliage, true)
|
||||||
}
|
}
|
||||||
growCnt += 1
|
growCnt += 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -906,7 +906,7 @@ internal object BlocksDrawer {
|
|||||||
fun isPlatform(b: ItemID) = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
|
fun isPlatform(b: ItemID) = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
|
||||||
//fun isBlendMul(b: Int) = TILES_BLEND_MUL.contains(b)
|
//fun isBlendMul(b: Int) = TILES_BLEND_MUL.contains(b)
|
||||||
fun isTreeFoliage(b: ItemID) = BlockCodex[b].hasAllTagOf("TREE", "LEAVES")
|
fun isTreeFoliage(b: ItemID) = BlockCodex[b].hasAllTagOf("TREE", "LEAVES")
|
||||||
fun isTreeTrunk(b: ItemID) = BlockCodex[b].let { it.hasTag("TREE") && !it.hasTag("LEAVES") }
|
fun isTreeTrunk(b: ItemID) = BlockCodex[b].hasAllTagOf("TREE", "TREETRUNK")
|
||||||
|
|
||||||
fun tileInCamera(x: Int, y: Int) =
|
fun tileInCamera(x: Int, y: Int) =
|
||||||
x >= WorldCamera.x.div(TILE_SIZE) && y >= WorldCamera.y.div(TILE_SIZE) &&
|
x >= WorldCamera.x.div(TILE_SIZE) && y >= WorldCamera.y.div(TILE_SIZE) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user