-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add num_entities()
to World
#19780
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
Add num_entities()
to World
#19780
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left an extension to the docs, but I agree with this direction.
Co-authored-by: Alice Cecile <[email protected]>
@alice-i-cecile IMO we arguably should prefer naming things There's only a handful for functions starting with ![]() But more end with ![]() |
Yeah, I'm down with that. If you submit a rename PR I'll approve it :) |
As discussed in #19780 (comment).
There is a lot of `world.entities().len()`, especially in tests. In tests, usually, the assumption is made that empty worlds do not contain any entities. This is about to change (bevyengine#19711), and as such all of these tests are failing for that PR. `num_entities` is a convenience method that returns the number of entities inside a world. It can later be adapted to exclude 'unexpected' entities, associated with internal data structures such as Resources, Queries, Systems. In general I argue for a separation of concepts where `World` ignores internal entities in methods such as `iter_entities()` and `clear_entities()`, that discussion is, however, separate from this PR. I replaced most occurrences of `world.entities().len()` with `world.num_entities()` and the tests passed. --------- Co-authored-by: Alice Cecile <[email protected]>
Objective
There is a lot of
world.entities().len()
, especially in tests. In tests, usually, the assumption is made that empty worlds do not contain any entities. This is about to change (#19711), and as such all of these tests are failing for that PR.Solution
num_entities
is a convenience method that returns the number of entities inside a world. It can later be adapted to exclude 'unexpected' entities, associated with internal data structures such as Resources, Queries, Systems. In general I argue for a separation of concepts whereWorld
ignores internal entities in methods such asiter_entities()
andclear_entities()
, that discussion is, however, separate from this PR.Testing
I replaced most occurrences of
world.entities().len()
withworld.num_entities()
and the tests passed.