-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 an Entities::iter()
method to iterate over all entities when you only have &World
#6228
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Trivial
Nice and easy! A great choice to get started with Bevy
Comments
alice-i-cecile
added
D-Trivial
Nice and easy! A great choice to get started with Bevy
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
labels
Oct 10, 2022
ramirezmike
added a commit
to ramirezmike/bevy
that referenced
this issue
Oct 12, 2022
ramirezmike
added a commit
to ramirezmike/bevy
that referenced
this issue
Oct 12, 2022
ramirezmike
added a commit
to ramirezmike/bevy
that referenced
this issue
Oct 12, 2022
FYI I was able to implement this on impl Entities {
/// Returns an iterator over entities in valid archetypes
pub fn iter(&'_ self) -> impl Iterator<Item = Entity> + '_ {
self.meta
.iter()
.enumerate()
.filter(|(_, meta)| meta.location.archetype_id != ArchetypeId::INVALID)
.map(|(index, meta)| Entity {
generation: meta.generation,
id: index as u32,
})
}
} |
ramirezmike
added a commit
to ramirezmike/bevy
that referenced
this issue
Oct 13, 2022
bors bot
pushed a commit
that referenced
this issue
Oct 17, 2022
# Objective - Add a way to iterate over all entities from &World ## Solution - Added a function `iter_entities` on World which returns an iterator of `Entity` derived from the entities in the `World`'s `archetypes` --- ## Changelog - Added a function `iter_entities` on World, allowing iterating over all entities in contexts where you only have read-only access to the World.
closed by #6242 |
james7132
pushed a commit
to james7132/bevy
that referenced
this issue
Oct 19, 2022
# Objective - Add a way to iterate over all entities from &World ## Solution - Added a function `iter_entities` on World which returns an iterator of `Entity` derived from the entities in the `World`'s `archetypes` --- ## Changelog - Added a function `iter_entities` on World, allowing iterating over all entities in contexts where you only have read-only access to the World.
james7132
pushed a commit
to james7132/bevy
that referenced
this issue
Oct 28, 2022
# Objective - Add a way to iterate over all entities from &World ## Solution - Added a function `iter_entities` on World which returns an iterator of `Entity` derived from the entities in the `World`'s `archetypes` --- ## Changelog - Added a function `iter_entities` on World, allowing iterating over all entities in contexts where you only have read-only access to the World.
Pietrek14
pushed a commit
to Pietrek14/bevy
that referenced
this issue
Dec 17, 2022
# Objective - Add a way to iterate over all entities from &World ## Solution - Added a function `iter_entities` on World which returns an iterator of `Entity` derived from the entities in the `World`'s `archetypes` --- ## Changelog - Added a function `iter_entities` on World, allowing iterating over all entities in contexts where you only have read-only access to the World.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this issue
Feb 1, 2023
# Objective - Add a way to iterate over all entities from &World ## Solution - Added a function `iter_entities` on World which returns an iterator of `Entity` derived from the entities in the `World`'s `archetypes` --- ## Changelog - Added a function `iter_entities` on World, allowing iterating over all entities in contexts where you only have read-only access to the World.
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
D-Trivial
Nice and easy! A great choice to get started with Bevy
What problem does this solve or what need does it fill?
The ordinary approach for getting the list of entities (query for
Query<Entity>
) doesn't work in contexts where you only have read-only access to theWorld
.What solution would you like?
Add an
Entities::iter()
orWorld::iter_entities()
method.What alternative(s) have you considered?
The following snippet works
Borrowed from @mockersf in https://github.com/bevyengine/bevy/pull/6227/files#diff-717fbf581c75ed1fc65c9755af2bf8a2ddc97c02e89f4044f86efa70a2ea4260L45
Additional context
It's not entirely clear if
Entities::iter()
can be implemented directly without digging in; I'm not sure if we have all of the information needed there.The text was updated successfully, but these errors were encountered: