pub struct IdMaps {
uid_mapping: HashMap<Uid, Entity>,
uid_allocator: UidAllocator,
character_to_ecs: HashMap<CharacterId, Entity>,
rtsim_to_ecs: HashMap<RtSimEntity, Entity>,
}Expand description
Mappings from various Id types to Entitys.
Fields§
§uid_mapping: HashMap<Uid, Entity>“Universal” IDs (used to communicate entity identity over the network).
uid_allocator: UidAllocator§character_to_ecs: HashMap<CharacterId, Entity>Character IDs.
rtsim_to_ecs: HashMap<RtSimEntity, Entity>Rtsim Entities.
Implementations§
Source§impl IdMaps
impl IdMaps
pub fn new() -> Self
Sourcepub fn uid_entity(&self, id: Uid) -> Option<Entity>
pub fn uid_entity(&self, id: Uid) -> Option<Entity>
Given a Uid retrieve the corresponding Entity.
Sourcepub fn character_entity(&self, id: CharacterId) -> Option<Entity>
pub fn character_entity(&self, id: CharacterId) -> Option<Entity>
Given a CharacterId retrieve the corresponding Entity.
Sourcepub fn rtsim_entity(&self, id: RtSimEntity) -> Option<Entity>
pub fn rtsim_entity(&self, id: RtSimEntity) -> Option<Entity>
Given a RtSimEntity retrieve the corresponding Entity.
pub fn actor_entity(&self, actor: Actor) -> Option<Entity>
Sourcepub fn remove_entity(
&mut self,
expected_entity: Option<Entity>,
uid: Option<Uid>,
cid: Option<CharacterId>,
rid: Option<RtSimEntity>,
) -> Option<Entity>
pub fn remove_entity( &mut self, expected_entity: Option<Entity>, uid: Option<Uid>, cid: Option<CharacterId>, rid: Option<RtSimEntity>, ) -> Option<Entity>
Removes mappings for the provided Id(s).
Returns the Entity that the provided Uid was mapped to.
Used on both the client and the server when deleting entities,
although the client only ever provides a Some value for the
Uid parameter since the other mappings are not used on the
client.
Sourcepub fn add_entity(&mut self, uid: Uid, entity: Entity)
pub fn add_entity(&mut self, uid: Uid, entity: Entity)
Only used on the client (server solely uses Self::allocate to
allocate and add Uid mappings and Self::remap to move the Uid to
a different entity).
Sourcepub fn add_character(&mut self, cid: CharacterId, entity: Entity)
pub fn add_character(&mut self, cid: CharacterId, entity: Entity)
Only used on the server.
Sourcepub fn add_rtsim(&mut self, rid: RtSimEntity, entity: Entity)
pub fn add_rtsim(&mut self, rid: RtSimEntity, entity: Entity)
Only used on the server.
Sourcepub fn allocate(&mut self, entity: Entity) -> Uid
pub fn allocate(&mut self, entity: Entity) -> Uid
Allocates a new Uid and links it to the provided entity.
Only used on the server.
Sourcepub fn remap_entity(&mut self, uid: Uid, new_entity: Entity)
pub fn remap_entity(&mut self, uid: Uid, new_entity: Entity)
Links an existing Uid to a new entity.
Only used on the server.
Used for handle_exit_ingame which moves the same Uid to a new
entity.
fn already_present<ID>()
fn insert<ID: Hash + Eq>( mapping: &mut HashMap<ID, Entity>, new_id: ID, entity: Entity, )
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IdMaps
impl RefUnwindSafe for IdMaps
impl Send for IdMaps
impl Sync for IdMaps
impl Unpin for IdMaps
impl UnwindSafe for IdMaps
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default and panics on an error case.