Entity
In one line: one instance of an archetype, identified by a 64-bit
EntityId.
Entities are created with tx.Spawn<Unit>(…) (which returns an EntityId) and removed with Destroy(id) — both transactional in all storage modes. To read or write an entity you open it inside a transaction: tx.Open(id) returns a read-only EntityRef, tx.OpenMut(id) a writable EntityRefMut — the access is in the type, so writing through Open does not compile. You call Read<T> (both) / Set<T> (EntityRefMut) with a component's Comp<T> handle; TryOpen / TryOpenMut return false for a stale id, and IsAlive(id) tests existence.
An EntityId is a compact value you can store and pass around; a typed cross-entity reference is an EntityLink<T>.
How it relates
- Archetype — an entity's shape; you spawn an archetype.
- Component — what you read/write through the entity's
EntityRef. - Transaction — the scope in which an entity is opened; reads see its snapshot.
- EntityLink — a typed, stored reference from one entity to another.
In the API
EntityId— the 64-bit identity returned bySpawn.EntityRef/EntityRefMut— the handles fromOpen/OpenMut;Read<T>/Set<T>.
Learn & use
- Narrative: Guide ch.1 — spawn, read, query
- Feature detail: component collections