use bevy::prelude::*;
use crate::shared::server_entity_map::ServerEntityMap;
#[non_exhaustive]
pub struct ClientSendCtx<'a> {
pub type_registry: &'a AppTypeRegistry,
pub entity_map: &'a ServerEntityMap,
pub(crate) invalid_entities: Vec<Entity>,
}
impl EntityMapper for ClientSendCtx<'_> {
fn get_mapped(&mut self, entity: Entity) -> Entity {
if let Some(mapped_entity) = self.entity_map.to_server().get(&entity) {
*mapped_entity
} else {
self.invalid_entities.push(entity);
Entity::PLACEHOLDER
}
}
fn set_mapped(&mut self, _source: Entity, _target: Entity) {
unimplemented!()
}
}
#[non_exhaustive]
pub struct ServerReceiveCtx<'a> {
pub type_registry: &'a AppTypeRegistry,
}
#[non_exhaustive]
pub struct ServerSendCtx<'a> {
pub type_registry: &'a AppTypeRegistry,
}
#[non_exhaustive]
pub struct ClientReceiveCtx<'a> {
pub type_registry: &'a AppTypeRegistry,
pub entity_map: &'a ServerEntityMap,
pub(crate) invalid_entities: Vec<Entity>,
}
impl EntityMapper for ClientReceiveCtx<'_> {
fn get_mapped(&mut self, source: Entity) -> Entity {
if let Some(mapped_entity) = self.entity_map.to_client().get(&source) {
*mapped_entity
} else {
self.invalid_entities.push(source);
Entity::PLACEHOLDER
}
}
fn set_mapped(&mut self, _source: Entity, _target: Entity) {
unimplemented!()
}
}