From ef55419bb770b3968bc3c8c6365e847ba63552ae Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 11 May 2022 14:41:17 -0500 Subject: [PATCH] Restore transforms so portals' transforms update correctly, and don't add children twice. --- src/map.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/map.rs b/src/map.rs index 7b84f74..73187e5 100644 --- a/src/map.rs +++ b/src/map.rs @@ -134,6 +134,8 @@ pub struct MapBundle { pub spawn_colliders: SpawnColliders, pub spawn_collider_per_tile: SpawnColliderPerTile, pub spawn_portals: SpawnPortals, + pub transform: Transform, + pub global_transform: GlobalTransform, } pub struct GridBuilder { @@ -363,9 +365,9 @@ fn spawn_portals( mut commands: Commands, map: Query<(Entity, &Map, &SpawnPortals), Changed>, ) { - for (entity, map, spawn_portals) in map.iter() { + for (map_entity, map, spawn_portals) in map.iter() { if **spawn_portals { - commands.entity(entity).remove::(); + commands.entity(map_entity).remove::(); let mut portals: Vec<(f32, f32)> = vec![]; for x in 1..map.width { for y in 1..map.height { @@ -407,7 +409,7 @@ fn spawn_portals( ..default() }) .id(); - commands.entity(entity).push_children(&[portal]); + commands.entity(map_entity).push_children(&[portal]); } } } @@ -415,10 +417,10 @@ fn spawn_portals( fn spawn_portal_colliders( mut commands: Commands, - map: Query<(Entity, &SpawnColliders), With>>, + map: Query<&SpawnColliders, With>>, portals: Query<(Entity, &Transform), (With, Without)>, ) { - for (map_entity, spawn_colliders) in map.iter() { + for spawn_colliders in map.iter() { if **spawn_colliders { for (portal_entity, coordinates) in portals.iter() { let position = Vec2::new(coordinates.x() + 0.5, coordinates.y() + 0.5); @@ -428,7 +430,6 @@ fn spawn_portal_colliders( .insert(Collider::cuboid(0.5, 0.5)) .insert(Sensor(true)) .insert(ActiveEvents::COLLISION_EVENTS); - commands.entity(map_entity).push_children(&[portal_entity]); } } }