Package org.terasology.logic.behavior.asset

Examples of org.terasology.logic.behavior.asset.BehaviorTreeLoader.save()


        BehaviorTreeLoader loader = new BehaviorTreeLoader();
        try {
            Files.createDirectories(savePath);
            Path file = savePath.resolve(uri.getAssetName() + ".behavior");
            try (FileOutputStream fos = new FileOutputStream(file.toFile())) {
                loader.save(fos, tree.getData());
            }
        } catch (IOException e) {
            throw new RuntimeException("Cannot save asset " + uri + " to " + savePath, e);
        }
    }
View Full Code Here


    public String save() {
        BehaviorTreeLoader loader = new BehaviorTreeLoader();
        ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
        try {
            loader.save(baos, tree.getData());
            return baos.toString(Charsets.UTF_8.name());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        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);
View Full Code Here

        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);
        os = new ByteArrayOutputStream(10000);
        loader = new BehaviorTreeLoader();
        loader.save(os, data);
View Full Code Here

        loader.save(os, data);
        String jsonExpected = os.toString();
        data = loader.load(null, new ByteArrayInputStream(jsonExpected.getBytes()), null, null);
        os = new ByteArrayOutputStream(10000);
        loader = new BehaviorTreeLoader();
        loader.save(os, data);
        String jsonActual = os.toString();
        Assert.assertEquals(jsonActual, jsonExpected);
    }

    private BehaviorTreeData buildSample() {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.