This commit is contained in:
timokoesters 2019-06-02 16:35:21 +02:00
parent c10a43f541
commit a69b5022c2
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
println!("Ping: {:?}", client.get_ping_ms());
println!(
"Players online: {:?}",
client
.get_players()
.into_iter()
.map(|(e, p)| p)
.collect::<Vec<comp::Player>>()
);
println!("Players online: {:?}", client.get_players());
client.register(comp::Player::new("test".to_string(), None));
client.send_chat("Hello!".to_string());

View File

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