wire is back! but not the render

This commit is contained in:
minjaesong
2021-07-28 14:19:50 +09:00
parent 8cb3fc2d33
commit 5aacbe84b8
21 changed files with 228 additions and 107 deletions

View File

@@ -1,9 +1,9 @@
"id";"drop";"name";"accept";"inputcount";"inputtype";"outputtype"
"8192";"8192";"WIRE_RED";"digital_bit";"N/A";"N/A";"N/A"
"8193";"8193";"WIRE_GREEN";"digital_bit";"N/A";"N/A";"N/A"
"8194";"8194";"WIRE_BLUE";"digital_bit";"N/A";"N/A";"N/A"
"8195";"8195";"WIRE_BUNDLE";"digital_3bits";"N/A";"N/A";"N/A"
"bundlemaker";"bundlemaker";"WIRE_BUNDLEMAKER";"N/A";3;"digital_bit";"digital_3bits"
"id";"drop";"name";"renderclass";"accept";"inputcount";"inputtype";"outputtype";"javaclass";"inventoryimg"
"8192";"8192";"WIRE_RED";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,9"
"8193";"8193";"WIRE_GREEN";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,10"
"8194";"8194";"WIRE_BLUE";"signal";"digital_bit";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,11"
#"8195";"8195";"WIRE_BUNDLE";"signal";"digital_3bits";"3";"N/A";"N/A";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,2"
#"bundlemaker";"bundlemaker";"WIRE_BUNDLEMAKER";"signal";"digital_bit";3;"digital_bit";"digital_3bits";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire";"basegame.items16,1,9"
# accept: which wiretype (defined elsewhere) the wires acceps. Use comma to separate multiple. N/A for electronic components (aka "not wires")
Can't render this file because it contains an unexpected character in line 9 and column 131.

View File

@@ -2,6 +2,5 @@
"1";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper"
"2";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron"
"3";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel"
"4";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire"
"5";"net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester"
"6";"net.torvald.terrarum.modulebasegame.gameitems.ItemStorageChest"
1 id classname
2 1 net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper
3 2 net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron
4 3 net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel
4 net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire
5 5 net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester
6 6 net.torvald.terrarum.modulebasegame.gameitems.ItemStorageChest

View File

