mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
i dont even know what am i doing :/
This commit is contained in:
@@ -428,14 +428,14 @@ open class GameWorld : Disposable {
|
||||
wiringGraph[blockAddr]!![itemID]!!.recvStates.add(state)
|
||||
}
|
||||
|
||||
fun getAllWiringGraph(x: Int, y: Int): Iterable<Map.Entry<ItemID, WiringSimCell>>? {
|
||||
fun getAllWiringGraph(x: Int, y: Int): HashMap<ItemID, WiringSimCell>? {
|
||||
val (x, y) = coerceXY(x, y)
|
||||
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
||||
return getAllWiringGraphUnsafe(blockAddr)
|
||||
}
|
||||
|
||||
fun getAllWiringGraphUnsafe(blockAddr: BlockAddress): Iterable<Map.Entry<ItemID, WiringSimCell>>? {
|
||||
return wiringGraph[blockAddr]?.asIterable()
|
||||
fun getAllWiringGraphUnsafe(blockAddr: BlockAddress): HashMap<ItemID, WiringSimCell>? {
|
||||
return wiringGraph[blockAddr]
|
||||
}
|
||||
|
||||
fun clearAllWireRecvStateUnsafe(blockAddr: BlockAddress) {
|
||||
|
||||
@@ -6,9 +6,11 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
import net.torvald.terrarum.blockproperties.WireCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame.Companion.inUpdateRange
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.BlockBoxIndex
|
||||
@@ -478,11 +480,28 @@ object WorldSimulator {
|
||||
fixture.worldBlockPos?.let {
|
||||
val branchesVisited = ArrayList<Point2i>()
|
||||
val branchingStack = Stack<Point2i>()
|
||||
val startPoint = it + fixture.blockBoxIndexToPoint2i(bbi)
|
||||
branchingStack.push(startPoint)
|
||||
val point = it + fixture.blockBoxIndexToPoint2i(bbi)
|
||||
branchingStack.push(point.copy())
|
||||
|
||||
while (branchingStack.isNotEmpty()) {
|
||||
|
||||
// get all wires that matches 'accepts' (such as Red/Green/Blue wire) and propagate signal for each of them
|
||||
world.getAllWiresFrom(point.x, point.y)?.filter { WireCodex[it].accepts == wireType }?.forEach { wire ->
|
||||
world.getAllWiringGraph(point.x, point.y)?.get(wire)?.let { node ->
|
||||
val connexion = node.con.toInt()
|
||||
when (wireConToStatus[connexion]) {
|
||||
WireConStatus.THRU -> {
|
||||
// TODO
|
||||
}
|
||||
WireConStatus.END -> {
|
||||
// TODO
|
||||
}
|
||||
WireConStatus.BRANCH -> {
|
||||
// TODO
|
||||
branchingStack.push(point.copy())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user