diff --git a/src/sound.rs b/src/sound.rs index b9fb9ee..8911ad8 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -204,22 +204,40 @@ fn sound_icon( } fn sound_icon_exploration_focus_changed( - mut focused: Query<(&ExplorationFocused, Option<&mut SoundIcon>), Changed>, + mut focused: Query<(Entity, Option<&Children>), Changed>, + mut icons: Query<&mut SoundIcon>, ) { - for (_, icon) in focused.iter_mut() { - if let Some(mut icon) = icon { - icon.gain *= 3.; + const ICON_GAIN: f32 = 3.; + for (entity, children) in focused.iter_mut() { + if let Ok(mut icon) = icons.get_mut(entity) { + icon.gain *= ICON_GAIN; + } + if let Some(children) = children { + for child in children.iter() { + if let Ok(mut icon) = icons.get_mut(*child) { + icon.gain *= ICON_GAIN; + } + } } } } fn sound_icon_exploration_focus_removed( removed: RemovedComponents, - mut icons: Query<&mut SoundIcon>, + mut query: Query<&mut SoundIcon>, + children: Query<&Children>, ) { + const ICON_GAIN: f32 = 3.; for entity in removed.iter() { - if let Ok(mut icon) = icons.get_component_mut::(entity) { - icon.gain /= 3.; + if let Ok(mut icon) = query.get_mut(entity) { + icon.gain /= ICON_GAIN; + } + if let Ok(children) = children.get(entity) { + for child in children.iter() { + if let Ok(mut icon) = query.get_mut(*child) { + icon.gain *= ICON_GAIN; + } + } } } }