Skip to content
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

PluginGroups like Bundles #67

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions rfcs/67-plugingroups-like-bundles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Feature Name: Plugingroups like Bundles

## Summary

Make PluginGroups like Bundles, so they are just structs. Then the ordering will be made by a gen_graph function, maybe with the new planned `bevy_graph` (https://github.com/bevyengine/bevy/discussions/6719) ?
This will make PluginGroups from the design consistent to the other bevy types.

## Motivation

First, a new possibilty: adding plugingroups inside of pluginsgroup (cool). (a guy on discord asked this https://discord.com/channels/691052431525675048/1044672077451513906) and what he wanted (adding plugingroups inside of plugingroups) just wans't possible :c.
Every time when I see PluginGroups it makes my brain think about **Design consitency**, because most of the other bevy types are just structs with default rust constructors.
It also bothers me when i set plugins that for example then implement `WindowPlugin::default()` only to let me use `.set(WindowPlugin { .. })` later.

## Example Design Impl

```rust
#[derive(Default)]
pub struct MyPlugins {
main_plugin: MainPlugin,
#[plugingroup]
other_plugin_group: OtherPlugins,
#[cfg(feature = "optional")]
optional: OptionalPlugin,
}

impl PluginGroup for MyPlugins {
fn gen_graph(mut self) -> PluginGraph<Self> {
let mut graph_builder = PluginGraph::new();
builder.append::<MainPlugin>();
builder.before::<OtherPlugins, MainPlugin>();
#[cfg(feature = "optional")]
{
builder.append::<OptionalPlugin>();
}
graph_builder.build(self)
}
}

app.add_plugins(MyPlugins {
main_plugin: MainPlugin { .. },
..Default::default()
}).plugin_graph().after::<OtherPlugins, MainPlugin>(); // make plugin graph editable in app, make it also change order later
```

## Final Note

I'm not sure about the naming, about the RFC in general. But thats a RFC about (i think). But with your help i think this can be a well done feature :).

And a thing i just saw: this will remove a functionality (which i never saw used and i am even not sure if it is even possible):
```rust
app.add_plugins(MyPlugins::custom_setting(CustomSetting::Minimum)); // this would for example just add Plugin x and y, with CustomSetting::Everything, it would also add Plugin z.
// something like optional plugins via constructor isn't possible with the new design, i think.
```

So yeah, I'm looking forward to make this feature good and cool so everybody likes it (hopefully) and it can be adopted to also make it easier for the above mentioned `bevy_graph` and bevy in general.
Maybe this could be also an addition to the new stageless design? idk, we'll see :)