~starkingdoms/starkingdoms

974150613a3bb63135bf27a7659881211f51c1f0 — ghostly_zsh 8 months ago 4f47f9a
fixed player ghost bug
1 files changed, 30 insertions(+), 0 deletions(-)

M crates/client/src/networking/mod.rs
M crates/client/src/networking/mod.rs => crates/client/src/networking/mod.rs +30 -0
@@ 145,6 145,36 @@ pub fn process_packets(
                *amount = *m_amount;
                *max = *m_max;
            }
            PlayerLeave { id } => {
                let mut part_query = world.query_filtered::<(Entity, &ServerId), With<Part>>();
                let mut entity_to_remove = None;
                for (entity, server_id) in part_query.iter_mut(world) {
                    if server_id.0 == *id {
                        entity_to_remove = Some(entity);
                    }
                }
                match entity_to_remove {
                    Some(entity) => {
                        world.despawn(entity);
                    }
                    None => {}
                }
            }
            DespawnPart { id } => {
                let mut part_query = world.query_filtered::<(Entity, &ServerId), With<Part>>();
                let mut entity_to_remove = None;
                for (entity, server_id) in part_query.iter_mut(world) {
                    if server_id.0 == *id {
                        entity_to_remove = Some(entity);
                    }
                }
                match entity_to_remove {
                    Some(entity) => {
                        world.despawn(entity);
                    }
                    None => {}
                }
            }
            _ => {}
        }
    }