Skip to content

Commit c036682

Browse files
bors[bot]azriel91
andauthored
1883: Improvement/system desc ergonomics r=jojolepro a=azriel91 ## Description Extend `SystemDesc` derive to generate implementation for system with event channel reader fields. Essentially: ```patch -#[derive(Debug)] +#[derive(Debug, SystemDesc)] +#[system_desc(name(SystemWithEventChannelDesc))] struct SystemWithEventChannel { + #[system_desc(event_channel_reader)] u32_reader: ReaderId<u32>, } -use amethyst_core::SystemDesc; - -/// Builds a `SystemWithEventChannel`. -#[derive(Default, Debug)] -pub struct SystemWithEventChannelDesc; - -impl<'a, 'b> SystemDesc<'a, 'b, SystemWithEventChannel> for SystemWithEventChannelDesc { - fn build(self, world: &mut World) -> SystemWithEventChannel { - <SystemWithEventChannel as System<'_>>::SystemData::setup(world); - - let u32_reader = world.fetch_mut::<EventChannel<u32>>().register_reader(); - - SystemWithEventChannel::new() - } -} ``` **Note:** built on top of amethyst#1882, so build is green. See commit 932a58d onwards ## Modifications * `SystemDesc` proc macro supports `#[system_desc(event_reader_id)]` to register event reader. ## PR Checklist By placing an x in the boxes I certify that I have: - [x] Updated the content of the book if this PR would make the book outdated. - [x] Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment. - [x] Added unit tests for new code added in this PR. - [x] Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme. If this modified or created any rs files: - [x] Ran `cargo +stable fmt --all` - [x] Ran `cargo clippy --all --features "empty"` - [x] Ran `cargo test --all --features "empty"` Co-authored-by: Azriel Hoh <[email protected]>
2 parents 5c89c99 + 891852e commit c036682

File tree

4 files changed

+719
-83
lines changed

4 files changed

+719
-83
lines changed

0 commit comments

Comments
 (0)