@@ -10,7 +10,7 @@ use bevy_ecs::{
10
10
} ;
11
11
use bevy_platform:: collections:: HashMap ;
12
12
13
- use crate :: state:: { FreelyMutableState , OnExit , StateTransitionEvent } ;
13
+ use crate :: state:: { OnExit , StateTransitionEvent , States } ;
14
14
15
15
fn clear_event_queue < E : Event > ( w : & mut World ) {
16
16
if let Some ( mut queue) = w. get_resource_mut :: < Events < E > > ( ) {
@@ -19,11 +19,11 @@ fn clear_event_queue<E: Event>(w: &mut World) {
19
19
}
20
20
21
21
#[ derive( Resource ) ]
22
- struct StateScopedEvents < S : FreelyMutableState > {
22
+ struct StateScopedEvents < S : States > {
23
23
cleanup_fns : HashMap < S , Vec < fn ( & mut World ) > > ,
24
24
}
25
25
26
- impl < S : FreelyMutableState > StateScopedEvents < S > {
26
+ impl < S : States > StateScopedEvents < S > {
27
27
fn add_event < E : Event > ( & mut self , state : S ) {
28
28
self . cleanup_fns
29
29
. entry ( state)
@@ -41,15 +41,15 @@ impl<S: FreelyMutableState> StateScopedEvents<S> {
41
41
}
42
42
}
43
43
44
- impl < S : FreelyMutableState > Default for StateScopedEvents < S > {
44
+ impl < S : States > Default for StateScopedEvents < S > {
45
45
fn default ( ) -> Self {
46
46
Self {
47
47
cleanup_fns : HashMap :: default ( ) ,
48
48
}
49
49
}
50
50
}
51
51
52
- fn cleanup_state_scoped_event < S : FreelyMutableState > (
52
+ fn cleanup_state_scoped_event < S : States > (
53
53
mut c : Commands ,
54
54
mut transitions : EventReader < StateTransitionEvent < S > > ,
55
55
) {
@@ -70,7 +70,7 @@ fn cleanup_state_scoped_event<S: FreelyMutableState>(
70
70
} ) ;
71
71
}
72
72
73
- fn add_state_scoped_event_impl < E : Event , S : FreelyMutableState > (
73
+ fn add_state_scoped_event_impl < E : Event , S : States > (
74
74
app : & mut SubApp ,
75
75
_p : PhantomData < E > ,
76
76
state : S ,
@@ -94,18 +94,18 @@ pub trait StateScopedEventsAppExt {
94
94
/// cleanup and the [`OnExit`] schedule for the target state. All of these (state scoped
95
95
/// entities and events cleanup, and `OnExit`) occur within schedule [`StateTransition`](crate::prelude::StateTransition)
96
96
/// and system set `StateTransitionSystems::ExitSchedules`.
97
- fn add_state_scoped_event < E : Event > ( & mut self , state : impl FreelyMutableState ) -> & mut Self ;
97
+ fn add_state_scoped_event < E : Event > ( & mut self , state : impl States ) -> & mut Self ;
98
98
}
99
99
100
100
impl StateScopedEventsAppExt for App {
101
- fn add_state_scoped_event < E : Event > ( & mut self , state : impl FreelyMutableState ) -> & mut Self {
101
+ fn add_state_scoped_event < E : Event > ( & mut self , state : impl States ) -> & mut Self {
102
102
add_state_scoped_event_impl ( self . main_mut ( ) , PhantomData :: < E > , state) ;
103
103
self
104
104
}
105
105
}
106
106
107
107
impl StateScopedEventsAppExt for SubApp {
108
- fn add_state_scoped_event < E : Event > ( & mut self , state : impl FreelyMutableState ) -> & mut Self {
108
+ fn add_state_scoped_event < E : Event > ( & mut self , state : impl States ) -> & mut Self {
109
109
add_state_scoped_event_impl ( self , PhantomData :: < E > , state) ;
110
110
self
111
111
}
0 commit comments