public sealed class BehaviorTreeModelAn editable behaviour tree: the document, plus everything a gesture needs to ask it.
Remarks
The document is BehaviorTreeContent — the same shape the file holds and the same shape the compiler takes — and this is the operations over it. There is no second model to keep in step, which is the bargain Vixen.Editor.AnimationGraph makes and for the same reason: two models is two places for a field to be added and one place for it to be forgotten.
⚠ Undo is a snapshot, not a per-field inverse. The node graphs use fine-grained commands because a shader graph is thousands of nodes and a snapshot per keystroke would be megabytes; a behaviour tree is tens of nodes, and a snapshot is a few kilobytes of strings. What that buys is that every gesture is undoable by construction — a reparent, a reorder, a key rename that rewrote forty references — with no chance of an inverse that restores four of the five things it changed. BehaviorTreeDocument is where the snapshots become undo entries.
⚠ A node's identity is the object. Nothing carries a GUID: the content tree is reachable only through this model, a snapshot restore replaces the whole tree at once, and a selection is re-resolved from the path after one. An id would be a second thing the file has to carry and a person editing the YAML has to keep unique.
Fields and properties (3)
public BehaviorTreeContent ContentThe tree.
public BehaviorNodeSchema SchemaThe node library.
public int CountHow many nodes there are.
Events (1)
public Action<BehaviorTreeModel>? ChangedRaised after anything changes.
Methods (31)
public BehaviorTreeModel(BehaviorTreeContent content, BehaviorNodeSchema? schema = null)Creates a model over a document.
public IEnumerable<BehaviorNodeContent> Walk()Every node, in pre-order — which is the priority order the badges show.
public int IndexOf(BehaviorNodeContent node)A node's position in the pre-order walk, or -1.
public BehaviorNodeContent? At(int index)The node at a pre-order index, or null.
public BehaviorNodeContent? Parent(BehaviorNodeContent node)A node's parent, or null for the root and for anything not in this tree.
public static bool Contains(BehaviorNodeContent ancestor, BehaviorNodeContent node)Whether one node is inside another's subtree, itself included.
public BehaviorNodeType? TypeOf(BehaviorNodeContent node)What a node's type declares, or null when the file names something unknown.
public BehaviorNodeType? TypeOf(BehaviorAttachmentContent attachment)What an attachment's type declares.
public void Replace(BehaviorTreeContent content)Replaces the whole document. What an undo does.
public BehaviorTreeContent Snapshot()A deep copy of the document, for an undo entry.
public static BehaviorTreeContent Copy(BehaviorTreeContent content)A deep copy of any tree.
public static BehaviorNodeContent Make(BehaviorNodeType type, string? name = null)Makes a node of a type, with its declared defaults filled in.
public static BehaviorAttachmentContent MakeAttachment(BehaviorNodeType type)Makes an attachment of a type, with its declared defaults filled in.
public void Insert(BehaviorNodeContent? parent, BehaviorNodeContent node, int at = -1)Puts a node under a parent.
public bool Remove(BehaviorNodeContent node)Takes a node and its subtree out.
public bool Reparent(BehaviorNodeContent node, BehaviorNodeContent parent, int at = -1)Moves a node to a new parent and position.
public bool Reorder(BehaviorNodeContent node, int delta)Moves a child up or down among its siblings.
public static List<BehaviorAttachmentContent> Attachments(BehaviorNodeContent node, BehaviorAttachmentSlot slot)One of a node's two attachment lists.
public void Attach(BehaviorNodeContent node, BehaviorAttachmentSlot slot, BehaviorAttachmentContent attachment, int at = -1)Attaches something to a node.
public bool Detach(BehaviorNodeContent node, BehaviorAttachmentSlot slot, BehaviorAttachmentContent attachment)Takes an attachment off.
public bool MoveAttachment(BehaviorNodeContent node, BehaviorAttachmentSlot slot, BehaviorAttachmentContent attachment, int delta)Moves an attachment up or down its list.
public void SetField(BehaviorNodeContent node, string field, string value)Writes one field on a node.
public void SetField(BehaviorAttachmentContent attachment, string field, string value)Writes one field on an attachment.
public void Rename(BehaviorNodeContent node, string name)Renames a node.
public void Move(BehaviorNodeContent node, float x, float y)Moves a node's box.
public BehaviorKeyContent? AddKey(string name, BlackboardValueType type)Adds a key.
public int RenameKey(BehaviorKeyContent key, string name)Renames a key, and every reference to it in this document.
public void RetypeKey(BehaviorKeyContent key, BlackboardValueType type)Changes what a key holds.
public int RemoveKey(BehaviorKeyContent key)Deletes a key.
public IReadOnlyList<BehaviorNodeContent> AbortScope(BehaviorNodeContent node, BehaviorAttachmentContent attachment)What a decorator with an observer can interrupt.
public string Summarise(BehaviorAttachmentContent attachment)A one-line summary of an attachment's settings, for the row on the node.
Used by (7)
- BehaviorTreeDocumentVixen.Editor.AssetEditors
- BehaviorTreeDocumentTestsVixen.Editor.AssetEditors.Tests
- BehaviorTreeLayoutVixen.Editor.Ai
- BehaviorTreeModelTestsVixen.Editor.Ai.Tests
- BehaviorTreeProjectionVixen.Editor.Ai
- BehaviorTreeViewVixen.Editor.AssetEditors
- SnapshotCommandVixen.Editor.AssetEditors