Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::ecs::ComponentManager Class Reference

Central manager for all component storage (archetype and sparse-set). More...

#include <manager.hpp>

Classes

struct  SparseStorageEntry
 Type-erased entry for sparse-set component storage. More...

Public Types

using size_type = size_t

Public Member Functions

 ComponentManager ()=default
 ComponentManager (const ComponentManager &)=delete
 ComponentManager (ComponentManager &&) noexcept=default
 ~ComponentManager ()=default
ComponentManageroperator= (const ComponentManager &)=delete
ComponentManageroperator= (ComponentManager &&) noexcept=default
void Clear ()
 Clears all component data, archetypes, and metadata.
void ClearData () noexcept
 Clears all component data and archetypes but retains metadata registrations.
template<ComponentTrait T>
void Register ()
 Registers a component type so the manager knows its metadata.
template<ComponentTrait... Ts>
requires (sizeof...(Ts) > 1)
void RegisterAll ()
 Registers multiple component types.
void InitEntity (Entity entity)
 Initializes an entity in the component manager with an empty archetype.
void RemoveEntity (Entity entity)
 Removes all component data for an entity.
bool TryRemoveEntity (Entity entity)
 Tries to remove all component data for an entity.
void Clear (Entity entity)
 Removes all archetype and sparse-set components from an entity.
template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void AddArchetypeComponents (Entity entity, Ts &&... components)
 Adds multiple archetype-stored components to an entity.
template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto TryAddArchetypeComponents (Entity entity, Ts &&... components) -> std::array< bool, sizeof...(Ts)>
 Adds multiple archetype-stored components to an entity.
template<ArchetypeComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void EmplaceArchetypeComponent (Entity entity, Args &&... args)
 Emplaces an archetype-stored component (construct in-place).
template<ArchetypeComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
bool TryEmplaceArchetypeComponent (Entity entity, Args &&... args)
 Tries to emplace an archetype-stored component.
template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void RemoveArchetypeComponents (Entity entity)
 Removes multiple archetype-stored components from an entity.
template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto TryRemoveArchetypeComponents (Entity entity) -> std::array< bool, sizeof...(Ts)>
 Tries to remove multiple archetype-stored components.
template<SparseComponentTrait T>
void AddSparseComponent (Entity entity, T &&component)
 Adds a sparse-set-stored component to an entity.
template<SparseComponentTrait T>
bool TryAddSparseComponent (Entity entity, T &&component)
 Tries to add a sparse-set-stored component.
template<SparseComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void EmplaceSparseComponent (Entity entity, Args &&... args)
 Emplaces a sparse-set-stored component.
template<SparseComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
bool TryEmplaceSparseComponent (Entity entity, Args &&... args)
 Tries to emplace a sparse-set-stored component.
template<SparseComponentTrait T>
void RemoveSparseComponent (Entity entity)
 Removes a sparse-set-stored component from an entity.
template<SparseComponentTrait T>
bool TryRemoveSparseComponent (Entity entity)
 Tries to remove a sparse-set-stored component.
template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void Add (Entity entity, Ts &&... components)
 Adds multiple components to an entity.
template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto TryAdd (Entity entity, Ts &&... components) -> std::conditional_t< sizeof...(Ts)==1, bool, std::array< bool, sizeof...(Ts)> >
 Tries to add multiple components.
template<ComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void Emplace (Entity entity, Args &&... args)
 Emplaces a component (construct in-place), dispatching by storage type.
template<ComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
bool TryEmplace (Entity entity, Args &&... args)
 Tries to emplace a component.
template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void Remove (Entity entity)
 Removes multiple components from an entity.
template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto TryRemove (Entity entity) -> std::conditional_t< sizeof...(Ts)==1, bool, std::array< bool, sizeof...(Ts)> >
 Tries to remove multiple components.
template<ComponentTrait T>
T & Get (Entity entity)
 Gets a mutable reference to a component.
template<ComponentTrait T>
const T & Get (Entity entity) const
 Gets a const reference to a component.
template<ComponentTrait T>
T * TryGet (Entity entity)
 Tries to get a mutable pointer to a component.
template<ComponentTrait T>
const T * TryGet (Entity entity) const
 Tries to get a const pointer to a component.
template<ComponentTrait T>
bool Registered () const noexcept
 Checks if a component type is registered.
