public Constellation(ConstellationScriptData constellationScriptData, NodesFactory nodesFactory, IConstellationFileParser constellationFileParser, NodeAdded onNodeAdded = null) { fileParser = constellationFileParser; isConstellationInitialized = false; NodesFactory = nodesFactory; var newAssembly = new List <ConstellationScriptData>(); if (nodesFactory.GetStaticScripts() == null || nodesFactory.GetIsLocalScope()) { foreach (var node in constellationScriptData.Nodes) { if (node.Namespace == ConstellationNodes.NameSpace.NAME) { newAssembly.Add(constellationFileParser.ParseConstellationScript(node.DiscreteParametersData[1].Value.GetString())); } } nodesFactory.UpdateConstellationScripts(newAssembly.ToArray()); nodesFactory.SetLocalScope(); } SetNodes(constellationScriptData.GetNodes(), onNodeAdded); SetLinks(constellationScriptData.GetLinks()); isConstellationInitialized = true; }
public Node <INode> AddNode(Node <INode> node, string guid, NodeData nodeData = null) { if (Nodes == null) { Nodes = new List <Node <INode> >(); } var newNode = node; newNode.Initialize(guid, node.Name); if (nodeData != null) { newNode.XPosition = nodeData.XPosition; newNode.YPosition = nodeData.YPosition; newNode.XSize = nodeData.SizeX; newNode.YSize = nodeData.SizeY; for (var i = 0; i < newNode.Inputs.Count; i++) { newNode.Inputs[i].Type = nodeData.Inputs[i].Type; } for (var i = 0; i < newNode.Outputs.Count; i++) { newNode.Outputs[i].Type = nodeData.Outputs[i].Type; } } Nodes.Add(newNode); if (newNode.NodeType is ICustomNode) { (newNode.NodeType as ICustomNode).InitializeConstellation(NodesFactory.GetStaticConstellationScripts(), fileParser, NodesFactory.GetIsLocalScope()); } if (Injector != null) { Injector.RefreshConstellationEvents(); } if (isConstellationInitialized) { if (newNode.NodeType is IAwakable) { (newNode.NodeType as IAwakable).OnAwake(); } } return(newNode); }