AppExtStates

Trait AppExtStates 

Source
pub trait AppExtStates {
    // Required methods
    fn init_state<S>(&mut self) -> &mut Self
       where S: FreelyMutableState + FromWorld;
    fn insert_state<S>(&mut self, state: S) -> &mut Self
       where S: FreelyMutableState;
    fn add_computed_state<S>(&mut self) -> &mut Self
       where S: ComputedStates;
    fn add_sub_state<S>(&mut self) -> &mut Self
       where S: SubStates;
    fn register_type_state<S>(&mut self) -> &mut Self
       where S: States + FromReflect + GetTypeRegistration + Typed;
    fn register_type_mutable_state<S>(&mut self) -> &mut Self
       where S: FreelyMutableState + FromReflect + GetTypeRegistration + Typed;
}
Expand description

State installation methods for App and SubApp.

Required Methods§

Source

fn init_state<S>(&mut self) -> &mut Self

Initializes a State with standard starting values.

This method is idempotent: it has no effect when called again using the same generic type.

Adds State<S> and NextState<S> resources, and enables use of the OnEnter, OnTransition and OnExit schedules. These schedules are triggered before Update and at startup.

If you would like to control how other systems run based on the current state, you can emulate this behavior using the in_state SystemCondition.

Note that you can also apply state transitions at other points in the schedule by triggering the StateTransition schedule manually.

The use of any states requires the presence of StatesPlugin (which is included in DefaultPlugins).

Source

fn insert_state<S>(&mut self, state: S) -> &mut Self

Inserts a specific State to the current App and overrides any State previously added of the same type.

Adds State<S> and NextState<S> resources, and enables use of the OnEnter, OnTransition and OnExit schedules. These schedules are triggered before Update and at startup.

If you would like to control how other systems run based on the current state, you can emulate this behavior using the in_state SystemCondition.

Note that you can also apply state transitions at other points in the schedule by triggering the StateTransition schedule manually.

Source

fn add_computed_state<S>(&mut self) -> &mut Self
where S: ComputedStates,

Sets up a type implementing ComputedStates.

This method is idempotent: it has no effect when called again using the same generic type.

Source

fn add_sub_state<S>(&mut self) -> &mut Self
where S: SubStates,

Sets up a type implementing SubStates.

This method is idempotent: it has no effect when called again using the same generic type.

Source

fn register_type_state<S>(&mut self) -> &mut Self

Registers the state type T using App::register_type, and adds ReflectState type data to T in the type registry.

This enables reflection code to access the state. For detailed information, see the docs on crate::reflect::ReflectState .

Source

fn register_type_mutable_state<S>(&mut self) -> &mut Self

Registers the state type T using App::register_type, and adds crate::reflect::ReflectState and crate::reflect::ReflectFreelyMutableState type data to T in the type registry.

This enables reflection code to access and modify the state. For detailed information, see the docs on crate::reflect::ReflectState and crate::reflect::ReflectFreelyMutableState.

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§