Untitled Game engine no.5  1.0
Public Member Functions | List of all members
Engine::ECS Class Reference

Entity Component System. More...

#include <ECS.hpp>

Public Member Functions

 ECS ()
 Creates a new ECS, entity counter is 1 to reserve for null.
 
 ~ECS ()
 ECS Destructor.
 
EntityID CreateEntityID ()
 Creates an entity and returns it's ID.
 
template<class C >
void RemoveComponent (const EntityID &id)
 
Archetype GetArchetype (EntityID id)
 
template<class C >
Ref< C > GetComponent (const EntityID &id)
 
void RemoveEntity (const EntityID &id)
 
template<class C , typename... Args>
Ref< C > AddComponent (EntityID id, Ref< C > args)
 
template<class C , typename... Args>
Ref< C > AddComponent (EntityID id, Args &&... args)
 
SystemID RegisterSystem (Ref< SystemBase > &s)
 
void RunSystem (SystemID sid)
 
void RunSystemArch (Archetype a)
 
template<class... Cs>
Archetype GetArchetype ()
 
template<class... Cs>
std::vector< EntityID > GetEntitiesWith ()
 
std::vector< EntityID > GetEntitiesWith (Archetype a)
 
template<class C >
void RegisterComponent ()
 
template<class C >
bool IsComponentRegistered ()
 

Detailed Description

Entity Component System.

Member Function Documentation

◆ AddComponent() [1/2]

template<class C , typename... Args>
Ref<C> Engine::ECS::AddComponent ( EntityID  id,
Args &&...  args 
)
inline

Adds a component of type C to the given entity

Parameters
idthe id of the entity we want to operate on
argsthe arguments to create the type of the component

◆ AddComponent() [2/2]

template<class C , typename... Args>
Ref<C> Engine::ECS::AddComponent ( EntityID  id,
Ref< C >  args 
)
inline

Adds a component of type C to the given entity

Parameters
idthe id of the entity we want to operate on
argsthe arguments to create the type of the component

◆ GetArchetype() [1/2]

template<class... Cs>
Archetype Engine::ECS::GetArchetype ( )
inline

Get an archetype from a call on multiple components

Returns
the Archetype

◆ GetArchetype() [2/2]

Archetype Engine::ECS::GetArchetype ( EntityID  id)
inline

Removes a component from the given entity

Parameters
idthe id of the entity we want to operate on

◆ GetComponent()

template<class C >
Ref<C> Engine::ECS::GetComponent ( const EntityID &  id)
inline

Gets a reference to a component from the given entity

Parameters
idthe id of the entity we want to operate on

◆ GetEntitiesWith() [1/2]

template<class... Cs>
std::vector<EntityID> Engine::ECS::GetEntitiesWith ( )
inline

Helper to gather entities of a certail archetype

Parameters
athe archetype we want

◆ GetEntitiesWith() [2/2]

std::vector<EntityID> Engine::ECS::GetEntitiesWith ( Archetype  a)
inline

Helper to gather entities of a certail archetype

Parameters
athe archetype we want

◆ IsComponentRegistered()

template<class C >
bool Engine::ECS::IsComponentRegistered ( )
inline

Checks if a component is registered

Parameters
ifit's registered

◆ RegisterComponent()

template<class C >
void Engine::ECS::RegisterComponent ( )
inline

Registers a component type for our use later MUST be done before using a component of type C

◆ RegisterSystem()

SystemID Engine::ECS::RegisterSystem ( Ref< SystemBase > &  s)
inline

Registers a system for us to use

Parameters
sthe system to add
Returns
the id of the system

◆ RemoveComponent()

template<class C >
void Engine::ECS::RemoveComponent ( const EntityID &  id)
inline

Removes a component from the given entity

Parameters
idthe id of the entity we want to operate on

◆ RemoveEntity()

void Engine::ECS::RemoveEntity ( const EntityID &  id)
inline

Removes an entity from the system

Parameters
idthe id of the entity delete

◆ RunSystem()

void Engine::ECS::RunSystem ( SystemID  sid)
inline

Runs a system

Parameters
sidthe id of the target system

◆ RunSystemArch()

void Engine::ECS::RunSystemArch ( Archetype  a)
inline

Runs several systems

Parameters
athe archetype of the target systems

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