Facepunch.ActionGraphs
1.3.59
See the version list below for details.
dotnet add package Facepunch.ActionGraphs --version 1.3.59
NuGet\Install-Package Facepunch.ActionGraphs -Version 1.3.59
<PackageReference Include="Facepunch.ActionGraphs" Version="1.3.59" />
paket add Facepunch.ActionGraphs --version 1.3.59
#r "nuget: Facepunch.ActionGraphs, 1.3.59"
// Install Facepunch.ActionGraphs as a Cake Addin #addin nuget:?package=Facepunch.ActionGraphs&version=1.3.59 // Install Facepunch.ActionGraphs as a Cake Tool #tool nuget:?package=Facepunch.ActionGraphs&version=1.3.59
Facepunch.ActionGraphs
Runtime-composable async methods that can be converted to and from JSON.
Overview
An action graph is made out of nodes, links and variables. Nodes either perform actions or evaluate expressions, and links connect them together to shuttle values or signals around. Variables provide storage local to each invocation of the graph, and are used to capture values at specific points during invocation. Arbitrary user data can be stored on each element, which could be used by a visual editor. Validation is performed to find any errors or warnings, and any errors will mean a graph can't be invoked. Node definitions are stored in a node library, and each graph will belong to exactly one such library to supply its node definitions. Action graphs can be serialized to JSON, and Delegate types created using graphs can also be serialized directly.
Node
Nodes have a definition and a binding. Bindings specify which properties, inputs, and outputs a node has. Inputs and outputs may transmit values or signals. A node with signal inputs / outputs is an Action node, which is invoked when an input signal fires. Nodes without any signal inputs / outputs are Expression nodes, which are lazily evaluated when any of their output values are requested by an Action node.
Definition
A node definition describes what the node will do, and provides bindings based
on which property values and input types a node currently has. Each definition
will belong to exactly one node library, and has a unique name
in that library. There are built-in definitions for common nodes like
operators, getting / setting variables, and the event
node which acts as an
entry point.
Binding
Definitions provide bindings, which are specifically typed sets of properties,
inputs, and outputs. Depending on the definition, the binding of a node may
change as you connect inputs or assign properties. For example, the type of the
result
output of an op.add
addition node depends on the types of the
provided inputs.
Property
Properties are constant named values stored in a node, which control its
binding. For example: a var.set
node, which would set a variable when
invoked, has a property specifying which variable it will assign. Changing
that property will change the input value type of the node, to match the
variable type.
Input
A node input will either receive a signal or a value.
Input values can be provided by another node's output through a Link, or a constant value stored inside the input. Input signals can only be provided by an output signal from another node, and control when the receiving node executes.
If an input value accepts an array type, it may be linked to multiple outputs in a specific order to provide the individual items of an array. Otherwise, inputs link to at most one output.
Output
A node output will emit either a signal or a value.
Output signals may fire mutliple times per invocation of the node, for example
the body
output of the loop node control.foreach
will fire once per element
in the items
input value. If multiple input signals are connected to the same
output signal, the receiving nodes will act as independent concurrent tasks.
Output values of Action nodes may be provided by a specific output signal, and can only be used downstream of that output signal.
Output values of expression nodes are always available, and will be evaluated lazily when requested by an Action node.
Link
Links are the connections between an output and an input. An output signal can only connect to input signals, and an output value can only connect to input values. See input and output for more details.
Variable
Variables are provided as a way to capture values at specific points to be read later on.
Each variable has a specific name and type. They are referenced in var.set
and var.get
nodes, and must be set before they can be read. They are local
to each invocation of an action graph, so if multiple instances of the same graph
are running simultaneously they won't share variables.
Node Library
Creating a node library is required to use action graphs. These contain all the
node definitions available when building a graph. An ITypeLoader
must be
provided to wrap any reflection, in case you want to restrict which types can
be used in a graph.
There are some built-in special node definitions that are provided by every
node library. For example, the event
entry point node, var.get
and
var.set
for using variables, and one for each operator like op.add
.
Custom Nodes
Custom nodes can be implemented as static C# methods. An
[Node( "ident" )]
is used for action node methods, and
[Node( "ident" ), Pure]
for expression node methods. Methods marked with
these attributes will be added to a library when calling
NodeLibrary.AddAssembly(asm)
. The parameters of the method will describe
the properties, inputs and outputs of the node.
Properties are defined with parameters marked with a [Property]
attribute.
Action node methods must return either void
or a Task
. Expression node
methods must return a non-Task
, and an output will be generated to emit the
return value. Output signals for action nodes are parameters with a delegate
type, and they will have corresponding output values based on the delegate
parameters. The method can invoke these delegate parameters to emit output
signals. If the delegates return Task
s, they will complete when all control
flow downstream of the emitted signal has finished.
All other parameters will become inputs for the node. An input with type
Input<T>
can be evaluated on demand by the method, allowing for input values
that change during the invocation of the method. All other input values will
be evaluated just before the method is invoked.
Generic methods are largely supported, and will produce a node that can change its binding as input or property types are modified.
User Data
Each main element of an action graph has a UserData
property, which can store
arbitary named values serialized as JSON nodes. This could be used to record
each node's position in a visual editor, for example.
Validation
Each time an action graph is modified, elements will be marked as needing
validation. This validation is performed either when attempting to invoke the
graph, or when accessing the Messages
property. This property will be
populated with a list of information, warnings and errors, each describing
the context and cause. Any error messages will mean the ActionGraph can't be
invoked.
You can also access the messages specific to a particular node / link /
property / input / output / variable by using the element.GetMessages()
extension method. Accessing this will also cause validation to occur, if any
elements have changed since the last validation.
Invocation
After validation succeeds, an action graph can be invoked. Special event
nodes
act as the entry point during invocation, which can have named parameters that
provide output values on the event node. If an action graph is created to match
the signature of a particular delegate type, an event node is automatically
created with the right output values.
Invocation is asynchronous, and returns a Task that completes when all action nodes have finished acting. If the same action graph instance is invoked multiple times, the separate invocations act in parallel and have their own local variables.
Action graphs can also be converted to delegate instances, as long as they match that delegate's signature. Invoking the delegate will invoke the graph.
Serialization
To be able to serialize action graphs with System.Text.Json, a
JsonSerializerOptions
instance must have the AddActionGraphConverters()
extension method called on it. After that it can convert ActionGraph
,
ActionGraph<T>
, and even delegate instances that are created from action
graphs.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- JetBrains.Annotations (>= 2023.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.11 | 132 | 7/2/2024 |
1.7.10 | 89 | 7/2/2024 |
1.7.9 | 72 | 7/1/2024 |
1.7.8 | 88 | 6/10/2024 |
1.7.7 | 71 | 6/10/2024 |
1.7.6 | 101 | 5/25/2024 |
1.7.5 | 80 | 5/25/2024 |
1.7.4 | 82 | 5/25/2024 |
1.7.3 | 95 | 5/21/2024 |
1.7.2 | 93 | 5/16/2024 |
1.7.1 | 79 | 5/3/2024 |
1.7.0 | 100 | 4/30/2024 |
1.6.21 | 97 | 4/22/2024 |
1.6.20 | 77 | 4/20/2024 |
1.6.19 | 83 | 4/20/2024 |
1.6.18 | 81 | 4/18/2024 |
1.6.17 | 84 | 4/18/2024 |
1.6.16 | 75 | 4/18/2024 |
1.6.15 | 82 | 4/17/2024 |
1.6.14 | 112 | 4/10/2024 |
1.6.13 | 77 | 4/10/2024 |
1.6.12 | 83 | 4/10/2024 |
1.6.11 | 79 | 4/8/2024 |
1.6.10 | 89 | 4/2/2024 |
1.6.9 | 102 | 3/20/2024 |
1.6.8 | 85 | 3/19/2024 |
1.6.7 | 96 | 3/18/2024 |
1.6.6 | 85 | 3/16/2024 |
1.6.5 | 86 | 3/16/2024 |
1.6.4 | 92 | 3/16/2024 |
1.6.3 | 93 | 3/16/2024 |
1.6.2 | 93 | 3/16/2024 |
1.6.1 | 80 | 3/16/2024 |
1.3.103 | 105 | 4/8/2024 |
1.3.102 | 110 | 4/3/2024 |
1.3.101 | 80 | 4/3/2024 |
1.3.100 | 109 | 3/22/2024 |
1.3.99 | 88 | 3/22/2024 |
1.3.98 | 85 | 3/22/2024 |
1.3.97 | 100 | 3/22/2024 |
1.3.96 | 74 | 3/22/2024 |
1.3.95 | 85 | 3/22/2024 |
1.3.94 | 117 | 3/11/2024 |
1.3.93 | 92 | 3/11/2024 |
1.3.92 | 77 | 3/11/2024 |
1.3.91 | 95 | 3/11/2024 |
1.3.90 | 91 | 3/8/2024 |
1.3.89 | 95 | 3/7/2024 |
1.3.88 | 105 | 3/5/2024 |
1.3.87 | 121 | 3/1/2024 |
1.3.86 | 95 | 3/1/2024 |
1.3.85 | 93 | 2/29/2024 |
1.3.84 | 77 | 2/29/2024 |
1.3.83 | 82 | 2/29/2024 |
1.3.82 | 79 | 2/29/2024 |
1.3.81 | 74 | 2/29/2024 |
1.3.80 | 76 | 2/29/2024 |
1.3.79 | 97 | 2/28/2024 |
1.3.78 | 91 | 2/28/2024 |
1.3.77 | 100 | 2/28/2024 |
1.3.76 | 86 | 2/28/2024 |
1.3.75 | 92 | 2/28/2024 |
1.3.74 | 87 | 2/27/2024 |
1.3.73 | 81 | 2/27/2024 |
1.3.72 | 84 | 2/26/2024 |
1.3.71 | 104 | 2/26/2024 |
1.3.70 | 91 | 2/26/2024 |
1.3.69 | 88 | 2/26/2024 |
1.3.68 | 92 | 2/26/2024 |
1.3.67 | 96 | 2/23/2024 |
1.3.66 | 97 | 2/22/2024 |
1.3.65 | 94 | 2/20/2024 |
1.3.64 | 94 | 2/20/2024 |
1.3.63 | 93 | 2/20/2024 |
1.3.62 | 80 | 2/19/2024 |
1.3.61 | 88 | 2/19/2024 |
1.3.60 | 84 | 2/16/2024 |
1.3.59 | 82 | 2/16/2024 |
1.3.58 | 101 | 2/15/2024 |
1.3.57 | 90 | 2/15/2024 |
1.3.56 | 84 | 2/15/2024 |
1.3.55 | 77 | 2/15/2024 |
1.3.54 | 91 | 2/14/2024 |
1.3.53 | 77 | 2/14/2024 |
1.3.52 | 81 | 2/14/2024 |
1.3.51 | 80 | 2/14/2024 |
1.3.50 | 82 | 2/14/2024 |
1.3.49 | 78 | 2/13/2024 |
1.3.48 | 87 | 2/11/2024 |
1.3.47 | 89 | 2/10/2024 |
1.3.46 | 95 | 2/10/2024 |
1.3.45 | 94 | 2/9/2024 |
1.3.44 | 90 | 2/9/2024 |
1.3.43 | 92 | 2/8/2024 |
1.3.42 | 91 | 2/8/2024 |
1.3.41 | 95 | 2/8/2024 |
1.3.40 | 87 | 2/7/2024 |
1.3.39 | 100 | 2/7/2024 |
1.3.38 | 95 | 2/7/2024 |
1.3.37 | 87 | 2/6/2024 |
1.3.36 | 90 | 2/6/2024 |
1.3.35 | 99 | 2/6/2024 |
1.3.34 | 90 | 1/31/2024 |
1.3.33 | 106 | 1/30/2024 |
1.3.32 | 91 | 1/30/2024 |
1.3.31 | 88 | 1/30/2024 |
1.3.30 | 85 | 1/30/2024 |
1.3.29 | 83 | 1/30/2024 |
1.3.28 | 91 | 1/29/2024 |
1.3.27 | 83 | 1/29/2024 |
1.3.26 | 79 | 1/29/2024 |
1.3.25 | 91 | 1/27/2024 |
1.3.24 | 80 | 1/26/2024 |
1.3.23 | 94 | 1/26/2024 |
1.3.22 | 86 | 1/26/2024 |
1.3.21 | 91 | 1/26/2024 |
1.3.20 | 86 | 1/25/2024 |
1.3.19 | 90 | 1/25/2024 |
1.3.18 | 86 | 1/25/2024 |
1.3.17 | 89 | 1/25/2024 |
1.3.16 | 86 | 1/24/2024 |
1.3.15 | 82 | 1/24/2024 |
1.3.14 | 89 | 1/24/2024 |
1.3.13 | 91 | 1/23/2024 |
1.3.12 | 82 | 1/23/2024 |
1.3.11 | 84 | 1/23/2024 |
1.3.10 | 84 | 1/23/2024 |
1.3.9 | 88 | 1/23/2024 |
1.3.8 | 83 | 1/23/2024 |
1.3.7 | 83 | 1/23/2024 |
1.3.6 | 90 | 1/22/2024 |
1.3.5 | 82 | 1/22/2024 |
1.3.4 | 105 | 1/19/2024 |
1.3.3 | 88 | 1/19/2024 |
1.3.2 | 86 | 1/19/2024 |
1.3.1 | 84 | 1/19/2024 |
1.3.0 | 83 | 1/19/2024 |
1.2.10 | 81 | 1/19/2024 |
1.2.9 | 95 | 1/18/2024 |
1.2.8 | 91 | 1/18/2024 |
1.2.7 | 86 | 1/18/2024 |
1.2.6 | 86 | 1/18/2024 |
1.2.5 | 102 | 1/17/2024 |
1.2.4 | 99 | 1/16/2024 |
1.2.3 | 97 | 1/16/2024 |
1.2.2 | 94 | 1/16/2024 |
1.2.1 | 94 | 1/16/2024 |
1.2.0 | 90 | 1/16/2024 |
1.1.37 | 116 | 1/13/2024 |
1.1.36 | 90 | 1/13/2024 |
1.1.35 | 107 | 1/12/2024 |
1.1.34 | 99 | 1/12/2024 |
1.1.33 | 93 | 1/12/2024 |
1.1.32 | 94 | 1/12/2024 |
1.1.31 | 97 | 1/12/2024 |
1.1.30 | 95 | 1/11/2024 |
1.1.29 | 93 | 1/11/2024 |
1.1.28 | 88 | 1/11/2024 |
1.1.27 | 90 | 1/11/2024 |
1.1.26 | 89 | 1/11/2024 |
1.1.25 | 110 | 1/11/2024 |
1.1.24 | 116 | 1/9/2024 |
1.1.23 | 120 | 1/8/2024 |
1.1.22 | 104 | 1/8/2024 |
1.1.21 | 128 | 1/5/2024 |
1.1.20 | 107 | 1/4/2024 |
1.1.19 | 106 | 1/4/2024 |
1.1.18 | 103 | 1/4/2024 |
1.1.17 | 102 | 1/4/2024 |
1.1.16 | 104 | 1/4/2024 |
1.1.15 | 188 | 12/7/2023 |
1.1.14 | 128 | 12/7/2023 |
1.1.13 | 131 | 12/6/2023 |
1.1.12 | 111 | 12/4/2023 |
1.1.11 | 137 | 12/2/2023 |
1.1.10 | 132 | 11/27/2023 |
1.1.9 | 151 | 11/24/2023 |
1.1.8 | 135 | 11/24/2023 |
1.1.7 | 142 | 11/22/2023 |
1.1.6 | 130 | 11/22/2023 |
1.1.5 | 110 | 11/21/2023 |
1.1.4 | 127 | 11/21/2023 |
1.1.3 | 147 | 11/17/2023 |
1.1.2 | 124 | 11/16/2023 |
1.1.1 | 119 | 11/16/2023 |
1.1.0 | 107 | 11/15/2023 |
1.0.17 | 131 | 11/8/2023 |
1.0.16 | 119 | 11/8/2023 |
1.0.15 | 124 | 11/7/2023 |
1.0.14 | 125 | 11/6/2023 |
1.0.13 | 127 | 11/1/2023 |
1.0.12 | 119 | 11/1/2023 |
1.0.11 | 119 | 10/31/2023 |
1.0.10 | 136 | 10/31/2023 |
1.0.9 | 129 | 10/31/2023 |
1.0.8 | 121 | 10/30/2023 |
1.0.7 | 119 | 10/27/2023 |
1.0.6 | 124 | 10/27/2023 |
1.0.5 | 121 | 10/27/2023 |
1.0.4 | 131 | 10/27/2023 |
1.0.3 | 124 | 10/25/2023 |
1.0.2 | 132 | 10/24/2023 |
1.0.1 | 104 | 10/24/2023 |
1.0.0 | 129 | 10/24/2023 |