Skip to content

Commit

Permalink
Apply buffers in ParamSet (bevyengine#4677)
Browse files Browse the repository at this point in the history
# Objective

- Fix bevyengine#4676

## Solution

- Fixes bevyengine#4676
- I have no reason to think this isn't sound, but `ParamSet` is a bit spooky
  • Loading branch information
DJMcNab authored and exjam committed May 22, 2022
1 parent 15a4512 commit a7292c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}


Expand Down
21 changes: 20 additions & 1 deletion crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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>());
}
}

0 comments on commit a7292c8

Please sign in to comment.