2023-02-12 00:32:59 +00:00
|
|
|
use shipyard::{Component, EntityId};
|
|
|
|
use hashbrown::HashMap;
|
|
|
|
use nohash_hasher::BuildNoHashHasher;
|
|
|
|
use kubi_udp::{ClientId, ClientIdRepr};
|
2023-02-11 23:37:24 +00:00
|
|
|
|
|
|
|
#[derive(Component)]
|
2023-02-12 00:32:59 +00:00
|
|
|
pub struct Client(ClientId);
|
|
|
|
|
|
|
|
|
|
|
|
// disconnected => connect => join => load => ingame
|
|
|
|
#[derive(Component)]
|
|
|
|
pub enum ClientJoinState {
|
|
|
|
/// Client has connected to the game, but haven't authenticated yet
|
|
|
|
Connected,
|
|
|
|
/// Client has joined the game, but haven't loaded the world yet
|
|
|
|
Joined,
|
|
|
|
/// Client is currently ingame
|
|
|
|
InGame,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ClientMap(HashMap<ClientId, EntityId, BuildNoHashHasher<ClientIdRepr>>);
|
|
|
|
impl ClientMap {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self(HashMap::with_hasher(BuildNoHashHasher::default()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Default for ClientMap {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|