@@ -105,6 +105,7 @@ impl ExclusiveSystem for ExclusiveSystemCoerced {
105
105
106
106
fn run ( & mut self , world : & mut World , resources : & mut Resources ) {
107
107
self . system . run ( ( ) , world, resources) ;
108
+ self . system . apply_buffers ( world, resources) ;
108
109
}
109
110
110
111
fn initialize ( & mut self , world : & mut World , resources : & mut Resources ) {
@@ -123,3 +124,38 @@ where
123
124
}
124
125
}
125
126
}
127
+
128
+ #[ test]
129
+ fn parallel_with_commands_as_exclusive ( ) {
130
+ use crate :: {
131
+ Commands , Entity , IntoExclusiveSystem , IntoSystem , ResMut , Resources , Stage , SystemStage ,
132
+ With , World ,
133
+ } ;
134
+ let mut world = World :: new ( ) ;
135
+ let mut resources = Resources :: default ( ) ;
136
+
137
+ fn removal (
138
+ commands : & mut Commands ,
139
+ query : Query < Entity , With < f32 > > ,
140
+ mut counter : ResMut < usize > ,
141
+ ) {
142
+ for entity in query. iter ( ) {
143
+ * counter += 1 ;
144
+ commands. remove_one :: < f32 > ( entity) ;
145
+ }
146
+ }
147
+
148
+ let mut stage = SystemStage :: parallel ( ) . with_system ( removal. system ( ) ) ;
149
+ world. spawn ( ( 0.0f32 , ) ) ;
150
+ resources. insert ( 0usize ) ;
151
+ stage. run ( & mut world, & mut resources) ;
152
+ stage. run ( & mut world, & mut resources) ;
153
+ assert_eq ! ( * resources. get:: <usize >( ) . unwrap( ) , 1 ) ;
154
+
155
+ let mut stage = SystemStage :: parallel ( ) . with_system ( removal. exclusive_system ( ) ) ;
156
+ world. spawn ( ( 0.0f32 , ) ) ;
157
+ resources. insert ( 0usize ) ;
158
+ stage. run ( & mut world, & mut resources) ;
159
+ stage. run ( & mut world, & mut resources) ;
160
+ assert_eq ! ( * resources. get:: <usize >( ) . unwrap( ) , 1 ) ;
161
+ }
0 commit comments