Search in sources :

Example 1 with BehaviorTreeRunner

use of org.terasology.engine.logic.behavior.core.BehaviorTreeRunner in project Terasology by MovingBlocks.

the class CounterTest method assertRun.

private void assertRun(String tree, int executions, String expectedOutput) {
    Print.output = new StringBuilder();
    BehaviorNode node = treeBuilder.fromJson(tree);
    String json = treeBuilder.toJson(node);
    BehaviorNode n2 = treeBuilder.fromJson(json);
    String json2 = treeBuilder.toJson(n2);
    assertEquals(json, json2);
    Actor actor = new Actor(null);
    actor.setDelta(0.5f);
    BehaviorTreeRunner runner = new DefaultBehaviorTreeRunner(node, actor);
    for (int i = 0; i < executions; i++) {
        runner.step();
    }
    assertEquals(expectedOutput, Print.output.toString());
}
Also used : Actor(org.terasology.engine.logic.behavior.core.Actor) BehaviorNode(org.terasology.engine.logic.behavior.core.BehaviorNode) BehaviorTreeRunner(org.terasology.engine.logic.behavior.core.BehaviorTreeRunner) Print(org.terasology.engine.logic.behavior.actions.Print)

Aggregations

Print (org.terasology.engine.logic.behavior.actions.Print)1 Actor (org.terasology.engine.logic.behavior.core.Actor)1 BehaviorNode (org.terasology.engine.logic.behavior.core.BehaviorNode)1 BehaviorTreeRunner (org.terasology.engine.logic.behavior.core.BehaviorTreeRunner)1