public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Transform.NAME: INode nodeTransform = new Transform() as INode; return(new Node <INode>(nodeTransform)); case SetActive.NAME: INode nodeSetActive = new SetActive() as INode; return(new Node <INode>(nodeSetActive)); case GetComponent.NAME: INode nodeGetComponent = new GetComponent() as INode; return(new Node <INode>(nodeGetComponent)); case Instantiate.NAME: INode instantiate = new Instantiate() as INode; return(new Node <INode>(instantiate)); case FindByName.NAME: INode nodeFindByName = new FindByName() as INode; return(new Node <INode>(nodeFindByName)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case AddForce.NAME: INode nodeAddForce = new AddForce() as INode; return(new Node <INode> (nodeAddForce)); case AddTorque.NAME: INode nodeAddTorque = new AddTorque() as INode; return(new Node <INode> (nodeAddTorque)); case RigidBody.NAME: INode nodeRigidBody = new RigidBody() as INode; return(new Node <INode> (nodeRigidBody)); case Velocity.NAME: INode nodeVelocity = new Velocity() as INode; return(new Node <INode> (nodeVelocity)); case CollisionEnter.NAME: INode nodeCollisionEnter = new CollisionEnter() as INode; return(new Node <INode> (nodeCollisionEnter)); case CollisionStay.NAME: INode nodeCollisionStay = new CollisionStay() as INode; return(new Node <INode> (nodeCollisionStay)); case CollisionExit.NAME: INode nodeCollisionExit = new CollisionExit() as INode; return(new Node <INode> (nodeCollisionExit)); case FixedUpdate.NAME: INode nodeFixedUpdate = new FixedUpdate() as INode; return(new Node <INode> (nodeFixedUpdate)); case AddImpulseForce.NAME: INode nodeImpulse = new AddImpulseForce() as INode; return(new Node <INode> (nodeImpulse)); case Character.NAME: var nodeCharacter = new Character() as INode; return(new Node <INode> (nodeCharacter)); case CharacterForward.NAME: var nodeCharacterForward = new CharacterForward() as INode; return(new Node <INode> (nodeCharacterForward)); case CameraRaycast.NAME: var nodeCameraRayCast = new CameraRaycast() as INode; return(new Node <INode> (nodeCameraRayCast)); case AddImpulseTorque.NAME: var nodeAddImpulseTorque = new AddImpulseTorque() as INode; return(new Node <INode>(nodeAddImpulseTorque)); default: return(null); } }
public Node <INode> GetNode(string _nodeName, string _nodenamespaces, IConstellationFileParser jsonParser) { if (NodeGetters == null) { Setup(); } if (_nodenamespaces.Contains("|" + ConstellationTypes.StaticConstellationNode.NAME + "|")) { _nodenamespaces = "Custom"; } foreach (var nodesGetter in NodeGetters) { if (nodesGetter.GetNameSpace() == _nodenamespaces) { var node = nodesGetter.GetNode(_nodeName, jsonParser); if (node != null) { return(node); } } } return(null); }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Forward.NAME: var nodeForward = new Forward() as INode; return(new Node <INode> (nodeForward)); case Vec3.NAME: INode nodeVec3 = new Vec3() as INode; return(new Node <INode>(nodeVec3)); case SplitVec3.NAME: INode nodeSplitVec3 = new SplitVec3() as INode; return(new Node <INode>(nodeSplitVec3)); case LookAtPosition.NAME: INode nodeLookAt = new LookAtPosition() as INode; return(new Node <INode>(nodeLookAt)); case ScreenToWorld.NAME: INode nodeScreenToWorld = new ScreenToWorld() as INode; return(new Node <INode>(nodeScreenToWorld)); default: return(null); } }
public void SetupNodeIO(IConstellationFileParser constellationFileParser) { var constellation = constellationFileParser.ParseConstellationScript(constellationNodeData.Value.GetString());//constellationFileParser.ParseConstellationScript(constellationNodeData.Value.GetString()); NodeParameters = new List <Ray>(); foreach (var nestedNode in constellation.Nodes) { if (nestedNode.Name == CoreNodes.Entry.NAME || nestedNode.Name == CoreNodes.BrightEntry.NAME) { node.AddInput(this, nestedNode.Outputs[0].IsBright, nestedNode.Outputs[0].Type, nestedNode.GetParameters()[0].Value.GetString()); } if (nestedNode.Name == CoreNodes.Exit.NAME || nestedNode.Name == CoreNodes.BrightExit.NAME) { node.AddOutput(nestedNode.Inputs[0].IsBright, nestedNode.Inputs[0].Type, nestedNode.GetParameters()[0].Value.GetString()); } if (nestedNode.Name == Parameters.ValueParameter.NAME) { var attributeVariable = new Ray(0); node.AddParameter(attributeVariable, Parameter.ParameterType.Value, "The value"); NodeParameters.Add(attributeVariable); } if (nestedNode.Name == Parameters.WordParameter.NAME) { var attributeVariable = new Ray("Word"); node.AddParameter(attributeVariable, Parameter.ParameterType.Word, "The value"); NodeParameters.Add(attributeVariable); } } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case AudioSource.NAME: INode nodeAudioSource = new AudioSource() as INode; return(new Node <INode> (nodeAudioSource)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case AnimatorComponent.NAME: var nodeAnimator = new AnimatorComponent() as INode; return(new Node <INode> (nodeAnimator)); default: return(null); } }
public Node <INode> GetNode(NodeData _nodeData, IConstellationFileParser constellationFileParser) { Node <INode> node = null; foreach (var nodesGetter in NodeGetters) { if (nodesGetter.GetNameSpace() == _nodeData.Namespace) { var selectedNode = nodesGetter.GetNode(_nodeData.Name, constellationFileParser); if (selectedNode != null) { node = selectedNode; break; } } } var i = 0; foreach (Input input in node.GetInputs()) { input.Guid = _nodeData.GetInputs()[i].Guid; i++; } var j = 0; foreach (Output output in node.GetOutputs()) { output.Guid = _nodeData.GetOutputs()[j].Guid; j++; } var a = 0; foreach (Parameter parameter in node.GetParameters()) { if (_nodeData.GetParameters()[a].Value.IsFloat()) { parameter.Value.Set(_nodeData.GetParameters()[a].Value.GetFloat()); } else { parameter.Value.Set(_nodeData.GetParameters()[a].Value.GetString()); } a++; } return(node); }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case ValueParameter.NAME: INode nodeValueAttribute = new ValueParameter() as INode; return(new Node <INode> (nodeValueAttribute)); case WordParameter.NAME: INode nodeWordAttribute = new WordParameter() as INode; return(new Node <INode> (nodeWordAttribute)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Tutorial.NAME: INode nodeTutorial = new Tutorial() as INode; return(new Node <INode> (nodeTutorial)); case StaticConstellationNode.NAME: INode nodeNestable = new StaticConstellationNode() as INode; return(new Node <INode>(nodeNestable)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { INode customNode = new StaticConstellation() as INode; var node = new Node <INode>(customNode); node.GetDiscreteParameters()[0].Value = new Ray().Set(nodeName); foreach (var script in constellationsScripts) { if (script.Name == nodeName) { (customNode as ICustomNode).UpdateNode(script, constellationFileParser); (customNode as ICustomNode).SetupNodeIO(constellationFileParser); return(node); } } return(node); }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Color.NAME: INode nodeColor = new Color() as INode; return(new Node <INode>(nodeColor)); case MaterialColor.NAME: INode materialColor = new MaterialColor() as INode; return(new Node <INode>(materialColor)); case ParticlesEmission.NAME: INode particleEmission = new ParticlesEmission() as INode; return(new Node <INode>(particleEmission)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case StreamingAssetsPath.NAME: INode streamingAssetsPath = new StreamingAssetsPath() as INode; return(new Node <INode>(streamingAssetsPath)); case LoadTextFileAtPath.NAME: INode loadTextFileAtPath = new LoadTextFileAtPath() as INode; return(new Node <INode>(loadTextFileAtPath)); case LoadResource.NAME: INode loadResource = new LoadResource() as INode; return(new Node <INode>(loadResource)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case DeltaTime.NAME: INode nodeDeltaTime = new DeltaTime() as INode; return(new Node <INode> (nodeDeltaTime)); case ObjectParameter.NAME: INode nodeObjectAttribute = new ObjectParameter() as INode; return(new Node <INode> (nodeObjectAttribute)); case Update.NAME: INode nodeUpdate = new Update() as INode; return(new Node <INode> (nodeUpdate)); case LateUpdate.NAME: INode nodeLateUpdate = new LateUpdate() as INode; return(new Node <INode> (nodeLateUpdate)); case PlayerPreferences.NAME: INode nodePlayerPref = new PlayerPreferences() as INode; return(new Node <INode> (nodePlayerPref)); case LoadScene.NAME: INode nodeLoadScene = new LoadScene() as INode; return(new Node <INode> (nodeLoadScene)); case Quit.NAME: INode quit = new Quit() as INode; return(new Node <INode> (quit)); case AddConstellationBehaviourFromJSON.NAME: INode addConstellationBehaviourFromJSON = new AddConstellationBehaviourFromJSON() as INode; return(new Node <INode>(addConstellationBehaviourFromJSON)); default: return(null); } }
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> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Text.NAME: INode nodeText = new Text() as INode; return(new Node <INode> (nodeText)); case Button.NAME: INode nodeButton = new Button() as INode; return(new Node <INode> (nodeButton)); case Image.NAME: INode nodeImage = new Image() as INode; return(new Node <INode> (nodeImage)); case Slider.NAME: INode nodeSlider = new Slider() as INode; return(new Node <INode> (nodeSlider)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case KeyDown.NAME: INode nodeKeyDown = new KeyDown() as INode; return(new Node <INode>(nodeKeyDown)); case Key.NAME: INode nodeKey = new Key() as INode; return(new Node <INode>(nodeKey)); case MouseButtonDown.NAME: INode nodeMouseButtonDown = new MouseButtonDown() as INode; return(new Node <INode>(nodeMouseButtonDown)); case MousePosition.NAME: INode nodeMousePosition = new MousePosition() as INode; return(new Node <INode>(nodeMousePosition)); default: return(null); } }
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); if (nodeObject == null) { nodesToRemove.Add(node); } else if (node.Inputs.Count != nodeObject.Inputs.Count || node.Outputs.Count != nodeObject.Outputs.Count || node.GetParameters().Length != nodeObject.GetParameters().Length) { nodesToRemove.Add(node); } else if (node.Namespace == Constellation.ConstellationNodes.NameSpace.NAME) // to be done only when the node is edited { nodesToRemove.Add(node); } else { var foundDifference = false; var i = 0; foreach (var input in node.GetInputs()) { if ((input.Type != nodeObject.Inputs[i].Type && nodeObject.Inputs[i].Type != ConstellationEditorRules.ANY && nodeObject.Inputs[i].Type != ConstellationEditorRules.GENERIC && nodeObject.Inputs[i].Type != ConstellationEditorRules.UNDEFINED) || input.IsBright != nodeObject.Inputs[i].isBright || input.Description != nodeObject.Inputs[i].Description) { nodesToRemove.Add(node); foundDifference = true; break; } i++; } if (!foundDifference) { i = 0; foreach (var output in node.GetOutputs()) { if ((output.Type != nodeObject.Outputs[i].Type && nodeObject.Outputs[i].Type != ConstellationEditorRules.ANY && nodeObject.Outputs[i].Type != ConstellationEditorRules.GENERIC && nodeObject.Outputs[i].Type != ConstellationEditorRules.UNDEFINED) || output.IsBright != nodeObject.Outputs[i].IsWarm || output.Description != nodeObject.Outputs[i].Description) { nodesToRemove.Add(node); break; } i++; } } if (!foundDifference) { i = 0; if (node.GetParameters().Length != nodeObject.GetParameters().Length) { nodesToRemove.Add(node); } foreach (var parameter in node.GetParameters()) { if (parameter.Type != nodeObject.GetParameters()[i].Type) { nodesToRemove.Add(node); break; } i++; } } } } 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() } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Add.NAME: INode nodeAdd = new Add() as INode; return(new Node <INode> (nodeAdd)); case Condition.NAME: INode nodeCondition = new Condition() as INode; return(new Node <INode> (nodeCondition)); case Multiply.NAME: INode nodeMultiply = new Multiply() as INode; return(new Node <INode> (nodeMultiply)); case Note.NAME: INode note = new Note() as INode; return(new Node <INode> (note)); case Print.NAME: INode NodePrint = new Print() as INode; return(new Node <INode> (NodePrint)); case Remove.NAME: INode NodeRemove = new Remove() as INode; return(new Node <INode> (NodeRemove)); case Switch.NAME: INode NodeSwitch = new Switch() as INode; return(new Node <INode> (NodeSwitch)); case Value.NAME: INode nodeValue = new Value() as INode; return(new Node <INode> (nodeValue)); case Var.NAME: INode nodeVar = new Var() as INode; return(new Node <INode> (nodeVar)); case Word.NAME: INode nodeWord = new Word() as INode; return(new Node <INode> (nodeWord)); case Sender.NAME: INode nodeSender = new Sender() as INode; return(new Node <INode> (nodeSender)); case Receiver.NAME: INode nodeReceiver = new Receiver() as INode; return(new Node <INode>(nodeReceiver)); case CodeVar.NAME: INode nodeGetVar = new CodeVar() as INode; return(new Node <INode>(nodeGetVar)); case TeleportIn.NAME: INode nodeTeleportIn = new TeleportIn() as INode; return(new Node <INode>(nodeTeleportIn)); case TeleportOut.NAME: INode nodeTeleportOut = new TeleportOut() as INode; return(new Node <INode>(nodeTeleportOut)); case Exit.NAME: INode exit = new Exit() as INode; return(new Node <INode>(exit)); case Entry.NAME: INode entry = new Entry() as INode; return(new Node <INode>(entry)); case BrightEntry.NAME: INode brightEntry = new BrightEntry() as INode; return(new Node <INode>(brightEntry)); case BrightExit.NAME: INode brightExit = new BrightExit() as INode; return(new Node <INode>(brightExit)); case IsUpdated.NAME: INode isUpdated = new IsUpdated() as INode; return(new Node <INode>(isUpdated)); default: return(null); } }
public Node <INode> GetNode(string nodeName, IConstellationFileParser constellationFileParser) { switch (nodeName) { case Absolute.NAME: INode nodeAbsolute = new Absolute() as INode; return(new Node <INode>(nodeAbsolute)); case Approx.NAME: INode nodeAprox = new Approx() as INode; return(new Node <INode>(nodeAprox)); case ArcCos.NAME: INode nodeArcCos = new ArcCos() as INode; return(new Node <INode>(nodeArcCos)); case ArcSin.NAME: INode nodeArcSin = new ArcSin() as INode; return(new Node <INode>(nodeArcSin)); case ArcTan2.NAME: INode nodeArcTan2 = new ArcTan2() as INode; return(new Node <INode>(nodeArcTan2)); case Ceil.NAME: INode nodeCeil = new Ceil() as INode; return(new Node <INode>(nodeCeil)); case CeilToInt.NAME: INode nodeCeilToInt = new CeilToInt() as INode; return(new Node <INode>(nodeCeilToInt)); case Clamp.NAME: INode nodeClamp = new Clamp() as INode; return(new Node <INode>(nodeClamp)); case Clamp01.NAME: INode nodeClamp01 = new Clamp01() as INode; return(new Node <INode>(nodeClamp01)); case ClosestPowerOf2.NAME: INode nodeClosestPowerOf2 = new ClosestPowerOf2() as INode; return(new Node <INode>(nodeClosestPowerOf2)); case Cosinus.NAME: INode nodeCosinus = new Cosinus() as INode; return(new Node <INode>(nodeCosinus)); case DeltaAngle.NAME: INode nodeDeltaAngle = new DeltaAngle() as INode; return(new Node <INode>(nodeDeltaAngle)); case Exp.NAME: INode nodeExp = new Exp() as INode; return(new Node <INode>(nodeExp)); case Floor.NAME: INode nodeFloor = new Floor() as INode; return(new Node <INode>(nodeFloor)); case FloorToInt.NAME: INode nodeFloorToInt = new FloorToInt() as INode; return(new Node <INode>(nodeFloorToInt)); case Lerp.NAME: INode nodeLerp = new Lerp() as INode; return(new Node <INode>(nodeLerp)); case LerpAngle.NAME: INode nodeLerpAngle = new LerpAngle() as INode; return(new Node <INode>(nodeLerpAngle)); case Log10.NAME: INode nodeLog10 = new Log10() as INode; return(new Node <INode>(nodeLog10)); case Logarithm.NAME: INode nodeLogarithm = new Logarithm() as INode; return(new Node <INode>(nodeLogarithm)); case Sinus.NAME: INode nodeSinus_ = new Sinus() as INode; return(new Node <INode>(nodeSinus_)); case Max.NAME: INode nodeMax = new Max() as INode; return(new Node <INode>(nodeMax)); case Min.NAME: INode nodeMin = new Min() as INode; return(new Node <INode>(nodeMin)); case MoveTowards.NAME: INode nodeMoveTowards = new MoveTowards() as INode; return(new Node <INode>(nodeMoveTowards)); case MoveTowardsAngle.NAME: INode nodeMoveTowardsAngle = new MoveTowardsAngle() as INode; return(new Node <INode>(nodeMoveTowardsAngle)); case NextPowerOfTwo.NAME: INode nodeNextPowerOfTwo = new NextPowerOfTwo() as INode; return(new Node <INode>(nodeNextPowerOfTwo)); case PerlinNoise.NAME: INode nodePerlinNoise = new PerlinNoise() as INode; return(new Node <INode>(nodePerlinNoise)); case PingPong.NAME: INode nodePingPong = new PingPong() as INode; return(new Node <INode> (nodePingPong)); case Pow.NAME: INode nodePow = new Pow() as INode; return(new Node <INode>(nodePow)); case SquareRoot.NAME: INode nodeSqrt = new SquareRoot() as INode; return(new Node <INode>(nodeSqrt)); case Tan.NAME: INode nodeTan = new Tan() as INode; return(new Node <INode>(nodeTan)); case Random.NAME: INode nodeRandom = new Random() as INode; return(new Node <INode>(nodeRandom)); default: return(null); } }
public void UpdateNode(ConstellationScriptData constellation, IConstellationFileParser constellationFileParser) { nameParameter.Value = new Ray().Set(constellation.Name); constellationNodeData.Value = new Ray().Set(constellationFileParser.ParseConstellationScript(constellation)); }
public void InitializeConstellation(ConstellationScriptData[] constellationScripts, IConstellationFileParser constellationFileParser, bool isLocalScope) { Entries = new List <Node <INode> >(); BrightEntriesInfos = new List <BrightEntryInfos>(); ExitNodes = new List <IExitNode>(); parameters = new List <IReceiver>(); if (isInitialized) // do not initialize twice { return; } var scriptData = constellationFileParser.ParseConstellationScript(constellationNodeData.Value.GetString()); if (isLocalScope) { nodesFactory = new NodesFactory(null); var newAssembly = new List <ConstellationScriptData>(); foreach (var node in scriptData.Nodes) { if (node.Namespace == ConstellationNodes.NameSpace.NAME) { newAssembly.Add(constellationFileParser.ParseConstellationScript(node.DiscreteParametersData[1].Value.GetString())); } } nodesFactory.UpdateConstellationScripts(newAssembly.ToArray()); nodesFactory.SetLocalScope(); } else { nodesFactory = new NodesFactory(constellationScripts); } var parametersCounter = 0; var entryCounter = 0; var exitCounter = 0; constellation = new Constellation(scriptData, nodesFactory, constellationFileParser, (newNode, node) => { if (newNode.NodeType is IExitNode) { ExitNodes.Add(newNode.NodeType as IExitNode); if (newNode.NodeType is IBrightExitNode) { (newNode.NodeType as IBrightExitNode).SubscribeReceiver(this, exitCounter); } exitCounter++; } if (newNode.Name == CoreNodes.Entry.NAME || newNode.Name == CoreNodes.BrightEntry.NAME) { if (newNode.Name == CoreNodes.BrightEntry.NAME) { BrightEntriesInfos.Add(new BrightEntryInfos(newNode, entryCounter)); } entryCounter++; Entries.Add(newNode); } if (newNode.NodeType.NodeName() == Parameters.ValueParameter.NAME || newNode.NodeType.NodeName() == Parameters.WordParameter.NAME) { parameters.Add(newNode.NodeType as IReceiver); } if (IsAttribute(node) && NodeParameters[parametersCounter] != null) { IParameter nodeParameter = newNode.NodeType as IParameter; if (nodeParameter.DisplayInConstellation() && parametersCounter < NodeParameters.Count) { nodeParameter.SetParameter(NodeParameters[parametersCounter]); } parametersCounter++; } }); constellation.Initialize(System.Guid.NewGuid().ToString(), nameParameter.Value.GetString()); isInitialized = true; }
public void UpdateGenericNodeByLinkGUID(ConstellationScriptData constellationScript, NodesFactory nodesFactory, string guid, IConstellationFileParser constellationParser) { var linkedinputID = 0; var linkedOutputID = 0; var connectedNodes = constellationScript.GetNodesWithLinkGUID(guid, out linkedinputID, out linkedOutputID); var outputNode = connectedNodes[0]; var inputNode = connectedNodes[1]; var inputNodeType = nodesFactory.GetNode(inputNode, constellationParser).NodeType; var outputNodeType = nodesFactory.GetNode(outputNode, constellationParser).NodeType; var inputGenericNodeScript = inputNodeType as IGenericNode; var mirrorInputNodeScript = inputNodeType as IMirrorNode; var mirrorOutputNodeScript = outputNodeType as IMirrorNode; if (mirrorInputNodeScript != null) { for (var k = 0; k < inputNode.GetInputs().Length; k++) { inputNode.Inputs[k].Type = outputNode.Outputs[linkedOutputID].Type; } } else if (mirrorOutputNodeScript != null) { for (var k = 0; k < outputNode.GetOutputs().Length; k++) { outputNode.Outputs[k].Type = inputNode.Inputs[linkedinputID].Type; } } else { if (inputGenericNodeScript != null && inputGenericNodeScript.IsGenericInput(linkedinputID)) { var inputsID = linkedinputID; for (var k = 0; k < inputNode.GetInputs().Length; k++) { if (k == linkedinputID) { inputNode.Inputs[k].Type = outputNode.Outputs[linkedOutputID].Type; break; } } if (inputGenericNodeScript.IsGenericInput(linkedinputID)) { var outputID = inputGenericNodeScript.GetGenericOutputByLinkedInput(linkedinputID); for (var k = 0; k < inputNode.GetOutputs().Length; k++) { for (var l = 0; l < outputID.Length; l++) { if (k == outputID[l]) { inputNode.Outputs[k].Type = outputNode.Outputs[linkedOutputID].Type; } } } } } } }
public void UpdateGenericNodeByLinkGUID(ConstellationScriptData constellationScript, NodesFactory nodesFactory, string guid, IConstellationFileParser constellationParser) { foreach (var constellationRule in constellationRules) { constellationRule.LinkAdded(constellationScript, nodesFactory, guid, constellationParser); } }
public void UpdateScriptsNodes(ConstellationScriptData[] staticConstellationNodes, ConstellationScriptData[] constellationScripts, IConstellationFileParser constellationFileParser) { SetParsingRules(); foreach (var script in staticConstellationNodes) { foreach (var node in script.Nodes) { if (node.Name == ConstellationTypes.StaticConstellationNode.NAME) { script.NameSpace = node.GetParameters()[0].Value.GetString(); } } UpdateScriptNodes(script, staticConstellationNodes, constellationFileParser); } foreach (var script in constellationScripts) { UpdateScriptNodes(script, staticConstellationNodes, constellationFileParser); } }
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() } }