mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
slight elaboration on world wire changed event
This commit is contained in:
@@ -71,7 +71,7 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
protected val terrainChangeQueue = Queue<BlockChangeQueueItem>()
|
protected val terrainChangeQueue = Queue<BlockChangeQueueItem>()
|
||||||
protected val wallChangeQueue = Queue<BlockChangeQueueItem>()
|
protected val wallChangeQueue = Queue<BlockChangeQueueItem>()
|
||||||
protected val wireChangeQueue = Queue<BlockChangeQueueItem>()
|
protected val wireChangeQueue = Queue<BlockChangeQueueItem>() // if 'old' is set and 'new' is blank, it's a wire cutter
|
||||||
|
|
||||||
override fun hide() {
|
override fun hide() {
|
||||||
}
|
}
|
||||||
@@ -161,9 +161,9 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
* @param old previous settings of conduits in bit set format.
|
* @param old previous settings of conduits in bit set format.
|
||||||
* @param new current settings of conduits in bit set format.
|
* @param new current settings of conduits in bit set format.
|
||||||
*/
|
*/
|
||||||
open fun queueWireChangedEvent(new: ItemID, position: Long) {
|
open fun queueWireChangedEvent(wire: ItemID, isRemoval: Boolean, position: Long) {
|
||||||
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
||||||
wireChangeQueue.addLast(BlockChangeQueueItem("", new, x, y))
|
wireChangeQueue.addLast(BlockChangeQueueItem(if (isRemoval) wire else "", if (isRemoval) "" else wire, x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -582,8 +582,9 @@ inline fun printStackTrace(obj: Any) = printStackTrace(obj, System.out) // becau
|
|||||||
|
|
||||||
fun printStackTrace(obj: Any, out: PrintStream = System.out) {
|
fun printStackTrace(obj: Any, out: PrintStream = System.out) {
|
||||||
if (AppLoader.IS_DEVELOPMENT_BUILD) {
|
if (AppLoader.IS_DEVELOPMENT_BUILD) {
|
||||||
Thread.currentThread().stackTrace.forEach {
|
Thread.currentThread().stackTrace.forEachIndexed { index, it ->
|
||||||
out.println("[${obj.javaClass.simpleName}] ... $it")
|
if (index >= 3)
|
||||||
|
out.println("[${obj.javaClass.simpleName}] ... $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -631,4 +632,9 @@ class UIContainer {
|
|||||||
|
|
||||||
interface Id_UICanvasNullable {
|
interface Id_UICanvasNullable {
|
||||||
fun get(): UICanvas?
|
fun get(): UICanvas?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// haskell-inspired array selectors
|
||||||
|
// head and last use first() and last()
|
||||||
|
fun <T> Array<T>.tail() = this.sliceArray(1 until this.size)
|
||||||
|
fun <T> Array<T>.init() = this.sliceArray(0 until this.lastIndex)
|
||||||
@@ -324,7 +324,7 @@ open class GameWorld : Disposable {
|
|||||||
wirings[blockAddr]!!.wires.add(tile)
|
wirings[blockAddr]!!.wires.add(tile)
|
||||||
|
|
||||||
if (!bypassEvent)
|
if (!bypassEvent)
|
||||||
Terrarum.ingame?.queueWireChangedEvent(tile, LandUtil.getBlockAddr(this, x, y))
|
Terrarum.ingame?.queueWireChangedEvent(tile, false, LandUtil.getBlockAddr(this, x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllWiresFrom(x: Int, y: Int): SortedArrayList<ItemID>? {
|
fun getAllWiresFrom(x: Int, y: Int): SortedArrayList<ItemID>? {
|
||||||
|
|||||||
Reference in New Issue
Block a user