Vixen
c7401864
csharp
public sealed class BehaviorTreeDocument

A behaviour tree, open for editing.

Read the guide page for this →

Remarks

The model and the compiler are Vixen.Editor.Ai's and Vixen.Ai's — neither knows about a project, a document or a panel — and this is the YAML end of it and the undo stack over it.

⚠ Every gesture is one snapshot in, one snapshot out. The node graphs use fine-grained inverses because a shader graph is thousands of nodes; a behaviour tree is tens, and a snapshot is a few kilobytes of strings. What that buys is that a reparent, a reorder and a key rename that rewrote forty references are all undoable by construction, with no chance of an inverse that puts back four of the five things it changed. The entries still merge, so dragging a number is one step rather than forty.

⚠ Compiled when it is asked for, not on every edit. Adding a composite produces a tree with a composite that has no children; adding a decorator produces one whose key is briefly empty. Compiling on every change would fill the panel with complaints about a node somebody is halfway through making — the rule CompositorDocument and AnimationGraphDocument both state.

Fields and properties (6)

  • public const string Extension

    What a behaviour tree is written as.

  • public string AssetPath

    Where the file is, absolute.

  • public BehaviorTreeModel Model

    The tree, and every operation over it.

  • public string? LoadError

    Why the file would not read, or .

  • public IReadOnlyList<BehaviorTreeDiagnostic> Diagnostics

    What the last Compile had to say.

  • public BehaviorTreeTemplate? Template

    What the last Compile produced, or .

Events (1)

Methods (6)

  • public BehaviorTreeDocument(EditorProject project, AssetId asset, string path)

    Opens a tree.

  • public string ToYaml()

    The tree as it would be written.

  • public BehaviorTreeTemplate? Compile(BehaviorTreeResolver? resolver = null)

    Compiles the tree, against whatever a caller can resolve.

  • public void Edit(string name, Action<BehaviorTreeModel> gesture, string? mergeKey = null)

    Runs a gesture as one undo entry.

  • public void Layout()

    Lays the tree out top-down, as one undo entry.

  • protected override void SaveCore()

    Writes the document back to wherever it came from.

Used by (5)

  • BehaviorTreeDocumentTestsVixen.Editor.AssetEditors.Tests
  • BehaviorTreeEditorFactoryVixen.Editor.AssetEditors
  • BehaviorTreeViewVixen.Editor.AssetEditors
  • LiveTreeCanvasTestsVixen.Editor.AssetEditors.Tests
  • SnapshotCommandVixen.Editor.AssetEditors