From 64fd169ba264cdfd0423ae453ab08904ab0e55bc Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 12 May 2022 10:46:32 -0500 Subject: [PATCH] Trigger icon check based on visibility, not presence of coordinates. --- src/sound.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/sound.rs b/src/sound.rs index 9bbf164..1cff0c0 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -9,7 +9,7 @@ use crate::{ commands::RunIfExistsExt, core::{CoreConfig, Player, PointLike}, exploration::ExplorationFocused, - visibility::VisibleEntities, + visibility::{Visible, VisibleEntities}, }; #[derive(Component, Clone, Debug, Reflect)] @@ -92,12 +92,10 @@ fn add_footstep_sounds( ) { for (entity, footstep) in footsteps.iter() { let buffer = assets.get_handle(footstep.sound); - let gain = footstep.gain; commands.run_if_exists(entity, move |mut entity| { entity.insert(Sound { buffer, state: SoundState::Stopped, - gain, ..default() }); }); @@ -172,7 +170,7 @@ fn sound_icon( mut icons: Query<( Entity, &mut SoundIcon, - Option<&Transform>, + Option<&Visible>, Option<&Parent>, &mut Sound, )>, @@ -186,8 +184,8 @@ fn sound_icon( return; } for visible in viewers.iter() { - for (icon_entity, mut icon, coordinates, parent, mut sound) in icons.iter_mut() { - let entity = if coordinates.is_some() { + for (icon_entity, mut icon, visibility, parent, mut sound) in icons.iter_mut() { + let entity = if visibility.is_some() { icon_entity } else { **parent.unwrap()