~starkingdoms/starkingdoms

1d8e8904f83c603ee05022ab934af06401066f16 — ghostlyzsh 2 years ago 8f153a1
rotation bug vanquished, but preattached modules still exist (please remove)
2 files changed, 10 insertions(+), 15 deletions(-)

M server/src/handler.rs
M server/src/module.rs
M server/src/handler.rs => server/src/handler.rs +6 -6
@@ 275,7 275,7 @@ pub async fn handle_client(
                                data_handle.rigid_body_set = rigid_body_set;
                                data_handle.collider_set = collider_set;

                                /*let module_id = AttachedModule::attach_new(
                                let module_id = AttachedModule::attach_new(
                                    &mut data_handle,
                                    &mut e_write_handle,
                                    player_id,


@@ 290,8 290,8 @@ pub async fn handle_client(
                                        module_type: ModuleType::Cargo,
                                    },
                                    1,
                                );*/
                                /*let module_id = AttachedModule::attach_new(
                                );
                                let module_id = AttachedModule::attach_new(
                                    &mut data_handle,
                                    &mut e_write_handle,
                                    module_id,


@@ 305,7 305,7 @@ pub async fn handle_client(
                                        ),
                                        module_type: ModuleType::Cargo,
                                    },
                                    1,
                                    2,
                                );
                                let module_id = AttachedModule::attach_new(
                                    &mut data_handle,


@@ 321,8 321,8 @@ pub async fn handle_client(
                                        ),
                                        module_type: ModuleType::Hub,
                                    },
                                    1,
                                );*/
                                    2,
                                );
                            }
                        }
                        MessageC2S::Goodbye(pkt) => {

M server/src/module.rs => server/src/module.rs +4 -9
@@ 175,16 175,11 @@ impl AttachedModule {
        };

        let relative_pos = 
            vector![anchor.x *  (rotation + parent_body.rotation().angle()).cos() + 
                    anchor.y * -(rotation + parent_body.rotation().angle()).sin(),
                    anchor.x *  (rotation + parent_body.rotation().angle()).sin() +
                    anchor.y *  (rotation + parent_body.rotation().angle()).cos()];
            vector![anchor.x *  (parent_body.rotation().angle()).cos() + 
                    anchor.y * -(parent_body.rotation().angle()).sin(),
                    anchor.x *  (parent_body.rotation().angle()).sin() +
                    anchor.y *  (parent_body.rotation().angle()).cos()];
        let module_pos = parent_pos + relative_pos;
        debug!("real pos: {}", parent_pos + relative_pos);
        debug!("parent pos: {}", parent_pos);
        debug!("relative pos: {}", relative_pos);
        debug!("real heading: {}", rotation.to_degrees() + parent_body.rotation().angle().to_degrees());
        debug!("parent heading: {}", parent_body.rotation().angle().to_degrees());

        // create attachment module
        let module_collider = ColliderBuilder::cuboid(25.0 / SCALE, 25.0 / SCALE)