More aggressively find sound icons when exploring.

This commit is contained in:
Nolan Darilek 2021-10-07 11:41:57 -05:00
parent 78e9e8b680
commit 8f76bf716f

View File

@ -204,22 +204,40 @@ fn sound_icon<S>(
} }
fn sound_icon_exploration_focus_changed( fn sound_icon_exploration_focus_changed(
mut focused: Query<(&ExplorationFocused, Option<&mut SoundIcon>), Changed<ExplorationFocused>>, mut focused: Query<(Entity, Option<&Children>), Changed<ExplorationFocused>>,
mut icons: Query<&mut SoundIcon>,
) { ) {
for (_, icon) in focused.iter_mut() { const ICON_GAIN: f32 = 3.;
if let Some(mut icon) = icon { for (entity, children) in focused.iter_mut() {
icon.gain *= 3.; 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( fn sound_icon_exploration_focus_removed(
removed: RemovedComponents<ExplorationFocused>, removed: RemovedComponents<ExplorationFocused>,
mut icons: Query<&mut SoundIcon>, mut query: Query<&mut SoundIcon>,
children: Query<&Children>,
) { ) {
const ICON_GAIN: f32 = 3.;
for entity in removed.iter() { for entity in removed.iter() {
if let Ok(mut icon) = icons.get_component_mut::<SoundIcon>(entity) { if let Ok(mut icon) = query.get_mut(entity) {
icon.gain /= 3.; 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;
}
}
} }
} }
} }