Skip to content

Commit 4f1a651

Browse files
committed
Fixed commands for coerced exclusive systems (#1531)
Fixes #1530.
1 parent 8bc7320 commit 4f1a651

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

crates/bevy_ecs/src/system/exclusive_system.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl ExclusiveSystem for ExclusiveSystemCoerced {
105105

106106
fn run(&mut self, world: &mut World, resources: &mut Resources) {
107107
self.system.run((), world, resources);
108+
self.system.apply_buffers(world, resources);
108109
}
109110

110111
fn initialize(&mut self, world: &mut World, resources: &mut Resources) {
@@ -123,3 +124,38 @@ where
123124
}
124125
}
125126
}
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

Comments
 (0)