-
-
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
Fast and correct one-shot systems with a system registry resource #7999
Closed
Closed
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
3e6a8c5
Basic functionality
alice-i-cecile f9b16c2
commands.run_system
alice-i-cecile 8e32c74
Add SystemRegistry resource as part of CorePlugin
alice-i-cecile 961af58
Run system by TypeId
alice-i-cecile d7ece72
Fix doc links
alice-i-cecile f54db1f
run_system_by_type_id for World and Commands
alice-i-cecile 4fc35e5
Always flush commands from systems
alice-i-cecile a9be933
Always initialize SystemRegistry on the `World`
alice-i-cecile fed175c
Add test suite
alice-i-cecile b883bca
Doc improvements
alice-i-cecile ee33630
Store registered systems by their system labels
alice-i-cecile b520291
Ensure that run_system always runs the system exactly once
alice-i-cecile 7041713
Advertise SystemRegistry in SystemState docs
alice-i-cecile 1a5e308
Doc tests for SystemRegistry
alice-i-cecile 6f3a676
Improve ergonomics of the register_system API
alice-i-cecile ebe2f29
Improve run_by_label API ergonomics
alice-i-cecile 3e41300
Improve ergonomics of registering systems
alice-i-cecile 0f0a6dd
Note limitations
alice-i-cecile 870b12d
Remove the need to manually update archetypes
alice-i-cecile ba66966
Move SystemRegistry to a field on `World`
alice-i-cecile 5baac51
Revert "Move SystemRegistry to a field on `World`"
alice-i-cecile 3be2a2e
Clippy fixes
alice-i-cecile 4feb974
Merge remote-tracking branch 'origin/main' into system_registry
alice-i-cecile 4fe2937
Clippy fix
alice-i-cecile 38fd422
System recursion should fail
alice-i-cecile 641f5df
Documentation improvements
alice-i-cecile 854a805
Nicer error handling
alice-i-cecile 7f41af9
Return index from register system methods
alice-i-cecile 5c35c51
Fix off by one error
alice-i-cecile 681a6fc
Reduce noisy returns
alice-i-cecile 091e50f
Fix broken tests
alice-i-cecile 5f3925e
Add example
alice-i-cecile e812bed
Improve ergonomics of register_system method
alice-i-cecile 79aba5c
Formatting
alice-i-cecile 7c02da4
Expose run_systems_by_boxed_label method
alice-i-cecile cdd8cfc
Create matching methods on App
alice-i-cecile e6094c6
Polish example
alice-i-cecile 61db824
Update examples README per CI
alice-i-cecile afec804
Simplify system_registry doc tests
alice-i-cecile 9423b49
Fix broken link
alice-i-cecile ebfca10
Add Callback type to bevy_ecs itself
alice-i-cecile 1088dc6
Implement PartialEq and Eq for Callback
alice-i-cecile 31b2277
Implement Hash for Callback
alice-i-cecile f505e2d
Change run_system_by_boxed_label to run_callback
alice-i-cecile d451282
Fix doc example
alice-i-cecile 89fa516
Manually implement Hash
alice-i-cecile 6cc0cb9
Fix doc example (for real?)
alice-i-cecile 5f29c93
Avoid box allocation
alice-i-cecile 707ec5d
Mostly fix doc example
alice-i-cecile e7b6190
Remove frustrating doc example
alice-i-cecile 0b46807
Merge branch 'main' into system_registry
alice-i-cecile ddfd7dc
Typo fix
alice-i-cecile 4d312e7
Clarify drawbacks of SystemState
alice-i-cecile 8cf91a4
Punctuation
alice-i-cecile b2f5bf7
Typo
alice-i-cecile 2254d4f
Fix mistake from merge conflict
alice-i-cecile 25c66db
Remove vague warning about callbacks
alice-i-cecile 3ad29fd
Add Send and Sync bounds to label traits
alice-i-cecile ac1c2aa
Clean up docs and naming around system registration
alice-i-cecile e730525
Make App and World APIs consistent
alice-i-cecile 55e61e1
Make doc links on higher level methods more useful
alice-i-cecile 596adce
Merge remote-tracking branch 'alice/system_registry' into system-regi…
Pascualex ba23d05
remove non-related clippy lint
Pascualex 9085d50
fix doc tests
Pascualex aca4998
remove run_systems_by_set
Pascualex 3319664
remove run_systems_by_label from Commands
Pascualex 68ba9bd
rename params to marker
Pascualex 98aa178
key systems by SystemId
Pascualex 0a59b3b
shorten system registry function names
Pascualex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::App; | ||
use bevy_ecs::{ | ||
prelude::*, | ||
system::{SystemId, SystemRegistryError}, | ||
}; | ||
|
||
impl App { | ||
/// Register a system with any number of [`SystemLabel`]s. | ||
/// | ||
/// Calls [`SystemRegistry::register_system`](bevy_ecs::system::SystemRegistry::register_system). | ||
pub fn register_system<M, S: IntoSystem<(), (), M> + 'static>( | ||
&mut self, | ||
system: S, | ||
) -> &mut Self { | ||
self.world.register_system(system); | ||
self | ||
} | ||
|
||
/// Runs the supplied system on the [`World`] a single time. | ||
/// | ||
/// Calls [`SystemRegistry::run_system`](bevy_ecs::system::SystemRegistry::run_system). | ||
#[inline] | ||
pub fn run_system<M, S: IntoSystem<(), (), M> + 'static>(&mut self, system: S) -> &mut Self { | ||
self.world.run_system(system); | ||
self | ||
} | ||
|
||
/// Run the systems corresponding to the label stored in the provided [`Callback`] | ||
/// | ||
/// Calls [`SystemRegistry::run_callback`](bevy_ecs::system::SystemRegistry::run_callback). | ||
#[inline] | ||
pub fn run_system_by_id(&mut self, system_id: SystemId) -> Result<(), SystemRegistryError> { | ||
self.world.run_system_by_id(system_id) | ||
} | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
SystemLabel should be removed from the docs.
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.
Yes, the docs are not up to date, I want to stabilize some things first :)