use of org.terasology.logic.behavior.core.BehaviorTreeBuilder in project Terasology by MovingBlocks.
the class CountCallsTest method init.
@Before
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.logic.behavior.core.BehaviorTreeBuilder in project Terasology by MovingBlocks.
the class CounterTest method setup.
@Before
public void setup() {
treeBuilder = new BehaviorTreeBuilder();
treeBuilder.registerAction("print", Print.class);
treeBuilder.registerDecorator("counter", CounterAction.class);
treeBuilder.registerDecorator("timeout", TimeoutAction.class);
}
use of org.terasology.logic.behavior.core.BehaviorTreeBuilder in project Terasology by MovingBlocks.
the class BehaviorTreeFormat method load.
@Override
public BehaviorTreeData load(ResourceUrn resourceUrn, List<AssetDataFile> list) throws IOException {
BehaviorTreeBuilder builder = CoreRegistry.get(BehaviorTreeBuilder.class);
if (builder == null) {
builder = new BehaviorTreeBuilder();
CoreRegistry.put(BehaviorTreeBuilder.class, builder);
}
try (InputStream stream = list.get(0).openStream()) {
return load(stream);
}
}
use of org.terasology.logic.behavior.core.BehaviorTreeBuilder in project Terasology by MovingBlocks.
the class BehaviorTreeFormat method load.
public BehaviorTreeData load(InputStream stream) {
BehaviorTreeBuilder builder = CoreRegistry.get(BehaviorTreeBuilder.class);
if (builder == null) {
builder = new BehaviorTreeBuilder();
CoreRegistry.put(BehaviorTreeBuilder.class, builder);
}
BehaviorNode node = builder.fromJson(stream);
BehaviorTreeData data = new BehaviorTreeData();
data.setRoot(node);
return data;
}
use of org.terasology.logic.behavior.core.BehaviorTreeBuilder in project Terasology by MovingBlocks.
the class BehaviorTreeFormat method save.
public void save(OutputStream stream, BehaviorTreeData data) throws IOException {
BehaviorTreeBuilder builder = CoreRegistry.get(BehaviorTreeBuilder.class);
OutputStreamWriter writer = new OutputStreamWriter(stream, Charsets.UTF_8);
writer.write(builder.toJson(data.getRoot()));
writer.close();
}
Aggregations