mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 13:04:05 +09:00
wire sim incremental graph update (partial)
This commit is contained in:
@@ -58,23 +58,24 @@ open class Electric : FixtureBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* When an Electric fixture is spawned, mark all wire graphs as structurally dirty
|
||||
* so they rebuild to include this fixture's emitter/sink nodes.
|
||||
* When an Electric fixture is spawned, mark wire graphs as needing structural rebuild.
|
||||
* This ensures the graphs will be rebuilt to include this fixture's emitter/sink nodes.
|
||||
*/
|
||||
override fun onSpawn(tx: Int, ty: Int) {
|
||||
super.onSpawn(tx, ty)
|
||||
// Mark wire graphs as needing structural rebuild to include this fixture
|
||||
// Mark wire graphs for rebuild - incremental fixture updates have timing issues
|
||||
// because the fixture may not be fully initialised in actorContainerActive yet
|
||||
if (wireEmitterTypes.isNotEmpty() || wireSinkTypes.isNotEmpty()) {
|
||||
INGAME.world.logicalWireGraph.markAllStructureDirty()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When an Electric fixture is despawned, mark all wire graphs as structurally dirty
|
||||
* so they rebuild without this fixture's nodes.
|
||||
* When an Electric fixture is despawned, mark wire graphs as needing structural rebuild.
|
||||
* This ensures the graphs will be rebuilt without this fixture's nodes.
|
||||
*/
|
||||
override fun despawn() {
|
||||
// Mark wire graphs as needing structural rebuild before this fixture is removed
|
||||
// Mark wire graphs for rebuild before this fixture is removed
|
||||
if (wireEmitterTypes.isNotEmpty() || wireSinkTypes.isNotEmpty()) {
|
||||
INGAME.world.logicalWireGraph.markAllStructureDirty()
|
||||
}
|
||||
|
||||
@@ -236,9 +236,9 @@ object BlockBase {
|
||||
oldTileX = mtx
|
||||
oldTileY = mty
|
||||
|
||||
// Rebuild logical wire graph after connectivity is fully established
|
||||
// Incrementally update logical wire graph after connectivity is fully established
|
||||
if (ret >= 0) {
|
||||
ingame.world.logicalWireGraph.rebuild(itemID)
|
||||
ingame.world.logicalWireGraph.updateAtPosition(itemID, mtx, mty)
|
||||
}
|
||||
|
||||
ret
|
||||
|
||||
@@ -87,6 +87,8 @@ class ItemWrench(originalID: ItemID) : GameItem(originalID), FixtureInteractionB
|
||||
else -> old
|
||||
}
|
||||
(INGAME as TerrarumIngame).world.setWireGraphOf(mtx, mty, "wire@basegame:256", new)
|
||||
// Update logical wire graph after connectivity change
|
||||
(INGAME as TerrarumIngame).world.logicalWireGraph.updateAtPosition("wire@basegame:256", mtx, mty)
|
||||
0L
|
||||
} ?: -1L
|
||||
}
|
||||
|
||||
@@ -67,6 +67,9 @@ object WireCutterBase {
|
||||
|
||||
wireItems.filter(wireFilter).notEmptyOrNull()?.forEach {
|
||||
disconnect(it, wireNetP.second!!, wireNetN.second!!, mouseTile.vector)
|
||||
// Update logical wire graph after connectivity change
|
||||
ingame.world.logicalWireGraph.updateAtPosition(it, mtx, mty)
|
||||
ingame.world.logicalWireGraph.updateAtPosition(it, ntx, nty)
|
||||
} ?: return@mouseInInteractableRangeTools false
|
||||
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user