pub struct ConditionNode { /* private fields */ }Expand description
Single-child decorator that gates its child on a ConditionKind predicate: it evaluates the
predicate FIRST and only ticks the child (forwarding the child’s status unchanged) while the
predicate holds; when the predicate is false it reports Failure WITHOUT ticking the child at
all.
Dropping several of these into a SelectOrNode gives capability- or state-gated branch
selection out of a small, reusable building block: SelectOrNode already advances past any
child that returns Failure, so a false condition naturally falls through to the next option
without ever running its subtree. A smaller, more composable primitive than a bespoke
branch-on-capability composite node, and it fits the existing decorator pattern
(InverterNode/ForceSuccessNode/ForceFailureNode).
Implementations§
Source§impl ConditionNode
impl ConditionNode
Sourcepub fn new(condition: ConditionKind, child: BoxedBehavior) -> Self
pub fn new(condition: ConditionKind, child: BoxedBehavior) -> Self
Create a new condition node gating child on condition.
Trait Implementations§
Source§impl BehaviorNode for ConditionNode
impl BehaviorNode for ConditionNode
Source§fn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
NodeStatus.Source§fn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode>
fn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode>
Source§fn active_capability(&self) -> Option<&str>
fn active_capability(&self) -> Option<&str>
capability this node implies should be published on /behavior/status while it’s
actively being ticked; None for nodes with no such gate (the default). Composite nodes
override this to forward whichever child is currently active.Source§fn status_snapshot(&self) -> TreeStatusSnapshot
fn status_snapshot(&self) -> TreeStatusSnapshot
tick(), for live behavior-tree visualization. The default implementation reports
status: None (as if never ticked) and no children - correct for a brand-new node type
that hasn’t been wired up for status tracking yet, but every node type should override
this once it stores a last_status field: leaf nodes return their own last_status,
composite nodes additionally recurse into children_mut’s non-mut counterpart (there’s
no shared non-mut child accessor, so each composite overrides this to walk its own child
collection directly - same pattern as children_mut).Source§fn reset_self(&mut self)
fn reset_self(&mut self)
Source§fn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for ConditionNode
impl !UnwindSafe for ConditionNode
impl Freeze for ConditionNode
impl Send for ConditionNode
impl Sync for ConditionNode
impl Unpin for ConditionNode
impl UnsafeUnpin for ConditionNode
Blanket Implementations§
Source§impl<T> BehaviorNodeExt for Twhere
T: BehaviorNode + ?Sized,
impl<T> BehaviorNodeExt for Twhere
T: BehaviorNode + ?Sized,
Source§fn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more