From d2ee73e74ad65a4a21a1450e880fbfd7eade1005 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Fri, 5 Jan 2024 00:12:05 -0600 Subject: [PATCH] no more attaching cargo to cargo --- server/src/main.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index cbe91a6d2d91802134452b684e5ddb580dd34160..5a8fd6f1a1596ce48697077e38e1e885216c955c 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -199,7 +199,7 @@ fn on_message( (Without, Without, Without), >, mut attached_query: Query< - (Entity, &PartType, &mut Transform, &mut Attach, &Velocity), + (Entity, &PartType, &mut Transform, &mut Attach, &Velocity, Option<&CanAttach>), (Without, Without), >, mut player_query: Query< @@ -325,7 +325,7 @@ fn on_message( }, )); } - for (entity, part_type, transform, _, _) in &attached_query { + for (entity, part_type, transform, _, _, _) in &attached_query { parts.push(( entity.index(), Part { @@ -613,7 +613,7 @@ fn on_message( vec3(x / SCALE, y / SCALE, 0.); break; } - for (entity, part_type, transform, _m_attach, _velocity) in + for (entity, part_type, transform, _m_attach, _velocity, _) in &attached_query { let pos = transform.translation; @@ -681,21 +681,21 @@ fn detach_recursive( commands: &mut Commands, attach: Attach, attached_query: &mut Query< - (Entity, &PartType, &mut Transform, &mut Attach, &Velocity), + (Entity, &PartType, &mut Transform, &mut Attach, &Velocity, Option<&CanAttach>), (Without, Without), >, ) { for child in attach.children { if let Some(child) = child { { - let (entity, _part_type, _transform, attach, _velocity) = + let (entity, _part_type, _transform, attach, _velocity, _) = attached_query.get(child).unwrap(); commands.entity(entity).remove::(); commands.entity(entity).remove::(); detach_recursive(commands, attach.clone(), attached_query); } - let (entity, _part_type, _transform, attach, _velocity) = + let (entity, _part_type, _transform, attach, _velocity, _) = attached_query.get_mut(child).unwrap(); let parent = attach.parent.unwrap(); if attached_query.contains(parent) { @@ -720,7 +720,7 @@ fn attach_on_module_tree( attach: Attach, select: Entity, attached_query: &mut Query< - (Entity, &PartType, &mut Transform, &mut Attach, &Velocity), + (Entity, &PartType, &mut Transform, &mut Attach, &Velocity, Option<&CanAttach>), (Without, Without), >, part_query: &mut Query< @@ -731,7 +731,7 @@ fn attach_on_module_tree( let mut ret = false; for child in attach.children { if let Some(child) = child { - let (entity, _part_type, transform, mut attach, velocity) = + let (entity, _part_type, transform, mut attach, velocity, can_attach) = attached_query.get_mut(child).unwrap(); let p_pos = transform.translation; @@ -742,7 +742,9 @@ fn attach_on_module_tree( rel_x * (-angle).sin() + rel_y * (-angle).cos(), ); let mut module = part_query.get_mut(select).unwrap(); + let attachable = can_attach != None; if attach.children[2] == None + && attachable && 15. / SCALE < rel_y && rel_y < 30. / SCALE && -20. / SCALE < rel_x @@ -766,6 +768,7 @@ fn attach_on_module_tree( attach.children[2] = Some(module.0); return true; } else if attach.children[1] == None + && attachable && -30. / SCALE < rel_x && rel_x < -15. / SCALE && -20. / SCALE < rel_y @@ -792,6 +795,7 @@ fn attach_on_module_tree( attach.children[1] = Some(module.0); return true; } else if attach.children[3] == None + && attachable && 15. / SCALE < rel_x && rel_x < 30. / SCALE && -20. / SCALE < rel_y @@ -956,7 +960,7 @@ fn convert_modules_recursive( let joint = PrismaticJointBuilder::new(Vec2::new(0., 1.)) .local_anchor1(Vec2::new(0., 0.)) .local_anchor2(Vec2::new(0., 0.)) - .motor_position(0., 32., 6.) + .motor_position(0., 150., 10.) .build(); let mut suspension = commands.spawn(PartBundle { transform: TransformBundle::from(*module_transform),