Skip to content
Outerminds edited this page Jan 31, 2019 · 8 revisions

Content


Description

A node is a description of the execution routine to be executed by a controller. A node hierarchy can be nested as much as needed and can be used to describe system libraries to promote modularity and reusability.


Usage

using Entia.Nodes;
using Entia.Systems;
using static Entia.Nodes.Node;

namespace Systems
{
    // Empty systems used as placeholders in the node hierarchies.
    public struct A : ISystem { }
    public struct B : ISystem { }
    public struct C : ISystem { }
}

public static class Game
{
    // 'Sequence()' describes a sequential execution of its children.
    public static readonly Node SequentialNode =
        Sequence(
            System<Systems.A>(),
            System<Systems.B>(),
            System<Systems.C>()
        );

    // 'Parallel()' describes a sequential execution of its children.
    // It uses 'System.Threading.Tasks.Parallel' by default, but this behaviour 
    // like the behaviour associated with any node can be overridden.
    public static readonly Node ParallelNode =
        Parallel(
            System<Systems.A>(),
            System<Systems.B>(),
            System<Systems.C>()
        );

    // 'Automatic()' uses the results of the thread safety analysis to decide 
    // which of its children should be run sequentially and which should be 
    // run in parallel.
    public static readonly Node AutomaticNode =
        Automatic(
            System<Systems.A>(),
            System<Systems.B>(),
            System<Systems.C>()
        );

    // Nodes can be nested in other nodes.
    // 'Profile()' will emit an 'Entia.Messages.OnProfile' message for every 
    // node in the hierarchy when it is executed.
    // This allows to display the execution time of every node.
    public static readonly Node NestedNode =
        Sequence(
            SequentialNode,
            ParallelNode,
            AutomaticNode
        ).Profile();
}

Related

Clone this wiki locally