use of org.terasology.engine.logic.behavior.core.BehaviorNode 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());
}
use of org.terasology.engine.logic.behavior.core.BehaviorNode in project Terasology by MovingBlocks.
the class CountCallsTest method init.
@BeforeEach
public void init() {
constructCalled.clear();
destructCalled.clear();
executeCalled.clear();
nextId2 = 1;
gsonBuilder = new GsonBuilder();
BehaviorTreeBuilder builder = new BehaviorTreeBuilder() {
@Override
public BehaviorNode createNode(BehaviorNode node) {
return new CountDelegate(node);
}
};
gsonBuilder.registerTypeAdapter(BehaviorNode.class, builder);
// gsonBuilder.registerTypeAdapter(Action.class, new InheritanceAdapter<Action>("delay", Delay.class));
}
use of org.terasology.engine.logic.behavior.core.BehaviorNode in project Terasology by MovingBlocks.
the class BehaviorEditorScreen method onNodeSelected.
private void onNodeSelected(RenderableNode value, PropertyProvider provider) {
selectedNode = value;
properties.clear();
if (value != null) {
BehaviorNode underlyingNode = value.getNode();
if (underlyingNode instanceof ActionNode) {
this.properties.addProperties("Behavior Node", provider.createProperties(((ActionNode) underlyingNode).getAction()));
}
properties.addProperties("Behavior Node", provider.createProperties(value.getNode()));
}
}
use of org.terasology.engine.logic.behavior.core.BehaviorNode in project Terasology by MovingBlocks.
the class LookupAction method construct.
@Override
public void construct(Actor actor) {
if (tree != null) {
BehaviorNode root = tree.getRoot().deepCopy();
if (root != null) {
actor.setValue(getId(), root);
root.construct(actor);
}
}
}
Aggregations