Reset source when panner strategy changes or is removed.

This commit is contained in:
Nolan Darilek 2022-06-13 09:24:30 -05:00
parent 28718d2e85
commit 5615a28ece

View File

@ -199,6 +199,27 @@ fn swap_buffers(
}
}
fn change_panner_strategy(
changed: Query<Entity, Changed<PannerStrategy>>,
removed: RemovedComponents<PannerStrategy>,
mut sounds: Query<&mut Sound>,
) {
let mut check = vec![];
for entity in changed.iter() {
check.push(entity);
}
for entity in removed.iter() {
check.push(entity);
}
for entity in check.iter() {
if let Ok(mut sound) = sounds.get_mut(*entity) {
if sound.source.is_some() {
sound.source = None;
}
}
}
}
pub fn update_sound_properties(
context: Res<syz::Context>,
buffers: Res<Assets<Buffer>>,
@ -571,6 +592,10 @@ impl Plugin for SynthizerPlugin {
CoreStage::PostUpdate,
swap_buffers.before(update_sound_properties),
)
.add_system_to_stage(
CoreStage::PostUpdate,
change_panner_strategy.before(update_sound_properties),
)
.add_system_to_stage(
CoreStage::PostUpdate,
update_listener