pub trait MarkerAllocator<M: Marker>: Resource {
    fn allocate(&mut self, entity: Entity, id: Option<M::Identifier>) -> M;
    fn retrieve_entity_internal(&self, id: M::Identifier) -> Option<Entity>;
    fn maintain(&mut self, _entities: &EntitiesRes, _storage: &ReadStorage<'_, M>);

    fn retrieve_entity(
        &mut self,
        marker: M,
        storage: &mut WriteStorage<'_, M>,
        entities: &EntitiesRes
    ) -> Entity { ... } fn mark<'m>(
        &mut self,
        entity: Entity,
        storage: &'m mut WriteStorage<'_, M>
    ) -> Option<(&'m M, bool)> { ... } }
Expand description

This allocator is used with the Marker trait. It provides a method for allocating new Markers. 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

Allocates a new marker for a given entity. If you don’t pass an id, a new unique id will be created.

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.

Maintain internal data. Cleanup if necessary.

Provided Methods

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.

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