bool Tracked (Entity entity) const noexcept
 Checks if an entity is tracked by the component manager.
template<ComponentTrait T>
bool Has (Entity entity) const
 Checks if an entity has a component.
template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 1)
auto Has (Entity entity) const -> std::array< bool, sizeof...(Ts)>
 Checks if an entity has multiple components.
ArchetypeEntityArchetype (Entity entity)
 Gets the archetype that the entity currently belongs to.
const ArchetypeEntityArchetype (Entity entity) const
 Gets the archetype that the entity currently belongs to (const).
template<SparseComponentTrait T>
auto SparseStorage () -> SparseComponentStorage< T > &
 Gets the sparse-set storage for a component type, creating it if necessary.
template<SparseComponentTrait T>
auto SparseStorage () const -> const SparseComponentStorage< T > &
 Gets the sparse-set storage for a component type (const).
template<ComponentTrait T>
const ComponentMetadataMetadata () const noexcept
 Gets metadata for a component type.
const ComponentMetadataMetadataByIndex (ComponentTypeIndex type_index) const noexcept
 Gets metadata for a component type by its runtime type index.
const SparseStorageEntrySparseEntry (ComponentTypeIndex type_index) const noexcept
size_type TrackedEntityCount () const noexcept
 Gets the number of entities currently tracked by the component manager.
size_type ArchetypeCount () const noexcept
 Gets the number of archetypes currently in the manager.
auto Archetypes () noexcept -> std::span< std::reference_wrapper< Archetype > >
 Gets all archetypes currently in the manager.
auto Archetypes () const noexcept -> std::span< const std::reference_wrapper< Archetype > >
 Gets all archetypes (const).
size_type StructuralVersion () const noexcept
 Gets the current structural version of the component manager.

Detailed Description

Central manager for all component storage (archetype and sparse-set).

Maintains:

  • A registry of component metadata (type-erased info per component type)
  • An archetype graph for entities with archetype-stored components
  • Sparse-set storages for sparse-set-stored components
  • Entity-to-archetype mapping for O(1) archetype lookup by entity

Archetype-stored components live in dense SoA columns inside Archetype instances. Adding/removing archetype components causes entity migration between archetypes.

Sparse-set-stored components live in independent SparseComponentStorage<T> instances, stored inside SparseStorageEntry values within a MultiTypeMap.

Archetypes are owned by a std::deque<Archetype> which provides pointer/reference stability on push_back, allowing all maps and edge caches to safely hold std::reference_wrapper<Archetype> without invalidation concerns.

Note
Not thread-safe.

Definition at line 133 of file manager.hpp.

Member Typedef Documentation

◆ size_type

Definition at line 135 of file manager.hpp.

Constructor & Destructor Documentation

◆ ComponentManager() [1/3]

helios::ecs::ComponentManager::ComponentManager ( )
default

◆ ComponentManager() [2/3]

helios::ecs::ComponentManager::ComponentManager ( const ComponentManager & )
delete

◆ ComponentManager() [3/3]

helios::ecs::ComponentManager::ComponentManager ( ComponentManager && )
defaultnoexcept

◆ ~ComponentManager()

helios::ecs::ComponentManager::~ComponentManager ( )
default

Member Function Documentation

◆ Add()

template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void helios::ecs::ComponentManager::Add ( Entity entity,
Ts &&... components )
inline

Adds multiple components to an entity.

Archetype components are batched into a single migration. Sparse components are added individually after the archetype migration.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must be unique and at least 1 type
Parameters
entityEntity
componentsComponent values

Definition at line 1306 of file manager.hpp.

◆ AddArchetypeComponents()

template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void helios::ecs::ComponentManager::AddArchetypeComponents ( Entity entity,
Ts &&... components )
inline

Adds multiple archetype-stored components to an entity.

Warning
Triggers assertion in next cases:
  • Entity is invalid.
  • Entity is not tracked.
  • Any component type is not part of this archetype.
Template Parameters
TsComponent types, must be unique and at least 1 type
Parameters
entityEntity
componentsComponent values

Definition at line 1087 of file manager.hpp.

◆ AddSparseComponent()

template<SparseComponentTrait T>
void helios::ecs::ComponentManager::AddSparseComponent ( Entity entity,
T && component )
inline

Adds a sparse-set-stored component to an entity.

Replaces if already present.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type (must have sparse-set storage)
Parameters
entityEntity
componentComponent value

Definition at line 1240 of file manager.hpp.

◆ ArchetypeCount()

size_type helios::ecs::ComponentManager::ArchetypeCount ( ) const
inlinenodiscardnoexcept

Gets the number of archetypes currently in the manager.

Returns
Number of archetypes

Definition at line 655 of file manager.hpp.

◆ Archetypes() [1/2]

auto helios::ecs::ComponentManager::Archetypes ( ) const -> std::span< const std::reference_wrapper< Archetype > >
inlinenodiscardnoexcept

Gets all archetypes (const).

Returns
Span of const reference wrappers to all archetypes

Definition at line 674 of file manager.hpp.

◆ Archetypes() [2/2]

auto helios::ecs::ComponentManager::Archetypes ( ) -> std::span< std::reference_wrapper< Archetype > >
inlinenodiscardnoexcept

Gets all archetypes currently in the manager.

Useful for query iteration. Callers can filter archetypes by their ArchetypeId.

Returns
Span of reference wrappers to all archetypes

Definition at line 665 of file manager.hpp.

◆ Clear() [1/2]

void helios::ecs::ComponentManager::Clear ( )
inline

Clears all component data, archetypes, and metadata.

Definition at line 966 of file manager.hpp.

◆ Clear() [2/2]

void helios::ecs::ComponentManager::Clear ( Entity entity)
inline

Removes all archetype and sparse-set components from an entity.

The entity is moved to the empty archetype.

Warning
Triggers assertion in next cases:
Parameters
entityEntity to clear

Definition at line 1056 of file manager.hpp.

◆ ClearData()

void helios::ecs::ComponentManager::ClearData ( )
inlinenoexcept

Clears all component data and archetypes but retains metadata registrations.

Definition at line 977 of file manager.hpp.

◆ Emplace()

template<ComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void helios::ecs::ComponentManager::Emplace ( Entity entity,
Args &&... args )
inline

Emplaces a component (construct in-place), dispatching by storage type.

Replaces if already present.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type
ArgsConstructor argument types
Parameters
entityEntity
argsArguments forwarded to T's constructor

Definition at line 1392 of file manager.hpp.

◆ EmplaceArchetypeComponent()

template<ArchetypeComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void helios::ecs::ComponentManager::EmplaceArchetypeComponent ( Entity entity,
Args &&... args )
inline

Emplaces an archetype-stored component (construct in-place).

Replaces if already present, otherwise migrates.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type (must have archetype storage)
ArgsConstructor argument types
Parameters
entityEntity
argsArguments forwarded to T's constructor

Definition at line 1178 of file manager.hpp.

◆ EmplaceSparseComponent()

template<SparseComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void helios::ecs::ComponentManager::EmplaceSparseComponent ( Entity entity,
Args &&... args )
inline

Emplaces a sparse-set-stored component.

Replaces if already present.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type (must have sparse-set storage)
ArgsConstructor argument types
Parameters
entityEntity
argsArguments forwarded to T's constructor

Definition at line 1260 of file manager.hpp.

◆ EntityArchetype() [1/2]

Archetype & helios::ecs::ComponentManager::EntityArchetype ( Entity entity)
inlinenodiscard

Gets the archetype that the entity currently belongs to.

Warning
Triggers assertion in next cases:
Parameters
entityEntity
Returns
Reference to the entity's archetype

Definition at line 1616 of file manager.hpp.

◆ EntityArchetype() [2/2]

const Archetype & helios::ecs::ComponentManager::EntityArchetype ( Entity entity) const
inlinenodiscard

Gets the archetype that the entity currently belongs to (const).

Warning
Triggers assertion in next cases:
Parameters
entityEntity
Returns
Const reference to the entity's archetype

Definition at line 1624 of file manager.hpp.

◆ Get() [1/2]

template<ComponentTrait T>
T & helios::ecs::ComponentManager::Get ( Entity entity)
inlinenodiscard

Gets a mutable reference to a component.

Warning
Triggers assertion in next cases:
  • Entity is invalid.
  • Entity is not tracked (for archetype-stored components).
  • Sparse storage does not exist for the component type (for sparse-stored components).
  • Entity does not have the component.
Template Parameters
TComponent type
Parameters
entityEntity
Returns
Mutable reference to component

