Package org.terasology.logic.behavior.tree

Examples of org.terasology.logic.behavior.tree.Node


        PortList portList = node.getPortList();
        Assert.assertEquals(1, portList.ports().size());
    }

    private Node node() {
        return new Node() {
            @Override
            public Task createTask() {
                return null;
            }
        };
View Full Code Here


    }

    @Test
    public void testFilter() {
        Interpreter interpreter = new Interpreter(null);
        Node mock = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING);
            }
        });
View Full Code Here

        Assert.assertEquals(Status.SUCCESS, task.getStatus());
    }


    private Node create(final Mocker mocker) {
        final Node node = new DebugNode(1);
        return new Node() {
            @Override
            public Task createTask() {
                Task spy = spy(new Task(null) {
                    @Override
                    public Status update(float dt) {
View Full Code Here

                            nextName(in, "nodeId");
                            int id = in.nextInt();
                            nextName(in, "node");
                            if (classMetadata != null) {
                                TypeAdapter<T> delegateAdapter = getDelegateAdapter(classMetadata.getType());
                                Node result;
                                if (classMetadata.getType() == LookupNode.class) {
                                    result = classMetadata.newInstance();
                                    in.beginObject();
                                    nextName(in, "tree");
                                    String uri = in.nextString();
View Full Code Here

    public RenderableNode createNode(BehaviorNodeComponent data) {
        if (tree == null) {
            return null;
        }
        Node node = CoreRegistry.get(BehaviorNodeFactory.class).getNode(data);
        newNode = tree.createNode(node);
        CoreRegistry.get(BehaviorSystem.class).treeModified(tree);
        return newNode;
    }
View Full Code Here

    @Test
    public void testSuccessRequireAll() {
        Interpreter interpreter = new Interpreter(null);
        ParallelNode parallel = new ParallelNode(ParallelNode.Policy.RequireAll, ParallelNode.Policy.RequireOne);

        Node one = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.SUCCESS);
            }
        });
        Node two = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.RUNNING, Status.SUCCESS);
            }
        });
View Full Code Here

    @Test
    public void testSuccessRequireOne() {
        Interpreter interpreter = new Interpreter(null);
        ParallelNode parallel = new ParallelNode(ParallelNode.Policy.RequireOne, ParallelNode.Policy.RequireAll);
        Node one = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.SUCCESS);
            }
        });
        Node two = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.RUNNING);
            }
        });
View Full Code Here

    @Test
    public void testFailureRequireAll() {
        Interpreter interpreter = new Interpreter(null);
        ParallelNode parallel = new ParallelNode(ParallelNode.Policy.RequireOne, ParallelNode.Policy.RequireAll);
        Node one = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.FAILURE);
            }
        });
        Node two = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.RUNNING, Status.FAILURE);
            }
        });
View Full Code Here

    @Test
    public void testFailureRequireOne() {
        Interpreter interpreter = new Interpreter(null);
        ParallelNode parallel = new ParallelNode(ParallelNode.Policy.RequireAll, ParallelNode.Policy.RequireOne);
        Node one = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.FAILURE);
            }
        });
        Node two = create(new Mocker() {
            @Override
            public void mock(Task spy) {
                when(spy.update(anyInt())).thenReturn(Status.RUNNING, Status.RUNNING);
            }
        });
View Full Code Here

        interpreter.tick(0);
        Assert.assertEquals(Status.FAILURE, task.getStatus());
    }

    private Node create(final Mocker mocker) {
        final Node node = new DebugNode(1);
        return new Node() {
            @Override
            public Task createTask() {
                Task spy = spy(new Task(null) {
                    @Override
                    public Status update(float dt) {
View Full Code Here

TOP

Related Classes of org.terasology.logic.behavior.tree.Node

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.