~starkingdoms/starkingdoms

d2ee73e74ad65a4a21a1450e880fbfd7eade1005 — ghostlyzsh 1 year, 11 months ago 4b1c9e1
no more attaching cargo to cargo
1 files changed, 13 insertions(+), 9 deletions(-)

M server/src/main.rs
M server/src/main.rs => server/src/main.rs +13 -9
@@ 199,7 199,7 @@ fn on_message(
        (Without<PlanetType>, Without<Player>, Without<Attach>),
    >,
    mut attached_query: Query<
        (Entity, &PartType, &mut Transform, &mut Attach, &Velocity),
        (Entity, &PartType, &mut Transform, &mut Attach, &Velocity, Option<&CanAttach>),
        (Without<PlanetType>, Without<Player>),
    >,
    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<PlanetType>, Without<Player>),
    >,
) {
    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::<ImpulseJoint>();
                commands.entity(entity).remove::<Attach>();

                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<PlanetType>, Without<Player>),
    >,
    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),