@@ -2,11 +2,11 @@ use crate::{
2
2
app:: { App , AppExit } ,
3
3
event:: Events ,
4
4
plugin:: Plugin ,
5
- stage , startup_stage , PluginGroup , PluginGroupBuilder ,
5
+ CoreStage , PluginGroup , PluginGroupBuilder , StartupStage ,
6
6
} ;
7
7
use bevy_ecs:: {
8
8
clear_trackers_system, FromResources , IntoExclusiveSystem , IntoSystem , Resource , Resources ,
9
- RunOnce , Schedule , Stage , StateStage , SystemDescriptor , SystemStage , World ,
9
+ RunOnce , Schedule , Stage , StageLabel , StateStage , SystemDescriptor , SystemStage , World ,
10
10
} ;
11
11
use bevy_utils:: tracing:: debug;
12
12
@@ -24,7 +24,7 @@ impl Default for AppBuilder {
24
24
app_builder
25
25
. add_default_stages ( )
26
26
. add_event :: < AppExit > ( )
27
- . add_system_to_stage ( stage :: LAST , clear_trackers_system. exclusive_system ( ) ) ;
27
+ . add_system_to_stage ( CoreStage :: Last , clear_trackers_system. exclusive_system ( ) ) ;
28
28
app_builder
29
29
}
30
30
}
@@ -54,110 +54,110 @@ impl AppBuilder {
54
54
self
55
55
}
56
56
57
- pub fn add_stage < S : Stage > ( & mut self , name : & ' static str , stage : S ) -> & mut Self {
58
- self . app . schedule . add_stage ( name , stage) ;
57
+ pub fn add_stage < S : Stage > ( & mut self , label : impl StageLabel , stage : S ) -> & mut Self {
58
+ self . app . schedule . add_stage ( label , stage) ;
59
59
self
60
60
}
61
61
62
62
pub fn add_stage_after < S : Stage > (
63
63
& mut self ,
64
- target : & ' static str ,
65
- name : & ' static str ,
64
+ target : impl StageLabel ,
65
+ label : impl StageLabel ,
66
66
stage : S ,
67
67
) -> & mut Self {
68
- self . app . schedule . add_stage_after ( target, name , stage) ;
68
+ self . app . schedule . add_stage_after ( target, label , stage) ;
69
69
self
70
70
}
71
71
72
72
pub fn add_stage_before < S : Stage > (
73
73
& mut self ,
74
- target : & ' static str ,
75
- name : & ' static str ,
74
+ target : impl StageLabel ,
75
+ label : impl StageLabel ,
76
76
stage : S ,
77
77
) -> & mut Self {
78
- self . app . schedule . add_stage_before ( target, name , stage) ;
78
+ self . app . schedule . add_stage_before ( target, label , stage) ;
79
79
self
80
80
}
81
81
82
- pub fn add_startup_stage < S : Stage > ( & mut self , name : & ' static str , stage : S ) -> & mut Self {
82
+ pub fn add_startup_stage < S : Stage > ( & mut self , label : impl StageLabel , stage : S ) -> & mut Self {
83
83
self . app
84
84
. schedule
85
- . stage ( stage :: STARTUP , |schedule : & mut Schedule | {
86
- schedule. add_stage ( name , stage)
85
+ . stage ( CoreStage :: Startup , |schedule : & mut Schedule | {
86
+ schedule. add_stage ( label , stage)
87
87
} ) ;
88
88
self
89
89
}
90
90
91
91
pub fn add_startup_stage_after < S : Stage > (
92
92
& mut self ,
93
- target : & ' static str ,
94
- name : & ' static str ,
93
+ target : impl StageLabel ,
94
+ label : impl StageLabel ,
95
95
stage : S ,
96
96
) -> & mut Self {
97
97
self . app
98
98
. schedule
99
- . stage ( stage :: STARTUP , |schedule : & mut Schedule | {
100
- schedule. add_stage_after ( target, name , stage)
99
+ . stage ( CoreStage :: Startup , |schedule : & mut Schedule | {
100
+ schedule. add_stage_after ( target, label , stage)
101
101
} ) ;
102
102
self
103
103
}
104
104
105
105
pub fn add_startup_stage_before < S : Stage > (
106
106
& mut self ,
107
- target : & ' static str ,
108
- name : & ' static str ,
107
+ target : impl StageLabel ,
108
+ label : impl StageLabel ,
109
109
stage : S ,
110
110
) -> & mut Self {
111
111
self . app
112
112
. schedule
113
- . stage ( stage :: STARTUP , |schedule : & mut Schedule | {
114
- schedule. add_stage_before ( target, name , stage)
113
+ . stage ( CoreStage :: Startup , |schedule : & mut Schedule | {
114
+ schedule. add_stage_before ( target, label , stage)
115
115
} ) ;
116
116
self
117
117
}
118
118
119
119
pub fn stage < T : Stage , F : FnOnce ( & mut T ) -> & mut T > (
120
120
& mut self ,
121
- name : & str ,
121
+ label : impl StageLabel ,
122
122
func : F ,
123
123
) -> & mut Self {
124
- self . app . schedule . stage ( name , func) ;
124
+ self . app . schedule . stage ( label , func) ;
125
125
self
126
126
}
127
127
128
128
pub fn add_system ( & mut self , system : impl Into < SystemDescriptor > ) -> & mut Self {
129
- self . add_system_to_stage ( stage :: UPDATE , system)
129
+ self . add_system_to_stage ( CoreStage :: Update , system)
130
130
}
131
131
132
132
pub fn add_system_to_stage (
133
133
& mut self ,
134
- stage_name : & ' static str ,
134
+ stage_label : impl StageLabel ,
135
135
system : impl Into < SystemDescriptor > ,
136
136
) -> & mut Self {
137
- self . app . schedule . add_system_to_stage ( stage_name , system) ;
137
+ self . app . schedule . add_system_to_stage ( stage_label , system) ;
138
138
self
139
139
}
140
140
141
141
pub fn add_startup_system ( & mut self , system : impl Into < SystemDescriptor > ) -> & mut Self {
142
- self . add_startup_system_to_stage ( startup_stage :: STARTUP , system)
142
+ self . add_startup_system_to_stage ( StartupStage :: Startup , system)
143
143
}
144
144
145
145
pub fn add_startup_system_to_stage (
146
146
& mut self ,
147
- stage_name : & ' static str ,
147
+ stage_label : impl StageLabel ,
148
148
system : impl Into < SystemDescriptor > ,
149
149
) -> & mut Self {
150
150
self . app
151
151
. schedule
152
- . stage ( stage :: STARTUP , |schedule : & mut Schedule | {
153
- schedule. add_system_to_stage ( stage_name , system)
152
+ . stage ( CoreStage :: Startup , |schedule : & mut Schedule | {
153
+ schedule. add_system_to_stage ( stage_label , system)
154
154
} ) ;
155
155
self
156
156
}
157
157
158
158
pub fn on_state_enter < T : Clone + Resource > (
159
159
& mut self ,
160
- stage : & str ,
160
+ stage : impl StageLabel ,
161
161
state : T ,
162
162
system : impl Into < SystemDescriptor > ,
163
163
) -> & mut Self {
@@ -168,7 +168,7 @@ impl AppBuilder {
168
168
169
169
pub fn on_state_update < T : Clone + Resource > (
170
170
& mut self ,
171
- stage : & str ,
171
+ stage : impl StageLabel ,
172
172
state : T ,
173
173
system : impl Into < SystemDescriptor > ,
174
174
) -> & mut Self {
@@ -179,7 +179,7 @@ impl AppBuilder {
179
179
180
180
pub fn on_state_exit < T : Clone + Resource > (
181
181
& mut self ,
182
- stage : & str ,
182
+ stage : impl StageLabel ,
183
183
state : T ,
184
184
system : impl Into < SystemDescriptor > ,
185
185
) -> & mut Self {
@@ -190,28 +190,28 @@ impl AppBuilder {
190
190
191
191
pub fn add_default_stages ( & mut self ) -> & mut Self {
192
192
self . add_stage (
193
- stage :: STARTUP ,
193
+ CoreStage :: Startup ,
194
194
Schedule :: default ( )
195
195
. with_run_criteria ( RunOnce :: default ( ) )
196
- . with_stage ( startup_stage :: PRE_STARTUP , SystemStage :: parallel ( ) )
197
- . with_stage ( startup_stage :: STARTUP , SystemStage :: parallel ( ) )
198
- . with_stage ( startup_stage :: POST_STARTUP , SystemStage :: parallel ( ) ) ,
196
+ . with_stage ( StartupStage :: PreStartup , SystemStage :: parallel ( ) )
197
+ . with_stage ( StartupStage :: Startup , SystemStage :: parallel ( ) )
198
+ . with_stage ( StartupStage :: PostStartup , SystemStage :: parallel ( ) ) ,
199
199
)
200
- . add_stage ( stage :: FIRST , SystemStage :: parallel ( ) )
201
- . add_stage ( stage :: PRE_EVENT , SystemStage :: parallel ( ) )
202
- . add_stage ( stage :: EVENT , SystemStage :: parallel ( ) )
203
- . add_stage ( stage :: PRE_UPDATE , SystemStage :: parallel ( ) )
204
- . add_stage ( stage :: UPDATE , SystemStage :: parallel ( ) )
205
- . add_stage ( stage :: POST_UPDATE , SystemStage :: parallel ( ) )
206
- . add_stage ( stage :: LAST , SystemStage :: parallel ( ) )
200
+ . add_stage ( CoreStage :: First , SystemStage :: parallel ( ) )
201
+ . add_stage ( CoreStage :: PreEvent , SystemStage :: parallel ( ) )
202
+ . add_stage ( CoreStage :: Event , SystemStage :: parallel ( ) )
203
+ . add_stage ( CoreStage :: PreUpdate , SystemStage :: parallel ( ) )
204
+ . add_stage ( CoreStage :: Update , SystemStage :: parallel ( ) )
205
+ . add_stage ( CoreStage :: PostUpdate , SystemStage :: parallel ( ) )
206
+ . add_stage ( CoreStage :: Last , SystemStage :: parallel ( ) )
207
207
}
208
208
209
209
pub fn add_event < T > ( & mut self ) -> & mut Self
210
210
where
211
211
T : Send + Sync + ' static ,
212
212
{
213
213
self . insert_resource ( Events :: < T > :: default ( ) )
214
- . add_system_to_stage ( stage :: EVENT , Events :: < T > :: update_system. system ( ) )
214
+ . add_system_to_stage ( CoreStage :: Event , Events :: < T > :: update_system. system ( ) )
215
215
}
216
216
217
217
/// Inserts a resource to the current [App] and overwrites any resource previously added of the same type.
0 commit comments