/// <summary> /// The Process function, returns NodeGraphData (generic) but can return more complex types (in our case, NodeGraphFloatData) /// </summary> /// <returns>NodeGraphFloatData</returns> public override NodeGraphData Process() { NodeGraphInvalidData v_Errors = new NodeGraphInvalidData(); bool v_HasErrors = false; float valueA = 0.0f; float valueB = 0.0f; float valueOut = 0.0f; // First we get the A & B values NodeGraphData A = m_Connectors[0].Process(); NodeGraphData B = m_Connectors[1].Process(); NodeGraphData Result; // 1st Check: validity of incoming Data if ((A is NodeGraphInvalidData)) { v_Errors.Merge(A as NodeGraphInvalidData); v_HasErrors = true; } if ((B is NodeGraphInvalidData)) { v_Errors.Merge(B as NodeGraphInvalidData); v_HasErrors = true; } // 2nd Check: validity of type Data if (A is NodeGraphFloatData) { valueA = (A as NodeGraphFloatData).Value; } else { v_Errors.AddInvalidNode(this, "A Input is not NodeGraphFloatData"); v_HasErrors = true; } if (B is NodeGraphFloatData) { valueB = (B as NodeGraphFloatData).Value; } else { v_Errors.AddInvalidNode(this, "B Input is not NodeGraphFloatData"); v_HasErrors = true; } // If we are ok to proceed... if (!v_HasErrors) { // Comparison and third test if (valueA == valueB) { // Get the output Result = m_Connectors[3].Process(); // If this is an error, add to the current errors if ((Result is NodeGraphInvalidData)) { v_Errors.Merge(Result as NodeGraphInvalidData); v_HasErrors = true; } else { // If the type is good.... if (Result is NodeGraphFloatData) { valueOut = (Result as NodeGraphFloatData).Value; } else // .. or add an error { v_Errors.AddInvalidNode(this, "A==B Input is not NodeGraphFloatData"); v_HasErrors = true; } } } // Same thing for other tests... else if (valueA < valueB) { Result = m_Connectors[4].Process(); if ((Result is NodeGraphInvalidData)) { v_Errors.Merge(Result as NodeGraphInvalidData); v_HasErrors = true; } else { if (Result is NodeGraphFloatData) { valueOut = (Result as NodeGraphFloatData).Value; } else { v_Errors.AddInvalidNode(this, "A<B Input is not NodeGraphFloatData"); v_HasErrors = true; } } } else // (A > B) { Result = m_Connectors[2].Process(); if ((Result is NodeGraphInvalidData)) { v_Errors.Merge(Result as NodeGraphInvalidData); v_HasErrors = true; } else { if (Result is NodeGraphFloatData) { valueOut = (Result as NodeGraphFloatData).Value; } else { v_Errors.AddInvalidNode(this, "A>B Input is not NodeGraphFloatData"); v_HasErrors = true; } } } } // Finally... we are returning data, whether it's good or not if (v_HasErrors) { if (m_eBehavior == IfNodeBehavior.ErrorOnMissingInput) { return(v_Errors); } else { return(new NodeGraphFloatData(this.m_fDefaultValue)); } } else { return(new NodeGraphFloatData(valueOut)); } }
/// <summary> /// Adds data to the list /// </summary> /// <param name="p_Data"></param> public void AddData(NodeGraphData p_Data) { this.m_lData.Add(p_Data); }
void Controller_GraphSaved(NodeGraphData obj) { _root.GraphData = obj; }
public NodePortConnectionCustomPainter(NodeGraphData nodeGraphData, Listenable repaint = null) : base(repaint) { NodeGraphData = nodeGraphData; }
/// <summary> /// Adds data to the list /// </summary> /// <param name="p_Data"></param> public void AddData(NodeGraphData p_Data) { this.m_lData.Add(p_Data); }
public NodeEditorWidget(Key key = null) : base(key) { NodeGraphData = NodeGraphInstanceManager.Instance.GetNewNodeGraphDataInstance(key); }