Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::Chunk Class Referencefinal

Public Types

using EntityArray = cnt::sarray_ext< Entity, ChunkHeader::MAX_COMPONENTS >
 
using ComponentArray = cnt::sarray_ext< Component, ChunkHeader::MAX_COMPONENTS >
 
using ComponentOffsetArray = cnt::sarray_ext< ChunkDataOffset, ChunkHeader::MAX_COMPONENTS >
 

Public Member Functions

template<bool WorldVersionUpdateWanted>
GAIA_NODISCARD GAIA_FORCEINLINE auto comp_ptr_mut_gen (uint32_t compIdx, uint32_t row)
 Returns a read-write span of the component data. Also updates the world version for the component.
 
void finish_write (uint32_t compIdx, uint16_t from, uint16_t to)
 Finishes a raw write over a chunk range by updating versions, running set hooks once, and notifying OnSet observers after the callback completed.
 
 Chunk (const Chunk &chunk)=delete
 
 Chunk (Chunk &&chunk)=delete
 
Chunkoperator= (const Chunk &chunk)=delete
 
Chunkoperator= (Chunk &&chunk)=delete
 
void save (ser::serializer &s)
 
void load (ser::serializer &s)
 
void remove_last_entity ()
 Remove the last entity from a chunk. If as a result the chunk becomes empty it is scheduled for deletion.
 
void update_versions ()
 Updates the version numbers for this chunk.
 
template<typename T >
GAIA_NODISCARD decltype(auto) view (uint16_t from, uint16_t to) const
 Returns a read-only entity or component view.
 
template<typename T >
GAIA_NODISCARD decltype(auto) view () const
 
template<typename T >
GAIA_NODISCARD decltype(auto) view_raw (const void *ptr, uint32_t size) const
 
template<typename T >
GAIA_NODISCARD decltype(auto) view_mut (uint16_t from, uint16_t to)
 Returns a mutable entity or component view.
 
template<typename T >
GAIA_NODISCARD decltype(auto) view_mut ()
 
template<typename T >
GAIA_NODISCARD decltype(auto) view_mut_raw (void *ptr, uint32_t size) const
 
template<typename T >
GAIA_NODISCARD decltype(auto) sview_mut (uint16_t from, uint16_t to)
 Returns a mutable component view. Doesn't update the world version when the access is acquired.
 
template<typename T >
GAIA_NODISCARD decltype(auto) sview_mut_raw (void *ptr, uint32_t size) const
 
template<typename T >
GAIA_NODISCARD decltype(auto) sview_mut ()
 
template<typename T >
GAIA_FORCEINLINE void modify ()
 Marks the component.
 
template<typename T >
GAIA_NODISCARD decltype(auto) view_auto (uint16_t from, uint16_t to)
 Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable.
 
template<typename T >
GAIA_NODISCARD decltype(auto) view_auto ()
 
template<typename T >
GAIA_NODISCARD decltype(auto) sview_auto (uint16_t from, uint16_t to)
 Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable. Doesn't update the world version when read-write access is acquired.
 
template<typename T >
GAIA_NODISCARD decltype(auto) sview_auto ()
 
GAIA_NODISCARD EntitySpan entity_view () const
 
GAIA_NODISCARD Worldworld ()
 
GAIA_NODISCARD const Worldworld () const
 
GAIA_NODISCARD EntitySpan ids_view () const
 
GAIA_NODISCARD std::span< const ComponentRecordcomp_rec_view () const
 
GAIA_NODISCARD uint8_t * comp_ptr_mut (uint32_t compIdx)
 
GAIA_NODISCARD uint8_t * comp_ptr_mut (uint32_t compIdx, uint32_t offset)
 
GAIA_NODISCARD const uint8_t * comp_ptr (uint32_t compIdx) const
 
GAIA_NODISCARD const uint8_t * comp_ptr (uint32_t compIdx, uint32_t offset) const
 
GAIA_NODISCARD uint16_t add_entity (Entity entity)
 Make.
 
void move_entity_data (Entity entity, uint16_t row, EntityContainers &recs)
 Moves all data associated with entity into the chunk so that it is stored at the row row.
 
void remove_entity_inter (uint16_t row, EntityContainers &recs)
 Tries to remove the entity at row. Removal is done via swapping with last entity in chunk. Upon removal, all associated data is also removed. If the entity at the given row already is the last chunk entity, it is removed directly.
 
