Struct BehaviorMutItem

Source
pub struct BehaviorMutItem<'__w, 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>

Source

pub fn current(&self) -> &T

Returns the current Behavior state.

Source

pub fn current_mut(&mut self) -> &mut T

Returns the current Behavior state as a mutable.

Source

pub fn previous(&self) -> Option<&T>

Source

pub fn previous_mut(&mut self) -> Option<&mut T>

Returns the previous Behavior state as a mutable.

See BehaviorRefItem::previous for more details.

Source

pub fn iter(&self) -> impl Iterator<Item = &T> + '_

Source

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.

Source

pub fn index(&self) -> BehaviorIndex

Source

pub fn has_index(&self, index: BehaviorIndex) -> bool

Source

pub fn has_transition(&self) -> bool

Source

pub fn has_sequence(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 index is the initial behavior
  • The given index is not in the stack
Source

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.

Source

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 index is not in the stack
Source

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.

Source

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
Source

pub fn reset(&mut self)

Stops the current and all previous behaviors and resumes the initial behavior.

This operation clears the stack and resumes the initial behavior. It can never fail. If the stack is empty (i.e. initial behavior), it does nothing.

Source

pub fn try_reset(&mut self) -> bool

Attempts to reset the current behavior.

This is similar to reset but will fail if there is a pending transition.

Trait Implementations§

Source§

impl<T: Behavior> AsMut<T> for BehaviorMutItem<'_, T>

Source§

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

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T: Behavior> AsRef<T> for BehaviorMutItem<'_, T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Behavior> Deref for BehaviorMutItem<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: Behavior> DerefMut for BehaviorMutItem<'_, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: Behavior> DetectChanges for BehaviorMutItem<'_, T>

Source§

fn is_added(&self) -> bool

Returns true if this value was added after the system last ran.
Source§

fn is_changed(&self) -> bool

Returns 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 more
Source§

fn last_changed(&self) -> Tick

Returns the change tick recording the time this data was most recently changed. Read more
Source§

fn added(&self) -> Tick

Returns the change tick recording the time this data was added.
Source§

fn changed_by(&self) -> MaybeLocation

The location that last caused this to change.
Source§

impl<T: Behavior> DetectChangesMut for BehaviorMutItem<'_, T>

Source§

type Inner = T

The type contained within this smart pointer Read more
Source§

fn set_changed(&mut self)

Flags this value as having been changed. Read more
Source§

fn set_last_changed(&mut self, last_changed: Tick)

Manually sets the change tick recording the time when this data was last mutated. Read more
Source§

fn bypass_change_detection(&mut self) -> &mut Self::Inner

Manually bypasses change detection, allowing you to mutate the underlying value without updating the change tick. Read more
Source§

fn set_added(&mut self)

Flags this value as having been added. Read more
Source§

fn set_last_added(&mut self, last_added: Tick)

Manually sets the added tick recording the time when this data was last added. Read more
Source§

fn set_if_neq(&mut self, value: Self::Inner) -> bool
where Self::Inner: Sized + PartialEq,

Overwrites this smart pointer with the given value, if and only if *self != value. Returns true if the value was overwritten, and returns false if it was not. Read more
Source§

fn replace_if_neq(&mut self, value: Self::Inner) -> Option<Self::Inner>
where Self::Inner: Sized + PartialEq,

Overwrites this smart pointer with the given value, if and only if *self != value, returning the previous value if this occurs. Read more
Source§

fn clone_from_if_neq<T>(&mut self, value: &T) -> bool
where T: ToOwned<Owned = Self::Inner> + ?Sized, Self::Inner: PartialEq<T>,

Overwrites this smart pointer with a clone of the given value, if and only if *self != value. Returns true if the value was overwritten, and returns false if it was not. Read more
Source§

impl<T: Behavior> Index<BehaviorIndex> for BehaviorMutItem<'_, T>

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<T: Behavior> IndexMut<BehaviorIndex> for BehaviorMutItem<'_, T>

Source§

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

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

Auto Trait Implementations§

§

impl<'__w, T> Freeze for BehaviorMutItem<'__w, T>

§

impl<'__w, T> RefUnwindSafe for BehaviorMutItem<'__w, T>
where T: RefUnwindSafe,

§

impl<'__w, T> Send for BehaviorMutItem<'__w, T>

§

impl<'__w, T> Sync for BehaviorMutItem<'__w, T>

§

impl<'__w, T> Unpin for BehaviorMutItem<'__w, T>

§

impl<'__w, T> !UnwindSafe for BehaviorMutItem<'__w, T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,