Paradise.BT
0.6.1
dotnet add package Paradise.BT --version 0.6.1
NuGet\Install-Package Paradise.BT -Version 0.6.1
<PackageReference Include="Paradise.BT" Version="0.6.1" />
<PackageVersion Include="Paradise.BT" Version="0.6.1" />
<PackageReference Include="Paradise.BT" />
paket add Paradise.BT --version 0.6.1
#r "nuget: Paradise.BT, 0.6.1"
#:package Paradise.BT@0.6.1
#addin nuget:?package=Paradise.BT&version=0.6.1
#tool nuget:?package=Paradise.BT&version=0.6.1
Paradise.BT
Paradise.BT is a pure .NET behavior tree runtime with struct-based nodes, an EntitiesBT-style blackboard API, and optional binary serialization through Paradise.BLOB.
Install
dotnet add package Paradise.BT
Features
- Pure .NET runtime with no Unity or ECS dependency.
- Targets
netstandard2.1andnet10.0. - Built-in sequence, selector, parallel, repeat, repeat-forever, inverter, succeeder, delay, success, failure, running, delegate action, and delegate condition nodes.
- Immutable compiled trees plus reusable
BehaviorTreeInstanceruntime state. - Custom node authoring via unmanaged
structtypes that implementINodeData. - Serialization and deserialization support through
Paradise.BLOB.
Quick start
using Paradise.BT;
public struct HasTargetData
{
public bool Value;
}
public struct ShotsFiredData
{
public int Value;
}
var blackboard = new Blackboard();
blackboard.SetData(new HasTargetData { Value = true });
blackboard.SetData(new ShotsFiredData());
var tree = BehaviorTreeBuilder.Build(
BehaviorNodes.Selector(
BehaviorNodes.Sequence(
BehaviorNodes.Condition(static bb => bb.GetData<HasTargetData>().Value),
BehaviorNodes.Repeat(
3,
BehaviorNodes.Sequence(
BehaviorNodes.Delay(0.5f),
BehaviorNodes.Action(static bb =>
{
ref ShotsFiredData shots = ref bb.GetDataRef<ShotsFiredData>();
shots.Value++;
return NodeState.Success;
})))),
BehaviorNodes.Action(static _ => NodeState.Success)));
BehaviorTreeInstance instance = tree.CreateInstance(blackboard);
NodeState firstTick = instance.Tick(0.25f);
NodeState secondTick = instance.Tick(0.25f);
Custom nodes
Implement INodeData on a struct and decorate it with GuidAttribute so it can participate in serialization.
using Paradise.BT;
using System.Runtime.InteropServices;
[Guid("7D4E31B3-0D57-4211-9C1F-91EAB87734E5")]
public struct CounterNode : INodeData
{
public int Count;
public NodeState Tick<TNodeBlob, TBlackboard>(int index, ref TNodeBlob blob, ref TBlackboard bb)
where TNodeBlob : struct, INodeBlob
where TBlackboard : struct, IBlackboard
{
Count++;
return Count >= 3 ? NodeState.Success : NodeState.Running;
}
}
var tree = BehaviorTreeBuilder.Build(
BehaviorNodes.Node(new CounterNode()));
If a node needs reset side effects in addition to restoring its default struct data, also implement ICustomResetAction.
Serialization
Compiled trees can be turned into binary blobs and loaded back later.
using Paradise.BT;
using var blob = tree.Serialize();
BehaviorTree roundTripped = BehaviorTreeBlobSerializer.Deserialize(blob);
Custom unmanaged nodes must be registered before deserialization.
var registry = new BehaviorTreeSerializationRegistry()
.Register<CounterNode>();
BehaviorTree roundTripped = BehaviorTreeBlobSerializer.Deserialize(blob, registry);
Notes
BehaviorTreeInstance.Tick(deltaTime)stores the supplied delta time in the blackboard, which is how nodes such asBehaviorNodes.Delay(...)advance.- Delegate-backed nodes are runtime-only and cannot be serialized because they capture managed references.
- The
Blackboardtype also supports object and keyed-value storage helpers for app-level data setup.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Paradise.BLOB (>= 0.6.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Paradise.BT:
| Package | Downloads |
|---|---|
|
Paradise.BT.Builder
Authoring DSL base classes for Paradise.BT behavior trees. |
|
|
Paradise.BT.Nodes
Built-in node library for Paradise.BT behavior trees (Sequence, Selector, Parallel, decorators, delegate-backed actions, delay timer). |
GitHub repositories
This package is not used by any popular GitHub repositories.