Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::Archetype Class Referencefinal

Fixed-shape group of chunks storing entities that share the same component layout. Owns chunk storage, component hashes, relation-pair indexing and inter-archetype graph edges. More...

#include <archetype.h>

+ Inheritance diagram for gaia::ecs::Archetype:

Classes

struct  Properties
 Shape properties of this archetype. More...
 

Public Types

using LookupHash = core::direct_hash_key< uint64_t >
 Direct hash type used for archetype lookups.
 

Public Member Functions

 Archetype (Archetype &&)=delete
 
 Archetype (const Archetype &)=delete
 
Archetypeoperator= (Archetype &&)=delete
 
Archetypeoperator= (const Archetype &)=delete
 
void save (ser::serializer &s)
 Serializes the archetype: free-chunk index, list index, and each chunk.
 
void load (ser::serializer &s)
 Deserializes the archetype, recreating missing chunks from the shape description.
 
void list_idx (uint32_t idx)
 Sets the archetype index in the world list of active archetypes.
 
uint32_t list_idx () const
 Archetype index in the world list of active archetypes.
 
GAIA_NODISCARD bool cmp_comps (const ArchetypeLookupChecker &other) const
 Compares the lookup checker component spans in archetype order.
 
QueryMask queryMask () const
 Query mask describing which simple queries may match this archetype.
 
ArchetypeIdLookupKey::LookupHash id_hash () const
 Archetype id hash used for graph edge storage.
 
void set_hashes (LookupHash hashLookup)
 Sets hashes for each component type and lookup.
 
void enable_entity (Chunk *pChunk, uint16_t row, bool enableEntity, EntityContainers &recs)
 Enables or disables the entity on a given row in the chunk.
 
void del (Chunk *pChunk)
 Removes a chunk from the list of chunks managed by their archetype and deletes its memory.
 
GAIA_NODISCARD Chunkfoc_free_chunk ()
 Tries to locate a chunk that has some space left for a new entity. If not found a new chunk is created.
 
void try_update_free_chunk_idx ()
 Tries to update the index of the first chunk that has space left for at least one entity.
 
void try_update_free_chunk_idx (Chunk &chunkThatRemovedEntity)
 Tries to update the index of the first chunk that has space left for at least one entity.
 
void remove_entity_raw (Chunk &chunk, uint16_t row, EntityContainers &recs)
 Removes an entity from the chunk.
 
void remove_entity (Chunk &chunk, uint16_t row, EntityContainers &recs)
 Removes an entity from the chunk and updates the chunk versions.
 
GAIA_NODISCARD const Propertiesprops () const
 Shape properties of this archetype.
 
GAIA_NODISCARD const cnt::darray< Chunk * > & chunks () const
 Chunks managed by this archetype.
 
GAIA_NODISCARD LookupHash lookup_hash () const
 Hash of the component terms used for archetype lookup.
 
GAIA_NODISCARD EntitySpan ids_view () const
 Span over the component and entity identifiers defining the archetype shape.
 
GAIA_NODISCARD ChunkDataOffsetSpan comp_offs_view () const
 Span over the per-term component data offsets.
 
GAIA_NODISCARD uint32_t pairs () const
 Returns the number of pairs registered in the archetype.
 
GAIA_NODISCARD uint32_t pairs_is () const
 Returns the number of Is pairs registered in the archetype.
 
GAIA_NODISCARD uint32_t pair_matches (Entity pair) const
 Returns how many pair ids in this archetype match the provided wildcard-capable pair query. This stays archetype-local because variable matching repeatedly probes a single candidate archetype.
 
GAIA_NODISCARD Entity entity_from_pairs_as_idx (uint32_t idx) const
 Resolves a relation-pair index to its pair entity.
 
GAIA_NODISCARD std::span< const uint8_t > pair_indices () const
 Indices of all relation pairs within the ids array.
 
GAIA_NODISCARD std::span< const uint8_t > pair_rel_indices (Entity relation) const
 Indices of pairs whose relation matches the given relation.
 
