Apply buffers in ParamSet (#4677)

# Objective

- Fix https://github.com/bevyengine/bevy/issues/4676

## Solution

- Fixes https://github.com/bevyengine/bevy/issues/4676
- I have no reason to think this isn't sound, but `ParamSet` is a bit spooky
This commit is contained in:
Daniel McNab 2022-05-06 18:52:26 +00:00
parent 96b4956126
commit ec805e9e07
2 changed files with 24 additions and 1 deletions

View file

@ -250,6 +250,10 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
#param.new_archetype(archetype, system_meta);
)*
}
fn apply(&mut self, world: &mut World) {
self.0.apply(world)
}
}

View file

@ -103,7 +103,7 @@ mod tests {
query::{Added, Changed, Or, With, Without},
schedule::{Schedule, Stage, SystemStage},
system::{
IntoExclusiveSystem, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query,
Commands, IntoExclusiveSystem, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query,
RemovedComponents, Res, ResMut, System, SystemState,
},
world::{FromWorld, World},
@ -906,4 +906,23 @@ mod tests {
expected_ids
);
}
#[test]
fn commands_param_set() {
// Regression test for #4676
let mut world = World::new();
let entity = world.spawn().id();
run_system(
&mut world,
move |mut commands_set: ParamSet<(Commands, Commands)>| {
commands_set.p0().entity(entity).insert(A);
commands_set.p1().entity(entity).insert(B);
},
);
let entity = world.entity(entity);
assert!(entity.contains::<A>());
assert!(entity.contains::<B>());
}
}