void remove_entity (uint16_t row, EntityContainers &recs)
 Tries to remove the entity at row row. Removal is done via swapping with last entity in chunk. Upon removal, all associated data is also removed. If the entity at the given row already is the last chunk entity, it is removed directly.
 
void swap_chunk_entities (uint16_t rowA, uint16_t rowB, EntityContainers &recs)
 Tries to swap the entity at row rowA with the one at the row rowB. When swapping, all data associated with the two entities is swapped as well. If rowA equals rowB no swapping is performed.
 
void enable_entity (uint16_t row, bool enableEntity, EntityContainers &recs)
 Enables or disables the entity on a given row in the chunk.
 
bool enabled (uint16_t row) const
 Checks if the entity is enabled.
 
uint8_t & data (uint32_t offset)
 Returns a mutable pointer to chunk data.
 
const uint8_t & data (uint32_t offset) const
 Returns an immutable pointer to chunk data.
 
void call_ctor (uint32_t entIdx, const ComponentCacheItem &item)
 
void call_gen_ctors (uint32_t entIdx, uint32_t entCnt)
 
void call_all_dtors ()
 
GAIA_NODISCARD bool has (Entity entity) const
 Checks if a component/entity entity is present in the chunk.
 
template<typename T >
GAIA_NODISCARD bool has () const
 Checks if component T is present in the chunk.
 
template<typename T >
decltype(auto) set (uint16_t row)
 Sets the value of the unique component T on row in the chunk.
 
template<typename T >
decltype(auto) set_idx (uint16_t row, uint32_t compIdx)
 Sets the value of a generic component using a pre-resolved component column.
 
template<typename T >
decltype(auto) set_idx (uint32_t compIdx)
 Sets the value of a unique component using a pre-resolved component column.
 
template<typename T >
decltype(auto) set (uint16_t row, Entity type)
 Sets the value of a generic entity type at the position row in the chunk.
 
template<typename T >
decltype(auto) sset (uint16_t row)
 Sets the value of the unique component T on row in the chunk.
 
template<typename T >
decltype(auto) sset_idx (uint16_t row, uint32_t compIdx)
 Sets the value of a generic component using a pre-resolved component column.
 
template<typename T >
decltype(auto) sset_idx (uint32_t compIdx)
 Sets the value of a unique component using a pre-resolved component column.
 
template<typename T >
decltype(auto) sset (uint16_t row, Entity type)
 Sets the value of a generic entity type at the position row in the chunk.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get (uint16_t row) const
 Returns the value stored in the generic component T on row in the chunk.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get_idx (uint16_t row, uint32_t compIdx) const
 Returns the value stored in the generic component T using a pre-resolved component column.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get (uint16_t row, Entity type) const
 Returns the value stored in the generic component type on row in the chunk.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get () const
 Returns the value stored in the unique component T.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get_idx (uint32_t compIdx) const
 Returns the value stored in the unique component T using a pre-resolved component column.
 
template<typename T >
GAIA_NODISCARD Entity comp_entity () const
 
GAIA_NODISCARD uint32_t comp_idx (Entity entity) const
 Returns the internal index of a component based on the provided entity.
 
GAIA_NODISCARD uint32_t comp_idx (Entity entity, uint32_t offset) const
 Returns the internal index of a component based on the provided entity.
 
void set_idx (uint32_t value)
 Sets the index of this chunk in its archetype's storage.
 
GAIA_NODISCARD uint32_t idx () const
 Returns the index of this chunk in its archetype's storage.
 
GAIA_NODISCARD bool has_enabled_entities () const
 Checks is this chunk has any enabled entities.
 
GAIA_NODISCARD bool has_disabled_entities () const
 Checks is this chunk has any disabled entities.
 
GAIA_NODISCARD bool dying () const
 Checks is this chunk is dying.
 
GAIA_NODISCARD bool queued_for_deletion () const
 Returns true when the chunk is currently queued for deferred deletion.
 
GAIA_NODISCARD uint32_t delete_queue_index () const
 Returns the index inside World's deferred chunk-delete queue.
 
void delete_queue_index (uint32_t idx)
 Stores the index inside World's deferred chunk-delete queue.
 
void clear_delete_queue_index ()
 Clears the deferred chunk-delete queue index.
 
void die ()
 Marks the chunk as dead (ready to delete)
 
GAIA_NODISCARD bool dead () const
 Checks is this chunk is dead (ready to delete)
 
