chore: Clean up code.

This commit is contained in:
Nolan Darilek 2023-10-16 07:23:15 -05:00
parent 2553ea9bc2
commit 53891eeaa8

View File

@ -276,8 +276,8 @@ fn add_generator(
if sound.generator.is_none() { if sound.generator.is_none() {
let mut source = if let Ok(s) = sources.get_mut(entity) { let mut source = if let Ok(s) = sources.get_mut(entity) {
Some(s) Some(s)
} else if let Some(parent) = parent { } else if parent.is_some() {
let mut parent: Option<&Parent> = Some(parent); let mut parent = parent;
let mut target = None; let mut target = None;
while let Some(p) = parent { while let Some(p) = parent {
if sources.get(**p).is_ok() { if sources.get(**p).is_ok() {
@ -357,7 +357,7 @@ fn swap_buffers(
) { ) {
for (entity, mut sound) in &mut query { for (entity, mut sound) in &mut query {
if let Some(l) = last_audio.get(&entity) { if let Some(l) = last_audio.get(&entity) {
if sound.audio != *l { if sound.generator.is_some() && sound.audio != *l {
sound.generator = None; sound.generator = None;
} }
} }
@ -667,11 +667,9 @@ fn events(
) { ) {
context.get_events().for_each(|event| { context.get_events().for_each(|event| {
if let Ok(event) = event { if let Ok(event) = event {
let mut matched = false;
for (entity, sound) in &sounds { for (entity, sound) in &sounds {
if let Some(generator) = &sound.generator { if let Some(generator) = &sound.generator {
if *generator.handle() == event.source { if *generator.handle() == event.source {
matched = true;
match event.r#type { match event.r#type {
syz::EventType::Finished => { syz::EventType::Finished => {
output.send(SynthizerEvent::Finished(entity)); output.send(SynthizerEvent::Finished(entity));
@ -685,9 +683,6 @@ fn events(
} }
} }
} }
if !matched {
println!("No match");
}
} }
}); });
} }