From be8a7634438a45a5018d63ab1cf47a4715def045 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Sat, 16 Mar 2024 12:13:12 -0500 Subject: [PATCH] Refactor to `commands.entity(...).with_children(...)`. --- src/map.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/map.rs b/src/map.rs index 05e01d2..89b8f35 100644 --- a/src/map.rs +++ b/src/map.rs @@ -220,8 +220,8 @@ fn spawn_colliders( let position = Isometry2::new(Vector2::new(room.center().x(), room.center().y()), 0.); let aabb = shape.raw.compute_aabb(&position); - let id = commands - .spawn(( + commands.entity(map_entity).with_children(|parent| { + parent.spawn(( TransformBundle::from_transform(Transform::from_xyz( position.translation.x, position.translation.y, @@ -232,9 +232,8 @@ fn spawn_colliders( ActiveEvents::COLLISION_EVENTS, Area(aabb), Zone, - )) - .id(); - commands.entity(map_entity).push_children(&[id]); + )); + }); } } } @@ -280,13 +279,12 @@ fn spawn_portals( } } for (x, y) in portals { - let portal = commands - .spawn(PortalBundle { + commands.entity(map_entity).with_children(|parent| { + parent.spawn(PortalBundle { transform: Transform::from_translation(Vec3::new(x, y, 0.)), ..default() - }) - .id(); - commands.entity(map_entity).push_children(&[portal]); + }); + }); } } }