-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: single & first entity queries (take 2) (#454)
Closes #289 Hello 👋 it's been a long while. This is take 2 of #386 which was reverted in cfce040 due to CI failures. ## Changes - Add `Entities::(get_)single_with` methods to get a single entity by a query - Add `Entities::(get_)first_with_bitset` methods to get the first entity in the given bitset - Add `Entities::(get_)first_with` methods to get the first entity in the given query ## Summary Add convenience methods to get a single entity (and one or more of its components) when there should only be one of the thing you're looking for. This could be useful, for example, to check if there is only one player alive in the game. You could use `Entities::get_single_with` which would allow you to detect when there is only one player (`Ok`) or when there are none/multiple (`Err`). All methods have a panicking and non-panicking variant -- e.g. `get_single_with` returns a `Result<_, QuerySingleError>`, while `single_with` panics if the return value is an `Err`. The `*first_with*` methods either return an `Option` or panic.
- Loading branch information
Showing
4 changed files
with
736 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.