Esempio n. 1
0
        public NodeType?GetOutputType()
        {
            if (OutputNode == null)
            {
                return(null);
            }

            if (OutputNode.Outputs.Count == 0)
            {
                return(null);
            }

            NodeOutput op = OutputNode.Outputs.Find(m => m.Type != NodeType.Execute);

            return(op.Type);
        }
Esempio n. 2
0
        /// <summary>
        /// This is used in the Undo / Redo System
        /// </summary>
        /// <returns></returns>
        public List <NodeConnection> GetParentConnections()
        {
            List <NodeConnection> connections = new List <NodeConnection>();
            int i = 0;

            foreach (NodeInput n in Inputs)
            {
                if (n.HasInput)
                {
                    int idx = n.Input.Node.Outputs.IndexOf(n.Input);
                    if (idx > -1)
                    {
                        NodeOutput     no  = n.Input.Node.Outputs[idx];
                        int            ord = no.To.IndexOf(n);
                        NodeConnection nc  = new NodeConnection(n.Input.Node.Id, Id, idx, i, ord);
                        connections.Add(nc);
                    }
                }
                i++;
            }

            return(connections);
        }
Esempio n. 3
0
        protected List <Node> TravelBranch(Node parent, HashSet <Node> seen)
        {
            List <Node>  forward = new List <Node>();
            Queue <Node> queue   = new Queue <Node>();

            queue.Enqueue(parent);

            while (queue.Count > 0)
            {
                int  count = 0;
                Node n     = queue.Dequeue();

                if (seen.Contains(n))
                {
                    continue;
                }

                seen.Add(n);

                count = n.Inputs.Count;
                for (int i = 0; i < count; i++)
                {
                    NodeInput op = n.Inputs[i];

                    if (op.HasInput)
                    {
                        bool nodeHasExecute = op.Input.Node.Outputs.Find(m => m.Type == NodeType.Execute) != null;

                        if (!nodeHasExecute)
                        {
                            //we don't trigger seen as
                            //it may be shared by another node
                            //further up the chain
                            //this type of node can only be
                            //one of two node types: Get Var
                            //and Constant types
                            //everything else requires
                            //an execute flow
                            forward.Add(op.Input.Node);
                        }
                    }
                }

                forward.Add(n);

                //prevent going past outputnode
                //if there is is one
                //this saves some time
                //in case the graphs have
                //nodes after the output
                //for some reason
                if (n == OutputNode)
                {
                    continue;
                }

                if (n.Outputs.Count > 0)
                {
                    int i = 0;
                    count = n.Outputs.Count;
                    for (i = 0; i < count; i++)
                    {
                        NodeOutput op = n.Outputs[i];

                        //we don't care about the actual for loop internals at the momemnt
                        //as each for loop will handle it
                        if (n is ForLoopNode && i == 0)
                        {
                            continue;
                        }

                        if (op.Type == NodeType.Execute)
                        {
                            if (op.To.Count > 1)
                            {
                                //we use recursion if there are multiple links
                                //from one output
                                //otherwise we queue up in queue
                                //and proceed in order
                                int count2 = op.To.Count;
                                for (int j = 0; j < count2; j++)
                                {
                                    NodeInput t      = op.To[j];
                                    var       branch = TravelBranch(t.Node, seen);
                                    forward.AddRange(branch);
                                }
                            }
                            else if (op.To.Count > 0)
                            {
                                queue.Enqueue(op.To[0].Node);
                            }
                        }
                    }
                }
            }

            return(forward);
        }
Esempio n. 4
0
 public void AssignReference(NodeOutput output)
 {
     reference = output;
 }
Esempio n. 5
0
 public void AssignInput(NodeOutput oinp)
 {
     input = oinp;
 }