public static void BypassWire(Input[] bypassFrom, Output[] bypassTo) { if (bypassFrom.Length != bypassTo.Length) { throw new Exception($"Can't bypass io when they are not of the same size. From: {bypassFrom.Length}, To: {bypassTo.Length}"); } for (int i = 0; i < bypassFrom.Length; i++) { Input from = bypassFrom[i]; Output to = bypassTo[i]; Connection[] connectFromCons = from.GetConnections(); Input[] connectTo = to.GetConnectedInputs().ToArray(); from.DisconnectAll(); foreach (var input in connectTo) { input.DisconnectAll(); foreach (var connection in connectFromCons) { connection.From.ConnectToInput(input, false, false, connection.Condition); } } } //After bypassing, the io shouldn't be connected to anything Debug.Assert(bypassFrom.All(x => !x.IsConnectedToAnything())); Debug.Assert(bypassTo.All(x => !x.IsConnectedToAnything())); }