2023-03-12 19:56:33 -05:00
|
|
|
use shipyard::{Component, EntityId, Unique, AllStoragesView};
|
2023-02-11 18:32:59 -06:00
|
|
|
use hashbrown::HashMap;
|
2023-03-08 20:30:37 -06:00
|
|
|
use std::net::SocketAddr;
|
2023-05-18 21:35:16 -05:00
|
|
|
pub use kubi_shared::networking::client::ClientIdMap;
|
2023-02-11 17:37:24 -06:00
|
|
|
|
2023-03-08 20:30:37 -06:00
|
|
|
#[derive(Component, Clone, Copy)]
|
|
|
|
pub struct ClientAddress(pub SocketAddr);
|
2023-02-11 18:32:59 -06:00
|
|
|
|
2023-03-08 20:30:37 -06:00
|
|
|
#[derive(Unique, Default)]
|
|
|
|
pub struct ClientAddressMap(pub HashMap<SocketAddr, EntityId>);
|
|
|
|
impl ClientAddressMap {
|
|
|
|
pub fn new() -> Self { Self::default() }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn init_client_maps(
|
|
|
|
storages: AllStoragesView
|
|
|
|
) {
|
|
|
|
storages.add_unique(ClientIdMap::new());
|
|
|
|
storages.add_unique(ClientAddressMap::new());
|
|
|
|
}
|