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

remove inaccurate warning from in_state #13862

Merged
merged 3 commits into from
Jun 16, 2024
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
17 changes: 2 additions & 15 deletions crates/bevy_state/src/condition.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use bevy_ecs::{change_detection::DetectChanges, system::Res};
use bevy_utils::warn_once;

use crate::state::{State, States};
use bevy_ecs::{change_detection::DetectChanges, system::Res};

/// A [`Condition`](bevy_ecs::prelude::Condition)-satisfying system that returns `true`
/// if the state machine exists.
Expand Down Expand Up @@ -99,18 +97,7 @@ pub fn state_exists<S: States>(current_state: Option<Res<State<S>>>) -> bool {
pub fn in_state<S: States>(state: S) -> impl FnMut(Option<Res<State<S>>>) -> bool + Clone {
move |current_state: Option<Res<State<S>>>| match current_state {
Some(current_state) => *current_state == state,
None => {
warn_once!("No state matching the type for {} exists - did you forget to `init_state` when initializing the app?", {
let debug_state = format!("{state:?}");
let result = debug_state
.split("::")
.next()
.unwrap_or("Unknown State Type");
result.to_string()
});

false
}
None => false,
}
}

Expand Down