use crate::{prelude::*, shared::net::{Mapped, SendTargets, SpawnEntity, ToClients}};
pub fn net_plugin(app: &mut App) {
app.add_systems(PreUpdate, detect_entity_spawn);
}
fn detect_entity_spawn(
mapped_entities: Query<Entity, Added<Mapped>>,
mut spawn_entity: MessageWriter<ToClients<SpawnEntity>>,
) {
for entity in mapped_entities {
debug!("entity was spawned");
spawn_entity.write(ToClients {
message: SpawnEntity { server: entity },
targets: SendTargets::All,
});
}
}