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