Replies: 2 comments
-
A comment I made on Discord that is worth reposting here: More often than not, I've seen people just use Query::get and just discard the unused parts, and the compiler optimizes out the unused fetches. It's definitely less ergonomic, but the fetches in Query::get are 100% in alignment with our safety checks used in iteration. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I would imagine any use case for these methods would be better-served by dynamic queries. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Query
has methods to access individual components of the query for a specific entity.But is it really useful? One can simply use
Query::get
and access the component they want.Those methods is code we need to take care of. This is not only a risk in terms of soundness (since it touches fairly hairy parts of the ECS) but it's also a burden. For example, you need to implement a
get_component
method when implementing dynamic queries. We also need to document them and test them, add similar API toQueryState
, addcomponent
(panicking version), etc.If we remove them, we don't have to worry about any of what we mentioned above.
Examinees
Query::get_component
Query::get_component_mut
Query::get_component_unchecked
Alleged usefulness
Q: WorldQuery
and don't know what components it has/what position they might be in.That's it? I've implemented a lot of bevy plugins and personally never came around a use case for
get_component
, but if you can give a compelling use-case I'll add it to the list.51 votes ·
Beta Was this translation helpful? Give feedback.
All reactions