GAIA_NODISCARD std::span< const uint8_t > pair_tgt_indices (Entity target) const
 Indices of pairs whose target matches the given target.
 
GAIA_NODISCARD bool has (Entity entity) const
 Checks if an entity is a part of the archetype.
 
void observed_terms_inc ()
 Increments the number of terms observing this archetype.
 
void observed_terms_dec ()
 Decrements the number of terms observing this archetype.
 
GAIA_NODISCARD bool has_observed_terms () const
 Whether any observer term currently observes this archetype.
 
template<typename T >
GAIA_NODISCARD bool has () const
 Checks if component T is present in the chunk.
 
template<bool Enabled>
Entity get_flat_entity (size_t flatIdx) const
 Given a flat index, returns an entity at that index. E.g., if there are 2 chunks, the first one with 10 entities and the second one with 5, flat index of 12 means the second entity inside the second chunk.
 
template<bool Enabled>
const void * get_flat_comp_ptr (uint32_t compIdx, size_t flatIdx, Entity &outEntity) const
 Given a flat index, returns pointer to component data at that index. E.g., if there are 2 chunks, the first one with 10 entities and the second one with 5, flat index of 12 means component data for the second entity inside the second chunk.
 
template<bool Enabled>
void sort_entities_inter (size_t low, size_t high, TSortByFunc func)
 Generic in-place quicksort across chunks.
 
template<bool Enabled>
void sort_entities_inter (const ComponentCacheItem *pItem, uint32_t compIdx, size_t low, size_t high, TSortByFunc func)
 Generic in-place quicksort across chunks.
 
void sort_entities (Entity entity, TSortByFunc func)
 Sorts all entities in the archetypes according to the given function.
 
void build_graph_edges (Archetype *pArchetypeRight, Entity entity)
 Builds a graph edge from this archetype to the right archetype.
 
void build_graph_edges_left (Archetype *pArchetypeLeft, Entity entity)
 Records a cached "del" graph edge from entity entity to this archetype.
 
void del_graph_edges (Archetype *pArchetypeRight, Entity entity)
 Removes the cached "add" edge for entity and propagates the delete to the right archetype.
 
void del_graph_edges_left (Archetype *pArchetypeLeft, Entity entity)
 Removes the cached "del" edge for entity after the matching "add" edge is removed.
 
void del_graph_edge_right_local (Entity entity)
 Deletes a cached local "add" edge formed by entity. Intended for stale edge cache recovery when the opposite archetype no longer exists.
 
void del_graph_edge_left_local (Entity entity)
 Deletes a cached local "del" edge formed by entity. Intended for stale edge cache recovery when the opposite archetype no longer exists.
 
GAIA_NODISCARD ArchetypeGraphEdge find_edge_right (Entity entity) const
 Checks if an archetype graph "add" edge with entity entity exists.
 
GAIA_NODISCARD ArchetypeGraphEdge find_edge_left (Entity entity) const
 Checks if an archetype graph "del" edge with entity entity exists.
 
GAIA_NODISCARD auto & right_edges ()
 Mutable view over the archetype "add" graph edges.
 
GAIA_NODISCARD const auto & right_edges () const
 Const view over the archetype "add" graph edges.
 
GAIA_NODISCARD auto & left_edges ()
 Mutable view over the archetype "del" graph edges.
 
GAIA_NODISCARD const auto & left_edges () const
 Const view over the archetype "del" graph edges.
 
GAIA_NODISCARD bool empty () const
 Checks is there are no chunk in the archetype.
 
void req_del ()
 Request deleting the archetype.
 
GAIA_NODISCARD bool is_req_del () const
 Returns true if this archetype is requested to be deleted.
 
void set_max_lifespan (uint32_t lifespan)
 Sets maximal lifespan of an archetype.
 
GAIA_NODISCARD uint32_t max_lifespan () const
 Returns the maximal lifespan of the archetype. If zero, the archetype it kept indefinitely.
 