@@ -161,9 +161,9 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
* @param old previous settings of conduits in bit set format.
* @param new current settings of conduits in bit set format.
*/
open fun queueWireChangedEvent(old: ItemID, new: ItemID, position: Long) {
open fun queueWireChangedEvent(new: ItemID, position: Long) {
val (x, y) = LandUtil.resolveBlockAddr(world, position)
wireChangeQueue.addLast(BlockChangeQueueItem(old, new, x, y))
wireChangeQueue.addLast(BlockChangeQueueItem("", new, x, y))
}

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.AppLoader.*
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.gameitem.ItemID
@@ -226,6 +227,7 @@ object ModMgr {
@JvmStatic operator fun invoke(module: String) {
BlockCodex(module, blockPath + "blocks.csv")
WireCodex(module, blockPath + "wires.csv")
}
}

View File

@@ -104,7 +104,7 @@ object PostProcessor : Disposable {
if (KeyToggler.isOn(Input.Keys.F10)) {
batch.color = Color.WHITE
batch.inUse {
AppLoader.fontSmallNumbers.draw(it, "Wire draw bits: ${BlocksDrawer.drawWires.toString(2)}", 2f, 2f)
AppLoader.fontSmallNumbers.draw(it, "Wire draw class: ${BlocksDrawer.selectedWireRenderClass}", 2f, 2f)
}
}

View File

@@ -0,0 +1,114 @@
package net.torvald.terrarum.blockproperties
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.utils.CSVFetcher
import org.apache.commons.csv.CSVRecord
import java.io.IOException
/**
* Created by minjaesong on 2016-02-16.
*/
object WireCodex {
private var wireProps = HashMap<ItemID, WireProp>()
private val nullProp = WireProp()
operator fun invoke(module: String, path: String) {
try {
val records = CSVFetcher.readFromModule(module, path)
AppLoader.printmsg(this, "Building wire properties table")
records.forEach {
/*if (intVal(it, "id") == -1) {
setProp(nullProp, it)
}
else {
setProp(wireProps[intVal(it, "id")], it)
}*/
WireCodex.setProp(module, intVal(it, "id"), it)
//val tileId = "$module:${intVal(it, "id")}"
}
}
catch (e: IOException) {
e.printStackTrace()
}
}
fun getAll() = WireCodex.wireProps.values
/*fun get(index: Int): WireProp {
try {
return wireProps[index]
}
catch (e: NullPointerException) {
throw NullPointerException("Blockprop with id $index does not exist.")
}
catch (e1: ArrayIndexOutOfBoundsException) {
if (index == -1) return nullProp
else throw e1
}
}*/
/*operator fun get(rawIndex: Int?): WireProp {
if (rawIndex == null || rawIndex == Block.NULL) {
return nullProp
}
try {
return wireProps[rawIndex]!!
}
catch (e: NullPointerException) {
throw NullPointerException("Blockprop with raw id $rawIndex does not exist.")
}
}*/
operator fun get(blockID: ItemID?): WireProp {
if (blockID == null || blockID == "basegame:"+Block.NULL) {
return WireCodex.nullProp
}
try {
return WireCodex.wireProps[blockID]!!
}
catch (e: NullPointerException) {
throw NullPointerException("Wireprop with id $blockID does not exist.")
}
}
fun getOrNull(blockID: ItemID?): WireProp? {//<O>
return WireCodex.wireProps[blockID]
}
private fun setProp(modname: String, key: Int, record: CSVRecord) {
val prop = WireProp()
prop.nameKey = record.get("name")
prop.id = "wire@$modname:$key"
prop.renderClass = record.get("renderclass")
prop.accepts = record.get("accept")
prop.inputCount = intVal(record, "inputcount")
prop.inputType = record.get("inputtype") ?: prop.accepts
prop.outputType = record.get("outputtype") ?: prop.accepts
WireCodex.wireProps[prop.id] = prop
// load java class
val invImgRef = record.get("inventoryimg").split(',')
val invImgSheet = invImgRef[0]
val invImgX = invImgRef[1].toInt()
val invImgY = invImgRef[2].toInt()
val className = record.get("javaclass")
val loadedClass = Class.forName(className)
val loadedClassConstructor = loadedClass.getConstructor(ItemID::class.java, String::class.java, Int::class.java, Int::class.java)
val loadedClassInstance = loadedClassConstructor.newInstance(prop.id, invImgSheet, invImgX, invImgY)
ItemCodex[prop.id] = loadedClassInstance as GameItem
AppLoader.printmsg(this, "Setting prop ${prop.id} ->>\t${prop.nameKey}")
}
}

View File

@@ -0,0 +1,19 @@
package net.torvald.terrarum.blockproperties
import net.torvald.terrarum.gameitem.ItemID
/**
* Created by minjaesong on 2021-07-28.
*/
class WireProp {
var id: ItemID = ""
var nameKey: String = ""
var renderClass: String = ""
var accepts: String = ""
var inputCount: Int = 0
var inputType: String = ""
var outputType: String = ""
}

View File

@@ -77,12 +77,12 @@ open class GameWorld : Disposable {
* Single block can have multiple conduits, different types of conduits are stored separately.
*/
@TEMzPayload("WiNt", TEMzPayload.EXTERNAL_JSON)
private val wirings: HashMap<BlockAddress, SortedArrayList<WiringNode>>
private val wirings: HashMap<BlockAddress, WiringNode>
/**
* Used by the renderer. When wirings are updated, `wirings` and this properties must be synchronised.
*/
private val wiringBlocks: HashMap<BlockAddress, ItemID>
//private val wiringBlocks: HashMap<BlockAddress, ItemID>
//public World physWorld = new World( new Vec2(0, -Terrarum.game.gravitationalAccel) );
//physics
@@ -130,7 +130,7 @@ open class GameWorld : Disposable {
fluidTypes = HashMap()
fluidFills = HashMap()
wiringBlocks = HashMap()
//wiringBlocks = HashMap()
wirings = HashMap()
// temperature layer: 2x2 is one cell
@@ -173,7 +173,7 @@ open class GameWorld : Disposable {
fluidTypes = layerData.fluidTypes
fluidFills = layerData.fluidFills
wiringBlocks = HashMap()
//wiringBlocks = HashMap()
wirings = HashMap()
spawnX = layerData.spawnX
@@ -312,48 +312,25 @@ open class GameWorld : Disposable {
Terrarum.ingame?.queueTerrainChangedEvent(oldTerrain, itemID, LandUtil.getBlockAddr(this, x, y))
}
/*fun setTileWire(x: Int, y: Int, tile: Byte) {
fun setTileWire(x: Int, y: Int, tile: ItemID, bypassEvent: Boolean) {
val (x, y) = coerceXY(x, y)
val oldWire = getTileFromWire(x, y)
layerWire.setTile(x, y, tile)
val blockAddr = LandUtil.getBlockAddr(this, x, y)
val wireNode = wirings[blockAddr]
if (oldWire != null)
Terrarum.ingame?.queueWireChangedEvent(oldWire, tile.toUint(), LandUtil.getBlockAddr(this, x, y))
}*/
fun getWiringBlocks(x: Int, y: Int): ItemID {
return Block.AIR // TODO
//return wiringBlocks.getOrDefault(LandUtil.getBlockAddr(this, x, y), Block.AIR)
}
fun getAllConduitsFrom(x: Int, y: Int): SortedArrayList<WiringNode>? {
return wirings.get(LandUtil.getBlockAddr(this, x, y))
}
/**
* @param conduitTypeBit defined in net.torvald.terrarum.blockproperties.Wire, always power-of-two
*/
fun getConduitByTypeFrom(x: Int, y: Int, conduitTypeBit: Int): WiringNode? {
val conduits = getAllConduitsFrom(x, y)
return conduits?.searchFor(conduitTypeBit) { it.typeBitMask }
}
fun addNewConduitTo(x: Int, y: Int, node: WiringNode) {
// TODO needs new conduit storage scheme
/*val blockAddr = LandUtil.getBlockAddr(this, x, y)
// check for existing type of conduit
// if there's no duplicate...
if (getWiringBlocks(x, y) and node.typeBitMask == 0) {
// store as-is
wirings.getOrPut(blockAddr) { SortedArrayList() }.add(node)
// synchronise wiringBlocks
wiringBlocks[blockAddr] = (wiringBlocks[blockAddr] ?: 0) or node.typeBitMask
if (wireNode == null) {
wirings[blockAddr] = WiringNode(blockAddr, SortedArrayList())
}
else {
TODO("need overwriting policy for existing conduit node")
}*/
wirings[blockAddr]!!.wires.add(tile)
if (!bypassEvent)
Terrarum.ingame?.queueWireChangedEvent(tile, LandUtil.getBlockAddr(this, x, y))
}
fun getAllWiresFrom(x: Int, y: Int): SortedArrayList<ItemID>? {
val (x, y) = coerceXY(x, y)
val blockAddr = LandUtil.getBlockAddr(this, x, y)
return wirings[blockAddr]?.wires
}
fun getTileFrom(mode: Int, x: Int, y: Int): ItemID {
@@ -363,9 +340,6 @@ open class GameWorld : Disposable {
else if (mode == WALL) {
return getTileFromWall(x, y)
}
else if (mode == WIRE) {
return getWiringBlocks(x, y)
}
else
throw IllegalArgumentException("illegal mode input: " + mode.toString())
}
@@ -532,10 +506,8 @@ open class GameWorld : Disposable {
* If the wire does not allow them (e.g. wire bridge, thicknet), connect top-bottom and left-right nodes.
*/
data class WiringNode(
val position: BlockAddress,
/** One defined in WireCodex, always power of two */
val typeBitMask: Int,
var fills: Float = 0f
val position: BlockAddress, // may seem redundant and it kinda is, but don't remove!
val wires: SortedArrayList<ItemID> // what could possibly go wrong bloating up the RAM footprint when it's practically infinite these days?
) : Comparable<WiringNode> {
override fun compareTo(other: WiringNode): Int {
return (this.position - other.position).sign

View File

@@ -16,6 +16,8 @@ import net.torvald.terrarum.worlddrawer.BlocksDrawer
import java.util.*
/**
* ItemCodex holds information of every item in the game, including blocks despite the 'item' naming
*
* Created by minjaesong on 2016-03-15.
*/
object ItemCodex {
@@ -94,7 +96,10 @@ object ItemCodex {
else if (itemID.startsWith("item@")) {
return itemCodex[itemID]?.itemImage
}
// TODO: wires
// wires
else if (itemID.startsWith("wire@")) {
return itemCodex[itemID]?.itemImage
}
// wall
else if (itemID.startsWith("wall@")) {
val itemSheetNumber = AppLoader.tileMaker.tileIDtoItemSheetNumber(itemID.substring(5))

View File

@@ -355,20 +355,6 @@ object IngameRenderer : Disposable {
internal var fboRGBexportRequested = false
/**
* Which wires should be drawn. Normally this value is set by the wiring item (e.g. wire pieces, wirecutters)
* This number is directly related with the World's wire bits:
*
* ```
* world.getWires(x, y) -> 0000101 (for example)
* value of 3 selects this ^ ^
* value of 1 selects this |
*
* The wire piece gets rendered when selected bit is set.
* ```
*/
var selectedWireBitToDraw = 0
private fun drawToRGB(
actorsRenderBehind: List<ActorWithBody>?,
actorsRenderMiddle: List<ActorWithBody>?,
@@ -411,7 +397,7 @@ object IngameRenderer : Disposable {
}
setCameraPosition(0f, 0f)
BlocksDrawer.drawFront(batch.projectionMatrix, selectedWireBitToDraw) // blue coloured filter of water, etc.
BlocksDrawer.drawFront(batch.projectionMatrix) // blue coloured filter of water, etc.
batch.inUse {
FeaturesDrawer.drawEnvOverlay(batch)

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.faction.FactionFactory
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
@@ -92,9 +93,16 @@ object PlayerBuilderSigrid {
inventory.add("item@basegame:1", 16) // copper pick
inventory.add("item@basegame:2") // iron pick
inventory.add("item@basegame:3") // steel pick
inventory.add("item@basegame:4", 9995) // wire piece
inventory.add("item@basegame:5", 385930603) // test tiki torch
inventory.add("item@basegame:6", 95) // crafting table
WireCodex.getAll().forEach {
try {
inventory.add(it.id, 9995)
}
catch (e: Throwable) {
System.err.println("[PlayerBuilder] $e")
}
}
}
}

View File

@@ -3,6 +3,8 @@ package net.torvald.terrarum.modulebasegame.gameitems
import net.torvald.terrarum.Point2d
import net.torvald.terrarum.Point2i
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.gameitem.ItemID
@@ -11,6 +13,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.worlddrawer.BlocksDrawer
/**
* Created by minjaesong on 2019-05-02.
@@ -73,35 +76,36 @@ object BlockBase {
}
fun blockEffectWhenEquipped(delta: Float) {
IngameRenderer.selectedWireBitToDraw = 0
BlocksDrawer.selectedWireRenderClass = ""
}
fun wireStartPrimaryUse(gameItem: GameItem, wireTypeBit: Int, delta: Float): Boolean {
return false // TODO need new wire storing format
/*val ingame = Terrarum.ingame!! as TerrarumIngame
fun wireStartPrimaryUse(gameItem: GameItem, delta: Float): Boolean {
val itemID = gameItem.originalID
val ingame = Terrarum.ingame!! as TerrarumIngame
val mouseTile = Point2i(Terrarum.mouseTileX, Terrarum.mouseTileY)
// return false if the tile is already there
if (ingame.world.getWiringBlocks(mouseTile.x, mouseTile.y) and wireTypeBit != 0)
if (ingame.world.getAllWiresFrom(mouseTile.x, mouseTile.y)?.searchFor(itemID) != null)
return false
// filter passed, do the job
// FIXME this is only useful for Player
ingame.world.addNewConduitTo(
ingame.world.setTileWire(
mouseTile.x,
mouseTile.y,
GameWorld.WiringNode(
LandUtil.getBlockAddr(ingame.world, mouseTile.x, mouseTile.y),
wireTypeBit,
0f
)
itemID,
false
)
return true*/
return true
}
fun wireEffectWhenEquipped(typebit: Int, delta: Float) {
IngameRenderer.selectedWireBitToDraw = typebit
fun wireEffectWhenEquipped(gameItem: GameItem, delta: Float) {
val itemID = gameItem.originalID
BlocksDrawer.selectedWireRenderClass = WireCodex[itemID].renderClass
}
fun wireEffectWhenUnequipped(gameItem: GameItem, delta: Float) {
BlocksDrawer.selectedWireRenderClass = ""
}
}

View File

@@ -8,9 +8,11 @@ import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.itemproperties.Material
/**
* @param originalID something like `basegame:8192` (the id must exist on wires.csv)
*
* Created by minjaesong on 2019-03-10.
*/
class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
class WirePieceSignalWire(originalID: ItemID, private val atlasID: String, private val sheetX: Int, private val sheetY: Int) : GameItem(originalID) {
override var dynamicID: ItemID = originalID
override val originalName = "ITEM_WIRE"
@@ -22,7 +24,7 @@ class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
override val isDynamic = false
override val material = Material()
override val itemImage: TextureRegion?
get() = CommonResourcePool.getAsTextureRegionPack("basegame.items16").get(1,9)
get() = CommonResourcePool.getAsTextureRegionPack(atlasID).get(sheetX, sheetY)
init {
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
@@ -30,10 +32,14 @@ class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
}
override fun startPrimaryUse(delta: Float): Boolean {
return BlockBase.wireStartPrimaryUse(this, Wire.BIT_SIGNAL_RED, delta)
return BlockBase.wireStartPrimaryUse(this, delta)
}
override fun effectWhenEquipped(delta: Float) {
BlockBase.wireEffectWhenEquipped(Wire.BIT_SIGNAL_RED, delta)
BlockBase.wireEffectWhenEquipped(this, delta)
}
override fun effectOnUnequip(delta: Float) {
BlockBase.wireEffectWhenUnequipped(this, delta)
}
}

View File

@@ -159,10 +159,12 @@ class BasicDebugInfoWindow : UICanvas() {
if (ingame != null) {
val wallNum = ingame!!.world.getTileFromWall(mouseTileX, mouseTileY)
val tileNum = ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY)
val wireNum = ingame!!.world.getWiringBlocks(mouseTileX, mouseTileY)
val wires = ingame!!.world.getAllWiresFrom(mouseTileX, mouseTileY)
val fluid = ingame!!.world.getFluid(mouseTileX, mouseTileY)
printLine(batch, 9, "tile@cursor ${ccO}W$ccG$wallNum ${ccO}T$ccG$tileNum ${ccO}C$ccG${wireNum} $ccY($mtX, $mtY)")
val wireCount = wires?.size?.toString() ?: "no"
printLine(batch, 9, "tile@cursor ${ccO}W$ccG$wallNum ${ccO}T$ccG$tileNum ${ccO}C$ccG($wireCount wires) $ccY($mtX, $mtY)")
printLine(batch, 10, "fluid@cursor ${ccO}Type $ccG${fluid.type.value} ${ccO}Fill $ccG${fluid.amount}f")
}

View File

@@ -170,6 +170,11 @@ internal object BlocksDrawer {
// NO draw lightmap using colour filter, actors must also be hidden behind the darkness
///////////////////////////////////////////
/**
* Which wires should be drawn. Normally this value is set by the wiring item (e.g. wire pieces, wirecutters)
*/
var selectedWireRenderClass = ""
internal fun renderData() {
try {
@@ -200,10 +205,8 @@ internal object BlocksDrawer {
renderUsingBuffer(FLUID, projectionMatrix, drawGlow)
}
var drawWires = 0
private set
internal fun drawFront(projectionMatrix: Matrix4, drawWires: Int) {
internal fun drawFront(projectionMatrix: Matrix4) {
// blend mul
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
Gdx.gl.glEnable(GL20.GL_BLEND)
@@ -216,8 +219,7 @@ internal object BlocksDrawer {
gdxSetBlendNormal()
this.drawWires = drawWires
if (drawWires != 0) {
if (selectedWireRenderClass.isNotBlank()) {
//println("Wires! draw: $drawWires") // use F10 instead
renderUsingBuffer(WIRE, projectionMatrix, false)
}

View File

@@ -12,6 +12,7 @@ import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.BlockProp
import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld
@@ -102,13 +103,14 @@ class CreateTileAtlas {
throw Error("Path '${dir.path()}' is not a directory")
}
dir.list().filter { tgaFile -> !tgaFile.isDirectory && (tgaFile.name().matches(tileNameRegex)) }
// filter files that do not exist on the blockcodex
dir.list().filter { tgaFile -> !tgaFile.isDirectory && (BlockCodex.getOrNull("$modname:${tgaFile.nameWithoutExtension()}") != null) }
.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()}")

View File

@@ -98,7 +98,7 @@ class SortedArrayList<T>(initialSize: Int = 10) : Iterable<T> {
* @param searchQuery what exactly are we looking for?
* @param searchHow and where or how can it be found?
*/
fun <R: Comparable<R>> searchFor(searchQuery: R, searchHow: (T) -> R): T? = getOrNull(searchForIndex(searchQuery, searchHow))
fun <R: Comparable<R>> searchFor(searchQuery: R, searchHow: (T) -> R = { it as R }): T? = getOrNull(searchForIndex(searchQuery, searchHow))
override fun iterator() = arrayList.iterator()
inline fun forEach(action: (T) -> Unit) = arrayList.forEach(action)