-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SystemParamBuilder - Support buildable Vec parameters (#14821)
# Objective Allow dynamic systems to take lists of system parameters whose length is not known at compile time. This can be used for building a system that runs a script defined at runtime, where the script needs a variable number of query parameters. It can also be used for building a system that collects a list of plugins at runtime, and provides a parameter to each one. This is most useful today with `Vec<Query<FilteredEntityMut>>`. It will be even more useful with `Vec<DynSystemParam>` if #14817 is merged, since the parameters in the list can then be of different types. ## Solution Implement `SystemParam` and `SystemParamBuilder` for `Vec` and `ParamSet<Vec>`. ## Example ```rust let system = (vec![ QueryParamBuilder::new_box(|builder| { builder.with::<B>().without::<C>(); }), QueryParamBuilder::new_box(|builder| { builder.with::<C>().without::<B>(); }), ],) .build_state(&mut world) .build_system(|params: Vec<Query<&mut A>>| { let mut count: usize = 0; params .into_iter() .for_each(|mut query| count += query.iter_mut().count()); count }); ```
- Loading branch information
Showing
2 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters