generated from hheik/bevy-template
20 lines
643 B
Rust
20 lines
643 B
Rust
use bevy::prelude::*;
|
|
|
|
use crate::game::grid::*;
|
|
|
|
pub fn grid_positioning(
|
|
grid_query: Query<(&Grid, &Children)>,
|
|
mut transform_query: Query<(&mut Transform, &GridTransform)>,
|
|
) {
|
|
for (grid, children) in grid_query.iter() {
|
|
for child in children.iter() {
|
|
if let Ok((mut transform, grid_transform)) = transform_query.get_mut(child) {
|
|
let new_pos = Vec2::from(grid_transform.translation) * grid.tile_size;
|
|
// Don't touch Z in case of layering
|
|
transform.translation.x = new_pos.x;
|
|
transform.translation.y = new_pos.y;
|
|
}
|
|
}
|
|
}
|
|
}
|