GAIA_NODISCARD bool dying () const
 Checks is this chunk is dying.
 
void die ()
 Marks the chunk as dead.
 
GAIA_NODISCARD bool dead () const
 Checks is this chunk is dying.
 
void start_dying ()
 Starts the process of dying.
 
void revive ()
 Makes the archetype alive again.
 
GAIA_NODISCARD bool progress_death ()
 Updates internal lifespan.
 
GAIA_NODISCARD bool ready_to_die () const
 Tells whether archetype is ready to be deleted.
 
- Public Member Functions inherited from gaia::ecs::ArchetypeBase
GAIA_NODISCARD ArchetypeId id () const
 Archetype id used to address the archetype in the world list.
 

Static Public Member Functions

static GAIA_NODISCARD Archetypecreate (const World &world, ArchetypeId archetypeId, uint32_t &worldVersion, EntitySpan ids)
 Creates a new archetype from a component term span.
 
static void destroy (Archetype *pArchetype)
 Destroys the archetype and frees its memory.
 
static void diag_entity (const World &world, Entity entity)
 Logs a diagnostic line for one entity, pair, or component of the archetype.
 
static void diag_basic_info (const World &world, const Archetype &archetype)
 Logs basic archetype diagnostics: sizes, chunk count, entity counts, and component ids.
 
static void diag_graph_info (const World &world, const Archetype &archetype)
 Logs the archetype graph edge diagnostics.
 
static void diag_chunk_info (const Archetype &archetype)
 Logs per-chunk diagnostics for all chunks of the archetype.
 
static void diag_entity_info (const World &world, const Archetype &archetype)
 Logs entity diagnostics for each entity of the archetype.
 
static void diag (const World &world, const Archetype &archetype)
 Performs diagnostics on a specific archetype. Prints basic info about it and the chunks it contains.
 

Static Public Attributes

static constexpr uint16_t ARCHETYPE_LIFESPAN_BITS = 7
 Number of bits representing archetype lifespan.
 
static constexpr uint16_t MAX_ARCHETYPE_LIFESPAN = (1 << ARCHETYPE_LIFESPAN_BITS) - 1
 Archetype lifespan must be at least as long as chunk lifespan.
 

Additional Inherited Members

- Protected Attributes inherited from gaia::ecs::ArchetypeBase
ArchetypeId m_archetypeId = ArchetypeIdBad
 Archetype ID - used to address the archetype directly in the world's list or archetypes.
 

Detailed Description

Fixed-shape group of chunks storing entities that share the same component layout. Owns chunk storage, component hashes, relation-pair indexing and inter-archetype graph edges.

Member Function Documentation

◆ build_graph_edges()

void gaia::ecs::Archetype::build_graph_edges ( Archetype pArchetypeRight,
Entity  entity 
)
inline

Builds a graph edge from this archetype to the right archetype.

Parameters
pArchetypeRightTarget archetype
entityEntity to link

◆ build_graph_edges_left()

void gaia::ecs::Archetype::build_graph_edges_left ( Archetype pArchetypeLeft,
Entity  entity 
)
inline

Records a cached "del" graph edge from entity entity to this archetype.

Parameters
pArchetypeLeftOwning archetype of entity.
entityEntity forming the left edge.

◆ chunks()

GAIA_NODISCARD const cnt::darray< Chunk * > & gaia::ecs::Archetype::chunks ( ) const
inline

Chunks managed by this archetype.

Returns
Array of chunk pointers.

◆ cmp_comps()

GAIA_NODISCARD bool gaia::ecs::Archetype::cmp_comps ( const ArchetypeLookupChecker other) const
inline

Compares the lookup checker component spans in archetype order.

Parameters
otherOther checker to compare against.
Returns
True when both spans match element-wise.

◆ comp_offs_view()

GAIA_NODISCARD ChunkDataOffsetSpan gaia::ecs::Archetype::comp_offs_view ( ) const
inline

Span over the per-term component data offsets.

Returns
Component offset span.

◆ create()

static GAIA_NODISCARD Archetype * gaia::ecs::Archetype::create ( const World world,
ArchetypeId  archetypeId,
uint32_t &  worldVersion,
EntitySpan  ids 
)
inlinestatic

Creates a new archetype from a component term span.

Parameters
worldWorld owning the component cache.
archetypeIdArchetype id to register.
worldVersionWorld version reference for chunk versioning.
idsComponent and entity identifiers defining the shape.
Returns
Newly created archetype.

◆ dead()

GAIA_NODISCARD bool gaia::ecs::Archetype::dead ( ) const
inline

Checks is this chunk is dying.

Returns
True when the archetype is dead and ready to be deleted.

◆ del()

void gaia::ecs::Archetype::del ( Chunk pChunk)
inline

Removes a chunk from the list of chunks managed by their archetype and deletes its memory.

Parameters
pChunkChunk to remove from the list of managed archetypes

◆ del_graph_edge_left_local()

void gaia::ecs::Archetype::del_graph_edge_left_local ( Entity  entity)
inline

Deletes a cached local "del" edge formed by entity. Intended for stale edge cache recovery when the opposite archetype no longer exists.

Parameters
entityEntity to remove

◆ del_graph_edge_right_local()

void gaia::ecs::Archetype::del_graph_edge_right_local ( Entity  entity)
inline

Deletes a cached local "add" edge formed by entity. Intended for stale edge cache recovery when the opposite archetype no longer exists.

Parameters
entityEntity to remove

◆ del_graph_edges()

void gaia::ecs::Archetype::del_graph_edges ( Archetype pArchetypeRight,
Entity  entity 
)
inline

Removes the cached "add" edge for entity and propagates the delete to the right archetype.

Parameters
pArchetypeRightTarget archetype of the edge.
entityEntity whose edge is removed.

◆ del_graph_edges_left()

void gaia::ecs::Archetype::del_graph_edges_left ( Archetype pArchetypeLeft,
Entity  entity 
)
inline

Removes the cached "del" edge for entity after the matching "add" edge is removed.

Parameters
pArchetypeLeftOwning archetype of entity.
entityEntity whose left edge is removed.

◆ destroy()

static void gaia::ecs::Archetype::destroy ( Archetype pArchetype)
inlinestatic

Destroys the archetype and frees its memory.

Parameters
pArchetypeArchetype to destroy.

◆ diag()

static void gaia::ecs::Archetype::diag ( const World world,
const Archetype archetype 
)
inlinestatic

Performs diagnostics on a specific archetype. Prints basic info about it and the chunks it contains.

Parameters
worldParent world
archetypeArchetype to run diagnostics on

◆ diag_basic_info()

static void gaia::ecs::Archetype::diag_basic_info ( const World world,
const Archetype archetype 
)
inlinestatic

Logs basic archetype diagnostics: sizes, chunk count, entity counts, and component ids.

Parameters
worldWorld owning the archetype.
archetypeArchetype to describe.

◆ diag_chunk_info()

static void gaia::ecs::Archetype::diag_chunk_info ( const Archetype archetype)
inlinestatic

Logs per-chunk diagnostics for all chunks of the archetype.

Parameters
archetypeArchetype whose chunks are described.

◆ diag_entity()

static void gaia::ecs::Archetype::diag_entity ( const World world,
Entity  entity 
)
inlinestatic

Logs a diagnostic line for one entity, pair, or component of the archetype.

Parameters
worldWorld owning the entity types.
entityEntity to describe.

◆ diag_entity_info()

static void gaia::ecs::Archetype::diag_entity_info ( const World world,
const Archetype archetype 
)
inlinestatic

Logs entity diagnostics for each entity of the archetype.

Parameters
worldWorld owning the archetype.
archetypeArchetype whose entities are described.

◆ diag_graph_info()

