Vixen
c7401864
csharp
public sealed class BehaviorTreeTemplate

A compiled behaviour tree: a flat array of nodes, immutable, shared by every agent running it.

Read the guide page for this →

Remarks

There is no per-agent field anywhere in here. An agent's state is a block from an AgentMemoryPool, sized by MemorySize and carved into windows by the offsets each node, decorator and service carries. A thousand agents on one tree is a thousand small blocks, all sized at load, and nothing is allocated during a step.

⚠ Unreal has an escape hatch this does not: node instancing, where a node that cannot fit its state in plain memory gets a real object per agent. It exists because Blueprint nodes hold UObject references. Adding it here would mean every node's memory access has two paths for the life of the engine, so a node that needs a reference stores an Entity or an AssetId instead — both of which are values.

Fields and properties (11)

  • public Symbol Name

    What the tree is called.

  • public BlackboardLayout Layout

    The shape of the blackboard its keys were resolved against.

  • public int MemorySize

    How many bytes one agent running this tree needs.

  • public int Count

    How many nodes it has.

  • public int NestedSlotCount

    How many nested instances an agent running it may need.

  • public ReadOnlySpan<Symbol> CooldownTags

    The named cooldowns any decorator in this tree reads or starts, once each.

  • public ReadOnlySpan<BehaviorNode> Nodes

    The nodes, in pre-order.

  • public ReadOnlySpan<BehaviorDecoratorSlot> Decorators

    Every decorator in the tree, grouped by the node it is attached to.

  • public ReadOnlySpan<BehaviorServiceSlot> Services

    Every service in the tree, grouped by the composite it is attached to.

  • public ReadOnlySpan<BlackboardKey> ObservedKeys

    The keys any observing decorator reads, once each.

  • public ref readonly BehaviorNode this[int index]

    The node at an index.

Methods (3)

  • public bool Contains(int ancestor, int index)

    Whether one node's subtree contains another.

  • public ReadOnlySpan<BlackboardKey> KeysOf(in BehaviorDecoratorSlot slot)

    The keys one decorator reads.

  • public string Dump()

    A one-line-per-node dump, for a golden test and for a bug report.

Used by (29)

  • AiBreakpointTestsVixen.Ai.Tests
  • AiBreakpointsVixen.Ai
  • AiSnapshotsVixen.Ai
  • AiSystemVixen.Ai
  • AuthorableNodeTestsVixen.Ai.Tests
  • BehaviorTreeAbortOrderingTestsVixen.Ai.Tests
  • BehaviorTreeCompilerVixen.Ai
  • BehaviorTreeCompilerTestsVixen.Ai.Tests
  • BehaviorTreeContentCompilerVixen.Ai
  • BehaviorTreeCostTestsVixen.Ai.Tests
  • BehaviorTreeDeterminismTestsVixen.Ai.Tests
  • BehaviorTreeInstanceVixen.Ai
  • BehaviorTreeLibraryVixen.Ai
  • BehaviorTreeResolverReuseTestsVixen.Ai.Tests
  • BehaviorTreeServiceTestsVixen.Ai.Tests
  • CompileStateVixen.Ai
  • FleetVixen.Ai.Tests
  • INestedTreeTaskVixen.Ai
  • PatrolChaseGiveUpTestsVixen.Ai.Nodes.Tests
  • PerceptionNodeTestsVixen.Ai.Perception.Tests
  • RunQueryNodeTestsVixen.Ai.Nodes.Tests
  • RunSubtreeDynamicTaskVixen.Ai
  • TreeHarnessVixen.Ai.Tests
  • VillageVixen.Ai.Nodes.Tests
  • BehaviorTreeDocumentVixen.Editor.AssetEditors
  • BehaviorTreeDocumentTestsVixen.Editor.AssetEditors.Tests
  • BehaviorTreeProjectionVixen.Editor.Ai
  • BehaviorTreeViewVixen.Editor.AssetEditors
  • LiveAgentVixen.Editor.AssetEditors.Tests