Definition at line 1493 of file manager.hpp.

◆ Get() [2/2]

template<ComponentTrait T>
const T & helios::ecs::ComponentManager::Get ( Entity entity) const
inlinenodiscard

Gets a const reference to a component.

Warning
Triggers assertion in next cases:
  • Entity is invalid.
  • Entity is not tracked (for archetype-stored components).
  • Sparse storage does not exist for the component type (for sparse-stored components).
  • Entity does not have the component.
Template Parameters
TComponent type
Parameters
entityEntity
Returns
Const reference to component

Definition at line 1517 of file manager.hpp.

◆ Has() [1/2]

template<ComponentTrait T>
bool helios::ecs::ComponentManager::Has ( Entity entity) const
inlinenodiscard

Checks if an entity has a component.

Warning
Triggers assertion if entity is invalid.
Template Parameters
TComponent type
Parameters
entityEntity
Returns
True if entity has the component

Definition at line 1590 of file manager.hpp.

◆ Has() [2/2]

template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 1)
auto helios::ecs::ComponentManager::Has ( Entity entity) const -> std::array< bool, sizeof...(Ts)>
inlinenodiscard

Checks if an entity has multiple components.

Warning
Triggers assertion if entity is invalid.
Template Parameters
TsComponent types
Parameters
entityEntity
Returns
Array of bools indicating whether the entity has each component

Definition at line 1610 of file manager.hpp.

◆ InitEntity()

void helios::ecs::ComponentManager::InitEntity ( Entity entity)
inline

Initializes an entity in the component manager with an empty archetype.

Must be called after entity creation but before any component operations.

Warning
Triggers assertion in next cases:
Parameters
entityEntity to initialize

Definition at line 998 of file manager.hpp.

◆ Metadata()

template<ComponentTrait T>
const ComponentMetadata & helios::ecs::ComponentManager::Metadata ( ) const
inlinenodiscardnoexcept

Gets metadata for a component type.

Warning
Triggers assertion if not registered.
Template Parameters
TComponent type
Returns
Const reference to metadata

Definition at line 1642 of file manager.hpp.

◆ MetadataByIndex()

const ComponentMetadata * helios::ecs::ComponentManager::MetadataByIndex ( ComponentTypeIndex type_index) const
inlinenodiscardnoexcept

Gets metadata for a component type by its runtime type index.

Parameters
type_indexComponent type index
Returns
Pointer to metadata, or nullptr if not registered

Definition at line 1650 of file manager.hpp.

◆ operator=() [1/2]

ComponentManager & helios::ecs::ComponentManager::operator= ( ComponentManager && )
defaultnoexcept

◆ operator=() [2/2]

ComponentManager & helios::ecs::ComponentManager::operator= ( const ComponentManager & )
delete

◆ Register()

template<ComponentTrait T>
void helios::ecs::ComponentManager::Register ( )
inline

Registers a component type so the manager knows its metadata.

Registration is optional for compile-time-typed APIs (they auto-register). Explicitly registering is useful for pre-warming or validation.

Template Parameters
TComponent type

Definition at line 990 of file manager.hpp.

◆ RegisterAll()

template<ComponentTrait... Ts>
requires (sizeof...(Ts) > 1)
void helios::ecs::ComponentManager::RegisterAll ( )
inline

Registers multiple component types.

Template Parameters
TsComponent types

Definition at line 168 of file manager.hpp.

◆ Registered()

template<ComponentTrait T>
bool helios::ecs::ComponentManager::Registered ( ) const
inlinenodiscardnoexcept

Checks if a component type is registered.

Template Parameters
TComponent type
Returns
True if registered

Definition at line 1579 of file manager.hpp.

◆ Remove()

template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void helios::ecs::ComponentManager::Remove ( Entity entity)
inline

Removes multiple components from an entity.

Archetype components are removed in a single migration. Sparse components are removed individually.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must be unique and at least 1 type
Parameters
entityEntity

Definition at line 1418 of file manager.hpp.

◆ RemoveArchetypeComponents()

template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
void helios::ecs::ComponentManager::RemoveArchetypeComponents ( Entity entity)
inline

Removes multiple archetype-stored components from an entity.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must have archetype storage, be unique and at least 1 type
Parameters
entityEntity

Definition at line 1195 of file manager.hpp.

◆ RemoveEntity()

void helios::ecs::ComponentManager::RemoveEntity ( Entity entity)
inline

Removes all component data for an entity.

Removes the entity from its archetype and from all sparse-set storages.

Warning
Triggers assertion in next cases:
Parameters
entityEntity to remove

Definition at line 1013 of file manager.hpp.

◆ RemoveSparseComponent()

template<SparseComponentTrait T>
void helios::ecs::ComponentManager::RemoveSparseComponent ( Entity entity)
inline

Removes a sparse-set-stored component from an entity.

Warning
Triggers assertion in next cases:
  • Entity is invalid.
  • Entity is not tracked.
  • Sparse storage for the component type does not exist.
  • Entity does not have the component.
Template Parameters
TComponent type (must have sparse-set storage)
Parameters
entityEntity

Definition at line 1281 of file manager.hpp.

◆ SparseEntry()

const SparseStorageEntry * helios::ecs::ComponentManager::SparseEntry ( ComponentTypeIndex type_index) const
inlinenodiscardnoexcept

Definition at line 637 of file manager.hpp.

◆ SparseStorage() [1/2]

template<SparseComponentTrait T>
auto helios::ecs::ComponentManager::SparseStorage ( ) -> SparseComponentStorage< T > &
inlinenodiscard

Gets the sparse-set storage for a component type, creating it if necessary.

Template Parameters
TComponent type (must have sparse-set storage)
Returns
Mutable reference to the sparse-set storage

Definition at line 604 of file manager.hpp.

◆ SparseStorage() [2/2]

template<SparseComponentTrait T>
auto helios::ecs::ComponentManager::SparseStorage ( ) const -> const SparseComponentStorage< T > &
inlinenodiscard

Gets the sparse-set storage for a component type (const).

Warning
Triggers assertion if the storage for the component type does not exist.
Template Parameters
TComponent type
Returns
Const reference to the sparse-set storage

Definition at line 1633 of file manager.hpp.

◆ StructuralVersion()

size_type helios::ecs::ComponentManager::StructuralVersion ( ) const
inlinenodiscardnoexcept

Gets the current structural version of the component manager.

Incremented on every archetype creation or entity migration.

Returns
Structural version counter

Definition at line 684 of file manager.hpp.

◆ Tracked()

bool helios::ecs::ComponentManager::Tracked ( Entity entity) const
inlinenodiscardnoexcept

Checks if an entity is tracked by the component manager.

Warning
Triggers assertion if entity is invalid.
Parameters
entityEntity to check
Returns
True if the entity has been initialized

Definition at line 1584 of file manager.hpp.

◆ TrackedEntityCount()

size_type helios::ecs::ComponentManager::TrackedEntityCount ( ) const
inlinenodiscardnoexcept

Gets the number of entities currently tracked by the component manager.

Returns
Number of tracked entities

Definition at line 647 of file manager.hpp.

◆ TryAdd()

template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto helios::ecs::ComponentManager::TryAdd ( Entity entity,
Ts &&... components ) -> std::conditional_t< sizeof...(Ts)==1, bool, std::array< bool, sizeof...(Ts)> >
inline

Tries to add multiple components.

Archetype components are batched into a single migration. Sparse components are added individually after the archetype migration. Results are returned in the same order as the input types.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must be unique and at least 1 type
Parameters
entityEntity
componentsComponent values
Returns
Array of bools indicating whether each component was added if multiple components were added, or a single bool if only one component was added

Definition at line 1334 of file manager.hpp.

◆ TryAddArchetypeComponents()

template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto helios::ecs::ComponentManager::TryAddArchetypeComponents ( Entity entity,
Ts &&... components ) -> std::array< bool, sizeof...(Ts)>
inline

Adds multiple archetype-stored components to an entity.

Components are added in a single migration to minimize overhead.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must have archetype storage, be unique and at least 1 type
Parameters
entityEntity
componentsComponent values

Definition at line 1132 of file manager.hpp.

◆ TryAddSparseComponent()

template<SparseComponentTrait T>
bool helios::ecs::ComponentManager::TryAddSparseComponent ( Entity entity,
T && component )
inline

Tries to add a sparse-set-stored component.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type (must have sparse-set storage)
Parameters
entityEntity
componentComponent value
Returns
True if added, false if entity already had the component

Definition at line 1249 of file manager.hpp.

◆ TryEmplace()

template<ComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
bool helios::ecs::ComponentManager::TryEmplace ( Entity entity,
Args &&... args )
inline

Tries to emplace a component.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type
ArgsConstructor argument types
Parameters
entityEntity
argsArguments forwarded to T's constructor
Returns
True if emplaced, false if entity already had the component

Definition at line 1405 of file manager.hpp.

◆ TryEmplaceArchetypeComponent()

template<ArchetypeComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
bool helios::ecs::ComponentManager::TryEmplaceArchetypeComponent ( Entity entity,
Args &&... args )
inline

Tries to emplace an archetype-stored component.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type (must have archetype storage)
ArgsConstructor argument types
Parameters
entityEntity
argsArguments forwarded to T's constructor
Returns
True if emplaced, false if entity already had the component

Definition at line 1186 of file manager.hpp.

◆ TryEmplaceSparseComponent()

template<SparseComponentTrait T, typename... Args>
requires std::constructible_from<T, Args...>
bool helios::ecs::ComponentManager::TryEmplaceSparseComponent ( Entity entity,
Args &&... args )
inline

Tries to emplace a sparse-set-stored component.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type
ArgsConstructor argument types
Parameters
entityEntity
argsArguments forwarded to T's constructor
Returns
True if emplaced, false if entity already had the component

Definition at line 1271 of file manager.hpp.

◆ TryGet() [1/2]

template<ComponentTrait T>
T * helios::ecs::ComponentManager::TryGet ( Entity entity)
inlinenodiscard

Tries to get a mutable pointer to a component.

Warning
Triggers assertion if entity is invalid.
Template Parameters
TComponent type
Parameters
entityEntity
Returns
Pointer to component or nullptr if not found

Definition at line 1541 of file manager.hpp.

◆ TryGet() [2/2]

template<ComponentTrait T>
const T * helios::ecs::ComponentManager::TryGet ( Entity entity) const
inlinenodiscard

Tries to get a const pointer to a component.

Warning
Triggers assertion if entity is invalid.
Template Parameters
TComponent type
Parameters
entityEntity
Returns
Const pointer to component or nullptr if not found

Definition at line 1560 of file manager.hpp.

◆ TryRemove()

template<ComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto helios::ecs::ComponentManager::TryRemove ( Entity entity) -> std::conditional_t< sizeof...(Ts)==1, bool, std::array< bool, sizeof...(Ts)> >
inline

Tries to remove multiple components.

Archetype components are removed in a single migration. Sparse components are removed individually. Results are returned in the same order as the input types.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must be unique and at least 1 type
Parameters
entityEntity
Returns
Array of bools indicating whether each component was removed if more than one type was passed, or a single bool if only one type was passed

Definition at line 1443 of file manager.hpp.

◆ TryRemoveArchetypeComponents()

template<ArchetypeComponentTrait... Ts>
requires utils::UniqueTypes<Ts...> && (sizeof...(Ts) > 0)
auto helios::ecs::ComponentManager::TryRemoveArchetypeComponents ( Entity entity) -> std::array< bool, sizeof...(Ts)>
inline

Tries to remove multiple archetype-stored components.

Warning
Triggers assertion in next cases:
Template Parameters
TsComponent types, must have archetype storage, be unique and at least 1 type
Parameters
entityEntity
Returns
Array of bools indicating whether each component was removed if more than one type passed, or a single bool if only one type passed

Definition at line 1215 of file manager.hpp.

◆ TryRemoveEntity()

bool helios::ecs::ComponentManager::TryRemoveEntity ( Entity entity)
inline

Tries to remove all component data for an entity.

Removes the entity from its archetype and from all sparse-set storages.

Warning
Triggers assertion if entity is invalid.
Parameters
entityEntity to remove
Returns
True if removed, false if entity was not tracked

Definition at line 1035 of file manager.hpp.

◆ TryRemoveSparseComponent()

template<SparseComponentTrait T>
bool helios::ecs::ComponentManager::TryRemoveSparseComponent ( Entity entity)
inline

Tries to remove a sparse-set-stored component.

Warning
Triggers assertion in next cases:
Template Parameters
TComponent type (must have sparse-set storage)
Parameters
entityEntity
Returns
True if removed, false if entity didn't have the component or storage doesn't exist

Definition at line 1293 of file manager.hpp.