Description
Bevy version
0.5
Problem description
- Many plugins add interesting and valuable gameplay systems.
- States are very commonly used to control whether a game's core systems operate, such as creating a Paused or Loading state.
- Systems added in plugins are inserted into the stage and state that the plugin author set, with no way to change this.
- System labels cannot be added to systems added via plugins.
The State problem here is side effect of the fact that we cannot add run criteria to systems added in plugins.
Potential solutions
Solution 1: Everything is pub
Rather than trying to solve this directly, the Bevy community forces plugin authors to make all of their systems (and supporting types) pub
.
Users then reconstitute the plugins from scratch by adding the systems etc. on their own terms in their own code to get the interoperability they need.
This is bad because it creates cluttered, confusing APIs and exposes details that should be internal carelessly. This then causes every non-trivial plugin crate version to have breaking changes.
It is also very heavy on boilerplate.
Solution 2: Just fork it
As Solution 1, but users fork all plugins (and the engine) and forcibly make the things they need pub
/ make the changes they need.
Like Solution 1, but shifts the maintenance burden and headaches to the end users.
Very bad for user experience and ecosystem fragmentation.
Solution 3: Post-hoc configurability
Allow users to set the stages / states / run criteria of all systems in a plugin at once.
This doesn't involve any changes to our logic, and patches the most pressing issues.
However, it starts to break down pretty badly if you need to have plugins with systems that cannot coexist in the same stage or state: startup systems and those that must be separated by commands are particularly common and painful here.
Solution 4: Plugins contain only one system set
As solution 3, but each plugin can only have a single system set.
Solves the problems above, but makes their common use more onerous.
Solution 5: App as a structured object
Completely rework how App
works by replacing the "mutate the entire AppBuilder" approach with one where the AppBuilder
(and App
) have carefully structured fields that you can mutate regardless of the visibility of the field.
To solve this particular issue:
- All systems belong to a system set, and the app can have any number of system sets.
- Each system set must have a label (although it might be automatically generated).
- All system sets can be modified using their label after their insertion into the
AppBuilder
. - Each plugin contains their own app in this way, and their labels are exposed to the larger app that they make up.
- The
App
is not constructed until.run
is called, at which point it is constituted in a deterministic order that is independent of insertion order.
Solves #1255, which would be great for clarity and ease of refactoring. This would be a serious endeavor though, and might limit users ability to throw new ad-hoc behavior onto the AppBuilder
(not that I've ever seen anyone try?).
This is a sensible compromise on the level of granularity and visibility that plugins expose, grouping their functionality into configurable units.
Conclusions
Solution 1 is the de-facto standard right now for the Bevy engine, as virtually all of our systems are pub. Solution 2 is what will happen if we do nothing (or advanced users instead develop severe NIH syndrome). Both of these are pretty terrible.
Thus, we need a thoughtful approach to configuration. Solutions 3 and 4 are somewhat better than what we have now as they allow more than 0 configurability, but are almost certain to fall short in real use.
I am in favor of Solution 5, but this needs some serious thought. If you want to make an RFC, go for it! Otherwise, I'll probably get around to it after 0.6 launches due to other priorities.
Of course, all of these problems get dramatically worse once we have large games and an editor, and want to examine and manipulate systems visually.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status