This commit is contained in:
timokoesters 2019-06-02 16:35:21 +02:00
parent b0ff00bc0f
commit 5cc2f11e58
No known key found for this signature in database
GPG Key ID: CD80BE9AAEE78097
2 changed files with 7 additions and 14 deletions

View File

@ -23,14 +23,7 @@ fn main() {
// TODO: Remove or move somewhere else, this doesn't work immediately after connecting // TODO: Remove or move somewhere else, this doesn't work immediately after connecting
println!("Ping: {:?}", client.get_ping_ms()); println!("Ping: {:?}", client.get_ping_ms());
println!( println!("Players online: {:?}", client.get_players());
"Players online: {:?}",
client
.get_players()
.into_iter()
.map(|(e, p)| p)
.collect::<Vec<comp::Player>>()
);
client.register(comp::Player::new("test".to_string(), None)); client.register(comp::Player::new("test".to_string(), None));
client.send_chat("Hello!".to_string()); client.send_chat("Hello!".to_string());

View File

@ -426,13 +426,13 @@ impl Client {
} }
/// Get a vector of all the players on the server /// Get a vector of all the players on the server
pub fn get_players(&mut self) -> Vec<(EcsEntity, comp::Player)> { pub fn get_players(&mut self) -> Vec<comp::Player> {
( // TODO: Don't clone players.
&self.state.ecs().entities(), self.state
&self.state.ecs().read_storage::<comp::Player>(), .ecs()
) .read_storage::<comp::Player>()
.join() .join()
.map(|(e, p)| (e, p.clone())) .map(|p| p.clone())
.collect() .collect()
} }
} }