void start_dying ()
 Starts the process of dying (not yet ready to delete, can be revived)
 
void revive ()
 Makes a dying chunk alive again.
 
bool progress_death ()
 Updates internal lifespan.
 
GAIA_NODISCARD bool full () const
 Checks is the full capacity of the has has been reached.
 
GAIA_NODISCARD bool is_semi () const
 Checks is the chunk is semi-full.
 
GAIA_NODISCARD uint16_t size () const
 Returns the total number of entities in the chunk (both enabled and disabled)
 
GAIA_NODISCARD bool empty () const
 Checks is there are any entities in the chunk.
 
GAIA_NODISCARD uint16_t size_enabled () const
 Return the number of entities in the chunk which are enabled.
 
GAIA_NODISCARD uint16_t size_disabled () const
 Return the number of entities in the chunk which are enabled.
 
GAIA_NODISCARD uint16_t capacity () const
 Returns the number of entities in the chunk.
 
GAIA_NODISCARD uint8_t size_generic () const
 Returns the total number of generic entities/components in the chunk.
 
GAIA_NODISCARD bool changed (uint32_t requiredVersion) const
 Returns true if the provided version is newer than the one stored internally. Use when checking if there was a movement in data in the world. E.g. if an entity was added, removed or moved in its archetype.
 
GAIA_NODISCARD bool changed (uint32_t requiredVersion, uint32_t compIdx) const
 Returns true if the provided version is newer than the one stored internally.
 
GAIA_NODISCARD bool entity_order_changed (uint32_t requiredVersion) const
 Returns true if entity order changed since requiredVersion. This is narrower than changed(requiredVersion): unrelated component writes do not affect it.
 
GAIA_FORCEINLINE void update_world_version (uint32_t compIdx)
 Update the version of a component at the index.
 
GAIA_FORCEINLINE void update_entity_order_version ()
 Updates the entity-order version after rows were added, removed, or reordered.
 
GAIA_FORCEINLINE void update_world_version ()
 Update the version of all components.
 
GAIA_FORCEINLINE void update_world_version_init ()
 Update the version of all components on chunk init.
 
void diag () const
 

Static Public Member Functions

static constexpr uint16_t chunk_header_size ()
 
static constexpr uint16_t chunk_total_bytes (uint16_t dataSize)
 
static constexpr uint16_t chunk_data_bytes (uint16_t totalSize)
 
static uintptr_t chunk_data_area_offset ()
 Returns the relative offset of m_data in Chunk.
 
static Chunkcreate (const World &wld, const ComponentCache &cc, uint32_t chunkIndex, uint16_t capacity, uint8_t cntEntities, uint8_t genEntities, uint16_t dataBytes, uint32_t &worldVersion, const ChunkDataOffsets &offsets, const Entity *ids, const Component *comps, const ChunkDataOffset *compOffs)
 Allocates memory for a new chunk.
 
static void free (Chunk *pChunk)
 Releases all memory allocated by pChunk.
 
static void copy_entity_data (Entity srcEntity, Entity dstEntity, EntityContainers &recs)
 Copies all data associated with srcEntity into dstEntity.
 
static void copy_entity_data_n_same_chunk (Chunk *pSrcChunk, uint32_t srcRow, Chunk *pDstChunk, uint32_t dstRow, uint32_t dstCount)
 Copies all data associated with srcRow into dstCount consecutive rows in the same-archetype chunk.
 
static void copy_foreign_entity_data_n (Chunk *pSrcChunk, uint32_t srcRow, Chunk *pDstChunk, uint32_t dstRow, uint32_t dstCount)
 Copies all data associated with srcRow into dstCount consecutive rows in a foreign chunk.
 
static void copy_foreign_entity_data (Chunk *pSrcChunk, uint32_t srcRow, Chunk *pDstChunk, uint32_t dstRow)
 Copies all data associated with entity into the chunk so that it is stored at the row row.
 
static void move_foreign_entity_data (Chunk *pSrcChunk, uint32_t srcRow, Chunk *pDstChunk, uint32_t dstRow)
 Moves all data associated with entity into the chunk so that it is stored at the row row.
 
static void swap_chunk_entities (World &world, Entity entityA, Entity entityB)
 Tries to swap entityA with entityB. When swapping, all data associated with the two entities is swapped as well. If entityA and entityB are the same entity no swapping is performed.
 

Member Function Documentation

◆ add_entity()

GAIA_NODISCARD uint16_t gaia::ecs::Chunk::add_entity ( Entity  entity)
inline

Make.

Parameters
entitya part of the chunk at the version of the world.
Returns
Row of entity within the chunk.

◆ comp_idx() [1/2]

GAIA_NODISCARD uint32_t gaia::ecs::Chunk::comp_idx ( Entity  entity) const
inline

Returns the internal index of a component based on the provided entity.

Parameters
entityComponent
Returns
Component index if the component was found. -1 otherwise.
Warning
The component id must be present in the array.

◆ comp_idx() [2/2]

GAIA_NODISCARD uint32_t gaia::ecs::Chunk::comp_idx ( Entity  entity,
uint32_t  offset 
) const
inline

Returns the internal index of a component based on the provided entity.

Parameters
entityComponent
offsetComponent offset
Returns
Component index if the component was found. -1 otherwise.
Warning
The component id must be present in the array.

◆ comp_ptr_mut_gen()

template<bool WorldVersionUpdateWanted>
GAIA_NODISCARD GAIA_FORCEINLINE auto gaia::ecs::Chunk::comp_ptr_mut_gen ( uint32_t  compIdx,
uint32_t  row 
)
inline

Returns a read-write span of the component data. Also updates the world version for the component.

Warning
It is expected the component with compIdx is present. Undefined behavior otherwise.
Parameters
compIdxComponent index
rowRow of entity in the chunk
Template Parameters
WorldVersionUpdateWantedIf true, the world version is updated as a result of the write access
Returns
Pointer to component data.

◆ copy_entity_data()

static void gaia::ecs::Chunk::copy_entity_data ( Entity  srcEntity,
Entity  dstEntity,
EntityContainers recs 
)
inlinestatic

Copies all data associated with srcEntity into dstEntity.

Parameters
srcEntitySource entity
dstEntityDestination entity
recsEntity containers

◆ copy_entity_data_n_same_chunk()

static void gaia::ecs::Chunk::copy_entity_data_n_same_chunk ( Chunk pSrcChunk,
uint32_t  srcRow,
Chunk pDstChunk,
uint32_t  dstRow,
uint32_t  dstCount 
)
inlinestatic

Copies all data associated with srcRow into dstCount consecutive rows in the same-archetype chunk.

Parameters
pSrcChunkSource chunk
srcRowRow in source chunk
pDstChunkDestination chunk
dstRowFirst destination row in destination chunk
dstCountNumber of destination rows to copy into

◆ copy_foreign_entity_data()

static void gaia::ecs::Chunk::copy_foreign_entity_data ( Chunk pSrcChunk,
uint32_t  srcRow,
Chunk pDstChunk,
uint32_t  dstRow 
)
inlinestatic

Copies all data associated with entity into the chunk so that it is stored at the row row.

Parameters
pSrcChunkSource chunk
srcRowRow in source chunk
pDstChunkDestination chunk
dstRowRow in destination chunk

◆ copy_foreign_entity_data_n()

static void gaia::ecs::Chunk::copy_foreign_entity_data_n ( Chunk pSrcChunk,
uint32_t  srcRow,
Chunk pDstChunk,
uint32_t  dstRow,
uint32_t  dstCount 
)
inlinestatic

Copies all data associated with srcRow into dstCount consecutive rows in a foreign chunk.

Parameters
pSrcChunkSource chunk
srcRowRow in source chunk
pDstChunkDestination chunk
dstRowFirst destination row in destination chunk
dstCountNumber of destination rows to copy into

◆ create()

static Chunk * gaia::ecs::Chunk::create ( const World wld,
const ComponentCache cc,
uint32_t  chunkIndex,
uint16_t  capacity,
uint8_t  cntEntities,
uint8_t  genEntities,
uint16_t  dataBytes,
uint32_t &  worldVersion,
const ChunkDataOffsets offsets,
const Entity ids,
const Component comps,
const ChunkDataOffset *  compOffs 
)
inlinestatic

Allocates memory for a new chunk.

Returns
Newly allocated chunk

◆ data() [1/2]

uint8_t & gaia::ecs::Chunk::data ( uint32_t  offset)
inline

Returns a mutable pointer to chunk data.

Parameters
offsetOffset into chunk data
Returns
Pointer to chunk data.

◆ data() [2/2]

const uint8_t & gaia::ecs::Chunk::data ( uint32_t  offset) const
inline

