mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
remove inaccurate warning from in_state
(#13862)
# Objective Fixes #13854 ## Solution Removed the inaccurate warning. This was done for a few reasons: - States not existing is now a valid "state" (for lack of a better term) - Other run conditions don't provide an equivalent warning
This commit is contained in:
parent
03f63e72cf
commit
1c838ff6b3
1 changed files with 2 additions and 15 deletions
|
@ -1,7 +1,5 @@
|
||||||
use bevy_ecs::{change_detection::DetectChanges, system::Res};
|
|
||||||
use bevy_utils::warn_once;
|
|
||||||
|
|
||||||
use crate::state::{State, States};
|
use crate::state::{State, States};
|
||||||
|
use bevy_ecs::{change_detection::DetectChanges, system::Res};
|
||||||
|
|
||||||
/// A [`Condition`](bevy_ecs::prelude::Condition)-satisfying system that returns `true`
|
/// A [`Condition`](bevy_ecs::prelude::Condition)-satisfying system that returns `true`
|
||||||
/// if the state machine exists.
|
/// if the state machine exists.
|
||||||
|
@ -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 {
|
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 {
|
move |current_state: Option<Res<State<S>>>| match current_state {
|
||||||
Some(current_state) => *current_state == state,
|
Some(current_state) => *current_state == state,
|
||||||
None => {
|
None => false,
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue