~starkingdoms/starkingdoms

913ef14a9fc364d89d5bc067b6033f731ecd3ec4 — ghostlyzsh 1 year, 11 months ago 1a32083
can no longer add two modules to one face
1 files changed, 12 insertions(+), 25 deletions(-)

M server/src/main.rs
M server/src/main.rs => server/src/main.rs +12 -25
@@ 356,7 356,7 @@ fn on_message(
                                        rel_x * (-angle).sin() + rel_y * (-angle).cos(),
                                    );

                                    if 15./SCALE < rel_y && rel_y < 30./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
                                    if attach.children[2] == None && 15./SCALE < rel_y && rel_y < 30./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
                                        module.2.translation = vec3(p_pos.x + 53./SCALE*angle.sin(), p_pos.y - 53./SCALE*angle.cos(), 0.);
                                        module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle, 0., 0.);
                                        module.3.linvel = velocity.linvel;


@@ 369,7 369,7 @@ fn on_message(
                                        });
                                        attach.children[2] = Some(module.0);
                                        break;
                                    } else if -30./SCALE < rel_y && rel_y < -15./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
                                    } else if attach.children[0] == None && -30./SCALE < rel_y && rel_y < -15./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
                                        module.2.translation = vec3(p_pos.x - 53./SCALE*angle.sin(), p_pos.y + 53./SCALE*angle.cos(), 0.);
                                        module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle + std::f32::consts::PI, 0., 0.);
                                        module.3.linvel = velocity.linvel;


@@ 382,7 382,7 @@ fn on_message(
                                        });
                                        attach.children[0] = Some(module.0);
                                        break;
                                    } else if -30./SCALE < rel_x && rel_x < -15./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
                                    } else if attach.children[1] == None && -30./SCALE < rel_x && rel_x < -15./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
                                        module.2.translation = vec3(p_pos.x + 53./SCALE*angle.cos(), p_pos.y + 53./SCALE*angle.sin(), 0.);
                                        module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle + (std::f32::consts::PI/2.), 0., 0.);
                                        module.3.linvel = velocity.linvel;


@@ 397,7 397,7 @@ fn on_message(
                                        });
                                        attach.children[1] = Some(module.0);
                                        break;
                                    } else if 15./SCALE < rel_x && rel_x < 30./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
                                    } else if attach.children[3] == None && 15./SCALE < rel_x && rel_x < 30./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
                                        module.2.translation = vec3(p_pos.x - 53./SCALE*angle.cos(), p_pos.y - 53./SCALE*angle.sin(), 0.);
                                        module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle - (std::f32::consts::PI/2.), 0., 0.);
                                        module.3.linvel = velocity.linvel;


@@ 410,7 410,7 @@ fn on_message(
                                            associated_player: Some(entity),
                                            children: [None, None, None, None],
                                        });
                                        attach.children[1] = Some(module.0);
                                        attach.children[3] = Some(module.0);
                                        break;
                                    }
                                }


@@ 477,33 477,20 @@ fn attach_on_module_tree(
                rel_x * (-angle).sin() + rel_y * (-angle).cos(),
            );
            let mut module = part_query.get_mut(select).unwrap();
            if 15./SCALE < rel_y && rel_y < 30./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
            if attach.children[2] == None && 15./SCALE < rel_y && rel_y < 30./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
                module.2.translation = vec3(p_pos.x + 53./SCALE*angle.sin(), p_pos.y - 53./SCALE*angle.cos(), 0.);
                module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle, 0., 0.);
                module.3.linvel = velocity.linvel;
                let joint = FixedJointBuilder::new().local_anchor1(vec2(0. / SCALE, -53. / SCALE));
                let mut module_entity = commands.entity(module.0);
                module_entity.insert(Attach {
                    associated_player: Some(entity),
                    children: [None, None, None, None],
                });
                module_entity.insert(ImpulseJoint::new(entity, joint));
                attach.children[2] = Some(module.0);
                return true;
            } else if -30./SCALE < rel_y && rel_y < -15./SCALE && -20./SCALE < rel_x && rel_x < 20./SCALE {
                module.2.translation = vec3(p_pos.x - 53./SCALE*angle.sin(), p_pos.y + 53./SCALE*angle.cos(), 0.);
                module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle + std::f32::consts::PI, 0., 0.);
                module.3.linvel = velocity.linvel;
                let joint = FixedJointBuilder::new().local_anchor1(vec2(0. / SCALE, 53. / SCALE));
                let mut module_entity = commands.entity(module.0);
                module_entity.insert(Attach {
                    associated_player: Some(entity),
                    children: [None, None, None, None],
                });
                module_entity.insert(ImpulseJoint::new(entity, joint));
                attach.children[0] = Some(module.0);
                attach.children[2] = Some(module.0);
                return true;
            } else if -30./SCALE < rel_x && rel_x < -15./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
            } else if attach.children[1] == None && -30./SCALE < rel_x && rel_x < -15./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
                module.2.translation = vec3(p_pos.x + 53./SCALE*angle.cos(), p_pos.y + 53./SCALE*angle.sin(), 0.);
                module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle + (std::f32::consts::PI/2.), 0., 0.);
                module.3.linvel = velocity.linvel;


@@ 511,14 498,14 @@ fn attach_on_module_tree(
                    .local_anchor1(vec2(53. / SCALE, 0. / SCALE))
                    .local_basis2(std::f32::consts::PI/2.);
                let mut module_entity = commands.entity(module.0);
                module_entity.insert(ImpulseJoint::new(entity, joint));
                module_entity.insert(Attach {
                    associated_player: Some(entity),
                    children: [None, None, None, None],
                });
                module_entity.insert(ImpulseJoint::new(entity, joint));
                attach.children[1] = Some(module.0);
                return true;
            } else if 15./SCALE < rel_x && rel_x < 30./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
            } else if attach.children[3] == None && 15./SCALE < rel_x && rel_x < 30./SCALE && -20./SCALE < rel_y && rel_y < 20./SCALE {
                module.2.translation = vec3(p_pos.x - 53./SCALE*angle.cos(), p_pos.y - 53./SCALE*angle.sin(), 0.);
                module.2.rotation = Quat::from_euler(EulerRot::ZYX, angle - (std::f32::consts::PI/2.), 0., 0.);
                module.3.linvel = velocity.linvel;


@@ 526,12 513,12 @@ fn attach_on_module_tree(
                    .local_anchor1(vec2(-53. / SCALE, 0. / SCALE))
                    .local_basis2(-std::f32::consts::PI/2.);
                let mut module_entity = commands.entity(module.0);
                module_entity.insert(ImpulseJoint::new(entity, joint));
                module_entity.insert(Attach {
                    associated_player: Some(entity),
                    children: [None, None, None, None],
                });
                module_entity.insert(ImpulseJoint::new(entity, joint));
                attach.children[1] = Some(module.0);
                attach.children[3] = Some(module.0);
                return true;
            }
            ret = ret | attach_on_module_tree(x, y, commands, attach.clone(), select, attached_query, part_query);