Search in sources :

Example 6 with BehaviorTreeBuilder

use of org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder 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));
}
Also used : BehaviorTreeBuilder(org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder) GsonBuilder(com.google.gson.GsonBuilder) BehaviorNode(org.terasology.engine.logic.behavior.core.BehaviorNode) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with BehaviorTreeBuilder

use of org.terasology.engine.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();
}
Also used : BehaviorTreeBuilder(org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

BehaviorTreeBuilder (org.terasology.engine.logic.behavior.core.BehaviorTreeBuilder)7 BehaviorNode (org.terasology.engine.logic.behavior.core.BehaviorNode)4 BeforeEach (org.junit.jupiter.api.BeforeEach)2 GsonBuilder (com.google.gson.GsonBuilder)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Vector2f (org.joml.Vector2f)1 Print (org.terasology.engine.logic.behavior.actions.Print)1 Actor (org.terasology.engine.logic.behavior.core.Actor)1