Returns an immutable pointer to chunk data.

Parameters
offsetOffset into chunk data
Returns
Pointer to chunk data.

◆ enable_entity()

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

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

Parameters
rowRow of the entity within chunk
enableEntityEnables or disables the entity
recsEntity container records

◆ enabled()

bool gaia::ecs::Chunk::enabled ( uint16_t  row) const
inline

Checks if the entity is enabled.

Parameters
rowRow of the entity within chunk
Returns
True if entity is enabled. False otherwise.

◆ free()

static void gaia::ecs::Chunk::free ( Chunk pChunk)
inlinestatic

Releases all memory allocated by pChunk.

Parameters
pChunkChunk which we want to destroy

◆ get() [1/3]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::get ( ) const
inline

Returns the value stored in the unique component T.

Template Parameters
TComponent or pair
Warning
It is expected the unique component T is present. Undefined behavior otherwise.
Returns
Value stored in the component.

◆ get() [2/3]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::get ( uint16_t  row) const
inline

Returns the value stored in the generic component T on row in the chunk.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
Warning
It is expected the row is valid. Undefined behavior otherwise.
It is expected the component T is present. Undefined behavior otherwise.
Returns
Value stored in the component.

◆ get() [3/3]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::get ( uint16_t  row,
Entity  type 
) const
inline

Returns the value stored in the generic component type on row in the chunk.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
typeComponent/entity/pair
Warning
It is expected the component is present. Undefined behavior otherwise.

