From 9f34e42b7dd9581502df9d3dd659ddad355153e7 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Thu, 4 Jan 2024 23:46:06 -0600 Subject: [PATCH] what is git doing --- server/src/main.rs | 87 ++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index a968923529b5ed2148cf14be5aa10e4aa1c76327..cbe91a6d2d91802134452b684e5ddb580dd34160 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -131,7 +131,8 @@ fn spawn_planets(mut commands: Commands) { .insert(AdditionalMassProperties::Mass(MARS_MASS)) .insert(ReadMassProperties::default()) .with_children(|children| { - children.spawn(Collider::ball((MARS_SIZE + 3.) / SCALE)) + children + .spawn(Collider::ball((MARS_SIZE + 3.) / SCALE)) .insert(ActiveEvents::COLLISION_EVENTS) .insert(Sensor); }) @@ -278,7 +279,7 @@ fn on_message( radius: match *planet_type { PlanetType::Earth => EARTH_SIZE, PlanetType::Moon => MOON_SIZE, - PlanetType::Mars => MARS_SIZE + PlanetType::Mars => MARS_SIZE, }, }, )); @@ -837,8 +838,14 @@ fn convert_modules( rapier_context: Res, planet_query: Query<(Entity, &PlanetType, &Children)>, player_query: Query<&Attach, With>, - mut attached_query: Query<(Entity, &mut PartType, &mut Attach, &Children, &Transform), Without>, - mut collider_query: Query<(&mut Collider, &mut Transform, &Parent), (Without, Without)>, + mut attached_query: Query< + (Entity, &mut PartType, &mut Attach, &Children, &Transform), + Without, + >, + mut collider_query: Query< + (&mut Collider, &mut Transform, &Parent), + (Without, Without), + >, mut packet_send: EventWriter, ) { for (_planet_entity, planet_type, children) in &planet_query { @@ -893,13 +900,20 @@ fn convert_modules_recursive( commands: &mut Commands, planet_type: PlanetType, attach: Attach, - attached_query: &mut Query<(Entity, &mut PartType, &mut Attach, &Children, &Transform), Without>, - collider_query: &mut Query<(&mut Collider, &mut Transform, &Parent), (Without, Without)>, + attached_query: &mut Query< + (Entity, &mut PartType, &mut Attach, &Children, &Transform), + Without, + >, + collider_query: &mut Query< + (&mut Collider, &mut Transform, &Parent), + (Without, Without), + >, packet_send: &mut EventWriter, ) { for child in attach.children { if let Some(child) = child { - let (module_entity, mut part_type, mut attach, children, module_transform) = attached_query.get_mut(child).unwrap(); + let (module_entity, mut part_type, mut attach, children, module_transform) = + attached_query.get_mut(child).unwrap(); if *part_type == PartType::Cargo { match planet_type { PlanetType::Mars => { @@ -909,8 +923,14 @@ fn convert_modules_recursive( *collider = Collider::cuboid(PART_HALF_SIZE / SCALE, PART_HALF_SIZE / SCALE); *transform = Transform::from_xyz(0., 0., 0.); - commands.get_entity(module_entity).unwrap().remove::(); - commands.get_entity(module_entity).unwrap().insert(CanAttach(15)); + commands + .get_entity(module_entity) + .unwrap() + .remove::(); + commands + .get_entity(module_entity) + .unwrap() + .insert(CanAttach(15)); let packet = Packet::DespawnPart { id: child.index() }; let buf = serde_json::to_vec(&packet).unwrap(); packet_send.send(ServerEvent::Broadcast(MessageType::Text, buf.clone())); @@ -930,8 +950,7 @@ fn convert_modules_recursive( *part_type = PartType::LandingThruster; let (mut collider, mut transform, _) = collider_query.get_mut(*children.first().unwrap()).unwrap(); - *collider = - Collider::cuboid(PART_HALF_SIZE / SCALE, 18.75 / SCALE); + *collider = Collider::cuboid(PART_HALF_SIZE / SCALE, 18.75 / SCALE); *transform = Transform::from_xyz(0., 6.25 / SCALE, 0.); //commands.get_entity(module_entity).unwrap().remove::(); let joint = PrismaticJointBuilder::new(Vec2::new(0., 1.)) @@ -943,29 +962,29 @@ fn convert_modules_recursive( transform: TransformBundle::from(*module_transform), part_type: PartType::LandingThrusterSuspension, }); - suspension.insert(RigidBody::Dynamic) - .with_children(|children| { - children - .spawn(Collider::cuboid(PART_HALF_SIZE / SCALE, 1. / SCALE)) - .insert(TransformBundle::from(Transform::from_xyz( - 0., - -24. / SCALE, - 0., - ))); - }) - .insert(ImpulseJoint::new(module_entity, joint)) - .insert(ExternalForce::default()) - .insert(ExternalImpulse::default()) - .insert(Velocity::default()) - .insert(ReadMassProperties::default()) - .insert(Attach { - associated_player: attach.associated_player, - parent: Some(module_entity), - children: [None, None, None, None], - }); + suspension + .insert(RigidBody::Dynamic) + .with_children(|children| { + children + .spawn(Collider::cuboid(PART_HALF_SIZE / SCALE, 1. / SCALE)) + .insert(TransformBundle::from(Transform::from_xyz( + 0., + -24. / SCALE, + 0., + ))); + }) + .insert(ImpulseJoint::new(module_entity, joint)) + .insert(ExternalForce::default()) + .insert(ExternalImpulse::default()) + .insert(Velocity::default()) + .insert(ReadMassProperties::default()) + .insert(Attach { + associated_player: attach.associated_player, + parent: Some(module_entity), + children: [None, None, None, None], + }); attach.children[2] = Some(suspension.id()); - let packet = Packet::DespawnPart { id: child.index() }; let buf = serde_json::to_vec(&packet).unwrap(); packet_send.send(ServerEvent::Broadcast(MessageType::Text, buf.clone())); @@ -985,8 +1004,8 @@ fn convert_modules_recursive( id: suspension.id().index(), part: Part { part_type: PartType::LandingThrusterSuspension, - transform: proto_transform!(transform) - } + transform: proto_transform!(transform), + }, }; let buf = serde_json::to_vec(&packet).unwrap(); packet_send.send(ServerEvent::Broadcast(MessageType::Text, buf));