本文整理汇总了C#中BehaviorNode.PostExport方法的典型用法代码示例。如果您正苦于以下问题:C# BehaviorNode.PostExport方法的具体用法?C# BehaviorNode.PostExport怎么用?C# BehaviorNode.PostExport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BehaviorNode
的用法示例。
在下文中一共展示了BehaviorNode.PostExport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportBody
private void ExportBody(StreamWriter file, BehaviorNode behavior)
{
behavior.PreExport();
string filename = Path.ChangeExtension(behavior.RelativePath, "").Replace(".", "");
filename = filename.Replace('\\', '/');
// write comments
file.WriteLine("\t// Source file: {0}\r\n", filename);
string btClassName = string.Format("bt_{0}", getValidFilename(filename));
string agentType = behavior.AgentType.AgentTypeName;
// create the class definition of its attachments
ExportAttachmentClass(file, btClassName, (Node)behavior);
// create the class definition of its children
foreach (Node child in ((Node)behavior).GetChildNodes())
ExportNodeClass(file, btClassName, agentType, behavior, child);
// create the bt class
file.WriteLine("\tpublic static class {0}\r\n\t{{", btClassName);
// export the build function
file.WriteLine("\t\tpublic static bool build_behavior_tree(BehaviorTree bt)\r\n\t\t{");
file.WriteLine("\t\t\tbt.SetClassNameString(\"BehaviorTree\");");
file.WriteLine("\t\t\tbt.SetId(-1);");
file.WriteLine("\t\t\tbt.SetName(\"{0}\");", filename);
file.WriteLine("\t\t\tbt.IsFSM = {0};", ((Node)behavior).IsFSM ? "true" : "false");
file.WriteLine("#if !BEHAVIAC_RELEASE");
file.WriteLine("\t\t\tbt.SetAgentType(\"{0}\");", agentType.Replace("::", "."));
file.WriteLine("#endif");
if (!string.IsNullOrEmpty(((Behavior)behavior).Domains))
{
file.WriteLine("\t\t\tbt.SetDomains(\"{0}\");", ((Behavior)behavior).Domains);
}
if (((Behavior)behavior).DescriptorRefs.Count > 0)
{
file.WriteLine("\t\t\tbt.SetDescriptors(\"{0}\");", DesignerPropertyUtility.RetrieveExportValue(((Behavior)behavior).DescriptorRefs));
}
ExportPars(file, agentType, "bt", (Node)behavior, "\t\t");
// export its attachments
ExportAttachment(file, btClassName, agentType, "bt", (Node)behavior, "\t\t\t");
file.WriteLine("\t\t\t// children");
// export its children
if (((Node)behavior).IsFSM)
{
file.WriteLine("\t\t\t{");
file.WriteLine("\t\t\t\tFSM fsm = new FSM();");
file.WriteLine("\t\t\t\tfsm.SetClassNameString(\"FSM\");");
file.WriteLine("\t\t\t\tfsm.SetId(-1);");
file.WriteLine("\t\t\t\tfsm.InitialId = {0};", behavior.InitialStateId);
file.WriteLine("#if !BEHAVIAC_RELEASE");
file.WriteLine("\t\t\t\tfsm.SetAgentType(\"{0}\");", agentType.Replace("::", "."));
file.WriteLine("#endif");
foreach (Node child in ((Node)behavior).FSMNodes)
{
ExportNode(file, btClassName, agentType, "fsm", child, 4);
}
file.WriteLine("\t\t\t\tbt.AddChild(fsm);");
file.WriteLine("\t\t\t}");
}
else
{
foreach (Node child in ((Node)behavior).GetChildNodes())
{
ExportNode(file, btClassName, agentType, "bt", child, 3);
}
}
file.WriteLine("\t\t\treturn true;");
// close the build function
file.WriteLine("\t\t}");
// close class
file.WriteLine("\t}\r\n");
behavior.PostExport();
}