Compare commits

..

No commits in common. "436456dcc53bbc89e3fd4060e6b6b21fd85934cf" and "43afa73df7743bc28578e1f8a383ffa037043dda" have entirely different histories.

2 changed files with 6 additions and 36 deletions

View File

@ -20,14 +20,10 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
private val livelyNodesList = ArrayList<EnergyCableBlockEntity.Node>()
fun addLivelyNode(node: EnergyCableBlockEntity.Node) {
when (contains(node)) {
ContainsStatus.ABOUT_TO_BE_REMOVED, ContainsStatus.ABOUT_TO_BE_ADDED -> { } // do nothing
ContainsStatus.DOES_NOT_BELONG -> throw IllegalArgumentException("$node does not belong to $this")
ContainsStatus.CONTAINS -> {
if (livelyNodes.add(node)) {
livelyNodesList.add(node)
}
}
require(node in nodesSet) { "$node does not belong to $this" }
if (livelyNodes.add(node)) {
livelyNodesList.add(node)
}
}
@ -99,14 +95,8 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
var transferredLastTick = Decimal.ZERO
private set
val availableThroughput: Decimal get() {
if (!throughputKnown) {
throughput = nodes.maxOf { it.energyThroughput }
throughputKnown = true
}
return throughput - transferredLastTick
}
val availableThroughput: Decimal
get() = throughput - transferredLastTick
private var throughputKnown = false
private var lastTick = 0

View File

@ -22,26 +22,6 @@ open class GraphNodeList<N : GraphNode<N, G>, G : GraphNodeList<N, G>> : ICondit
val nodesSet: Set<N> = Collections.unmodifiableSet(nodesSetInternal)
val size get() = nodesInternal.size
enum class ContainsStatus(val belongs: Boolean, val potentiallyBelongs: Boolean) {
ABOUT_TO_BE_REMOVED(true, false),
DOES_NOT_BELONG(false, false),
ABOUT_TO_BE_ADDED(false, true),
CONTAINS(true, true)
}
fun contains(node: N): ContainsStatus {
if (node in nodesSet) {
if (node in queuedRemove)
return ContainsStatus.ABOUT_TO_BE_REMOVED
return ContainsStatus.CONTAINS
} else if (node in queuedAdd) {
return ContainsStatus.ABOUT_TO_BE_ADDED
} else {
return ContainsStatus.DOES_NOT_BELONG
}
}
var isValid = true
private set