Skip to content

Commit

Permalink
Change into despawn_recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
guimcaballero committed Nov 16, 2020
1 parent f2c1619 commit 22f65da
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ struct Taken;
fn despawn_taken_pieces(
mut commands: Commands,
mut app_exit_events: ResMut<Events<AppExit>>,
query: Query<(Entity, &Piece, &Children, &Taken)>,
query: Query<(Entity, &Piece, &Taken)>,
) {
for (entity, piece, children, _taken) in query.iter() {
for (entity, piece, _taken) in query.iter() {
// If the king is taken, we should exit
if piece.piece_type == PieceType::King {
println!(
Expand All @@ -230,12 +230,8 @@ fn despawn_taken_pieces(
app_exit_events.send(AppExit);
}

// Despawn piece
commands.despawn(entity);
// Despawn all of it's children
for child in children.iter() {
commands.despawn(*child);
}
// Despawn piece and children
commands.despawn_recursive(entity);
}
}

Expand Down

0 comments on commit 22f65da

Please sign in to comment.