Module entity

Source
Expand description

Entity handling types.

An entity exclusively owns zero or more component instances, all of different types, and can dynamically acquire or lose them over its lifetime.

empty entity: Entity with zero components. pending entity: Entity reserved, but not flushed yet (see Entities::flush docs for reference). reserved entity: same as pending entity. invalid entity: pending entity flushed with invalid (see Entities::flush_as_invalid docs for reference).

See Entity to learn more.

§Usage

Operations involving entities and their components are performed either from a system by submitting commands, or from the outside (or from an exclusive system) by directly using World methods:

OperationCommandMethod
Spawn an entity with componentsCommands::spawnWorld::spawn
Spawn an entity without componentsCommands::spawn_emptyWorld::spawn_empty
Despawn an entityEntityCommands::despawnWorld::despawn
Insert a component, bundle, or tuple of components and bundles to an entityEntityCommands::insertEntityWorldMut::insert
Remove a component, bundle, or tuple of components and bundles from an entityEntityCommands::removeEntityWorldMut::remove

Re-exports§

pub use hash_map::EntityHashMap;
pub use hash_set::EntityHashSet;
pub use index_map::EntityIndexMap;
pub use index_set::EntityIndexSet;
pub use unique_array::UniqueEntityArray;
pub use unique_array::UniqueEntityEquivalentArray;
pub use unique_slice::UniqueEntityEquivalentSlice;
pub use unique_slice::UniqueEntitySlice;
pub use unique_vec::UniqueEntityEquivalentVec;
pub use unique_vec::UniqueEntityVec;

Modules§

hash_map
Contains the EntityHashMap type, a HashMap pre-configured to use EntityHash hashing.
hash_set
Contains the EntityHashSet type, a HashSet pre-configured to use EntityHash hashing.
index_map
Contains the EntityIndexMap type, an IndexMap pre-configured to use EntityHash hashing.
index_set
Contains the EntityIndexSet type, a IndexSet pre-configured to use EntityHash hashing.
unique_array
A wrapper around entity arrays with a uniqueness invariant.
unique_slice
A wrapper around entity slices with a uniqueness invariant.
unique_vec
A wrapper around entity Vecs with a uniqueness invariant.

Structs§

ComponentCloneCtx
Context for component clone handlers.
Entities
A World’s internal metadata store on all of its entities.
Entity
Lightweight identifier of an entity.
EntityCloner
A configuration determining how to clone entities. This can be built using EntityCloner::build, which returns an EntityClonerBuilder.
EntityClonerBuilder
A builder for configuring EntityCloner. See EntityCloner for more information.
EntityDoesNotExistDetails
Helper struct that, when printed, will write the appropriate details regarding an entity that did not exist.
EntityDoesNotExistError
An error that occurs when a specified Entity does not exist.
EntityHash
A BuildHasher that results in a EntityHasher.
EntityHasher
A very fast hash that is only designed to work on generational indices like Entity. It will panic if attempting to hash a type containing non-u64 fields.
EntityLocation
A location of an entity in an archetype.
ReserveEntitiesIterator
An Iterator returning a sequence of Entity values from
SceneEntityMapper
A wrapper for EntityHashMap<Entity>, augmenting it with the ability to allocate new Entity references in a destination world. These newly allocated references are guaranteed to never point to any living entity in that world.
SourceComponent
Provides read access to the source component (the component being cloned) in a ComponentCloneFn.
UniqueEntityIter
An iterator that yields unique entities.

Traits§

ContainsEntity
A trait for types that contain an Entity.
EntityEquivalent
A trait for types that represent an Entity.
EntityMapper
An implementor of this trait knows how to map an Entity into another Entity.
EntitySet
A set of unique entities.
EntitySetIterator
An iterator over a set of unique entities.
FromEntitySetIterator
Conversion from an EntitySetIterator.
MapEntities
Operation to map all contained Entity fields in a type to new values.

Derive Macros§

MapEntities