Esempio n. 1
0
 void SetNodes(NodeData[] nodes, NodeAdded onNodeAdded)
 {
     foreach (NodeData node in nodes)
     {
         var newNode = NodesFactory.GetNode(node);
         AddNode(newNode, node.Guid, node);
         if (onNodeAdded != null)
         {
             onNodeAdded(newNode, node);
         }
     }
 }
Esempio n. 2
0
        void SetNodes(NodeData[] nodes)
        {
            var attributesCounter = 0;

            foreach (NodeData node in nodes)
            {
                var newNode = nodeFactory.GetNode(node);
                Constellation.AddNode(newNode, node.Guid);
                if (IsAttribute(node) && Attributes != null)
                {
                    IAttribute nodeAttribute = newNode.NodeType as IAttribute;
                    if (node.Name != "ObjectAttribute" && attributesCounter < Attributes.Count)
                    {
                        nodeAttribute.SetAttribute(Attributes[attributesCounter].Variable);
                    }
                    else if (attributesCounter < Attributes.Count)
                    {
                        nodeAttribute.SetAttribute(new Variable().Set(Attributes[attributesCounter].UnityObject as object));
                    }

                    attributesCounter++;
                }
            }
        }
Esempio n. 3
0
        public NodeData AddNode(NodesFactory nodesFactory, string nodeName, string nameSpace, ConstellationScriptData constellationScript)
        {
            var newNode  = nodesFactory.GetNode(nodeName, nameSpace, new UnityConstellationParser());
            var nodeData = new NodeData(newNode);

            foreach (var constellationRule in constellationRules)
            {
                nodeData = constellationRule.NodeAdded(nodeData, newNode, constellationScript);
            }

            nodeData           = constellationScript.AddNode(nodeData);
            nodeData.XPosition = 0;
            nodeData.YPosition = 0;

            return(nodeData);
        }
Esempio n. 4
0
        public void UpdateScriptNodes(ConstellationScriptData script, ConstellationScriptData[] constellationScripts, IConstellationFileParser constellationFileParser)
        {
            List <NodeData> nodesToRemove = new List <NodeData>();

            NodesFactory = new NodesFactory(constellationScripts);
            foreach (var node in script.Nodes)
            {
                var nodeObject = NodesFactory.GetNodeSafeMode(node, constellationFileParser);
                foreach (var parsingRule in parsingRules)
                {
                    if (!parsingRule.isNodeValid(node, nodeObject, NodesFactory))
                    {
                        nodesToRemove.Add(node);
                        break;
                    }
                }
            }

            foreach (var node in nodesToRemove)
            {
                script.RemoveNode(node.Guid);
                var replacementNode = NodesFactory.GetNode(node.Name, node.Namespace, new UnityConstellationParser());
                if (replacementNode != null)
                {
                    replacementNode.XPosition = node.XPosition;
                    replacementNode.YPosition = node.YPosition;
                    replacementNode.XSize     = node.SizeX;
                    replacementNode.YSize     = node.SizeY;

                    if (node.ParametersData != null && replacementNode.NodeParameters != null)
                    {
                        if (node.ParametersData.Count == replacementNode.NodeParameters.Count)
                        {
                            for (var i = 0; i < replacementNode.NodeParameters.Count; i++)
                            {
                                replacementNode.NodeParameters[i].Value = new Ray(node.ParametersData[i].Value);
                            }
                        }
                    }


                    if (node.Inputs != null && replacementNode.Inputs != null)
                    {
                        if (node.Inputs.Count >= replacementNode.Inputs.Count)
                        {
                            for (var i = 0; i < replacementNode.Inputs.Count; i++)
                            {
                                replacementNode.Inputs[i].Guid = node.Inputs[i].Guid;
                            }
                        }
                        else
                        {
                            for (var i = 0; i < node.Inputs.Count; i++)
                            {
                                replacementNode.Inputs[i].Guid = node.Inputs[i].Guid;
                            }
                        }
                    }

                    if (node.Outputs != null && replacementNode.Outputs != null)
                    {
                        if (node.Outputs.Count >= replacementNode.Outputs.Count)
                        {
                            for (var i = 0; i < replacementNode.Outputs.Count; i++)
                            {
                                replacementNode.Outputs[i].Guid = node.Outputs[i].Guid;
                            }
                        }
                        else
                        {
                            for (var i = 0; i < node.Outputs.Count; i++)
                            {
                                replacementNode.Outputs[i].Guid = node.Outputs[i].Guid;
                            }
                        }
                    }
                    script.AddNode(new NodeData(replacementNode));
                }
                else
                {
                    script.RemoveNode(node.Guid);
                }
            }

            foreach (var link in script.Links)
            {
                //if()
            }
        }