Jan 30/2020 - This is a very tiny guideline for creating nodes
LABELING
Trigger output ports must be labeled Output Single Data output ports is labeled Result Input & Output data, which range from 0..1 is called Progress (ex: Lerp) For nodes that are executing on many frames, use the trigger ports Start for Input, Done for output when completed. If you are doing a FlowNode, you must have an input trigger in order to update the data & you must have an Output that trigger every time it is updated
NODES TYPES
A node can be either:
- a data node:
IDataNode
has a singlevoid Execute(ctx)
method- there's a specialized version of IDataNode only executed once during the graph's set-up:
IConstantNode<T>
- there's a specialized version of IDataNode only executed once during the graph's set-up:
- a non-data node:
- an entry point:
IEntryPoint
has anExecution Execute(ctx)
method. These nodes will be executed without having to trigger one of their entry points (e.g. OnUpdate, OnCollision, ...) - a flow node:
IFlowNode
has anExecution Execute(ctx, InputTriggerPort)
method - non-data nodes can then implement extra interfaces:
IUpdatableNode
adds anExecution Update(ctx)
method. If a node returnsExecution.Running
, it is required to implement this interfaceIStatefulNode<T>
allows the node to callctx.GetState(ref this)
- an entry point:
There's two convenience interfaces grouping multiple interfaces: IStatefulFlowNode<T>
and IStatefulUpdatableNode<T>
.
CONSTANT NODES
Constant node are executed only at initalzation, and never after.
Node example: ConstantFloat
Inherit from : IConstantNode
DATA NODES
Data nodes are executed only when an output value is read by another node (Pull model). They do not have any internal state & are deterministics (result is only determined by inputs) Node example: Multiplication, Addition, Substraction, etc. (MathBinaryNumber) Inherit from : IDataNode Members to implement: void Execute(GraphInstance ctx), called every time output values must be recomputed.
ENTRY POINTS NODES (TRIGGERS)
These nodes have only outputs & are triggered by external events Node example: OnUpdate, OnTriggerEnter, OnCollisionEnter, etc. Inherit from : IEntryPointNode Members to implement: void Execute(GraphInstance ctx), called every time the event occur.
FLOW NODES
Flow nodes always have triggers in input. They usually perform logical decisions or operations/actions. They execute in a single frame, when triggered. Node example: If, Switch, SetPosition, etc. Inherit from : IFlowNode Members to implement: void Execute(GraphInstance ctx, InputTriggerPort port) They receive a port identifier, to identify which pin was triggered when there is more than one input trigger.
STATEFULL FLOW NODES
Statefull flow noded act like flow nodes, but they laso have he capacity to store data, which can be used for execution over multiple frames.
Inside the node, call GraphInstance.GetState() to retreive your own state data.
Node example: StopWatch, Wait, All, etc.
Inherit from : IFlowNode
GraphInstance usefull functions
GetState- Retreive your persistent Data ReadData - Read from a data port WriteData - Write a data port Trigger - Start execution on a trigger output port
Dynamic ports numbers
All ports types, also have a Multiport version, which enable the dynamic creation of more entries. One good example of this type of port is for the switch case node. All MultiPort node have a SelectPort member, which will create a port based on a runtime index number. This new port can be used to call ReadData/WriteData/Trigger/etc.
Edge connections
It is possible to connect an output trigger node, to many input trigger node. The order of execution is undetermined for now. It is possible to connect 1 data output, to multiple data input. The data will be stored in the type selected by the node having the output data node. All reading nodes will cast their data when reading if necessary. What des it mean? If you connect your output data node to a node that requires an int as an input, that would not affect if you create an edge from the same output to a second input node.