ControlTree

Struct ControlTree 

Source
pub struct ControlTree<D: Decorator> { /* private fields */ }

Implementations§

Source§

impl<D: Decorator> ControlTree<D>

Source§

impl<D: Decorator + From<StandardDecorator>> ControlTree<D>

Source

pub fn add_subtree_as_last_child( &mut self, from: CTreeNodeID, subtree: impl Into<Self>, )

Source

pub fn add_subtree_as_first_child( &mut self, from: CTreeNodeID, subtree: impl Into<Self>, )

Source

pub fn add_subtree_with_priority( &mut self, from: CTreeNodeID, priority: usize, subtree: impl Into<Self>, )

Add a subtree below the node at from, with a priority value (the position in the left->right order of the tree). The priority is simply the index in the children vector in Self::tree, and the bt runs from 0..tree.len().

Source§

impl<D: Decorator> ControlTree<D>

Source

pub fn add_child( &mut self, parent_id: CTreeNodeID, child: impl Into<CTreeNode<D>>, ) -> ShrubberyResult<CTreeNodeID>

Add a new node as a child with a priority (0 runs first).

Source

pub fn add_child_with_priority( &mut self, parent_id: CTreeNodeID, child: impl Into<CTreeNode<D>>, priority: usize, ) -> ShrubberyResult<CTreeNodeID>

Add a new node as a child with a priority (0 runs first).

Source

pub fn remove(&mut self, id: CTreeNodeID)

Remove a node and all references to it from the tree (does not remove the actual node from Self::nodes, so you can put it back by ID without re-inserting the node).

Source§

impl<D: Decorator> ControlTree<D>

Source

pub fn iter_control_nodes(&self) -> impl Iterator<Item = &ControlNode<D>> + '_

Source

pub fn iter_decorators(&self) -> impl Iterator<Item = &ControlNode<D>> + '_

Source

pub fn iter_tree( &self, ) -> impl Iterator<Item = (&CTreeNodeID, &Vec<CTreeNodeID>)> + '_

Source

pub fn status(&self) -> Status

The status of the whole control tree (reflected by the status of the root node).

Source

pub fn run<Hook: ExecutorHook>(&mut self, hook: &mut Hook) -> Status

Source

pub fn run_with_update_callback<Hook: ExecutorHook, Callback: UpdateCallback<D>>( &mut self, hook: &mut Hook, cb: &mut Callback, ) -> Status

Source

pub fn run_from<Hook: ExecutorHook>( &mut self, node_id: CTreeNodeID, hook: &mut Hook, ) -> Status

Source

pub fn run_from_with_update_callback<Hook: ExecutorHook, Callback: UpdateCallback<D>>( &mut self, node_id: CTreeNodeID, hook: &mut Hook, cb: &mut Callback, ) -> Status

Source

pub fn reset_branch(&mut self, from: CTreeNodeID)

Source

pub fn new() -> Self

Source

pub fn as_subtree(&self, start_at: CTreeNodeID) -> Self

Extract a section of the ControlTree into a new one.

Source

pub fn insert_between( &mut self, parent_id: CTreeNodeID, move_down: &[CTreeNodeID], node: impl Into<CTreeNode<D>>, ) -> CTreeNodeID

Insert node between parent and move_down.

The inserted node with be the n’th child, where n is the index of the first child node in move_down. i.e. left->right order is maintained if move_down is contiguous with the original children.

§Examples
insert_between(0, &[2], X)
        0                                  0
      / | \            ------>           / | \
     1  2  3                            1  X  3
                                           |
                                           2
insert_between(0, &[1, 3], X)
        0                                 0
      / | \            ------>           / \
     1  2  3                            X   2
                                       / \
                                      1   3
Source

pub fn iter_children_mut<'a, O>( &'a mut self, node_id: &CTreeNodeID, f: impl FnMut(&mut CTreeNode<D>) -> O + 'a, ) -> impl Iterator<Item = O> + '_

Source

pub fn node_mut(&mut self, id: CTreeNodeID) -> &mut CTreeNode<D>

Source

pub fn children(&self, node_id: &CTreeNodeID) -> Vec<CTreeNodeID>

Source

pub fn iter_children( &self, node_id: &CTreeNodeID, ) -> impl Iterator<Item = &CTreeNode<D>> + '_

Source

pub fn iter_child_ids( &self, node_id: &CTreeNodeID, ) -> impl Iterator<Item = &CTreeNodeID> + '_

Source§

impl<D: Decorator + GraphvizAttrs> ControlTree<D>

Source

pub fn run_save_animation( &mut self, hook: &mut impl ExecutorHook, name: &str, frame_time: f32, ) -> Status

Runs the control tree and saves the animation to `out/[name].html

XXX: This writes a new svg for every frame, kinda scuffed & not good for performance so only use for debugging

Source

pub fn run_with_animatior<Hook: ExecutorHook>( &mut self, hook: &mut Hook, ) -> GraphvizAnimator

Source

pub fn save_dot(&self, name: &str)

Saves the control tree to out/[name].dot.

Source

pub fn graphviz_graph(&self) -> Graph

Get the [graphviz_rust::Graph] representation of the control tree in its current state.

Trait Implementations§

Source§

impl<D: Clone + Decorator> Clone for ControlTree<D>

Source§

fn clone(&self) -> ControlTree<D>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + Decorator> Debug for ControlTree<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: Decorator> Default for ControlTree<D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<D: Decorator> From<ControlTree<D>> for CTreeBuilder<D>

Source§

fn from(value: ControlTree<D>) -> Self

Converts to this type from the input type.
Source§

impl<D: Decorator> Index<CTreeNodeID> for ControlTree<D>

Source§

type Output = CTreeNode<D>

The returned type after indexing.
Source§

fn index(&self, index: CTreeNodeID) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<D: Decorator> IndexMut<CTreeNodeID> for ControlTree<D>

Source§

fn index_mut(&mut self, index: CTreeNodeID) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<D> Freeze for ControlTree<D>

§

impl<D> RefUnwindSafe for ControlTree<D>
where D: RefUnwindSafe,

§

impl<D> Send for ControlTree<D>
where D: Send,

§

impl<D> Sync for ControlTree<D>
where D: Sync,

§

impl<D> Unpin for ControlTree<D>
where D: Unpin,

§

impl<D> UnwindSafe for ControlTree<D>
where D: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Blackboard for T
where T: Default + Clone + Debug,