Skip to content
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

Getting QueryState from immutable World reference #16434

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vil-mo
Copy link

@vil-mo vil-mo commented Nov 19, 2024

Objective

There is currently no way of getting QueryState from &World, so it is hard to, for example, iterate over all entities with a component, only having &World.

Solution

Add try_new function to QueryState that internally uses WorldQuery's get_state.

Testing

No testing

@alice-i-cecile
Copy link
Member

This partially resolves #3774 :)

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to return results everywhere in this chain to improve debugging, but this is a very useful workaround currently.

That should be done in follow-up, but for now, can you add World::try_query + try_query_filtered methods to make this easier to use?

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Nov 19, 2024
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Nov 19, 2024
@alice-i-cecile alice-i-cecile removed the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Nov 19, 2024
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants