Skip to main content

CommandsStatesExt

Trait CommandsStatesExt 

Source
pub trait CommandsStatesExt {
    // Required methods
    fn set_state<S>(&mut self, state: S)
       where S: FreelyMutableState;
    fn set_state_if_neq<S>(&mut self, state: S)
       where S: FreelyMutableState;
}
Expand description

Extension trait for Commands adding bevy_state helpers.

Required Methods§

Source

fn set_state<S>(&mut self, state: S)

Sets the next state the app should move to.

Internally this schedules a command that updates the NextState<S> resource with state.

Note that commands introduce sync points to the ECS schedule, so modifying NextState directly may be more efficient depending on your use-case.

Source

fn set_state_if_neq<S>(&mut self, state: S)

Sets the next state the app should move to, skipping any state transitions if the next state is the same as the current state.

Internally this schedules a command that updates the NextState<S> resource with state.

Note that commands introduce sync points to the ECS schedule, so modifying NextState directly may be more efficient depending on your use-case.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§