Ejemplo n.º 1
0
        private void BeginProcessingNodes()
        {
            foreach (Node n in nodes)
            {
                PCGNode nn = n as PCGNode;
                if (nn != null)
                {
                    bool hasInput = false;
                    foreach (NodePort np in nn.Inputs)
                    {
                        if (np.ConnectionCount > 0)
                        {
                            hasInput = true;
                            break;
                        }
                    }

                    if (hasInput)
                    {
                        UnProcessed.Add(nn);
                    }
                    else
                    {
                        ToBeProcessed.Add(nn);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public virtual void UpdateData(bool withOutputs = true)
 {
     if (withOutputs)
     {
         //update all outputs
         foreach (NodePort np in Outputs)
         {
             for (int i = 0; i < np.ConnectionCount; i++)
             {
                 PCGNode nn = (PCGNode)np.GetConnection(i).node;
                 if (nn != null)
                 {
                     nn.UpdateData();
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void ProcessNodes()
        {
            for (int i = ToBeProcessed.Count - 1; i >= 0; i--)
            {
                PCGNode node = ToBeProcessed[i];
                ToBeProcessed.RemoveAt(i);
                node.UpdateData(false);
                Processed.Add(node);
            }

            for (int i = UnProcessed.Count - 1; i >= 0; i--)
            {
                PCGNode node           = UnProcessed[i];
                bool    canBeProcessed = true;
                foreach (NodePort np in node.Inputs)
                {
                    foreach (NodePort outer in np.GetConnections())
                    {
                        PCGNode connectedNode = outer.node as PCGNode;
                        if (connectedNode != null)
                        {
                            if (!Processed.Contains(connectedNode))
                            {
                                canBeProcessed = false;
                                break;
                            }
                        }
                    }
                }
                if (canBeProcessed)
                {
                    UnProcessed.RemoveAt(i);
                    ToBeProcessed.Add(node);
                }
            }
        }