ECSM v0.2.0
System

Base system class. More...

#include <ecsm.hpp>

Public Member Functions

virtual const std::stringgetComponentName () const
 Returns specific component name of the system.
 
virtual std::type_index getComponentType () const
 Returns specific component typeid() of the system.
 
virtual View< ComponentgetComponent (ID< Component > instance)
 Returns specific system component View.
 
virtual void disposeComponents ()
 Actually destroys system components.
 

Protected Member Functions

virtual ~System ()=default
 Destroys system instance.
 
virtual ID< ComponentcreateComponent (ID< Entity > entity)
 Creates a new system component instance for the entity.
 
virtual void destroyComponent (ID< Component > instance)
 Destroys system component instance.
 
virtual void copyComponent (View< Component > source, View< Component > destination)
 Copies system component data from source to destination.
 

Friends

class Entity
 
class Manager
 
class SystemExt
 

Detailed Description

Base system class.

Systems are responsible for updating and processing entities with specific components. Each system typically focuses on a particular aspect of the game or simulation. Systems iterate over entities that have the necessary components and perform the required actions or calculations.

Constructor & Destructor Documentation

◆ ~System()

virtual ~System ( )
protectedvirtualdefault

Destroys system instance.

Warning
Override it to destroy unmanaged resources.

Member Function Documentation

◆ createComponent()

virtual ID< Component > createComponent ( ID< Entity > entity)
protectedvirtual

Creates a new system component instance for the entity.

You should use Manager to add components to the entity.

Note
Override it to define a custom component of the system.
Parameters
entitytarget entity instance

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, and ComponentSystem< DoNotDuplicateComponent, false >.

◆ destroyComponent()

virtual void destroyComponent ( ID< Component > instance)
protectedvirtual

Destroys system component instance.

You should use Manager to remove components from the entity.

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

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, and ComponentSystem< DoNotDuplicateComponent, false >.

◆ copyComponent()

virtual void copyComponent ( View< Component > source,
View< Component > destination )
protectedvirtual

Copies system component data from source to destination.

You should use Manager to copy component data of entities.

Note
Override it to define a custom component of the system.
Parameters
sourcesource component view (from)
destinationdestination component view (to)

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, and ComponentSystem< DoNotDuplicateComponent, false >.

◆ getComponentName()

virtual const std::string & getComponentName ( ) const
virtual

Returns specific component name of the system.

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

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, ComponentSystem< DoNotDuplicateComponent, false >, DoNotDestroySystem, and DoNotDuplicateSystem.

◆ getComponentType()

virtual std::type_index getComponentType ( ) const
virtual

Returns specific component typeid() of the system.

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

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, and ComponentSystem< DoNotDuplicateComponent, false >.

◆ getComponent()

virtual View< Component > getComponent ( ID< Component > instance)
virtual

Returns specific system component View.

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

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, and ComponentSystem< DoNotDuplicateComponent, false >.

◆ disposeComponents()

virtual void disposeComponents ( )
virtual

Actually destroys system components.

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

Reimplemented in ComponentSystem< T, DestroyComponents >, ComponentSystem< DoNotDestroyComponent, false >, and ComponentSystem< DoNotDuplicateComponent, false >.