static void gaia::ecs::Archetype::diag_graph_info ( const World world,
const Archetype archetype 
)
inlinestatic

Logs the archetype graph edge diagnostics.

Parameters
worldWorld owning the archetype.
archetypeArchetype whose graph is described.

◆ dying()

GAIA_NODISCARD bool gaia::ecs::Archetype::dying ( ) const
inline

Checks is this chunk is dying.

Returns
True when the archetype is in its dying lifespan countdown.

◆ empty()

GAIA_NODISCARD bool gaia::ecs::Archetype::empty ( ) const
inline

Checks is there are no chunk in the archetype.

Returns
True when the archetype holds no chunks.

◆ enable_entity()

void gaia::ecs::Archetype::enable_entity ( Chunk pChunk,
uint16_t  row,
bool  enableEntity,
EntityContainers &  recs 
)
inline

Enables or disables the entity on a given row in the chunk.

Parameters
pChunkChunk the entity belongs to
rowRow of the entity
enableEntityEnables the entity
recsEntity containers

◆ entity_from_pairs_as_idx()

GAIA_NODISCARD Entity gaia::ecs::Archetype::entity_from_pairs_as_idx ( uint32_t  idx) const
inline

Resolves a relation-pair index to its pair entity.

Parameters
idxIndex within the archetype pair array.
Returns
Pair entity at idx.

◆ find_edge_left()

GAIA_NODISCARD ArchetypeGraphEdge gaia::ecs::Archetype::find_edge_left ( Entity  entity) const
inline

Checks if an archetype graph "del" edge with entity entity exists.

Returns
Archetype id of the target archetype if the edge is found. ArchetypeIdBad otherwise.
Parameters
entityEntity to find

◆ find_edge_right()

GAIA_NODISCARD ArchetypeGraphEdge gaia::ecs::Archetype::find_edge_right ( Entity  entity) const
inline

Checks if an archetype graph "add" edge with entity entity exists.

Returns
Archetype id of the target archetype if the edge is found. ArchetypeIdBad otherwise.
Parameters
entityEntity to find

◆ foc_free_chunk()

GAIA_NODISCARD Chunk * gaia::ecs::Archetype::foc_free_chunk ( )
inline

Tries to locate a chunk that has some space left for a new entity. If not found a new chunk is created.

Warning
Always used in tandem with try_update_free_chunk_idx() or remove_entity()
Returns
Chunk with free space, or a newly created chunk.

◆ get_flat_comp_ptr()

template<bool Enabled>
const void * gaia::ecs::Archetype::get_flat_comp_ptr ( uint32_t  compIdx,
size_t  flatIdx,
Entity outEntity 
) const
inline

Given a flat index, returns pointer to component data at that index. E.g., if there are 2 chunks, the first one with 10 entities and the second one with 5, flat index of 12 means component data for the second entity inside the second chunk.

Parameters
compIdxComponent index we are searching for
flatIdxFlat index of entity inside the archetype
[out]outEntityEntity belonging to the flatIdx
Returns
Pointer to component data at given flat index

◆ get_flat_entity()

template<bool Enabled>
Entity gaia::ecs::Archetype::get_flat_entity ( size_t  flatIdx) const
inline

Given a flat index, returns an entity at that index. E.g., if there are 2 chunks, the first one with 10 entities and the second one with 5, flat index of 12 means the second entity inside the second chunk.

Parameters
flatIdxFlat index of entity inside the archetype
Returns
Entity at given flat index

◆ has() [1/2]

template<typename T >
GAIA_NODISCARD bool gaia::ecs::Archetype::has ( ) const
inline

Checks if component T is present in the chunk.

Template Parameters
TComponent or pair
Returns
True if the component is present. False otherwise.

◆ has() [2/2]

GAIA_NODISCARD bool gaia::ecs::Archetype::has ( Entity  entity) const
inline

Checks if an entity is a part of the archetype.

Parameters
entityEntity
Returns
True if found. False otherwise.

