-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
One-shot systems via Commands for scripting-like logic #2192
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!X-Needs-SMEThis type of work requires an SME to approve it.This type of work requires an SME to approve it.
Milestone
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!X-Needs-SMEThis type of work requires an SME to approve it.This type of work requires an SME to approve it.
What problem does this solve or what need does it fill?
Some operations are only done very rarely: scripting-like game logic that modifies levels, unlocks achievements or handles a boss's special attack come to mind.
These systems clutter the schedule, waste resources as they constantly spin, and are harder to extend.
What solution would you like?
There are two parts to my proposed solution:
Commands::run_system(system: impl Into<SystemDescriptor>). This runs the specified system on theWorldthe next time commands are processed.What alternative(s) have you considered?
Writing custom commands types each time will be onerous and have much increased boilerplate, and because they take exclusive access to
World, force the users to learn a new syntax and reduce our ability to parallelize commands of this sort in the future.This same functionality could also be framed as "dynamically inserting systems", but that may complicate the API somewhat when you often don't end up caring a lot about overhead.
Other approaches to reactivity may be able to fill this niche in some form instead.
Additional context
Making sure the ordering on this is correct enough is going to be one of the larger challenges. May be better to wait until after #1375. Chaining also needs some careful thought.
Brought up in response to the following user request:
Depending on the efficiency and ergonomics of this, could also be used to support push data-flow for UI (see #254).
Related to #1273.