You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sheepyhead opened this issue
May 28, 2021
· 3 comments
Labels
A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleD-TrivialNice and easy! A great choice to get started with Bevy
What problem does this solve or what need does it fill?
I find myself occasionally want to check on game state in the way that I want to know if any entities of a given query exist already, but I don't need to use the actual query data. For instance whether the I button opens or closes the inventory window in my game depends on whether the inventory window is already open, and this is most directly checked by finding the marker component for the inventory window.
What solution would you like?
The quick solution would be simply a .empty() function on Query that returns true if the query matches no entities and false otherwise. More ideally I'd also like to be able to make a Query<(), (With<A>, Without<B>, Changed<C>)> so that no data is even passed to the function other than whether the query matches anything or not (having number of matches may be useful but I have no use cases for that currently)
What alternative(s) have you considered?
Currently I write my query like Query<Entity, (With<A>, Without<B>, Changed<C>)> and check on matches using query.iter().count() == 0 which is both wordy and not immediatly explicit. query.empty() would be much nicer
The text was updated successfully, but these errors were encountered:
## Problem
- The `Query` struct does not provide an easy way to check if it is empty.
- Specifically, users have to use `.iter().peekable()` or `.iter().next().is_none()` which is not very ergonomic.
- Fixes: bevyengine#2270
## Solution
- Implement an `is_empty` function for queries to more easily check if the query is empty.
A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleD-TrivialNice and easy! A great choice to get started with Bevy
What problem does this solve or what need does it fill?
I find myself occasionally want to check on game state in the way that I want to know if any entities of a given query exist already, but I don't need to use the actual query data. For instance whether the I button opens or closes the inventory window in my game depends on whether the inventory window is already open, and this is most directly checked by finding the marker component for the inventory window.
What solution would you like?
The quick solution would be simply a .empty() function on Query that returns true if the query matches no entities and false otherwise. More ideally I'd also like to be able to make a
Query<(), (With<A>, Without<B>, Changed<C>)>
so that no data is even passed to the function other than whether the query matches anything or not (having number of matches may be useful but I have no use cases for that currently)What alternative(s) have you considered?
Currently I write my query like
Query<Entity, (With<A>, Without<B>, Changed<C>)>
and check on matches usingquery.iter().count() == 0
which is both wordy and not immediatly explicit.query.empty()
would be much nicerThe text was updated successfully, but these errors were encountered: