Closed nelson137 closed 1 month ago
Merged this but I think there may have been a conflict or something that caused CI to fail in main - I couldn't for the life of me figure out how to re-run CI for some reason (possibly because it was cancelled on hung Miri last time).
Anywho sorry for the chaos - reverted in main, I will re-open this PR once I figure out best way to do that / fix and merge.
@nelson137 seems I can't revert/re-open merged PR, if you want to re-open a new PR from your branch so you get attributed with commit I can handle the rest, otherwise I'll go ahead and re-open. Sorry about that.
Closes #289.
Changes
Entities::(get_)single_with
methods to get a single entity by a queryEntities::(get_)first_with_bitset
methods to get the first entity in the given bitsetEntities::(get_)first_with
methods to get the first entity in the given querySummary
Add convenience methods to get a single entity (and optionally 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 aResult<_, QuerySingleError>
, whilesingle_with
panics if the return value would not beOk
. The*first_with*
methods either return anOption
or panic.