Archetype
In one line: the fixed shape of an entity — the set of component types it has.
An archetype is declared once as a sealed partial class Unit : Archetype<Unit> marked [Archetype]. Its identity is the CLR type name (or [Archetype(Name="...")]); it self-registers at assembly load, and the engine auto-assigns a per-process catalog id and a persisted per-DB routing id — no numeric id is author-set. Each Register<T>() declares a component slot and yields a static Comp<T> handle (Unit.Position) — the compile-time key you use to spawn, read, and query that component.
Marking the class partial lets Typhon's source generator add typed bulk accessors (Unit.ReadAll / ReadWriteAll). Archetypes can also inherit (Archetype<TSelf, TParent>) to share a common component prefix. An entity is one instance of an archetype.
How it relates
- Component — an archetype is a fixed set of them; it owns each one's
Comp<T>handle. - Entity — an instance of an archetype, created with
Spawn<TArch>. - Query — queries are typed on an archetype:
tx.Query<Unit>(). - Schema evolution — archetype membership and component versions are part of the persisted schema.
- Cluster storage — the archetype's component mix silently decides its physical layout (clustered SoA vs legacy per-entity) — a ~50× bulk-iteration difference.
In the API
- Archetype<T> — the base class an archetype derives from;
Register<T>()declares slots. - Comp<T> — the per-slot handle the archetype exposes.
[Archetype]— the identity attribute (declaration-only, not in the API reference).
Learn & use
- Narrative: Guide ch.1 — an archetype is the shape of an entity · ch.2 — modeling
- Feature detail: component collections