From 64ed56fb411417366b5cab21ba0e627b170ff6d2 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Sun, 7 Jan 2024 23:28:35 -0600 Subject: [PATCH] fixed loaded module colliders --- server/src/main.rs | 57 +++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index e41fe08ff72916c93bb887b5710283b58295ad3e..0851f77a35337af63af06a2a94e6efa10bd1ae3d 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1055,10 +1055,22 @@ fn load_savefile( .insert(RigidBody::Dynamic) .with_children(|children| { children - .spawn(Collider::cuboid(18.75 / SCALE, 23.4375 / SCALE)) + .spawn(if part_type == PartType::Cargo { + Collider::cuboid(18.75 / SCALE, 23.4375 / SCALE) + } else if part_type == PartType::Hub { + Collider::cuboid(PART_HALF_SIZE / SCALE, PART_HALF_SIZE / SCALE) + } else if part_type == PartType::LandingThruster { + Collider::cuboid(PART_HALF_SIZE / SCALE, 18.75 / SCALE) + } else { Collider::cuboid(PART_HALF_SIZE / SCALE, PART_HALF_SIZE / SCALE) }) .insert(TransformBundle::from(Transform::from_xyz( 0., - 1.5625 / SCALE, + if part_type == PartType::Cargo { + 1.5625 / SCALE + } else if part_type == PartType::Hub { + 0. / SCALE + } else if part_type == PartType::LandingThruster { + 6.25 / SCALE + } else { 0. / SCALE }, 0., ))); }) @@ -1088,25 +1100,28 @@ fn load_savefile( .motor_position(0., 150., 10.) .limits([0., 50. / SCALE]) .build(); - let mut suspension = commands - .spawn(PartBundle { - transform: TransformBundle::from( - Transform::from_xyz( - p_pos.x + offset.x / SCALE * angle.cos() - offset.y / SCALE * angle.sin(), - p_pos.y + offset.x / SCALE * angle.sin() + offset.y / SCALE * angle.cos(), - 0., - ) - .with_rotation(Quat::from_euler( - EulerRot::ZYX, - angle + angle_offset, - 0., - 0., - )), - ), - part_type: PartType::LandingThrusterSuspension, - flags: PartFlags { attached: true}, - }); - suspension.insert(RigidBody::Dynamic) + let mut suspension = commands.spawn(PartBundle { + transform: TransformBundle::from( + Transform::from_xyz( + p_pos.x + offset.x / SCALE * angle.cos() + - offset.y / SCALE * angle.sin(), + p_pos.y + + offset.x / SCALE * angle.sin() + + offset.y / SCALE * angle.cos(), + 0., + ) + .with_rotation(Quat::from_euler( + EulerRot::ZYX, + angle + angle_offset, + 0., + 0., + )), + ), + part_type: PartType::LandingThrusterSuspension, + flags: PartFlags { attached: true }, + }); + suspension + .insert(RigidBody::Dynamic) .with_children(|children| { children .spawn(Collider::cuboid(PART_HALF_SIZE / SCALE, 1. / SCALE))