Skip to content
Snippets Groups Projects
Verified Commit 289eeab7 authored by Louis's avatar Louis :fire:
Browse files

Use layers getter instead of directly accessing layers in MapQuery

parent a03ae944
No related branches found
No related tags found
No related merge requests found
......@@ -74,38 +74,29 @@ impl<'w, 's> MapQuery<'w, 's> {
// --- call the static accessors on whatever the current level is
pub fn for_each_layer_of(level: &LdtkLevel, mut cb: impl FnMut(&LdtkLayer)) {
for layer in level.layers().rev() {
for layer in level.layers() {
cb(layer);
}
}
pub fn get_entities_of(level: &LdtkLevel) -> Vec<&EntityInstance> {
level
.level_ref()
.layer_instances
.as_ref()
.map(|layers| {
layers
.iter()
.flat_map(|layer| layer.entity_instances.iter())
.collect()
})
.unwrap_or_default()
.layers()
.flat_map(|layer| layer.as_ref().entity_instances.iter())
.collect()
}
pub fn get_instance_refs_of(level: &LdtkLevel) -> Vec<InstanceRef> {
level
.level_ref()
.layer_instances
.as_ref()
.map(|layers| {
layers
.layers()
.flat_map(|layer| {
layer
.as_ref()
.entity_instances
.iter()
.flat_map(|layer| layer.entity_instances.iter())
.map(|inst| InstanceRef { entity: inst })
.collect()
})
.unwrap_or_default()
.collect()
}
pub fn get_filtered_entities_of(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment