public void AddChildCircuit(IntegratedCircuit circuit)
 {
     //Adds a child
     if (!children.Contains(circuit))
     {
         children.Add(circuit);
     }
 }
        public IntegratedCircuit(string name, IntegratedCircuit parent)
        {
            if (parent != null)
            {
                parent.AddChildCircuit(this);
            }

            this.name = name;
        }
        //Constructors
        public LogicNode(string name, IntegratedCircuit circuit, bool inverted = false, NodeType type = NodeType.internalNode, params LogicNode[] inputs)
        {
            //Do the normal constructor stuff
            circuit.AddNode(this, type);
            this.inverted = inverted;
            this.name = name;
            this.type = type;

            //Connect all the inputs
            foreach (LogicNode node in inputs)
            {
                this.inputs.Add(node);
            }

            //Call the intialize method
            Initialize();
        }
Beispiel #4
0
        private void BuildCircuitControls(IntegratedCircuit circuit)
        {
            //Creates a control for every node in the circuit, and in all of the circuit's children

            //Create controls for every child of the circuit
            for (int i = 0; i < circuit.ChildCount; i++)
            {
                BuildCircuitControls(circuit.GetChild(i));
            }

            //Create a checkbox for every node
            for (int i = 0; i < circuit.NodeCount; i++)
            {
                LogicNode node = circuit.GetNode(i);

                //Create and configure the checkbox
                CheckBox cb = new CheckBox();
                cb.Text = node.Name;
                cb.Enabled = false;

                //Add it to the flow panel
                flowPanel.Controls.Add(cb);

                //Add it to a different list depending on if it's an InputButton or not.
                if (node is InputButton)
                {
                    buttons.Add((InputButton)node);
                    buttonBoxes.Add(cb);
                    cb.Enabled = true;
                }
                else
                {
                    nodes.Add(node);
                    nodeBoxes.Add(cb);
                }
            }
        }
 /*
  * Propegates its input signal instantly, rather than on the next tick.
  * Can only have one input, so it can't be used as a gate.
  *
  * Useful for connecting input/output signals to integrated circuits without incurring extra delay.
  */
 public InstantNode(string name, IntegratedCircuit circuit, NodeType type = NodeType.internalNode, params LogicNode[] inputs)
     : base(name, circuit, false, type, inputs)
 {
 }
Beispiel #6
0
 public OrGate(string name, IntegratedCircuit circuit, bool inverted = false, NodeType type = NodeType.internalNode, params LogicNode[] inputs)
     : base(name, circuit, inverted, type, inputs)
 {
 }
 public void AddChild(IntegratedCircuit circuit)
 {
     childNames.Add(circuit.Name, new IntegratedCircuitParseData(circuit, parser));
 }
 public IntegratedCircuitParseData(IntegratedCircuit integratedCircuit, LogicCircuitParser parser)
 {
     this.integratedCircuit = integratedCircuit;
     this.parser = parser;
 }
        private void BeginIC(string[] parameters)
        {
            //Begins a new integrated circuit.
            IntegratedCircuitParseData currentIC = circuitStack.Peek();

            //Create the new IC
            IntegratedCircuit newIC = new IntegratedCircuit(parameters[0], currentIC.integratedCircuit);

            //Add it the to child list
            currentIC.AddChild(newIC);

            //Push it to the top of the stack.
            circuitStack.Push(new IntegratedCircuitParseData(newIC, this));
        }