private void ExportNodeClass(StreamWriter file, string btClassName, string agentType, BehaviorNode behavior, Node node) { if (!node.Enable) return; string nodeName = string.Format("node{0}", node.Id); NodeCppExporter nodeExporter = NodeCppExporter.CreateInstance(node); nodeExporter.GenerateClass(node, file, "", nodeName, agentType, btClassName); ExportAttachmentClass(file, btClassName, node); if (!(node is ReferencedBehavior)) { foreach (Node child in node.GetChildNodes()) { ExportNodeClass(file, btClassName, agentType, behavior, child); } } }
private void ExportNode(StreamWriter file, string btClassName, string agentType, string parentName, Node node, int indentDepth) { if (!node.Enable) return; // generate the indent string string indent = string.Empty; for (int i = 0; i < indentDepth; ++i) { indent += '\t'; } string nodeName = string.Format("node{0}", node.Id); // open some brackets for a better formatting in the generated code file.WriteLine("{0}{{", indent); // export its instance and the properties NodeCppExporter nodeExporter = NodeCppExporter.CreateInstance(node); nodeExporter.GenerateInstance(node, file, indent, nodeName, agentType, btClassName); ExportPars(file, agentType, nodeName, node, indent); ExportAttachment(file, btClassName, agentType, nodeName, node, indent + "\t"); bool isAsChild = true; if (node.Parent != null) { BaseNode.Connector connector = node.Parent.GetConnector(node); if (connector != null && !connector.IsAsChild) { isAsChild = false; } } if (isAsChild) { // add the node to its parent file.WriteLine("{0}\t{1}->AddChild({2});", indent, parentName, nodeName); } else { // add the node as its customized children file.WriteLine("{0}\t{1}->SetCustomCondition({2});", indent, parentName, nodeName); } // export the child nodes if (!node.IsFSM && !(node is ReferencedBehavior)) { foreach (Node child in node.GetChildNodes()) { ExportNode(file, btClassName, agentType, nodeName, child, indentDepth + 1); } } file.WriteLine("{0}\t{1}->SetHasEvents({1}->HasEvents() | {2}->HasEvents());", indent, parentName, nodeName); // close the brackets for a better formatting in the generated code file.WriteLine("{0}}}", indent); }
public static void CheckPar(Node node, ParInfo par, ref List<Node.ErrorCheck> result) { try { // self checkPar(node, par, ref result); // attachment foreach(Attachments.Attachment attach in node.Attachments) { checkPar(attach, par, ref result); } // children foreach(BaseNode child in node.GetChildNodes()) { if (child is Node && !(child is ReferencedBehaviorNode)) { Node childNode = child as Node; CheckPar(childNode, par, ref result); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Resources.LoadError, MessageBoxButtons.OK); } }