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,76 +121,79 @@ 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 visible.contains(&entity) { if let Some(entity) = entity {
let looping = sound.looping; if visible.contains(&entity) {
if looping { if sound.looping {
sound.paused = false;
} else if let Some(interval) = icon.interval.as_mut() {
interval.tick(time.delta());
if interval.finished() {
sound.paused = false; sound.paused = false;
sound.restart = true; } else if let Some(interval) = icon.interval.as_mut() {
interval.reset(); interval.tick(time.delta());
if interval.finished() {
sound.paused = false;
sound.restart = true;
interval.reset();
}
} }
} let buffer = asset_server.get_handle(icon.sound);
let buffer = asset_server.get_handle(icon.sound); if sound.buffer != buffer {
sound.looping = icon.interval.is_none(); sound.buffer = buffer;
if sound.buffer != buffer {
sound.buffer = buffer;
}
sound.gain = icon.gain;
sound.pitch = icon.pitch;
if let Some(v) = icon.reference_distance {
let insert = if let Some(v2) = distance_ref {
v != **v2
} else {
true
};
if insert {
commands.run_if_exists(icon_entity, move |mut entity| {
entity.insert(DistanceRef(v));
})
} }
} else if distance_ref.is_some() { sound.gain = icon.gain;
commands.run_if_exists(icon_entity, |mut entity| { sound.pitch = icon.pitch;
entity.remove::<DistanceRef>(); sound.looping = icon.interval.is_none();
}); if let Some(v) = icon.reference_distance {
} let insert = if let Some(v2) = distance_ref {
if let Some(v) = icon.max_distance { v != **v2
let insert = if let Some(v2) = distance_max { } else {
v != **v2 true
} else { };
true if insert {
}; commands.run_if_exists(icon_entity, move |mut entity| {
if insert { entity.insert(DistanceRef(v));
commands.run_if_exists(icon_entity, move |mut entity| { })
entity.insert(DistanceMax(v)); }
}) } else if distance_ref.is_some() {
commands.run_if_exists(icon_entity, |mut entity| {
entity.remove::<DistanceRef>();
});
} }
} else if distance_max.is_some() { if let Some(v) = icon.max_distance {
commands.run_if_exists(icon_entity, |mut entity| { let insert = if let Some(v2) = distance_max {
entity.remove::<DistanceMax>(); v != **v2
}); } else {
} true
if let Some(v) = icon.rolloff { };
let insert = if let Some(v2) = rolloff { if insert {
v != **v2 commands.run_if_exists(icon_entity, move |mut entity| {
} else { entity.insert(DistanceMax(v));
true })
}; }
if insert { } else if distance_max.is_some() {
commands.run_if_exists(icon_entity, move |mut entity| { commands.run_if_exists(icon_entity, |mut entity| {
entity.insert(Rolloff(v)); entity.remove::<DistanceMax>();
}) });
}
if let Some(v) = icon.rolloff {
let insert = if let Some(v2) = rolloff {
v != **v2
} else {
true
};
if insert {
commands.run_if_exists(icon_entity, move |mut entity| {
entity.insert(Rolloff(v));
})
}
} else if rolloff.is_some() {
commands.run_if_exists(icon_entity, |mut entity| {
entity.remove::<Rolloff>();
});
} }
} else if rolloff.is_some() {
commands.run_if_exists(icon_entity, |mut entity| {
entity.remove::<Rolloff>();
});
} }
} else { } else {
sound.paused = true; sound.paused = true;