mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 22:44:04 +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)
|
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 (x, y) = coerceXY(x, y)
|
||||||
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
||||||
return getAllWiringGraphUnsafe(blockAddr)
|
return getAllWiringGraphUnsafe(blockAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllWiringGraphUnsafe(blockAddr: BlockAddress): Iterable<Map.Entry<ItemID, WiringSimCell>>? {
|
fun getAllWiringGraphUnsafe(blockAddr: BlockAddress): HashMap<ItemID, WiringSimCell>? {
|
||||||
return wiringGraph[blockAddr]?.asIterable()
|
return wiringGraph[blockAddr]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearAllWireRecvStateUnsafe(blockAddr: BlockAddress) {
|
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.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.blockproperties.Fluid
|
import net.torvald.terrarum.blockproperties.Fluid
|
||||||
|
import net.torvald.terrarum.blockproperties.WireCodex
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
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.TerrarumIngame.Companion.inUpdateRange
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.BlockBoxIndex
|
import net.torvald.terrarum.modulebasegame.gameactors.BlockBoxIndex
|
||||||
@@ -478,11 +480,28 @@ object WorldSimulator {
|
|||||||
fixture.worldBlockPos?.let {
|
fixture.worldBlockPos?.let {
|
||||||
val branchesVisited = ArrayList<Point2i>()
|
val branchesVisited = ArrayList<Point2i>()
|
||||||
val branchingStack = Stack<Point2i>()
|
val branchingStack = Stack<Point2i>()
|
||||||
val startPoint = it + fixture.blockBoxIndexToPoint2i(bbi)
|
val point = it + fixture.blockBoxIndexToPoint2i(bbi)
|
||||||
branchingStack.push(startPoint)
|
branchingStack.push(point.copy())
|
||||||
|
|
||||||
while (branchingStack.isNotEmpty()) {
|
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