// Load node info public void LoadNodes() { string nodesfile = App._projectDir + App._resourcesDir + App._nodesFileName; string[] lines = System.IO.File.ReadAllLines(nodesfile); int index = 0; foreach (string line in lines) { // get node type BTNodeType type = BTNodeType.None; if (line.StartsWith("REGISTER_CONTROLFLOW")) { type = BTNodeType.Composite; } else if (line.StartsWith("REGISTER_DECORATOR")) { type = BTNodeType.Decorator; } else if (line.StartsWith("REGISTER_LEAF")) { type = BTNodeType.Leaf; } if (type != BTNodeType.None) { // get node name int node_startindex = line.IndexOf("(") + 1; int node_endindex = line.IndexOf(",") - 1; string nodename = line.Substring(node_startindex, node_endindex - node_startindex + 1); // get node summary int summary_startindex = line.IndexOf("\"") + 1; int summary_endindex = line.LastIndexOf("\"") - 1; string nodesummary = line.Substring(summary_startindex, summary_endindex - summary_startindex + 1); _nodes.Add(new BTNode() { _name = nodename, _summary = nodesummary, _type = type, _index = index++ }); } } }
// Load node info private void LoadNodes() { string[] lines = System.IO.File.ReadAllLines(@"..\..\..\..\Project\Sources\Nodes.def"); int index = 0; foreach (string line in lines) { // get node type BTNodeType type = BTNodeType.None; if (line.StartsWith("REGISTER_COMPOSITE")) { type = BTNodeType.Composite; } else if (line.StartsWith("REGISTER_DECORATOR")) { type = BTNodeType.Decorator; } else if (line.StartsWith("REGISTER_LEAF")) { type = BTNodeType.Leaf; } if (type != BTNodeType.None) { // get node name int node_startindex = line.IndexOf("(") + 1; int node_endindex = line.IndexOf(",") - 1; string nodename = line.Substring(node_startindex, node_endindex - node_startindex + 1); // get node summary int summary_startindex = line.IndexOf("\"") + 1; int summary_endindex = line.LastIndexOf("\"") - 1; string nodesummary = line.Substring(summary_startindex, summary_endindex - summary_startindex + 1); _nodes.Add(new BTNode() { _name = nodename, _summary = nodesummary, _type = type, _index = index++ }); } } }
public static BTNode BuildNode(BTNodeType type) { switch (type) { case BTNodeType.ExecutePath: return(new BTN_ExecutePath()); case BTNodeType.FindObjectRNG: return(new BTN_FindObjectRNG()); case BTNodeType.FindObjectClose: return(new BTN_FindObjectClose()); case BTNodeType.GetPath: return(new BTN_GeneratePath()); case BTNodeType.IntGTZ: return(new BTN_IntGTZero()); case BTNodeType.Selector: return(new BTN_Selector()); case BTNodeType.Sequence: return(new BTN_Sequence()); case BTNodeType.Succeeder: return(new BTN_Succeeder()); case BTNodeType.Inverter: return(new BTN_Inverter()); case BTNodeType.UntilSuccess: return(new BTN_UntilSucceed()); } return(new BTN_Succeeder()); }
public SBTNode(BTNodeType t, string[] v, SBTNode[] c) { type = t; children = c; variables = v; }