tree foliage tiles

This commit is contained in:
minjaesong
2023-10-15 00:01:52 +09:00
parent 0a65794756
commit 1cce4e6ee2
6 changed files with 48 additions and 15 deletions

View File

@@ -264,6 +264,7 @@ internal object BlocksDrawer {
private lateinit var wallStickerTiles: Array<Int>
private lateinit var connectMutualTiles: Array<Int>
private lateinit var connectSelfTiles: Array<Int>
private lateinit var treeTiles: Array<Int>
internal fun rebuildInternalPrecalculations() {
if (App.IS_DEVELOPMENT_BUILD) {
@@ -294,6 +295,11 @@ internal object BlocksDrawer {
connectSelfTiles = BlockCodex.blockProps.filter { (id, prop) ->
isConnectSelf(id) && !id.startsWith("virt:") && id != Block.NULL
}.map { world.tileNameToNumberMap[it.key] ?: throw NullPointerException("No tilenumber for ${it.key} exists") }.sorted().toTypedArray()
treeTiles = BlockCodex.blockProps.filter { (id, prop) ->
isTreeTile(id) && !id.startsWith("virt:") && id != Block.NULL
}.map { world.tileNameToNumberMap[it.key] ?: throw NullPointerException("No tilenumber for ${it.key} exists") }.sorted().toTypedArray()
}
/**
@@ -351,6 +357,9 @@ internal object BlocksDrawer {
/*else if (mode == FLUID) {
getNearbyTilesInfoFluids(x, y)
}*/
else if (treeTiles.binarySearch(thisTile) >= 0) {
getNearbyTilesInfoTrees(x, y, mode)
}
else if (platformTiles.binarySearch(thisTile) >= 0) {
getNearbyTilesInfoPlatform(x, y)
}
@@ -487,7 +496,20 @@ internal object BlocksDrawer {
var ret = 0
for (i in nearbyTiles.indices) {
if (BlockCodex[nearbyTiles[i]].isSolidForTileCnx) {
if (BlockCodex[nearbyTiles[i]].isSolidForTileCnx && isConnectMutual(nearbyTiles[i])) {
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
}
}
return ret
}
private fun getNearbyTilesInfoTrees(x: Int, y: Int, mode: Int): Int {
val nearbyTiles: List<ItemID> = getNearbyTilesPos(x, y).map { world.getTileFrom(mode, it.x, it.y) }
var ret = 0
for (i in nearbyTiles.indices) {
if (isTreeTile(nearbyTiles[i])) {
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
}
}
@@ -813,11 +835,12 @@ internal object BlocksDrawer {
fun getRenderEndX(): Int = clampWTile(getRenderStartX() + (WorldCamera.width / TILE_SIZE) + 2)
fun getRenderEndY(): Int = clampHTile(getRenderStartY() + (WorldCamera.height / TILE_SIZE) + 2)
fun isConnectSelf(b: ItemID): Boolean = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_SELF
fun isConnectMutual(b: ItemID): Boolean = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_MUTUAL
fun isWallSticker(b: ItemID): Boolean = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER
fun isPlatform(b: ItemID): Boolean = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF
//fun isBlendMul(b: Int): Boolean = TILES_BLEND_MUL.contains(b)
fun isConnectSelf(b: ItemID) = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_SELF
fun isConnectMutual(b: ItemID) = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_MUTUAL
fun isWallSticker(b: ItemID) = App.tileMaker.getRenderTag(b).connectionType == CreateTileAtlas.RenderTag.CONNECT_WALL_STICKER
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 isTreeTile(b: ItemID) = BlockCodex[b].hasTag("TREE")
fun tileInCamera(x: Int, y: Int) =
x >= WorldCamera.x.div(TILE_SIZE) && y >= WorldCamera.y.div(TILE_SIZE) &&