new_sequence + new_selector for CompositeNode

This commit is contained in:
Dmitry
2021-08-10 23:47:21 +03:00
parent 5d768b612b
commit a0f3d814d4
+16
View File
@@ -53,6 +53,22 @@ impl<B> CompositeNode<B> {
Self { children, kind }
}
/// Creates new sequence composite node with a set of children nodes.
pub fn new_sequence(children: Vec<Handle<BehaviorNode<B>>>) -> Self {
Self {
children,
kind: CompositeNodeKind::Sequence,
}
}
/// Creates new selector composite node with a set of children nodes.
pub fn new_selector(children: Vec<Handle<BehaviorNode<B>>>) -> Self {
Self {
children,
kind: CompositeNodeKind::Selector,
}
}
/// Adds self to the tree and return handle to self.
pub fn add(self, tree: &mut BehaviorTree<B>) -> Handle<BehaviorNode<B>> {
tree.add_node(BehaviorNode::Composite(self))