/** Parses the given input stream. * @param input the input stream to parse * @param object the blackboard object. It can be {@code null}. * @return the behavior tree * @throws SerializationException if the input stream cannot be successfully parsed. */ public BehaviorTree<E> parse (InputStream input, E object) { btReader.parse(input); return createBehaviorTree(btReader.root, object); }
@Override protected <E> boolean attribute (DefaultBehaviorTreeReader<E> reader, String name, Object value) { if (!(value instanceof String)) reader.throwAttributeTypeException(this.name, name, "String"); reader.addImport(name, (String)value); return true; }
/** * Dispose behavior tree obtain by this library manager. * @param treeReference the tree identifier. * @param behaviorTree the tree to dispose. */ public void disposeBehaviorTree(String treeReference, BehaviorTree<?> behaviorTree){ library.disposeBehaviorTree(treeReference, behaviorTree); }
private Task<E> createSubtreeRootTask () { return BehaviorTreeLibraryManager.getInstance().createRootTask(subtree); }
private BehaviorTreeLibraryManager () { setLibrary(new BehaviorTreeLibrary()); }
public BehaviorTreeParser (DistributionAdapters distributionAdapters, int debugLevel, DefaultBehaviorTreeReader<E> reader) { this.distributionAdapters = distributionAdapters; this.debugLevel = debugLevel; btReader = reader == null ? new DefaultBehaviorTreeReader<E>() : reader; btReader.setParser(this); }
/** Creates the {@link BehaviorTree} for the specified reference and blackboard object. * @param treeReference the tree identifier, typically a path * @param blackboard the blackboard object (it can be {@code null}). * @return the tree cloned from the archetype. * @throws SerializationException if the reference cannot be successfully parsed. * @throws TaskCloneException if the archetype cannot be successfully parsed. */ public <T> BehaviorTree<T> createBehaviorTree (String treeReference, T blackboard) { return library.createBehaviorTree(treeReference, blackboard); }
@Override protected <E> void exit (DefaultBehaviorTreeReader<E> reader) { reader.switchToNewTree(reader.subtreeName); reader.subtreeName = null; } },
void initCurrentTree(Task<E> rootTask, int startIndent) { currentDepth = -1; step = 1; currentTreeStartIndent = startIndent; this.currentTree.init(rootTask); prevTask = null; }
/** Creates the root task of {@link BehaviorTree} for the specified reference. * @param treeReference the tree identifier, typically a path * @return the root task of the tree cloned from the archetype. * @throws SerializationException if the reference cannot be successfully parsed. * @throws TaskCloneException if the archetype cannot be successfully parsed. */ public <T> Task<T> createRootTask (String treeReference) { return library.createRootTask(treeReference); }
public BehaviorTreeParser (int debugLevel) { this(new DistributionAdapters(), debugLevel); }
@Override protected void endStatement () { statement.exit(this); }
@Override protected BehaviorTree newObject() { return newBehaviorTree(treeReference); } };
/** Parses the given file. * @param file the file to parse * @param object the blackboard object. It can be {@code null}. * @return the behavior tree * @throws SerializationException if the file cannot be successfully parsed. */ public BehaviorTree<E> parse (FileHandle file, E object) { btReader.parse(file); return createBehaviorTree(btReader.root, object); }
/** * creates concrete tree instance. * @param treeReference * @return a new tree instance. */ protected <T> BehaviorTree<T> newBehaviorTree (String treeReference) { return super.createBehaviorTree(treeReference, null); }
@Override protected <E> void enter (DefaultBehaviorTreeReader<E> reader, String name, boolean isGuard) { // Root tree is the default one if (reader.currentTree == null) { reader.switchToNewTree(""); reader.subtreeName = null; } reader.openTask(name, isGuard); }
/** Parses the given reader. * @param reader the reader to parse * @param object the blackboard object. It can be {@code null}. * @return the behavior tree * @throws SerializationException if the reader cannot be successfully parsed. */ public BehaviorTree<E> parse (Reader reader, E object) { btReader.parse(reader); return createBehaviorTree(btReader.root, object); }
/** Creates the {@link BehaviorTree} for the specified reference. * @param treeReference the tree identifier, typically a path * @return the tree cloned from the archetype. * @throws SerializationException if the reference cannot be successfully parsed. * @throws TaskCloneException if the archetype cannot be successfully parsed. */ public <T> BehaviorTree<T> createBehaviorTree (String treeReference) { return library.createBehaviorTree(treeReference); }
/** Parses the given string. * @param string the string to parse * @param object the blackboard object. It can be {@code null}. * @return the behavior tree * @throws SerializationException if the string cannot be successfully parsed. */ public BehaviorTree<E> parse (String string, E object) { btReader.parse(string); return createBehaviorTree(btReader.root, object); }
/** Creates the {@link BehaviorTree} for the specified reference. * @param treeReference the tree identifier, typically a path * @return the tree cloned from the archetype. * @throws SerializationException if the reference cannot be successfully parsed. * @throws TaskCloneException if the archetype cannot be successfully parsed. */ public <T> BehaviorTree<T> createBehaviorTree (String treeReference) { return createBehaviorTree(treeReference, null); }