/// <summary> /// Connects a given circuit component as an input to the /// invoking logic gate. /// </summary> /// <param name="wire">The component to connect</param> public void ConnectInput(CircuitComponent component, int sourceindex) { // If we already made this connection, we're done! if (!_inputComponents.ContainsKey(component)) { _inputComponents[component] = new List <int>(); } // Make the connection. _inputComponents[component].Add(sourceindex); // Ensure that the given component also has this connection. component.ConnectOutput(this, sourceindex); }
/// <summary> /// Connects a given circuit component as an input to the /// invoking logic gate. /// </summary> /// <param name="wire">The component to connect</param> public void ConnectInput(CircuitComponent component, int index) { // If we already made this connection, we're done! if (_inputComponents.ContainsKey(component)) { return; } // Make the connection. _inputComponents.Add(component, index); // Ensure that the given component also has this connection. component.ConnectOutput(this, index); }
/// <summary> /// Connects all the circuit components (logic gates, /// circuit inputs, and circuit outputs) that share /// a wire-mesh to each other /// </summary> private void connectComponentsToComponents() { foreach (WireMesh wireMesh in _wireMeshes.Values) { if (!wireMesh.HasSource) { continue; } CircuitComponent wireInput = wireMesh.Source; foreach (CircuitComponent wireOutput in wireMesh.Dependents) { wireInput.ConnectOutput(wireOutput, wireMesh.SourceIndex); } } }