public void rediscoverNetwork(IWorldAccessor world) { // System.out.println("rediscovering networks"); BlockEntity te = world.BlockAccessor.GetBlockEntity(firstPowerNode); if (te is IMechanicalPowerNetworkNode) { // System.out.println("go"); IMechanicalPowerNetworkNode node = (IMechanicalPowerNetworkNode)te; node.propagateNetworkToNeighbours(myManager.getUniquePropagationId(), networkId, node.getOutputSideForNetworkPropagation()); } //System.out.println("rediscovery complete, found " + powerNodes.size() + " power nodes"); }
public void rebuildNetwork() { //System.out.println("rebuilding network"); foreach (IMechanicalPowerDevice device in powerRelays) { if (device != null) { device.clearNetwork(); } } if (powerNodes.Count == 0) { //System.out.println("no more power nodes in the network :("); return; } IMechanicalPowerNetworkNode firstNode = powerNodes[0]; Dictionary <IMechanicalPowerNetworkNode, BlockFacing> otherNodes = new Dictionary <IMechanicalPowerNetworkNode, BlockFacing>(); foreach (IMechanicalPowerNetworkNode powernode in powerNodes) { if (powernode != null && firstNode != powernode) { otherNodes[powernode] = powernode.getFacing(this); powernode.clearNetwork(); } } if (firstNode == null) { //System.out.println("node is null"); return; } powerNodes.Clear(); powerRelays.Clear(); firstNode.propagateNetworkToNeighbours( myManager.getUniquePropagationId(), networkId, firstNode.getOutputSideForNetworkPropagation() ); // Whatever power nodes are now not in the current network now need to have the current network forked for them foreach (IMechanicalPowerNetworkNode otherNode in otherNodes.Keys) { bool found = false; foreach (MechanicalNetwork network in otherNode.getNetworks()) { if (network.networkId == networkId) { found = true; } } if (!found) { //System.out.println("forked network"); forkMechanicalNetwork(otherNode, otherNodes[otherNode]); } } //System.out.println("total networks in game: " + myManager.networksById.size()); }