diff --git a/src/net/torvald/terrarum/blockproperties/BlockCodex.kt b/src/net/torvald/terrarum/blockproperties/BlockCodex.kt index fdf2a142a..cc3568c7b 100644 --- a/src/net/torvald/terrarum/blockproperties/BlockCodex.kt +++ b/src/net/torvald/terrarum/blockproperties/BlockCodex.kt @@ -62,7 +62,7 @@ object BlockCodex { setProp(blockProps[intVal(it, "id")], it) }*/ - setProp(module, it) + setProp(module, intVal(it, "id"), it) val tileId = "$module:${intVal(it, "id")}" // register tiles with dynamic light @@ -77,7 +77,7 @@ object BlockCodex { virtualToTile[virtualID] = tileId virtualChunk.add(virtualID) - setProp("virt", it, virtualTileCursor) + setProp("virt", virtualTileCursor, it) printdbg(this, "Block ID $tileId -> Virtual ID $virtualID, baseLum: ${blockProps[virtualID]?.baseLumCol}") virtualTileCursor += 1 @@ -150,11 +150,11 @@ object BlockCodex { return blockProps[blockID] } - private fun setProp(modname: String, record: CSVRecord, newKey: Int? = null) { + private fun setProp(modname: String, key: Int, record: CSVRecord) { val prop = BlockProp() prop.nameKey = record.get("name") - prop.id = if (newKey != null) "$modname:$newKey" else "$modname:${intVal(record, "id")}" + prop.id = "$modname:$key" prop.drop = "$modname:${intVal(record, "drop")}" prop.shadeColR = floatVal(record, "shdr") @@ -186,9 +186,9 @@ object BlockCodex { prop.dynamicLuminosityFunction = intVal(record, "dlfn") - blockProps["$modname:${prop.id}"] = prop + blockProps[prop.id] = prop - printmsg(this, "Setting prop $modname:${prop.id}\t" + prop.nameKey) + printmsg(this, "Setting prop ${prop.id} ->>\t${prop.nameKey}\tsolid:${prop.isSolid}") } } diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt index 75d7fed41..e9c7f49dd 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/PlayerBuilderSigrid.kt @@ -77,20 +77,20 @@ object PlayerBuilderSigrid { CreateTileAtlas.tags.forEach { t, _ -> inventory.add(t, 9995) - if (BlockCodex[t].isWallable) { + try { inventory.add("wall@"+t, 9995) } + catch (e: Throwable) {} } // item ids are defined in /items/itemid.csv - + /* inventory.add("item@basegame:0", 16) // copper pick inventory.add("item@basegame:1") // iron pick inventory.add("item@basegame:2") // steel pick inventory.add("item@basegame:3", 9995) // wire piece inventory.add("item@basegame:4", 385930603) // test tiki torch inventory.add("item@basegame:5", 95) // crafting table - //inventory.add(9000) // TEST water bucket - //inventory.add(9001) // TEST lava bucket + */ } } diff --git a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt index a05391737..c4df1f179 100644 --- a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt +++ b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt @@ -55,11 +55,8 @@ object CreateTileAtlas { var initialised = false private set - /** 0000.tga, 1.tga.gz, 3242423.tga, 000033.tga.gz */ - // for right now, TGA file only, no gzip - private val validFluidTilesFilename = Regex("""fluid_[0-9]+\.tga""") - private val tileNameRegex = Regex("""[0-9]+\.tga""") - private val tileGlowNameRegex = Regex("""[0-9]+_glow\.tga""") + /** 0.tga, 1.tga.gz, 3242423.tga, 33.tga.gz */ + private val tileNameRegex = Regex("""(0|[1-9][0-9]*)\.tga(\.gz)?""") // 16 tiles are reserved for internal use: solid black, solid white, breakage stages. // 0th tile is complete transparent tile and is also a BlockID of zero: air. @@ -89,30 +86,27 @@ object CreateTileAtlas { atlasFluid.blending = Pixmap.Blending.None atlasGlow.blending = Pixmap.Blending.None - val initMap = Pixmap(Gdx.files.internal(atlasInit)) - drawToAtlantes(initMap, nullTile, 16) - initMap.dispose() - - // get all the files applicable // first, get all the '/blocks' directory, and add all the files, regardless of their extension, to the list val tgaList = ArrayList>() //Pair of - ModMgr.getGdxFilesFromEveryMod("blocks").forEach { (modname, filehandle) -> - if (!filehandle.isDirectory) { - throw Error("Path '${filehandle.path()}' is not a directory") + ModMgr.getGdxFilesFromEveryMod("blocks").forEach { (modname, dir) -> + if (!dir.isDirectory) { + throw Error("Path '${dir.path()}' is not a directory") } - filehandle.list().forEach { tgaFile -> - if (!tgaFile.isDirectory && (tgaFile.name().matches(tileNameRegex))) { - tgaList.add(modname to tgaFile) - } - } + + dir.list().filter { tgaFile -> !tgaFile.isDirectory && (tgaFile.name().matches(tileNameRegex)) } + .sortedBy { it.nameWithoutExtension().toInt() }.forEach { tgaFile -> // toInt() to sort by the number, not lexicographically + tgaList.add(modname to tgaFile) + } } // Sift through the file list for blocks, but TGA format first tgaList.forEach { (modname, filehandle) -> + printdbg(this, "processing $modname:${filehandle.name()}") + try { - val glowFile = Gdx.files.internal(filehandle.path().dropLast(4) + "_glow.tga") // assuming strict ".tga" file + val glowFile = Gdx.files.internal(filehandle.path().dropLast(4) + "_glow.tga") // assuming strict ".tga" file for now... fileToAtlantes(modname, filehandle, if (glowFile.exists()) glowFile else null) } catch (e: GdxRuntimeException) {