pub struct BehaviorMutItem<'__w, '__s, T: Behavior> { /* private fields */ }Expand description
Automatically generated WorldQuery item type for BehaviorMut, returned when iterating over query results.
Implementations§
Source§impl<T: Behavior> BehaviorMutItem<'_, '_, T>
impl<T: Behavior> BehaviorMutItem<'_, '_, T>
Sourcepub fn current_mut(&mut self) -> &mut T
pub fn current_mut(&mut self) -> &mut T
Returns the current Behavior state as a mutable.
Sourcepub fn previous_mut(&mut self) -> Option<&mut T>
pub fn previous_mut(&mut self) -> Option<&mut T>
Returns the previous Behavior state as a mutable.
See BehaviorRefItem::previous for more details.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> + '_
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> + '_
Returns a mutable iterator over all Behavior states in the stack, including the current one.
See BehaviorRefItem::iter for more details.
Sourcepub fn enumerate_mut(
&mut self,
) -> impl Iterator<Item = (BehaviorIndex, &mut T)> + '_
pub fn enumerate_mut( &mut self, ) -> impl Iterator<Item = (BehaviorIndex, &mut T)> + '_
Returns a mutable iterator over all (BehaviorIndex, Behavior) pairs in the stack, including the current one.
See BehaviorRefItem::enumerate for more details.
Sourcepub fn start(&mut self, next: T)
pub fn start(&mut self, next: T)
Starts the given next behavior.
This operation pushes the current behavior onto the stack and inserts the new behavior.
Note that this will fail if the current behavior rejects next through Behavior::filter_next.
See Error for details on how to handle transition failures.
Sourcepub fn try_start(&mut self, next: T) -> Result<(), T>
pub fn try_start(&mut self, next: T) -> Result<(), T>
Attempts to start the given next behavior if there are no pending transitions and the
current behavior allows it.
Note that it’s still possible for the transition to fail if the current behavior mutates
in such a way as to no longer allow the transition between the time this function is called
and when the transition system runs.
Do NOT use this method to react to transition failures.
See Error for details on how to correctly handle transition failures.
§Usage
This is similar to start but will return an error containing
the given next behavior if it fails.
This is useful for fire-and-forget transitions where you don’t want to override a pending transition or may expect a transition failure.
If multiple systems call this method before transition, only the first one will succeed.
Sourcepub fn interrupt_start(&mut self, next: T)
pub fn interrupt_start(&mut self, next: T)
Interrupts the current behavior and starts the given next behavior.
This operation stops all behaviors which yield to the new behavior and pushes it onto the stack.
See Behavior::filter_yield for details on how to define how states yield to each other.
This also removes any remaining [TransitionSequence] steps.
The initial behavior is never allowed to yield.
Note that this will fail if the first non-yielding behavior rejects next through Behavior::filter_next.
See Error for details on how to handle transition failures.
Sourcepub fn try_interrupt_start(&mut self, next: T) -> Result<(), T>
pub fn try_interrupt_start(&mut self, next: T) -> Result<(), T>
Attempts to interrupt the current behavior and start the given next behavior.
This is similar to interrupt_start but will fail if there is a pending transition.
Sourcepub fn interrupt_stop(&mut self, index: BehaviorIndex)
pub fn interrupt_stop(&mut self, index: BehaviorIndex)
Stops all behaviors above and including the given BehaviorIndex.
This also removes any remaining [TransitionSequence] steps.
The initial behavior is never allowed to yield.
Sourcepub fn try_interrupt_stop(
&mut self,
index: BehaviorIndex,
) -> Result<(), BehaviorIndex>
pub fn try_interrupt_stop( &mut self, index: BehaviorIndex, ) -> Result<(), BehaviorIndex>
Attempts to stop all behaviors above and including the given BehaviorIndex.
This is similar to interrupt_stop but will fail if:
- There is a pending transition
- The given
indexis the initial behavior - The given
indexis not in the stack
Sourcepub fn interrupt_resume(&mut self, index: BehaviorIndex)
pub fn interrupt_resume(&mut self, index: BehaviorIndex)
Stops all behaviors above the given BehaviorIndex and resume the behavior at that index.
This also removes any remaining [TransitionSequence] steps.
Sourcepub fn try_interrupt_resume(
&mut self,
index: BehaviorIndex,
) -> Result<(), BehaviorIndex>
pub fn try_interrupt_resume( &mut self, index: BehaviorIndex, ) -> Result<(), BehaviorIndex>
Attempts to stop all behaviors above the given BehaviorIndex and resume the behavior at that index.
This is similar to interrupt_resume but will fail if:
- There is a pending transition
- The given
indexis not in the stack
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stops the current behavior.
This operation pops the current behavior off the stack and resumes the previous behavior.
Note that this will fail if the current behavior is the initial behavior.
See Error for details on how to handle transition failures.
Sourcepub fn try_stop(&mut self) -> bool
pub fn try_stop(&mut self) -> bool
Attempts to stop the current behavior.
This is similar to stop but will fail if:
- There is a pending transition
- The current behavior is the initial behavior
Trait Implementations§
Source§impl<T: Behavior> AsMut<T> for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> AsMut<T> for BehaviorMutItem<'_, '_, T>
Source§impl<T: Behavior> AsRef<T> for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> AsRef<T> for BehaviorMutItem<'_, '_, T>
Source§impl<T: Behavior> BehaviorItem for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> BehaviorItem for BehaviorMutItem<'_, '_, T>
Source§fn current_index(&self) -> BehaviorIndex
fn current_index(&self) -> BehaviorIndex
BehaviorIndex associated with the current Behavior state.Source§fn enumerate(
&self,
) -> impl Iterator<Item = (BehaviorIndex, &Self::Behavior)> + '_
fn enumerate( &self, ) -> impl Iterator<Item = (BehaviorIndex, &Self::Behavior)> + '_
BehaviorIndex, Behavior) pairs in the stack, including the current one. Read moreSource§fn get(&self, BehaviorIndex: BehaviorIndex) -> Option<&T>
fn get(&self, BehaviorIndex: BehaviorIndex) -> Option<&T>
Behavior at the given BehaviorIndex, if it exists.Source§fn has_transition(&self) -> bool
fn has_transition(&self) -> bool
Source§fn index(&self) -> BehaviorIndex
fn index(&self) -> BehaviorIndex
current_index insteadBehaviorIndex associated with the current Behavior state.Source§fn has_index(&self, index: BehaviorIndex) -> bool
fn has_index(&self, index: BehaviorIndex) -> bool
Source§impl<T: Behavior> Deref for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> Deref for BehaviorMutItem<'_, '_, T>
Source§impl<T: Behavior> DerefMut for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> DerefMut for BehaviorMutItem<'_, '_, T>
Source§impl<T: Behavior> DetectChanges for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> DetectChanges for BehaviorMutItem<'_, '_, T>
Source§fn is_changed(&self) -> bool
fn is_changed(&self) -> bool
true if this value was added or mutably dereferenced
either since the last time the system ran or, if the system never ran,
since the beginning of the program. Read moreSource§fn last_changed(&self) -> Tick
fn last_changed(&self) -> Tick
Source§fn changed_by(&self) -> MaybeLocation
fn changed_by(&self) -> MaybeLocation
Source§impl<T: Behavior> DetectChangesMut for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> DetectChangesMut for BehaviorMutItem<'_, '_, T>
Source§fn set_changed(&mut self)
fn set_changed(&mut self)
Source§fn set_last_changed(&mut self, last_changed: Tick)
fn set_last_changed(&mut self, last_changed: Tick)
Source§fn bypass_change_detection(&mut self) -> &mut Self::Inner
fn bypass_change_detection(&mut self) -> &mut Self::Inner
Source§fn set_last_added(&mut self, last_added: Tick)
fn set_last_added(&mut self, last_added: Tick)
Source§fn set_if_neq(&mut self, value: Self::Inner) -> bool
fn set_if_neq(&mut self, value: Self::Inner) -> bool
*self != value.
Returns true if the value was overwritten, and returns false if it was not. Read moreSource§fn replace_if_neq(&mut self, value: Self::Inner) -> Option<Self::Inner>
fn replace_if_neq(&mut self, value: Self::Inner) -> Option<Self::Inner>
*self != value,
returning the previous value if this occurs. Read moreSource§impl<T: Behavior> Index<BehaviorIndex> for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> Index<BehaviorIndex> for BehaviorMutItem<'_, '_, T>
Source§impl<T: Behavior> IndexMut<BehaviorIndex> for BehaviorMutItem<'_, '_, T>
impl<T: Behavior> IndexMut<BehaviorIndex> for BehaviorMutItem<'_, '_, T>
Auto Trait Implementations§
impl<'__w, '__s, T> Freeze for BehaviorMutItem<'__w, '__s, T>
impl<'__w, '__s, T> RefUnwindSafe for BehaviorMutItem<'__w, '__s, T>where
T: RefUnwindSafe,
impl<'__w, '__s, T> Send for BehaviorMutItem<'__w, '__s, T>
impl<'__w, '__s, T> Sync for BehaviorMutItem<'__w, '__s, T>
impl<'__w, '__s, T> Unpin for BehaviorMutItem<'__w, '__s, T>
impl<'__w, '__s, T> !UnwindSafe for BehaviorMutItem<'__w, '__s, T>
Blanket Implementations§
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.