Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add with_enter_stage (and other variants) #1091

Merged
merged 1 commit into from
Dec 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/bevy_ecs/src/schedule/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ impl<T> Default for StateStage<T> {

#[allow(clippy::mem_discriminant_non_enum)]
impl<T> StateStage<T> {
pub fn with_enter_stage<S: Stage>(mut self, state: T, stage: S) -> Self {
self.set_enter_stage(state, stage);
self
}

pub fn with_exit_stage<S: Stage>(mut self, state: T, stage: S) -> Self {
self.set_exit_stage(state, stage);
self
}

pub fn with_update_stage<S: Stage>(mut self, state: T, stage: S) -> Self {
self.set_update_stage(state, stage);
self
}

pub fn set_enter_stage<S: Stage>(&mut self, state: T, stage: S) -> &mut Self {
let stages = self.state_stages(state);
stages.enter = Box::new(stage);
Expand Down