-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
237: Allow Queries to be requested as parameters in #[system] r=TomGillen a=TomGillen This PR allows users to request queries as parameters in basic `#[system]` macro invocations. This allows a system to request multiple queries without the user having to construct them themselves. It also adds these queries to the system (via `SystemBuilder`), which means (in most cases) users won't need to use `#[read_component(T)]`/`#[write_component(T)]` attributes, and the queries persist between each run of the system, allowing for some level of caching between runs. For example, prior to this PR: ```rust #[system] #[read_component(A, B)] #[write_component(C)] fn my_system(world: &mut SubWorld) { let query_a = <(&A, &mut C)>::query(); for (a, c) in query_a.iter_mut(world) { ... } let query_b = <(&B, &mut C)>::query(); for (b, c) in query_b.iter_mut(world) { ... } } ``` Can now be written as: ```rust #[system] fn my_system( world: &mut SubWorld, query_a: &mut Query<(&A, &mut C)>, query_b: &mut Query<(&B, &mut C)>, ) { for (a, c) in query_a.iter_mut(world) { ... } for (b, c) in query_b.iter_mut(world) { ... } } ``` Co-authored-by: Tom Gillen <[email protected]>
- Loading branch information
Showing
3 changed files
with
162 additions
and
49 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
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