~starkingdoms/starkingdoms

b7300c2a478de07b4d6fe60439fb9d3ac68fca32 — ghostlyzsh 1 year, 11 months ago d07a0e2
can now convert by touching cargo against planet
1 files changed, 8 insertions(+), 4 deletions(-)

M server/src/main.rs
M server/src/main.rs => server/src/main.rs +8 -4
@@ 819,7 819,7 @@ fn convert_modules(
    planet_query: Query<(Entity, &PlanetType, &Children)>,
    player_query: Query<&Attach, With<Player>>,
    mut attached_query: Query<(&mut PartType, &Attach, &Children), Without<Player>>,
    mut collider_query: Query<(&mut Collider, &mut Transform)>,
    mut collider_query: Query<(&mut Collider, &mut Transform, &Parent)>,
    mut packet_send: EventWriter<ServerEvent>,
) {
    for (_planet_entity, planet_type, children) in &planet_query {


@@ 834,6 834,11 @@ fn convert_modules(
                    other
                } else if attached_query.contains(other) {
                    attached_query.get(other).unwrap().1.associated_player.unwrap()
                } else if collider_query.contains(other) {
                    let parent = collider_query.get(other).unwrap().2.get();
                    if attached_query.contains(parent) {
                        attached_query.get(parent).unwrap().1.associated_player.unwrap()
                    } else { continue }
                } else { continue };
                let player_attach = player_query.get(player_entity).unwrap();
                convert_modules_recursive(*planet_type, player_attach.clone(), &mut attached_query, &mut collider_query, &mut packet_send);


@@ 846,10 851,9 @@ fn convert_modules_recursive(
    planet_type: PlanetType,
    attach: Attach,
    attached_query: &mut Query<(&mut PartType, &Attach, &Children), Without<Player>>,
    collider_query: &mut Query<(&mut Collider, &mut Transform)>,
    collider_query: &mut Query<(&mut Collider, &mut Transform, &Parent)>,
    packet_send: &mut EventWriter<ServerEvent>,
) {
    //println!("here");
    for child in attach.children {
        if let Some(child) = child {
            let (mut part_type, attach, children) = attached_query.get_mut(child).unwrap();


@@ 857,7 861,7 @@ fn convert_modules_recursive(
                match planet_type {
                    PlanetType::Moon => {
                        *part_type = PartType::Hub;
                        let (mut collider, mut transform) = collider_query.get_mut(*children.first().unwrap()).unwrap();
                        let (mut collider, mut transform, _) = collider_query.get_mut(*children.first().unwrap()).unwrap();
                        *collider = Collider::cuboid(PART_HALF_SIZE / SCALE, PART_HALF_SIZE / SCALE);
                        *transform = Transform::from_xyz(0., 0., 0.);
                        let packet = Packet::DespawnPart {