Exemple #1
0
 /// <summary>
 /// Merges two Invalid NodeGraphData
 /// </summary>
 /// <param name="p_Data">the Data to merge to the current object</param>
 public void Merge(NodeGraphInvalidData p_Data)
 {
     for (int i = 0; i < p_Data.InvalidNodes.Count; i++)
     {
         m_lInvalidNodes.Add(p_Data.InvalidNodes[i]);
         m_lErrorMessages.Add(p_Data.ErrorMessages[i]);
     }
 }
Exemple #2
0
        public override NodeGraphData Process()
        {
            NodeGraphData v_input0 = m_Connectors[0].Process();
            NodeGraphData v_input1 = m_Connectors[1].Process();
            NodeGraphInvalidData v_OutError = new NodeGraphInvalidData();
            if (v_input0 is NodeGraphInvalidData) v_OutError.Merge(v_input0 as NodeGraphInvalidData);
            if (v_input1 is NodeGraphInvalidData) v_OutError.Merge(v_input1 as NodeGraphInvalidData);
            if (v_OutError.InvalidNodes.Count > 0) return v_OutError;

            float input0 = (m_Connectors[0].Process() as DataTypes.NodeGraphFloatData).Value;
            float input1 = (m_Connectors[1].Process() as DataTypes.NodeGraphFloatData).Value;
            return new DataTypes.NodeGraphFloatData(input0 + input1);
        }
Exemple #3
0
        public override NodeGraphData Process()
        {
            NodeGraphData v_InA = m_Connectors[0].Process();
            NodeGraphData v_InB = m_Connectors[1].Process();
            NodeGraphInvalidData v_OutError = new NodeGraphInvalidData();
            if (v_InA is NodeGraphInvalidData) v_OutError.Merge(v_InA as NodeGraphInvalidData);
            if (v_InB is NodeGraphInvalidData) v_OutError.Merge(v_InB as NodeGraphInvalidData);
            if (v_OutError.InvalidNodes.Count > 0) return v_OutError;

            float A = (m_Connectors[0].Process() as DataTypes.NodeGraphFloatData).Value;
            float B = (m_Connectors[1].Process() as DataTypes.NodeGraphFloatData).Value;
            return new DataTypes.NodeGraphFloatData(A + B);
        }
Exemple #4
0
        public override NodeGraphData Process()
        {
            NodeGraphFloatListData v_OutputData = new NodeGraphFloatListData();
            NodeGraphInvalidData v_Errors = new NodeGraphInvalidData();

            NodeGraphListData v_InputData = this.GetInputData();

            foreach (NodeGraphData i_InputData in v_InputData.Data)
            {
                if (i_InputData is NodeGraphFloatData)
                {
                    v_OutputData.Values.Add((i_InputData as NodeGraphFloatData).Value);
                }
                else if (i_InputData is NodeGraphInvalidData)
                {
                    v_Errors.Merge(i_InputData as NodeGraphInvalidData);

                }

            }


            return new NodeGraphTestResultData(v_OutputData, v_Errors);
        }
Exemple #5
0
        /// <summary>
        /// Merges two Invalid NodeGraphData
        /// </summary>
        /// <param name="p_Data">the Data to merge to the current object</param>
        public void Merge(NodeGraphInvalidData p_Data)
        {
            for (int i = 0; i < p_Data.InvalidNodes.Count; i++)
            {
                m_lInvalidNodes.Add(p_Data.InvalidNodes[i]);
                m_lErrorMessages.Add(p_Data.ErrorMessages[i]);
            }

        }
 public NodeGraphTestResultData(NodeGraphFloatListData p_Data, NodeGraphInvalidData p_Errors)
 {
     m_Data = p_Data;
     m_Errors = p_Errors;
 }
Exemple #7
0
        /// <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);
                    }


        }