[−][src]Trait specs::saveload::MarkerAllocator
This allocator is used with the Marker
trait.
It provides a method for allocating new Marker
s.
It should also provide a Marker -> Entity
mapping.
The maintain
method can be implemented for cleanup and actualization.
See docs for Marker
for an example.
Required methods
fn allocate(&mut self, entity: Entity, id: Option<M::Identifier>) -> M
Allocates a new marker for a given entity. If you don't pass an id, a new unique id will be created.
fn retrieve_entity_internal(&self, id: M::Identifier) -> Option<Entity>
Get an Entity
by a marker identifier.
This function only accepts an id; it does not update the marker data.
Implementors usually maintain a marker -> entity mapping and use that to retrieve the entity.
fn maintain(&mut self, _entities: &EntitiesRes, _storage: &ReadStorage<M>)
Maintain internal data. Cleanup if necessary.
Provided methods
fn retrieve_entity(
&mut self,
marker: M,
storage: &mut WriteStorage<M>,
entities: &EntitiesRes
) -> Entity
&mut self,
marker: M,
storage: &mut WriteStorage<M>,
entities: &EntitiesRes
) -> Entity
Tries to retrieve an entity by the id of the marker;
if no entity has a marker with the same id, a new entity
will be created and marker
will be inserted for it.
In case the entity existed,
this method will update the marker data using Marker::update
.
fn mark<'m>(
&mut self,
entity: Entity,
storage: &'m mut WriteStorage<M>
) -> Option<(&'m M, bool)>
&mut self,
entity: Entity,
storage: &'m mut WriteStorage<M>
) -> Option<(&'m M, bool)>
Create new unique marker M
and attach it to entity.
Or get old marker if this entity is already marked.
If entity is dead then this will return None
.
Implementors
impl MarkerAllocator<UuidMarker> for UuidMarkerAllocator
[src]
fn allocate(&mut self, entity: Entity, id: Option<Uuid>) -> UuidMarker
[src]
fn retrieve_entity_internal(&self, id: Uuid) -> Option<Entity>
[src]
fn maintain(
&mut self,
entities: &EntitiesRes,
storage: &ReadStorage<UuidMarker>
)
[src]
&mut self,
entities: &EntitiesRes,
storage: &ReadStorage<UuidMarker>
)
impl<T: ?Sized> MarkerAllocator<SimpleMarker<T>> for SimpleMarkerAllocator<T> where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
fn allocate(&mut self, entity: Entity, id: Option<u64>) -> SimpleMarker<T>
[src]
fn retrieve_entity_internal(&self, id: u64) -> Option<Entity>
[src]
fn maintain(
&mut self,
entities: &EntitiesRes,
storage: &ReadStorage<SimpleMarker<T>>
)
[src]
&mut self,
entities: &EntitiesRes,
storage: &ReadStorage<SimpleMarker<T>>
)