-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example demonstrating how to send and receive events in the same system #11574
Add an example demonstrating how to send and receive events in the same system #11574
Conversation
The generated |
1 similar comment
The generated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful example, no issues.
My comments are mostly nit-picky (take it or leave it) and maybe there's a slight bias to cut some of the asides to keep the example focused on teaching just the one thing well
Amended, thanks a ton for the helpful reviews :) |
Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable names in the doc example seem to be the last place with "emit" instead of "send" 😅 Nice and useful example!
Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
# Objective - Example `send_and_receive_events` added in #11574 panics ``` thread 'Compute Task Pool (3)' panicked at bevy/crates/bevy_ecs/src/system/system_param.rs:570:17: Resource requested by send_and_receive_events::read_and_write_different_event_types does not exist: bevy_ecs::event::Events<send_and_receive_events::A> Encountered a panic in system `send_and_receive_events::read_and_write_different_event_types`! Encountered a panic in system `bevy_app::main_schedule::Main::run_main`! ``` ## Solution - Register the events used in the system - Don't use logger as it's not setup with `MinimalPlugins`, just print --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Kanabenki <lucien.menassol@gmail.com>
…me system (bevyengine#11574) # Objective - Sending and receiving events of the same type in the same system is a reasonably common need, generally due to event filtering. - However, actually doing so is non-trivial, as the borrow checker simultaneous hates mutable and immutable access. ## Solution - Demonstrate two sensible patterns for doing so. - Update the `ManualEventReader` docs to be more clear and link to this example. --------- Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com> Co-authored-by: Joona Aalto <jondolf.dev@gmail.com> Co-authored-by: ickk <git@ickk.io>
# Objective - Example `send_and_receive_events` added in bevyengine#11574 panics ``` thread 'Compute Task Pool (3)' panicked at bevy/crates/bevy_ecs/src/system/system_param.rs:570:17: Resource requested by send_and_receive_events::read_and_write_different_event_types does not exist: bevy_ecs::event::Events<send_and_receive_events::A> Encountered a panic in system `send_and_receive_events::read_and_write_different_event_types`! Encountered a panic in system `bevy_app::main_schedule::Main::run_main`! ``` ## Solution - Register the events used in the system - Don't use logger as it's not setup with `MinimalPlugins`, just print --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Kanabenki <lucien.menassol@gmail.com>
Objective
Solution
ManualEventReader
docs to be more clear and link to this example.