◆ has_observed_terms()

GAIA_NODISCARD bool gaia::ecs::Archetype::has_observed_terms ( ) const
inline

Whether any observer term currently observes this archetype.

Returns
True when the observed-term counter is non-zero.

◆ id_hash()

ArchetypeIdLookupKey::LookupHash gaia::ecs::Archetype::id_hash ( ) const
inline

Archetype id hash used for graph edge storage.

Returns
Hash of the archetype id.

◆ ids_view()

GAIA_NODISCARD EntitySpan gaia::ecs::Archetype::ids_view ( ) const
inline

Span over the component and entity identifiers defining the archetype shape.

Returns
Identifier span.

◆ is_req_del()

GAIA_NODISCARD bool gaia::ecs::Archetype::is_req_del ( ) const
inline

Returns true if this archetype is requested to be deleted.

Returns
True when the archetype is requested to be deleted.

◆ left_edges() [1/2]

GAIA_NODISCARD auto & gaia::ecs::Archetype::left_edges ( )
inline

Mutable view over the archetype "del" graph edges.

Returns
Left-edge container reference.

◆ left_edges() [2/2]

GAIA_NODISCARD const auto & gaia::ecs::Archetype::left_edges ( ) const
inline

Const view over the archetype "del" graph edges.

Returns
Left-edge container reference.

◆ list_idx() [1/2]

uint32_t gaia::ecs::Archetype::list_idx ( ) const
inline

Archetype index in the world list of active archetypes.

Returns
Archetype list index.

◆ list_idx() [2/2]

void gaia::ecs::Archetype::list_idx ( uint32_t  idx)
inline

Sets the archetype index in the world list of active archetypes.

Parameters
idxList index to store.

◆ load()

void gaia::ecs::Archetype::load ( ser::serializer s)
inline

Deserializes the archetype, recreating missing chunks from the shape description.

Parameters
sserializer to read from.

◆ lookup_hash()

GAIA_NODISCARD LookupHash gaia::ecs::Archetype::lookup_hash ( ) const
inline

Hash of the component terms used for archetype lookup.

Returns
Component-term lookup hash.

◆ max_lifespan()

GAIA_NODISCARD uint32_t gaia::ecs::Archetype::max_lifespan ( ) const
inline

Returns the maximal lifespan of the archetype. If zero, the archetype it kept indefinitely.

Returns
Lifespan in world updates kept after the archetype empties, zero when indefinite.

◆ pair_indices()

GAIA_NODISCARD std::span< const uint8_t > gaia::ecs::Archetype::pair_indices ( ) const
inline

Indices of all relation pairs within the ids array.

Returns
Pair index span.

◆ pair_matches()

GAIA_NODISCARD uint32_t gaia::ecs::Archetype::pair_matches ( Entity  pair) const
inline

Returns how many pair ids in this archetype match the provided wildcard-capable pair query. This stays archetype-local because variable matching repeatedly probes a single candidate archetype.

Parameters
pairWildcard-capable pair query.
Returns
Number of matching pair ids in this archetype.

◆ pair_rel_indices()

GAIA_NODISCARD std::span< const uint8_t > gaia::ecs::Archetype::pair_rel_indices ( Entity  relation) const
inline

Indices of pairs whose relation matches the given relation.

Parameters
relationRelation entity to match.
Returns
Matching pair index span.

◆ pair_tgt_indices()

GAIA_NODISCARD std::span< const uint8_t > gaia::ecs::Archetype::pair_tgt_indices ( Entity  target) const
inline

Indices of pairs whose target matches the given target.

Parameters
targetTarget entity to match.
Returns
Matching pair index span.

◆ pairs()

GAIA_NODISCARD uint32_t gaia::ecs::Archetype::pairs ( ) const
inline

Returns the number of pairs registered in the archetype.

Returns
Number of pairs

◆ pairs_is()

GAIA_NODISCARD uint32_t gaia::ecs::Archetype::pairs_is ( ) const
inline

