Trigger icon check based on visibility, not presence of coordinates.

This commit is contained in:
Nolan Darilek 2022-05-12 10:46:32 -05:00
parent 7e6fd923a3
commit 64fd169ba2

View File

@ -9,7 +9,7 @@ use crate::{
commands::RunIfExistsExt, commands::RunIfExistsExt,
core::{CoreConfig, Player, PointLike}, core::{CoreConfig, Player, PointLike},
exploration::ExplorationFocused, exploration::ExplorationFocused,
visibility::VisibleEntities, visibility::{Visible, VisibleEntities},
}; };
#[derive(Component, Clone, Debug, Reflect)] #[derive(Component, Clone, Debug, Reflect)]
@ -92,12 +92,10 @@ fn add_footstep_sounds(
) { ) {
for (entity, footstep) in footsteps.iter() { for (entity, footstep) in footsteps.iter() {
let buffer = assets.get_handle(footstep.sound); let buffer = assets.get_handle(footstep.sound);
let gain = footstep.gain;
commands.run_if_exists(entity, move |mut entity| { commands.run_if_exists(entity, move |mut entity| {
entity.insert(Sound { entity.insert(Sound {
buffer, buffer,
state: SoundState::Stopped, state: SoundState::Stopped,
gain,
..default() ..default()
}); });
}); });
@ -172,7 +170,7 @@ fn sound_icon<S>(
mut icons: Query<( mut icons: Query<(
Entity, Entity,
&mut SoundIcon, &mut SoundIcon,
Option<&Transform>, Option<&Visible>,
Option<&Parent>, Option<&Parent>,
&mut Sound, &mut Sound,
)>, )>,
@ -186,8 +184,8 @@ fn sound_icon<S>(
return; return;
} }
for visible in viewers.iter() { for visible in viewers.iter() {
for (icon_entity, mut icon, coordinates, parent, mut sound) in icons.iter_mut() { for (icon_entity, mut icon, visibility, parent, mut sound) in icons.iter_mut() {
let entity = if coordinates.is_some() { let entity = if visibility.is_some() {
icon_entity icon_entity
} else { } else {
**parent.unwrap() **parent.unwrap()