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

[Merged by Bors] - Rename state_equals condition to in_state #7677

Closed
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl App {
/// These systems sets only run if the [`State<S>`] resource matches their label.
///
/// If you would like to control how other systems run based on the current state,
/// you can emulate this behavior using the [`state_equals`] [`Condition`](bevy_ecs::schedule::Condition).
/// you can emulate this behavior using the [`in_state`] [`Condition`](bevy_ecs::schedule::Condition).
///
/// Note that you can also apply state transitions at other points in the schedule
/// by adding the [`apply_state_transition`] system manually.
Expand All @@ -342,7 +342,7 @@ impl App {
main_schedule.configure_set(
OnUpdate(variant.clone())
.in_base_set(CoreSet::Update)
.run_if(state_equals(variant))
.run_if(in_state(variant))
.after(apply_state_transition::<S>),
);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub mod common_conditions {
/// # Panics
///
/// The condition will panic if the resource does not exist.
pub fn state_equals<S: States>(state: S) -> impl FnMut(Res<State<S>>) -> bool {
pub fn in_state<S: States>(state: S) -> impl FnMut(Res<State<S>>) -> bool {
move |current_state: Res<State<S>>| current_state.0 == state
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct OnExit<S: States>(pub S);
/// A [`SystemSet`] that will run within `CoreSet::Update` when this state is active.
///
/// This set, when created via `App::add_state`, is configured with both a base set and a run condition.
/// If all you want is the run condition, use the [`state_equals`](crate::schedule::common_conditions::state_equals)
/// If all you want is the run condition, use the [`in_state`](crate::schedule::common_conditions::in_state)
/// [condition](super::Condition) directly.
#[derive(SystemSet, Clone, Debug, PartialEq, Eq, Hash)]
pub struct OnUpdate<S: States>(pub S);
Expand Down