Returns the number of Is pairs registered in the archetype.

Returns
Number of Is pairs

◆ progress_death()

GAIA_NODISCARD bool gaia::ecs::Archetype::progress_death ( )
inline

Updates internal lifespan.

Returns
True if there is some lifespan left, false otherwise.

◆ props()

GAIA_NODISCARD const Properties & gaia::ecs::Archetype::props ( ) const
inline

Shape properties of this archetype.

Returns
Archetype properties.

◆ queryMask()

QueryMask gaia::ecs::Archetype::queryMask ( ) const
inline

Query mask describing which simple queries may match this archetype.

Returns
Query mask of the archetype shape.

◆ ready_to_die()

GAIA_NODISCARD bool gaia::ecs::Archetype::ready_to_die ( ) const
inline

Tells whether archetype is ready to be deleted.

Returns
True when the archetype is empty, lifespan-bounded, and no longer dying.

◆ remove_entity()

void gaia::ecs::Archetype::remove_entity ( Chunk chunk,
uint16_t  row,
EntityContainers &  recs 
)
inline

Removes an entity from the chunk and updates the chunk versions.

Parameters
chunkChunk to remove the entity from
rowRow of the entity
recsEntity containers

◆ remove_entity_raw()

void gaia::ecs::Archetype::remove_entity_raw ( Chunk chunk,
uint16_t  row,
EntityContainers &  recs 
)
inline

Removes an entity from the chunk.

Parameters
chunkChunk to remove the entity from
rowRow of the entity
recsEntity containers

◆ right_edges() [1/2]

GAIA_NODISCARD auto & gaia::ecs::Archetype::right_edges ( )
inline

Mutable view over the archetype "add" graph edges.

Returns
Right-edge container reference.

◆ right_edges() [2/2]

GAIA_NODISCARD const auto & gaia::ecs::Archetype::right_edges ( ) const
inline

Const view over the archetype "add" graph edges.

Returns
Right-edge container reference.

◆ save()

void gaia::ecs::Archetype::save ( ser::serializer s)
inline

Serializes the archetype: free-chunk index, list index, and each chunk.

Parameters
sserializer to write to.

◆ set_hashes()

void gaia::ecs::Archetype::set_hashes ( LookupHash  hashLookup)
inline

Sets hashes for each component type and lookup.

Parameters
hashLookupHash used for archetype lookup purposes

◆ set_max_lifespan()

void gaia::ecs::Archetype::set_max_lifespan ( uint32_t  lifespan)
inline

Sets maximal lifespan of an archetype.

Parameters
lifespanHow many world updates an empty archetype is kept. If zero, the archetype it kept indefinitely.

◆ sort_entities()

void gaia::ecs::Archetype::sort_entities ( Entity  entity,
TSortByFunc  func 
)
inline

Sorts all entities in the archetypes according to the given function.

Parameters
entityEntity to sort by
funcFunction to sort by

◆ try_update_free_chunk_idx() [1/2]

void gaia::ecs::Archetype::try_update_free_chunk_idx ( )
inline

Tries to update the index of the first chunk that has space left for at least one entity.

Warning
Always use in tandem with foc_free_chunk()

◆ try_update_free_chunk_idx() [2/2]

void gaia::ecs::Archetype::try_update_free_chunk_idx ( Chunk chunkThatRemovedEntity)
inline

Tries to update the index of the first chunk that has space left for at least one entity.

Warning
Always use in tandem with foc_free_chunk() and remove_entity()

Member Data Documentation

◆ MAX_ARCHETYPE_LIFESPAN

constexpr uint16_t gaia::ecs::Archetype::MAX_ARCHETYPE_LIFESPAN = (1 << ARCHETYPE_LIFESPAN_BITS) - 1
staticconstexpr

Archetype lifespan must be at least as long as chunk lifespan.

Number of ticks before empty chunks are removed


The documentation for this class was generated from the following file: