Skip to content

Commit

Permalink
reduce api exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Dec 30, 2021
1 parent 4a503b2 commit d1f37cd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions crates/bevy_ecs/src/schedule/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum ScheduledOperationType<T: StateData> {
}

#[derive(Debug)]
pub enum Next {
enum Next {
NextFrame,
SameFrame,
}
Expand Down Expand Up @@ -95,10 +95,10 @@ impl<'a, T> StateTransitionConfig<'a, T>
where
T: StateData,
{
/// Controls where the transition will land, by default in the same frame.
pub fn next(self, next: Next) -> Self {
self.state.scheduled.as_mut().unwrap().next = next;
self
/// Stop reevaluating [`RunCriteria`](crate::schedule::RunCriteria) for this [`State`]
/// for this frame.
pub fn end_frame(self) {
self.state.scheduled.as_mut().unwrap().next = Next::NextFrame;
}
}

Expand Down Expand Up @@ -312,14 +312,14 @@ where
///
/// ```rust
/// # use bevy_ecs::system::{IntoSystem, ResMut};
/// # use bevy_ecs::schedule::{Next, State};
/// # use bevy_ecs::schedule::State;
/// # #[derive(Clone, PartialEq, Eq, Debug, Hash)]
/// # enum AppState {
/// # Game,
/// # }
/// #
/// fn change_state(mut state: ResMut<State<AppState>>) {
/// state.set(AppState::Game).unwrap().next(Next::NextFrame);
/// state.set(AppState::Game).unwrap().end_frame();
/// }
/// # change_state.system();
/// ```
Expand Down Expand Up @@ -760,8 +760,8 @@ mod test {

fn change_state(mut state: ResMut<State<AppState>>) {
let _ = match state.current() {
AppState::State1 => state.set(AppState::State2).unwrap().next(Next::NextFrame),
AppState::State2 => state.set(AppState::State1).unwrap().next(Next::NextFrame),
AppState::State1 => state.set(AppState::State2).unwrap().end_frame(),
AppState::State2 => state.set(AppState::State1).unwrap().end_frame(),
};
}

Expand Down

0 comments on commit d1f37cd

Please sign in to comment.