-
-
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 subgroup #5022
Add subgroup #5022
Conversation
I've fixed the doc example, though now it simulates If requested, I can add this to the plugin group example. Also, please look over the unit test and make sure I did it correctly. This is my first time contributing to Bevy, so I may have done something wrong. |
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.
I like this API; I think that this helps make the logic clearer when working with plugin groups.
Great work with the doc tests, and the PR writeup did a great job motivating this change.
I think this would be worth adding to the plugin group example, but I won't block on it.
Thanks for the feedback! I'll look into adding an example. |
I have updated the example to show using |
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.
Example looks good. This needs one more review from the community before I can merge it; perhaps ask in #engine-dev on Discord?
I'm sorry, but I don't use Discord. Do you have any other suggestions? |
I'll ask for you then :) No worries! |
Thanks! :D |
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.
This current implementation rebuilds the entire plugin group it depends on. If done from multiple plugin groups declaring them as dependencies, you'll reregister everything under that dependency N times. This is clearly not desirable in the general case. We need explicit deduplication before this should be considered.
Blocked on #69 then. |
It's been a while since there's been activity here. Should I close the PR or leave it open? |
Let's close this out per the comment from James; we can always reopen in the future. |
Ok, I won't delete my fork though until this gets resolved. |
Objective
Sometimes a
PluginGroup
requires anotherPluginGroup
, likeDefaultPlugins
. The previous solution to this was:This feels backwards, even though it is correct.
Solution
Add a quality-of-life function that merges another group into the current one.
Changelog
Added
PlugingGroupBuilder::add_subgroup()
.Reasoning
My game is structured in a set of plugins. All you need to do is call
App::new().add_plugins(GamePlugins).run()
. This ensures that all the required plugins are registered. Ifmain.rs
has to also registerDefaultPlugins
, but doesn't, then my game would break. To fix this, I attach the default plugins as seen in the first example. I was dissatisfied with how that broke the flow of the code, so I wrote this function to fix it.