Skip to content
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

Invert fill_tilemap usage of add_child to the tilemap parent entity to instead use add_children #377

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/helpers/filling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ pub fn fill_tilemap(
commands: &mut Commands,
tile_storage: &mut TileStorage,
) {
for x in 0..size.x {
for y in 0..size.y {
let tile_pos = TilePos { x, y };
let tile_entity = commands
.spawn(TileBundle {
position: tile_pos,
tilemap_id,
texture_index,
..Default::default()
})
.id();
commands.entity(tilemap_id.0).add_child(tile_entity);
tile_storage.set(&tile_pos, tile_entity);
let mut tilemap = commands.entity(tilemap_id.0);
tilemap.add_children(|parent| {
for x in 0..size.x {
for y in 0..size.y {
let tile_pos = TilePos { x, y };
let tile_entity = {
parent
.spawn(TileBundle {
position: tile_pos,
tilemap_id,
texture_index,
..Default::default()
})
.id()
};
tile_storage.set(&tile_pos, tile_entity);
}
}
}
});
}

/// Fills a rectangular region with the given tile.
Expand Down