forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparticle.rs
More file actions
26 lines (20 loc) · 689 Bytes
/
Copy pathparticle.rs
File metadata and controls
26 lines (20 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::Server;
use base::{Particle, Position};
use common::Game;
use ecs::{SysResult, SystemExecutor};
pub fn register(systems: &mut SystemExecutor<Game>) {
systems.group::<Server>().add_system(send_particle_packets);
}
fn send_particle_packets(game: &mut Game, server: &mut Server) -> SysResult {
let mut entities = Vec::new();
for (entity, (&particle, &position)) in game.ecs.query::<(&Particle, &Position)>().iter() {
server.broadcast_nearby_with(position, |client| {
client.send_particle(&particle, &position);
});
entities.push(entity);
}
for entity in entities {
game.ecs.despawn(entity)?;
}
Ok(())
}