diff --git a/src/exploration.rs b/src/exploration.rs index 1dfff30..3145dd7 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -62,7 +62,7 @@ where ExplorationType: Component + Default + Copy + Ord, State: 'static + Clone + Debug + Eq + Hash + Send + Sync, { - for (actions, visible, mut focused) in explorers.iter_mut() { + for (actions, visible, mut focused) in &mut explorers { let mut types: Vec = vec![]; for e in visible.iter() { if let Ok(t) = features.get(*e) { @@ -128,7 +128,7 @@ where ExplorationType: Component + Default + PartialEq, State: 'static + Clone + Debug + Eq + Hash + Send + Sync, { - for (entity, actions, visible_entities, focused_type, exploring) in explorers.iter() { + for (entity, actions, visible_entities, focused_type, exploring) in &explorers { let mut features = features .iter() .filter(|v| visible_entities.contains(&v.0)) @@ -218,7 +218,7 @@ fn exploration_focus( State: 'static + Clone + Debug + Eq + Hash + Send + Sync, MapData: 'static + Clone + Default + Send + Sync, { - for (entity, actions, transform, exploring) in explorers.iter() { + for (entity, actions, transform, exploring) in &explorers { let coordinates = transform.translation; let mut exploring = if let Some(exploring) = exploring { **exploring @@ -260,8 +260,8 @@ fn navigate_to_explored( State: 'static + Clone + Debug + Eq + Hash + Send + Sync, MapData: 'static + Clone + Default + Send + Sync, { - for (entity, actions, exploring) in explorers.iter() { - for (map, revealed_tiles) in map.iter() { + for (entity, actions, exploring) in &explorers { + for (map, revealed_tiles) in &map { let point = **exploring; let idx = point.to_index(map.width); let known = revealed_tiles[idx]; @@ -363,10 +363,10 @@ fn cleanup( explorers: Query>, focus: Query>, ) { - for entity in explorers.iter() { + for entity in &explorers { commands.entity(entity).remove::(); } - for entity in focus.iter() { + for entity in &focus { commands.entity(entity).remove::(); } } diff --git a/src/log.rs b/src/log.rs index 74647f2..8d9e47f 100644 --- a/src/log.rs +++ b/src/log.rs @@ -41,7 +41,7 @@ fn read_log( mut position: Local, log: Query<&Log, Changed>, ) -> Result<(), Box> { - for log in log.iter() { + for log in &log { if *position >= log.len() { *position = 0; } diff --git a/src/map.rs b/src/map.rs index f50087a..1b8148c 100644 --- a/src/map.rs +++ b/src/map.rs @@ -183,7 +183,7 @@ fn spawn_colliders( mut commands: Commands, maps: Query<(Entity, &Map, &SpawnColliders), Changed>, ) { - for (map_entity, map, spawn_colliders) in maps.iter() { + for (map_entity, map, spawn_colliders) in &maps { if **spawn_colliders { commands .entity(map_entity) @@ -244,7 +244,7 @@ fn spawn_portals( mut commands: Commands, map: Query<(Entity, &Map, &SpawnPortals), Changed>, ) { - for (map_entity, map, spawn_portals) in map.iter() { + for (map_entity, map, spawn_portals) in &map { if **spawn_portals { commands.entity(map_entity).remove::(); let mut portals: Vec<(f32, f32)> = vec![]; @@ -297,9 +297,9 @@ fn spawn_portal_colliders( map: Query<(Entity, &SpawnColliders), With>>, portals: Query, Without)>, ) { - for (entity, spawn_colliders) in map.iter() { + for (entity, spawn_colliders) in &map { if **spawn_colliders { - for portal_entity in portals.iter() { + for portal_entity in &portals { commands .entity(portal_entity) .insert((Collider::cuboid(0.5, 0.5), Sensor)); diff --git a/src/navigation.rs b/src/navigation.rs index c2da403..1d594d2 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -224,7 +224,7 @@ fn controls( } if cleanup { commands.entity(entity).remove::(); - for entity in exploration_focused.iter() { + for entity in &exploration_focused { commands.entity(entity).remove::(); } } @@ -289,7 +289,7 @@ fn update_direction( (With, Changed), >, ) { - for (entity, transform, direction) in query.iter_mut() { + for (entity, transform, direction) in &mut query { let yaw = transform.yaw(); let new_direction: CardinalDirection = yaw.into(); if let Some(mut direction) = direction { @@ -333,7 +333,7 @@ fn speak_direction( } fn add_speed(mut commands: Commands, query: Query, Without)>) { - for entity in query.iter() { + for entity in &query { commands.entity(entity).insert(Velocity { linvel: Vec2::ZERO, ..default() diff --git a/src/pathfinding.rs b/src/pathfinding.rs index ce5c047..f324451 100644 --- a/src/pathfinding.rs +++ b/src/pathfinding.rs @@ -244,7 +244,7 @@ fn calculate_path( } fn poll_tasks(mut commands: Commands, mut query: Query<(Entity, &mut Calculating)>) { - for (entity, mut calculating) in query.iter_mut() { + for (entity, mut calculating) in &mut query { if let Some(result) = future::block_on(future::poll_once(&mut **calculating)) { if let Some(path) = result { trace!("{entity:?}: Path: {path:?}"); diff --git a/src/pitch_shift.rs b/src/pitch_shift.rs index 8c20f69..656bec4 100644 --- a/src/pitch_shift.rs +++ b/src/pitch_shift.rs @@ -22,7 +22,7 @@ fn tag_behind( if config.downshift_behind { if let Ok(listener_transform) = listener.get_single() { let listener_forward = listener_transform.forward(); - for (entity, transform, sound, icon) in sounds.iter() { + for (entity, transform, sound, icon) in &sounds { if icon.is_none() && sound.is_none() { continue; } @@ -41,7 +41,7 @@ fn tag_behind( } } } else { - for entity in behind.iter() { + for entity in &behind { commands.run_if_exists(entity, |mut entity| { entity.remove::(); }); @@ -61,7 +61,7 @@ fn behind_added( mut last_sound_pitch: ResMut, mut query: Query<(Entity, Option<&mut SoundIcon>, Option<&mut Sound>), Added>, ) { - for (entity, icon, sound) in query.iter_mut() { + for (entity, icon, sound) in &mut query { if let Some(mut icon) = icon { icon.pitch *= config.downshift; last_icon_pitch.insert(entity, icon.pitch); @@ -97,7 +97,7 @@ fn sound_icon_changed( mut last_icon_pitch: ResMut, mut icons: Query<(Entity, &mut SoundIcon), (With, Changed)>, ) { - for (entity, mut icon) in icons.iter_mut() { + for (entity, mut icon) in &mut icons { let should_change = if let Some(pitch) = last_icon_pitch.get(&entity) { *pitch != icon.pitch } else { @@ -115,7 +115,7 @@ fn sound_changed( mut last_sound_pitch: ResMut, mut sounds: Query<(Entity, &mut Sound), (With, Without, Changed)>, ) { - for (entity, mut sound) in sounds.iter_mut() { + for (entity, mut sound) in &mut sounds { let should_change = if let Some(pitch) = last_sound_pitch.get(&entity) { *pitch != sound.pitch } else { @@ -134,7 +134,7 @@ fn sync_config( behind: Query>, ) { if config.is_changed() { - for entity in behind.iter() { + for entity in &behind { commands.entity(entity).remove::(); } } diff --git a/src/sound/footstep.rs b/src/sound/footstep.rs index 625c8b3..b105ac6 100644 --- a/src/sound/footstep.rs +++ b/src/sound/footstep.rs @@ -29,7 +29,7 @@ impl Default for Footstep { } fn added(mut commands: Commands, footsteps: Query<(Entity, &Footstep), Added>) { - for (entity, footstep) in footsteps.iter() { + for (entity, footstep) in &footsteps { let buffer = footstep.buffer.clone(); commands.run_if_exists(entity, move |mut entity| { entity.insert(Sound { @@ -46,7 +46,7 @@ fn update( mut footsteps: Query<(Entity, &Footstep, &Parent, &mut Sound)>, transforms_storage: Query<&GlobalTransform>, ) { - for (entity, footstep, parent, mut sound) in footsteps.iter_mut() { + for (entity, footstep, parent, mut sound) in &mut footsteps { if let Ok(transform) = transforms_storage.get(**parent) { if let Some(last) = last_step_distance.get(&entity) { let distance = last.0 + (last.1.distance(transform)); diff --git a/src/sound/icon.rs b/src/sound/icon.rs index f0f6711..932a618 100644 --- a/src/sound/icon.rs +++ b/src/sound/icon.rs @@ -39,7 +39,7 @@ impl Default for SoundIcon { } fn added(mut commands: Commands, icons: Query<(Entity, &SoundIcon), Added>) { - for (entity, icon) in icons.iter() { + for (entity, icon) in &icons { let buffer = icon.buffer.clone(); let gain = icon.gain; let pitch = icon.pitch; @@ -75,8 +75,8 @@ fn update( if !config.states.is_empty() && !config.states.contains(&state.0) { return; } - for visible in viewers.iter() { - for (icon_entity, mut icon, visibility, parent, mut sound) in icons.iter_mut() { + for visible in &viewers { + for (icon_entity, mut icon, visibility, parent, mut sound) in &mut icons { let entity = if visibility.is_some() { Some(icon_entity) } else if parent.is_some() { @@ -118,7 +118,7 @@ fn exploration_focus_changed( mut icons: Query<&mut SoundIcon>, ) { const ICON_GAIN: f64 = 3.; - for (entity, children) in focused.iter_mut() { + for (entity, children) in &mut focused { if let Ok(mut icon) = icons.get_mut(entity) { icon.gain *= ICON_GAIN; } diff --git a/src/sound/mod.rs b/src/sound/mod.rs index fccd4c2..6a7b42f 100644 --- a/src/sound/mod.rs +++ b/src/sound/mod.rs @@ -10,7 +10,7 @@ pub use volumetric::Volumetric; /*fn scale_sounds(config: Res, mut sounds: Query<&mut Sound>) { let pixels_per_unit = config.pixels_per_unit as f32; - for mut sound in sounds.iter_mut() { + for mut sound in &mut sounds { sound.reference_distance *= pixels_per_unit; if sound.max_distance != f32::MAX { sound.max_distance *= pixels_per_unit; diff --git a/src/visibility.rs b/src/visibility.rs index c4dfe1f..1e30026 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -253,7 +253,7 @@ fn add_visibility_indices( map_config: Res>, query: Query<(Entity, &Map), (Added>, Without)>, ) { - for (entity, map) in query.iter() { + for (entity, map) in &query { let count = map.width * map.height; commands .entity(entity) @@ -314,8 +314,7 @@ fn update_viewshed( return; } let mut cache = HashMap::new(); - for (viewer_entity, mut viewshed, mut visible_entities, viewer_transform) in viewers.iter_mut() - { + for (viewer_entity, mut viewshed, mut visible_entities, viewer_transform) in &mut viewers { viewshed.update( &viewer_entity, &mut visible_entities, @@ -345,7 +344,7 @@ fn remove_visible( if !removed.is_empty() { let mut cache = HashMap::new(); for removed in &mut removed { - for (viewer_entity, mut viewshed, mut visible_entities, start) in viewers.iter_mut() { + for (viewer_entity, mut viewshed, mut visible_entities, start) in &mut viewers { if !visible_entities.contains(&removed) { continue; } @@ -369,8 +368,8 @@ fn update_revealed_tiles( mut map: Query<(&Map, &mut RevealedTiles)>, viewers: Query<&Viewshed, (With, Changed)>, ) { - for viewshed in viewers.iter() { - for (map, mut revealed_tiles) in map.iter_mut() { + for viewshed in &viewers { + for (map, mut revealed_tiles) in &mut map { for v in viewshed.visible_points.iter() { let idx = v.to_index(map.width); if idx >= revealed_tiles.len() {