◆ get_idx() [1/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::get_idx ( uint16_t  row,
uint32_t  compIdx 
) const
inline

Returns the value stored in the generic component T using a pre-resolved component column.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
compIdxPre-resolved component column index

◆ get_idx() [2/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::get_idx ( uint32_t  compIdx) const
inline

Returns the value stored in the unique component T using a pre-resolved component column.

Template Parameters
TComponent or pair
Parameters
compIdxPre-resolved component column index

◆ has() [1/2]

template<typename T >
GAIA_NODISCARD bool gaia::ecs::Chunk::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::Chunk::has ( Entity  entity) const
inline

Checks if a component/entity entity is present in the chunk.

Parameters
entityEntity
Returns
True if found. False otherwise.

◆ modify()

template<typename T >
GAIA_FORCEINLINE void gaia::ecs::Chunk::modify ( )
inline

Marks the component.

Template Parameters
Tas modified. Best used with sview to manually trigger an update at user's whim. If
TriggerSetHooksis true, also triggers the component's set hooks.

◆ move_entity_data()

void gaia::ecs::Chunk::move_entity_data ( Entity  entity,
uint16_t  row,
EntityContainers recs 
)
inline

Moves all data associated with entity into the chunk so that it is stored at the row row.

Parameters
entityEntity to move
rowEntity's row within its chunk
recsEntity containers

◆ move_foreign_entity_data()

static void gaia::ecs::Chunk::move_foreign_entity_data ( Chunk pSrcChunk,
uint32_t  srcRow,
Chunk pDstChunk,
uint32_t  dstRow 
)
inlinestatic

Moves all data associated with entity into the chunk so that it is stored at the row row.

Parameters
pSrcChunkSource chunk
srcRowRow in source chunk
pDstChunkDestination chunk
dstRowRow in destination chunk

◆ progress_death()

bool gaia::ecs::Chunk::progress_death ( )
inline

Updates internal lifespan.

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

◆ remove_entity()

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

Tries to remove the entity at row row. Removal is done via swapping with last entity in chunk. Upon removal, all associated data is also removed. If the entity at the given row already is the last chunk entity, it is removed directly.

Parameters
rowRow within a chunk
recsEntity containers

◆ remove_entity_inter()

void gaia::ecs::Chunk::remove_entity_inter ( uint16_t  row,
EntityContainers recs 
)
inline

Tries to remove the entity at row. Removal is done via swapping with last entity in chunk. Upon removal, all associated data is also removed. If the entity at the given row already is the last chunk entity, it is removed directly.

Parameters
rowRow within a chunk
recsEntity containers

◆ set() [1/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::set ( uint16_t  row)
inline

Sets the value of the unique component T on row in the chunk.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
Warning
It is expected the component T is present. Undefined behavior otherwise.

◆ set() [2/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::set ( uint16_t  row,
Entity  type 
)
inline

Sets the value of a generic entity type at the position row in the chunk.

Parameters
rowRow of entity in the chunk
typeComponent/entity/pair
Warning
It is expected the component T is present. Undefined behavior otherwise.

◆ set_idx() [1/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::set_idx ( uint16_t  row,
uint32_t  compIdx 
)
inline

Sets the value of a generic component using a pre-resolved component column.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
compIdxPre-resolved component column index

◆ set_idx() [2/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::set_idx ( uint32_t  compIdx)
inline

Sets the value of a unique component using a pre-resolved component column.

Template Parameters
TComponent or pair
Parameters
compIdxPre-resolved component column index

◆ sset() [1/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::sset ( uint16_t  row)
inline

Sets the value of the unique component T on row in the chunk.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
Warning
It is expected the component T is present. Undefined behavior otherwise.
World version is not updated so Query filters will not be able to catch this change.

◆ sset() [2/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::sset ( uint16_t  row,
Entity  type 
)
inline

Sets the value of a generic entity type at the position row in the chunk.

Template Parameters
TComponent or pair
Parameters
rowRow of entity in the chunk
typeComponent/entity/pair
Warning
It is expected the component
Template Parameters
Tis present. Undefined behavior otherwise.
Warning
World version is not updated so Query filters will not be able to catch this change.

◆ sset_idx() [1/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::sset_idx ( uint16_t  row,
uint32_t  compIdx 
)
inline

Sets the value of a generic component using a pre-resolved component column.

Warning
World version is not updated so Query filters will not be able to catch this change.

◆ sset_idx() [2/2]

template<typename T >
decltype(auto) gaia::ecs::Chunk::sset_idx ( uint32_t  compIdx)
inline

Sets the value of a unique component using a pre-resolved component column.

Warning
World version is not updated so Query filters will not be able to catch this change.

◆ sview_auto()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::sview_auto ( uint16_t  from,
uint16_t  to 
)
inline

Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable. Doesn't update the world version when read-write access is acquired.

Warning
If T is a component it is expected to be present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Parameters
fromFirst valid entity row
toLast valid entity row
Returns
Entity or component view

◆ sview_mut()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::sview_mut ( uint16_t  from,
uint16_t  to 
)
inline

Returns a mutable component view. Doesn't update the world version when the access is acquired.

Warning
It is expected the component T is present. Undefined behavior otherwise.
Template Parameters
TComponent
Parameters
fromFirst valid entity row
toLast valid entity row
Returns
Component view with read-write access

◆ swap_chunk_entities() [1/2]

void gaia::ecs::Chunk::swap_chunk_entities ( uint16_t  rowA,
uint16_t  rowB,
EntityContainers recs 
)
inline

Tries to swap the entity at row rowA with the one at the row rowB. When swapping, all data associated with the two entities is swapped as well. If rowA equals rowB no swapping is performed.

Parameters
rowARow of the entityA within chunk
rowBRow of the entityB within chunk
[out]recsEntity container records
Warning
"rowA" must he smaller or equal to "rowB"

◆ swap_chunk_entities() [2/2]

static void gaia::ecs::Chunk::swap_chunk_entities ( World world,
Entity  entityA,
Entity  entityB 
)
inlinestatic

Tries to swap entityA with entityB. When swapping, all data associated with the two entities is swapped as well. If entityA and entityB are the same entity no swapping is performed.

Parameters
worldParent world
entityAFirst entity
entityBSecond entity

◆ update_world_version()

GAIA_FORCEINLINE void gaia::ecs::Chunk::update_world_version ( uint32_t  compIdx)
inline

Update the version of a component at the index.

Parameters
compIdx

◆ view()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::view ( uint16_t  from,
uint16_t  to 
) const
inline

Returns a read-only entity or component view.

Warning
If T is a component it is expected it is present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Parameters
fromFirst valid entity row
toLast valid entity row
Returns
Entity of component view with read-only access

◆ view_auto()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::view_auto ( uint16_t  from,
uint16_t  to 
)
inline

Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable.

Warning
If T is a component it is expected to be present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Parameters
fromFirst valid entity row
toLast valid entity row
Returns
Entity or component view

◆ view_mut()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::Chunk::view_mut ( uint16_t  from,
uint16_t  to 
)
inline

Returns a mutable entity or component view.

Warning
If T is a component it is expected it is present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Parameters
fromFirst valid entity row
toLast valid entity row
Returns
Entity or component view with read-write access

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