ECSM v0.4.0
ComponentSystem< T, DestroyComponents >

Base system class with components. More...

#include <ecsm.hpp>

Public Types

typedef T ComponentType
using Components = LinearPool<T, DestroyComponents>

Public Member Functions

const ComponentsgetComponents () const noexcept
 Returns system component pool.
std::string_view getComponentName () const override
 Returns specific component name of the system.
std::type_index getComponentType () const override
 Returns specific component typeid() of the system.
View< ComponentgetComponent (ID< Component > instance) override
 Returns specific component View.
void disposeComponents () override
 Actually destroys system components.
bool hasComponent (ID< Entity > entity) const
 Returns true if entity has specific component.
View< T > getComponent (ID< Entity > entity) const
 Returns entity specific component view.
View< T > tryGetComponent (ID< Entity > entity) const
 Returns entity specific component view if exist.
void resetComponentData (ID< Entity > entity, bool full=true)
 Resets entity specific component data.

Protected Member Functions

ID< ComponentcreateComponent (ID< Entity > entity) override
 Creates a new component instance for the entity.
void destroyComponent (ID< Component > instance) override
 Destroys component instance.
void resetComponent (View< Component > component, bool full) override
 Resets component data.
void copyComponent (View< Component > source, View< Component > destination) override
 Copies component data from source to destination.

Protected Attributes

Components components

Detailed Description

template<class T = Component, bool DestroyComponents = true>
class ecsm::ComponentSystem< T, DestroyComponents >

Base system class with components.

See the System.

Template Parameters
Ttype of the system component
DestroyComponentssystem should call destroy() function of the components

Member Typedef Documentation

◆ ComponentType

template<class T = Component, bool DestroyComponents = true>
typedef T ComponentType

Type of the system component.

◆ Components

template<class T = Component, bool DestroyComponents = true>
using Components = LinearPool<T, DestroyComponents>

System component pool type.

Member Function Documentation

◆ createComponent()

template<class T = Component, bool DestroyComponents = true>
ID< Component > createComponent ( ID< Entity > entity)
inlineoverrideprotectedvirtual

Creates a new component instance for the entity.

You should use Manager to add components to the entity.

Reimplemented from System.

◆ destroyComponent()

template<class T = Component, bool DestroyComponents = true>
void destroyComponent ( ID< Component > instance)
inlineoverrideprotectedvirtual

Destroys component instance.

You should use Manager to remove components from the entity.

Reimplemented from System.

◆ resetComponent()

template<class T = Component, bool DestroyComponents = true>
void resetComponent ( View< Component > component,
bool full )
inlineoverrideprotectedvirtual

Resets component data.

You should use Manager to remove components from the entity.

Reimplemented from System.

◆ copyComponent()

template<class T = Component, bool DestroyComponents = true>
void copyComponent ( View< Component > source,
View< Component > destination )
inlineoverrideprotectedvirtual

Copies component data from source to destination.

You should use Manager to copy component data of entities.

Reimplemented from System.

◆ getComponentName()

template<class T = Component, bool DestroyComponents = true>
std::string_view getComponentName ( ) const
inlineoverridevirtual

Returns specific component name of the system.

Reimplemented from System.

Reimplemented in DoNotDestroySystem, and DoNotDuplicateSystem.

◆ getComponentType()

template<class T = Component, bool DestroyComponents = true>
std::type_index getComponentType ( ) const
inlineoverridevirtual

Returns specific component typeid() of the system.

Note
Override it to define a custom component of the system.

Reimplemented from System.

◆ getComponent() [1/2]

template<class T = Component, bool DestroyComponents = true>
View< Component > getComponent ( ID< Component > instance)
inlineoverridevirtual

Returns specific component View.

Parameters
instancetarget system component instance

Reimplemented from System.

◆ disposeComponents()

template<class T = Component, bool DestroyComponents = true>
void disposeComponents ( )
inlineoverridevirtual

Actually destroys system components.

Components are not destroyed immediately, only after the dispose call.

Reimplemented from System.

◆ hasComponent()

template<class T = Component, bool DestroyComponents = true>
bool hasComponent ( ID< Entity > entity) const
inline

Returns true if entity has specific component.

Parameters
entitytarget entity with component
Note
This function is faster than the Manager one.

◆ getComponent() [2/2]

template<class T = Component, bool DestroyComponents = true>
View< T > getComponent ( ID< Entity > entity) const
inline

Returns entity specific component view.

Parameters
entitytarget entity with component
Note
This function is faster than the Manager one.

◆ tryGetComponent()

template<class T = Component, bool DestroyComponents = true>
View< T > tryGetComponent ( ID< Entity > entity) const
inline

Returns entity specific component view if exist.

Parameters
entitytarget entity with component
Note
This function is faster than the Manager one.

◆ resetComponentData()

template<class T = Component, bool DestroyComponents = true>
void resetComponentData ( ID< Entity > entity,
bool full = true )
inline

Resets entity specific component data.

Parameters
entitytarget entity with component
fullreset all component data
Note
This function is faster than the Manager one.

Member Data Documentation

◆ components

template<class T = Component, bool DestroyComponents = true>
Components components
protected

System component pool.