Package org.terasology.logic.behavior.asset

Examples of org.terasology.logic.behavior.asset.BehaviorTreeData$LayoutTree


            interpreter.tick(delta);
        }
    }

    public BehaviorTree createTree(String name, Node root) {
        BehaviorTreeData data = new BehaviorTreeData();
        data.setRoot(root);
        BehaviorTree behaviorTree = new BehaviorTree(new AssetUri(AssetType.BEHAVIOR, BEHAVIORS, name.replaceAll("\\W+", "")), data);
        trees.add(behaviorTree);
        save(behaviorTree);
        return behaviorTree;
    }
View Full Code Here


    /**
     * copy the given node. the new copy replaces the given one, so you should manipulate the original node, instead of the copy.
     * This is useful when in interaction listener, especially.
     */
    public void copyNode(RenderableNode node) {
        BehaviorTreeData data = new BehaviorTreeData();
        data.setRoot(node.getNode());
        BehaviorTreeLoader loader = new BehaviorTreeLoader();
        ByteArrayOutputStream os = new ByteArrayOutputStream(10000);

        try {
            loader.save(os, data);
            BehaviorTreeData copy = loader.load(null, new ByteArrayInputStream(os.toByteArray()), null, Collections.<URL>emptyList());
            Port.OutputPort parent = node.getInputPort().getTargetPort();
            copy.createRenderable();
            RenderableNode copyRenderable = copy.getRenderableNode(copy.getRoot());
            addNode(copyRenderable);
            RenderableNode nodeToLayout;
            if (parent != null && copyRenderable.getInputPort() != null) {
                parent.setTarget(copyRenderable.getInputPort());
                nodeToLayout = parent.node;
View Full Code Here

            e.printStackTrace();
        }
    }

    public void linkNode(RenderableNode node) {
        BehaviorTreeData data = new BehaviorTreeData();
        data.setRoot(node.getNode());
        Port.OutputPort parent = node.getInputPort().getTargetPort();
        data.createRenderable();
        RenderableNode copyRenderable = data.getRenderableNode(data.getRoot());
        addNode(copyRenderable);
        RenderableNode nodeToLayout;
        if (parent != null && copyRenderable.getInputPort() != null) {
            parent.setTarget(copyRenderable.getInputPort());
            nodeToLayout = parent.node;
View Full Code Here

        AssetManager assetManager = mock(AssetManager.class);
        CoreRegistry.put(AssetManager.class, assetManager);
        BehaviorNodeFactory nodeFactory = mock(BehaviorNodeFactory.class);
        CoreRegistry.put(BehaviorNodeFactory.class, nodeFactory);
        BehaviorTreeLoader loader = new BehaviorTreeLoader();
        BehaviorTreeData data = buildSample();

        OutputStream os = new ByteArrayOutputStream(10000);
        loader.save(os, data);
        String jsonExpected = os.toString();
        data = loader.load(null, new ByteArrayInputStream(jsonExpected.getBytes()), null, null);
View Full Code Here

        sequence.children().add(new RepeatNode(new DebugNode(2)));
        ParallelNode parallel = new ParallelNode(ParallelNode.Policy.RequireAll, ParallelNode.Policy.RequireAll);
        sequence.children().add(parallel);
        parallel.children().add(new MonitorNode());
        parallel.children().add(new DebugNode(3));
        BehaviorTreeData tree = new BehaviorTreeData();
        tree.setRoot(sequence);
        tree.createRenderable();
        tree.layout(null);
        return tree;
    }
View Full Code Here

TOP

Related Classes of org.terasology.logic.behavior.asset.BehaviorTreeData$LayoutTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.