Skip to content

Commit

Permalink
Use 'count_n_players' with Query
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jul 14, 2024
1 parent 3a45972 commit a08db23
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,9 @@ fn respond_to_mouse_wheel_press(
}

#[cfg(test)]
pub fn count_n_players(app: &App) -> usize {
let mut n = 0;
for c in app.world().components().iter() {
if c.name().contains("::Player") {
n += 1;
}
}
n
fn count_n_players(app: &mut App) -> usize {
let mut query = app.world_mut().query::<&Player>();
return query.iter(app.world_mut()).len();
}

#[cfg(test)]
Expand Down

0 comments on commit a08db23

Please sign in to comment.