From b7300c2a478de07b4d6fe60439fb9d3ac68fca32 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Thu, 4 Jan 2024 20:39:35 -0600 Subject: [PATCH] can now convert by touching cargo against planet --- server/src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 0ffc63f9c93a246dad13b7ce0e596c3e260b51d7..98080b8b5261ea225e83b5f5a9aeeaff30a67fde 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -819,7 +819,7 @@ fn convert_modules( planet_query: Query<(Entity, &PlanetType, &Children)>, player_query: Query<&Attach, With>, mut attached_query: Query<(&mut PartType, &Attach, &Children), Without>, - mut collider_query: Query<(&mut Collider, &mut Transform)>, + mut collider_query: Query<(&mut Collider, &mut Transform, &Parent)>, mut packet_send: EventWriter, ) { for (_planet_entity, planet_type, children) in &planet_query { @@ -834,6 +834,11 @@ fn convert_modules( other } else if attached_query.contains(other) { attached_query.get(other).unwrap().1.associated_player.unwrap() + } else if collider_query.contains(other) { + let parent = collider_query.get(other).unwrap().2.get(); + if attached_query.contains(parent) { + attached_query.get(parent).unwrap().1.associated_player.unwrap() + } else { continue } } else { continue }; let player_attach = player_query.get(player_entity).unwrap(); convert_modules_recursive(*planet_type, player_attach.clone(), &mut attached_query, &mut collider_query, &mut packet_send); @@ -846,10 +851,9 @@ fn convert_modules_recursive( planet_type: PlanetType, attach: Attach, attached_query: &mut Query<(&mut PartType, &Attach, &Children), Without>, - collider_query: &mut Query<(&mut Collider, &mut Transform)>, + collider_query: &mut Query<(&mut Collider, &mut Transform, &Parent)>, packet_send: &mut EventWriter, ) { - //println!("here"); for child in attach.children { if let Some(child) = child { let (mut part_type, attach, children) = attached_query.get_mut(child).unwrap(); @@ -857,7 +861,7 @@ fn convert_modules_recursive( match planet_type { PlanetType::Moon => { *part_type = PartType::Hub; - let (mut collider, mut transform) = collider_query.get_mut(*children.first().unwrap()).unwrap(); + let (mut collider, mut transform, _) = collider_query.get_mut(*children.first().unwrap()).unwrap(); *collider = Collider::cuboid(PART_HALF_SIZE / SCALE, PART_HALF_SIZE / SCALE); *transform = Transform::from_xyz(0., 0., 0.); let packet = Packet::DespawnPart {