|
|
|
|
@ -232,17 +232,27 @@ fn set_tile_sprite(
|
|
|
|
|
/// Sets a piece location given it's board index
|
|
|
|
|
fn set_transform(
|
|
|
|
|
mut events: Query<
|
|
|
|
|
(&mut Transform, &BoardIndex),
|
|
|
|
|
(&mut Transform, &BoardIndex, Option<&Piece>, Option<&Tile>),
|
|
|
|
|
(
|
|
|
|
|
With<Display2d>,
|
|
|
|
|
Or<(Changed<BoardIndex>, Added<BoardIndex>)>,
|
|
|
|
|
),
|
|
|
|
|
>,
|
|
|
|
|
) {
|
|
|
|
|
events.iter_mut().for_each(|(mut t, i)| {
|
|
|
|
|
events.iter_mut().for_each(|(mut t, i, piece, tile)| {
|
|
|
|
|
let x = SCALE * 16.0 * ((i.x as f32) - 3.5);
|
|
|
|
|
let y = SCALE * 16.0 * ((i.y as f32) - 1.5);
|
|
|
|
|
*t = Transform::from_scale(Vec3::splat(SCALE)).with_translation(Vec3::new(x, y, 0.0));
|
|
|
|
|
let z = match (piece, tile) {
|
|
|
|
|
(None, None) | (Some(_), Some(_)) => {
|
|
|
|
|
error!("Entity with BoardIndex is neither a Piece nor a Tile!");
|
|
|
|
|
0.0
|
|
|
|
|
}
|
|
|
|
|
// Piece
|
|
|
|
|
(Some(_), None) => 2.0,
|
|
|
|
|
// Tile
|
|
|
|
|
(None, Some(_)) => 1.0,
|
|
|
|
|
};
|
|
|
|
|
*t = Transform::from_scale(Vec3::splat(SCALE)).with_translation(Vec3::new(x, y, z));
|
|
|
|
|
debug!("setting position of {:?} to {:?}", i, t);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|