diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 0ad7f0591744c..ba7f51b4addc1 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -692,7 +692,7 @@ pub mod common_conditions { /// assert_eq!(world.resource::().0, 0); /// ``` pub fn in_state(state: S) -> impl FnMut(Res>) -> bool + Clone { - move |current_state: Res>| current_state.0 == state + move |current_state: Res>| *current_state.get() == state } /// Generates a [`Condition`](super::Condition)-satisfying closure that returns `true` @@ -751,7 +751,7 @@ pub mod common_conditions { state: S, ) -> impl FnMut(Option>>) -> bool + Clone { move |current_state: Option>>| match current_state { - Some(current_state) => current_state.0 == state, + Some(current_state) => *current_state.get() == state, None => false, } } diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index 21195112caf4c..e9c349d592de4 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -85,9 +85,9 @@ pub struct OnUpdate(pub S); #[derive(Resource, Default, Debug)] pub struct State(S); -impl std::ops::Deref for State { - type Target = S; - fn deref(&self) -> &Self::Target { +impl State { + /// Get the current state. + pub fn get(&self) -> &S { &self.0 } }