2023-05-18 21:35:16 -05:00
|
|
|
use shipyard::{Component, Unique, EntityId};
|
|
|
|
use hashbrown::HashMap;
|
|
|
|
use nohash_hasher::BuildNoHashHasher;
|
2023-03-08 20:30:37 -06:00
|
|
|
|
2023-03-08 10:27:53 -06:00
|
|
|
pub type ClientId = u16;
|
|
|
|
|
2023-05-19 00:02:20 -05:00
|
|
|
#[derive(Component, Clone, Debug)]
|
|
|
|
#[repr(transparent)]
|
|
|
|
pub struct Username(pub String);
|
|
|
|
|
2023-03-08 20:30:37 -06:00
|
|
|
#[derive(Component, Clone, Copy, Debug)]
|
2023-05-19 00:02:20 -05:00
|
|
|
#[repr(transparent)]
|
2023-03-08 20:30:37 -06:00
|
|
|
pub struct Client(pub ClientId);
|
2023-05-18 21:35:16 -05:00
|
|
|
|
|
|
|
#[derive(Unique)]
|
2023-05-19 00:02:20 -05:00
|
|
|
#[repr(transparent)]
|
2023-05-18 21:35:16 -05:00
|
|
|
pub struct ClientIdMap(pub HashMap<ClientId, EntityId, BuildNoHashHasher<ClientId>>);
|
2023-05-19 00:02:20 -05:00
|
|
|
|
2023-05-18 21:35:16 -05:00
|
|
|
impl ClientIdMap {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self(HashMap::with_capacity_and_hasher(16, BuildNoHashHasher::default()))
|
|
|
|
}
|
|
|
|
}
|
2023-05-19 00:02:20 -05:00
|
|
|
|
2023-05-18 21:35:16 -05:00
|
|
|
impl Default for ClientIdMap {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|