r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
ecs::Registry Class Reference

Class for managing entities and their components. More...

#include <Registry.hpp>

+ Collaboration diagram for ecs::Registry:

Classes

class  EntityBuilder
 
class  IPool
 
class  Pool
 

Public Member Functions

 Registry ()=default
 
 ~Registry ()=default
 
 Registry (const Registry &)=delete
 
Registryoperator= (const Registry &)=delete
 
 Registry (Registry &&)=delete
 
Registryoperator= (Registry &&)=delete
 
EntityBuilder createEntity ()
 
template<typename T , typename... Args>
T & addComponent (Entity e, Args &&...args)
 
template<typename T >
T * getComponent (Entity e)
 
template<typename T >
std::unordered_map< Entity, T > & getAll ()
 
template<typename T >
bool hasComponent (Entity e)
 
template<typename T >
void removeComponent (Entity e)
 
void onComponentAdded (std::function< void(Entity, const std::type_info &)> cb)
 

Private Member Functions

template<typename T >
Pool< T > & getPool ()
 

Private Attributes

Entity m_lastEntity = INVALID_ENTITY
 
std::vector< Entitym_entities
 
std::unordered_map< std::type_index, std::unique_ptr< IPool > > m_components
 
std::vector< std::function< void(Entity, const std::type_info &)> > m_onComponentAddedCallbacks
 

Detailed Description

Class for managing entities and their components.

Definition at line 24 of file Registry.hpp.

Constructor & Destructor Documentation

◆ Registry() [1/3]

ecs::Registry::Registry ( )
default

◆ ~Registry()

ecs::Registry::~Registry ( )
default

◆ Registry() [2/3]

ecs::Registry::Registry ( const Registry & )
delete

◆ Registry() [3/3]

ecs::Registry::Registry ( Registry && )
delete

Member Function Documentation

◆ addComponent()

template<typename T , typename... Args>
T & ecs::Registry::addComponent ( Entity e,
Args &&... args )
inline

Definition at line 60 of file Registry.hpp.

References getPool(), and m_onComponentAddedCallbacks.

Referenced by ecs::Registry::EntityBuilder::with().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createEntity()

◆ getAll()

◆ getComponent()

template<typename T >
T * ecs::Registry::getComponent ( Entity e)
inline

Definition at line 71 of file Registry.hpp.

References getPool().

Referenced by gme::EnemyAISystem::applyAggressiveMovement(), gme::CollisionSystem::applyDamageToEnemy(), gme::CollisionSystem::applyDamageToPlayer(), gme::EnemyAISystem::applySineWaveMovement(), gme::EnemyAISystem::applyZigzagMovement(), ecs::AudioSystem::AudioSystem(), gme::EnemyAISystem::canShoot(), gme::Game::checkCollisions(), gme::Game::checkScore(), gme::EnemyAISystem::clampToScreen(), gme::Game::drawDebugRectangles(), gme::EnemyAISystem::findNearestPlayer(), gme::EntityManager::getAllEntityStates(), gme::CollisionSystem::getCollisionInfo(), gme::EnemyAISystem::getDistanceToNearestPlayer(), gme::CollisionSystem::handleEnemyProjectilePlayerCollision(), gme::CollisionSystem::handlePlayerEnemyCollision(), gme::GameSolo::handlePlayerInputs(), gme::CollisionSystem::handlePlayerProjectileEnemyCollision(), gme::RTypeServer::handlePlayerShooting(), gme::CollisionSystem::playEnemyDeathSound(), gme::CollisionSystem::playPlayerDeathSound(), gme::RTypeServer::processPlayerInputEvent(), gme::WeaponSystem::showLoadingAnimation(), gme::WeaponSystem::tryFireSupercharged(), gme::EnemyAISystem::tryShoot(), ecs::AnimationSystem::update(), ecs::BeamSystem::update(), ecs::DebugSystem::update(), ecs::SpriteSystem::update(), ecs::StarfieldSystem::update(), ecs::TextSystem::update(), gme::AnimationSystem::update(), gme::BeamSystem::update(), gme::CollisionSystem::update(), gme::EnemySystem::update(), gme::ExplosionSystem::update(), gme::FlappyDebugSystem::update(), gme::HealthBarSystem::update(), gme::LoadingAnimationSystem::update(), gme::PlayerControllerMulti::update(), gme::PlayerDirectionSystem::update(), gme::ProjectileSystem::update(), gme::ScrollingSystem::update(), gme::WeaponSystem::update(), gme::EnemyAISystem::updateAdvancedEnemyAI(), gme::EnemyAISystem::updateBasicEnemyAI(), gme::EnemyAISystem::updateBossAI(), gme::RTypeServer::updateEntities(), gme::GameMulti::updateInterpolation(), cli::Client::updateKeyboardInput(), and gme::HUDSystem::updateScore().

+ Here is the call graph for this function:

◆ getPool()

template<typename T >
Pool< T > & ecs::Registry::getPool ( )
inlineprivate

Definition at line 129 of file Registry.hpp.

References m_components.

Referenced by addComponent(), getAll(), getComponent(), hasComponent(), and removeComponent().

+ Here is the caller graph for this function:

◆ hasComponent()

◆ onComponentAdded()

void ecs::Registry::onComponentAdded ( std::function< void(Entity, const std::type_info &)> cb)
inline

Definition at line 91 of file Registry.hpp.

References m_onComponentAddedCallbacks.

Referenced by ecs::AudioSystem::AudioSystem().

+ Here is the caller graph for this function:

◆ operator=() [1/2]

Registry & ecs::Registry::operator= ( const Registry & )
delete

◆ operator=() [2/2]

Registry & ecs::Registry::operator= ( Registry && )
delete

◆ removeComponent()

template<typename T >
void ecs::Registry::removeComponent ( Entity e)
inline

Member Data Documentation

◆ m_components

std::unordered_map<std::type_index, std::unique_ptr<IPool> > ecs::Registry::m_components
private

Definition at line 140 of file Registry.hpp.

Referenced by getPool().

◆ m_entities

std::vector<Entity> ecs::Registry::m_entities
private

Definition at line 139 of file Registry.hpp.

Referenced by createEntity().

◆ m_lastEntity

Entity ecs::Registry::m_lastEntity = INVALID_ENTITY
private

Definition at line 138 of file Registry.hpp.

Referenced by createEntity().

◆ m_onComponentAddedCallbacks

std::vector<std::function<void(Entity, const std::type_info &)> > ecs::Registry::m_onComponentAddedCallbacks
private

Definition at line 141 of file Registry.hpp.

Referenced by addComponent(), and onComponentAdded().


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