-
-
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
Event-dependent run criteria for systems #1272
Comments
Previous work/discussion that is in a similar vein: #1041 |
I think that the You'll want to configure it so then the system runs if any of its event queues are non-empty, to properly handle the case of systems that read more than one event type. This is mostly relevant at the system level, so losing the ability to generalize it in an ultra-convenient way to a The only other caveat is that by expanding the |
A similar pattern emerges for processing component data, where you only want to run a system if a query is non-empty, typically on the basis of This is also related to the idea of Ideally we could handle all this in a single abstraction? |
So to capture the idea from the comment above, what I think we actually want is a run criteria of:
The name could use some workshopping, but I think this is an abstraction that captures a lot of patterns. In particular, I think that this could seriously mitigate the need for hard run criteria at all (see the infamous #1144). I think this also requires some thinking about how exactly to handle Edit: I think this is too magical. Instead, we should have more explicit run criteria helpers based on change detecting queries and event readers. |
|
Blocked on a better design for run criteria in #2801. |
Closing this out; I don't think this is the right direction (at least for now). |
What problem does this solve or what need does it fill?
Some systems should only run when there are events to be processed.
This is a common pattern, but annoying
What solution would you like?
A simple run criteria helper function that checks whether an event queue of the specified type is empty.
Because run criteria apply to multiple systems at once, I don't think you can have it automatically inspect the parameters of the systems its modifying.
What alternative(s) have you considered?
Users can write their own run criteria by hand. This is tedious and error-prone.
Event-handling systems can return early if they have no work today. This combines internal logic with scheduling logic, and forces scheduling of a system when it's not needed, possibly blocking other systems' access to archetype-components or resources.
Additional context
This functionality relates to but is distinct from triggered systems, as discussed in #1273. Something morally similar might be helpful as part of a scheduler for a dedicated UI stage.
The text was updated successfully, but these errors were encountered: