-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
One-shot systems as Command
s -- allow commands to use SystemParam
s
#7252
Conversation
@alice-i-cecile I don't need a full review or approval yet, but I'd like to get your opinion on this PR before I move forward with it. |
I agree that we want a commands-powered API for one-shot systems :) Concerns with this approach though:
Excited to see work towards one-shot systems in one form or another, but I'm not sold on this approach. |
|
Generally agreed, but not my requirement :p
Once you start looking at using one shot systems for UI callbacks this makes a lot of sense to me :) |
Objective
Fixes #2192.
Currently, anonymous one-shot commands can be defined as a closure accepting
&mut World
. Working with exclusive world access is quite cumbersome, and is usually only necessary if a command makes changes to a world's archetypes. In cases where a command simply needs to access and mutate world data, it is much more ergonomic to do so viaSystemParam
s such asResMut<>
orQuery
.Solution
CommandSystemParam
, which is a subset ofSystemParam
that excludes types that don't make sense for one-shot systems, such asLocal<>
orCommands
.CommandSystemParam
s may be used as a command.Example
TODO: Docs. I'd like to see the response to this PR before putting in the effort to write full documentation.
TODO: Look into storing "command systems" in a registry resource, to avoid duplicate initialization code. This will require benchmarking.
Changelog
TODO
Migration Guide
TODO