Ergonomic observer queries: SystemInput-taking SystemParam edition - #25686
Draft
ItsDoot wants to merge 3 commits into
Draft
Ergonomic observer queries: SystemInput-taking SystemParam edition#25686ItsDoot wants to merge 3 commits into
SystemInput-taking SystemParam edition#25686ItsDoot wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Solution
SystemParams now take theSystemInputby reference when fetching the data for the system:trait SystemParamFetch<I: SystemInput>: SystemParam, a new super trait ofSystemParam.SystemParam::get_paramtoSystemParamFetch, and add a new argument to it that accepts a reference to theSystemInput.SystemParamFetchfor anyI: SystemInputfor all currentSystemParamimplementations, and move theget_paramimplementation over.SystemStateto work with non-()system inputs.FunctionSystemtrait machinery fromP: SystemParamtoP: SystemParamFetch<System::In>.TargetEntitytrait andTarget<D, F>query type. The latter is similar toSingle<D, F>, but fetches the query data for the target entity rather than the unique entity that matches the query.a.
Target<D, F>is bounded to only work withSystemInputs that take a type that implementsTargetEntity.Benefits of this approach:
Target<D, F>in a normal scheduled system (which has no input), you get an error when trying to register the system viaadd_systems.Entityused byTarget<D, F>is the same data available viaOn<E>.SystemParamfetching based on anySystemInputOriginalTarget<D, F>for propagating events, for example.Drawbacks of this approach:
SystemParamimplementations are already in advanced territory, complicating the API surface further does have an impact.Testing
Added a test for
Target<D, F>.Showcase
Ergonomic target entity queries are here!