~starkingdoms/starkingdoms

9e32164288a31f45041247ae4744c6461472e226 — ghostlyzsh 1 year, 11 months ago 7f9073f
stronger module break off
1 files changed, 9 insertions(+), 8 deletions(-)

M server/src/main.rs
M server/src/main.rs => server/src/main.rs +9 -8
@@ 76,7 76,10 @@ fn main() {
        .add_systems(Update, on_message)
        .add_systems(Update, on_close)
        .add_systems(FixedUpdate, on_position_change)
        .add_systems(FixedUpdate, (break_modules, gravity_update, player_input_update).chain())
        .add_systems(
            FixedUpdate,
            (break_modules, gravity_update, player_input_update).chain(),
        )
        .add_systems(FixedUpdate, convert_modules)
        //.insert_resource(Time::<Fixed>::from_seconds(1.0/20.0))
        .run();


@@ 1311,10 1314,12 @@ fn break_modules(
    let joints = rapier_context.entity2impulse_joint();
    let mut detach_list = Vec::new();
    for (entity, part_type, _, attach, _, _, _) in &mut attached_query {
        if *part_type == PartType::LandingThrusterSuspension { continue }
        if *part_type == PartType::LandingThrusterSuspension {
            continue;
        }
        let handle = joints.get(&entity).unwrap();
        let joint = rapier_context.impulse_joints.get(*handle).unwrap();
        if joint.impulses.magnitude() > 0.00001 {
        if joint.impulses.magnitude() > 0.00005 {
            detach_list.push((entity, *part_type, attach.clone()));
        }
    }


@@ 1329,11 1334,7 @@ fn break_modules(
                .entity(attach.children[2].unwrap())
                .remove::<Attach>();
        } else {
            detach_recursive(
                &mut commands,
                attach.clone(),
                &mut attached_query,
            );
            detach_recursive(&mut commands, attach.clone(), &mut attached_query);
        }
        let parent = attach.parent.unwrap();
        if attached_query.contains(parent) {