Closed voxelias closed 3 years ago
This PR implements application states stack.
Developer can define rules on what states what systems should run. By default any system runs on any state.
States are identified by data types and can be structure with or without data:
struct MainState { name: String, } struct PauseState { name: String, handled: bool, }
This will add rule to enable system only when MainState is active
MainState
.with( System::from(camera::control) .with(State::on::<MainState>()) )
There could be more rules in fact:
.with( System::from(player::control) .with(State::on::<MainState>()) .with(State::on::<InventoryState>()) )
It is also possible to enable on all but some states:
.with( System::from(ui_main) .with(State::off::<PauseState>()) )
There is a new service State that implements API to control the state of application:
State
fn startup( mut state: Mut<State>, ) { // Push main state state.push(MainState { name: String::from("Main state") }); }
When you need, you can return to previous state:
fn system_where_you_pop_the_state ( mut state: Mut<State>, ) { .... if exit_state { state.pop_any(); } }
This PR implements application states stack.
Developer can define rules on what states what systems should run. By default any system runs on any state.
States are identified by data types and can be structure with or without data:
This will add rule to enable system only when
MainState
is activeThere could be more rules in fact:
It is also possible to enable on all but some states:
There is a new service
State
that implements API to control the state of application:When you need, you can return to previous state: