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,
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<S>(
mut icons: Query<(
Entity,
&mut SoundIcon,
Option<&Transform>,
Option<&Visible>,
Option<&Parent>,
&mut Sound,
)>,
@ -186,8 +184,8 @@ fn sound_icon<S>(
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()