Merge branch 'main' into synthizer

This commit is contained in:
Nolan Darilek 2022-05-31 10:38:05 -05:00
commit b2e4f9b729

View File

@ -121,13 +121,15 @@ fn update<S>(
) in icons.iter_mut() ) in icons.iter_mut()
{ {
let entity = if visibility.is_some() { let entity = if visibility.is_some() {
icon_entity Some(icon_entity)
} else if parent.is_some() {
Some(**parent.unwrap())
} else { } else {
**parent.unwrap() None
}; };
if let Some(entity) = entity {
if visible.contains(&entity) { if visible.contains(&entity) {
let looping = sound.looping; if sound.looping {
if looping {
sound.paused = false; sound.paused = false;
} else if let Some(interval) = icon.interval.as_mut() { } else if let Some(interval) = icon.interval.as_mut() {
interval.tick(time.delta()); interval.tick(time.delta());
@ -138,12 +140,12 @@ fn update<S>(
} }
} }
let buffer = asset_server.get_handle(icon.sound); let buffer = asset_server.get_handle(icon.sound);
sound.looping = icon.interval.is_none();
if sound.buffer != buffer { if sound.buffer != buffer {
sound.buffer = buffer; sound.buffer = buffer;
} }
sound.gain = icon.gain; sound.gain = icon.gain;
sound.pitch = icon.pitch; sound.pitch = icon.pitch;
sound.looping = icon.interval.is_none();
if let Some(v) = icon.reference_distance { if let Some(v) = icon.reference_distance {
let insert = if let Some(v2) = distance_ref { let insert = if let Some(v2) = distance_ref {
v != **v2 v != **v2
@ -192,6 +194,7 @@ fn update<S>(
entity.remove::<Rolloff>(); entity.remove::<Rolloff>();
}); });
} }
}
} else { } else {
sound.paused = true; sound.paused = true;
} }