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:
| Operation | Command | Method |
|---|---|---|
| Spawn an entity with components | Commands::spawn | World::spawn |
| Spawn an entity without components | Commands::spawn_empty | World::spawn_empty |
| Despawn an entity | EntityCommands::despawn | World::despawn |
| Insert a component, bundle, or tuple of components and bundles to an entity | EntityCommands::insert | EntityWorldMut::insert |
| Remove a component, bundle, or tuple of components and bundles from an entity | EntityCommands::remove | EntityWorldMut::remove |
Modules§
- hash_
map - Contains the
EntityHashMaptype, aHashMappre-configured to useEntityHashhashing. - hash_
set - Contains the
EntityHashSettype, aHashSetpre-configured to useEntityHashhashing. - index_
map - Contains the
EntityIndexMaptype, anIndexMappre-configured to useEntityHashhashing. - index_
set - Contains the
EntityIndexSettype, aIndexSetpre-configured to useEntityHashhashing. - 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§
- Component
Clone Ctx - Context for component clone handlers.
- Entities
- A
World’s internal metadata store on all of its entities. - Entity
- Lightweight identifier of an entity.
- Entity
Cloner - A configuration determining how to clone entities. This can be built using
EntityCloner::build_opt_out/opt_in, which returns anEntityClonerBuilder. - Entity
Cloner Builder - A builder for configuring
EntityCloner. SeeEntityClonerfor more information. - Entity
Does NotExist Details - Helper struct that, when printed, will write the appropriate details regarding an entity that did not exist.
- Entity
Does NotExist Error - An error that occurs when a specified
Entitydoes not exist. - Entity
Generation - This tracks different versions or generations of an
EntityRow. Importantly, this can wrap, meaning each generation is not necessarily unique perEntityRow. - Entity
Hash - A
BuildHasherthat results in aEntityHasher. - Entity
Hash Map - A
HashMappre-configured to useEntityHashhashing. - Entity
Hash Set - A
HashSetpre-configured to useEntityHashhashing. - Entity
Hasher - 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. - Entity
Index Map - A
IndexMappre-configured to useEntityHashhashing. - Entity
Index Set - An
IndexSetpre-configured to useEntityHashhashing. - Entity
Location - A location of an entity in an archetype.
- Entity
Row - This represents the row or “index” of an
Entitywithin theEntitiestable. This is a lighter weight version ofEntity. - OptIn
- Generic for
EntityClonerBuilderthat makes the cloner try to clone every component that was explicitly allowed from the source entity, for example by using theallowmethod. - OptOut
- Generic for
EntityClonerBuilderthat makes the cloner try to clone every component from the source entity except for components that were explicitly denied, for example by using thedenymethod. - Reserve
Entities Iterator - An
Iteratorreturning a sequence ofEntityvalues from - Scene
Entity Mapper - A wrapper for
EntityHashMap<Entity>, augmenting it with the ability to allocate newEntityreferences in a destination world. These newly allocated references are guaranteed to never point to any living entity in that world. - Source
Component - Provides read access to the source component (the component being cloned) in a
ComponentCloneFn. - Unique
Entity Equivalent Array - An array that contains only unique entities.
- Unique
Entity Equivalent Slice - A slice that contains only unique entities.
- Unique
Entity Equivalent Vec - A
Vecthat contains only unique entities. - Unique
Entity Iter - An iterator that yields unique entities.
Traits§
- Contains
Entity - A trait for types that contain an
Entity. - Entity
Equivalent - A trait for types that represent an
Entity. - Entity
Mapper - An implementor of this trait knows how to map an
Entityinto anotherEntity. - Entity
Set - A set of unique entities.
- Entity
SetIterator - An iterator over a set of unique entities.
- From
Entity SetIterator - Conversion from an
EntitySetIterator. - MapEntities
- Operation to map all contained
Entityfields in a type to new values.
Type Aliases§
- Entity
IdLocation - An
Entityid may or may not correspond to a valid conceptual entity. If it does, the conceptual entity may or may not have a location. If it has no location, theEntityLocationwill beNone. An location ofNonemeans the entity effectively does not exist; it has an id, but is not participating in the ECS. This is different from a location in the empty archetype, which is participating (queryable, etc) but just happens to have no components. - Unique
Entity Array - An array that contains only unique
Entity. - Unique
Entity Slice - A slice that contains only unique
Entity. - Unique
Entity Vec - A
Vecthat contains only uniqueEntity.
Derive Macros§
- MapEntities
- Implement the
MapEntitiestrait.