Add option check.
This commit is contained in:
parent
1022037efe
commit
a26cf344d6
|
@ -101,31 +101,35 @@ fn update<S>(
|
||||||
for visible in viewers.iter() {
|
for visible in viewers.iter() {
|
||||||
for (icon_entity, mut icon, visibility, parent, mut sound) in icons.iter_mut() {
|
for (icon_entity, mut icon, visibility, parent, mut sound) 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 visible.contains(&entity) {
|
if let Some(entity) = entity {
|
||||||
let looping = sound.looping;
|
if visible.contains(&entity) {
|
||||||
if looping {
|
let looping = sound.looping;
|
||||||
sound.state = SoundState::Playing;
|
if looping {
|
||||||
} else if let Some(interval) = icon.interval.as_mut() {
|
|
||||||
interval.tick(time.delta());
|
|
||||||
if interval.finished() {
|
|
||||||
sound.state = SoundState::Playing;
|
sound.state = SoundState::Playing;
|
||||||
interval.reset();
|
} else if let Some(interval) = icon.interval.as_mut() {
|
||||||
|
interval.tick(time.delta());
|
||||||
|
if interval.finished() {
|
||||||
|
sound.state = SoundState::Playing;
|
||||||
|
interval.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
let buffer = buffers.get_handle(icon.sound);
|
||||||
|
sound.looping = icon.interval.is_none();
|
||||||
|
if sound.buffer != buffer {
|
||||||
|
sound.buffer = buffer;
|
||||||
|
}
|
||||||
|
sound.gain = icon.gain;
|
||||||
|
sound.pitch = icon.pitch;
|
||||||
|
sound.reference_distance = icon.reference_distance;
|
||||||
|
sound.max_distance = icon.max_distance;
|
||||||
|
sound.rolloff_factor = icon.rolloff_factor;
|
||||||
}
|
}
|
||||||
let buffer = buffers.get_handle(icon.sound);
|
|
||||||
sound.looping = icon.interval.is_none();
|
|
||||||
if sound.buffer != buffer {
|
|
||||||
sound.buffer = buffer;
|
|
||||||
}
|
|
||||||
sound.gain = icon.gain;
|
|
||||||
sound.pitch = icon.pitch;
|
|
||||||
sound.reference_distance = icon.reference_distance;
|
|
||||||
sound.max_distance = icon.max_distance;
|
|
||||||
sound.rolloff_factor = icon.rolloff_factor;
|
|
||||||
} else {
|
} else {
|
||||||
sound.state = SoundState::Stopped;
|
sound.state = SoundState::Stopped;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user