From 6e34161f6f4f8e840399f11ccd1cec0aff05281a Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Sat, 6 Aug 2022 11:07:43 -0500 Subject: [PATCH] cargo fmt --- src/lib.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6cd1b40..13c4f49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -284,19 +284,25 @@ fn add_generator( fn add_sound_without_source( mut commands: Commands, - query: Query<(Entity, Option<&Parent>), (Added, Without)>, + query: Query< + (Entity, Option<&Parent>, Option<&GlobalTransform>), + (Added, Without), + >, parents: Query<&Parent>, sources: Query<&Source>, transforms: Query<&GlobalTransform>, ) { - for (entity, parent) in &query { + for (entity, parent, transform) in &query { + let should_check_for_transform = transform.is_none(); let mut has_transform = false; let source = if let Some(parent) = parent { - has_transform = transforms.get(**parent).is_ok(); + if should_check_for_transform { + has_transform = transforms.get(**parent).is_ok(); + } let mut target = None; let mut parent: Option<&Parent> = Some(parent); while let Some(p) = parent { - if !has_transform { + if should_check_for_transform && !has_transform { has_transform = transforms.get(**p).is_ok(); } if sources.get(**p).is_ok() { @@ -312,7 +318,9 @@ fn add_sound_without_source( if source.is_none() { let id = commands.entity(entity).insert(Source::default()).id(); if has_transform { - commands.entity(id).insert_bundle(TransformBundle::default()); + commands + .entity(id) + .insert_bundle(TransformBundle::default()); } } }