public void RebuildNode(List <CKlaxVariable> inputParameters) { // Adjust the nodes output pins to the new input parameters // Note the editor has to take care of adjusting pin connections if (inputParameters.Count >= OutputPins.Count) { for (int i = 0; i < inputParameters.Count; i++) { CKlaxVariable inputParameter = inputParameters[i]; if (OutputPins.Count > i) { COutputPin pin = OutputPins[i]; pin.Name = inputParameter.Name; pin.Type = inputParameter.Type; } else { OutputPins.Add(new COutputPin(inputParameter.Name, inputParameter.Type)); } } } else { for (int i = OutputPins.Count - 1; i >= 0; i--) { if (inputParameters.Count > i) { CKlaxVariable inputParameter = inputParameters[i]; COutputPin pin = OutputPins[i]; pin.Name = inputParameter.Name; pin.Type = inputParameter.Type; } else { OutputPins.RemoveAt(i); } } } RaiseNodeRebuildEvent(); }
private void OnFunctionRebuilt() { // Input parameter rebuild if (m_targetFunction.InputParameters.Count > InputPins.Count) { for (int i = 0; i < m_targetFunction.InputParameters.Count; i++) { CKlaxVariable inputParameter = m_targetFunction.InputParameters[i]; if (InputPins.Count > i) { InputPins[i].Type = inputParameter.Type; InputPins[i].Name = inputParameter.Name; } else { InputPins.Add(new CInputPin(inputParameter.Name, inputParameter.Type)); } } } else { for (int i = InputPins.Count - 1; i >= 0; i--) { if (m_targetFunction.InputParameters.Count > i) { CKlaxVariable inputParameter = m_targetFunction.InputParameters[i]; InputPins[i].Type = inputParameter.Type; InputPins[i].Name = inputParameter.Name; } else { InputPins.RemoveAt(i); } } } // Output parameter rebuild if (m_targetFunction.OutputParameters.Count > OutputPins.Count) { for (int i = 0; i < m_targetFunction.OutputParameters.Count; i++) { CKlaxVariable outputParameter = m_targetFunction.OutputParameters[i]; if (OutputPins.Count > i) { OutputPins[i].Type = outputParameter.Type; OutputPins[i].Name = outputParameter.Name; } else { OutputPins.Add(new COutputPin(outputParameter.Name, outputParameter.Type)); } } } else { for (int i = OutputPins.Count - 1; i >= 0; i--) { if (m_targetFunction.OutputParameters.Count > i) { CKlaxVariable outputParameter = m_targetFunction.OutputParameters[i]; OutputPins[i].Type = outputParameter.Type; OutputPins[i].Name = outputParameter.Name; } else { OutputPins.RemoveAt(i); } } } RaiseNodeRebuildEvent(); }