public void TryToAddConnection(Connection con) { NodePos pos1 = con.pos1; NodePos pos2 = con.pos2; SignalNetwork net1 = GetNetworkAt(pos1, false); SignalNetwork net2 = GetNetworkAt(pos2, false); if (net1 == null && net2 == null) { return; } if (net1 == null) { ISignalNode node = GetDeviceAt(pos1.blockPos)?.GetNodeAt(pos1); if (node == null) { return; } net2.AddNodesFoundFrom(pos1, node); } else if (net2 == null) { ISignalNode node = GetDeviceAt(pos2.blockPos)?.GetNodeAt(pos2); if (node == null) { return; } net1.AddNodesFoundFrom(pos2, node); } AddConnection(con); }