Skip to content

Commit

Permalink
Make wires force-disconnect their neighbors
Browse files Browse the repository at this point in the history
  • Loading branch information
amadornes committed Dec 22, 2021
1 parent 74a29bc commit 7f61975
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public void onAdded() {
public void beforeRemove() {
super.beforeRemove();
invalidateNetworks();
for (var side : getConnectableSides()) {
if (getState(side).isWire() && getConnectionTarget(side) instanceof WireComponentBase<?> wire) {
wire.setState(side.getOpposite(), WireConnectionState.DISCONNECTED);
}
}
}

@Override
Expand Down Expand Up @@ -113,7 +118,7 @@ private Pair<VecDirectionFlags, Boolean> updateConnections(VecDirectionFlags nei
}

// If there is no neighbor
if (neighbor == null) {
if (neighbor == null || (state.isWire() && neighbor.getInterface(neighborSide, state.getTargetInterface()) == null)) {
// And it wasn't disconnected
if (state != WireConnectionState.DISCONNECTED) {
// If it was connected to a wire, schedule a network recalculation
Expand Down

0 comments on commit 7f61975

Please sign in to comment.