r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
gme::EntityManager Class Reference

Central entity lifecycle manager for the R-Type game server. More...

#include <EntityManager.hpp>

+ Collaboration diagram for gme::EntityManager:

Public Member Functions

 EntityManager (ecs::Registry &registry)
 Constructor.
 
 ~EntityManager ()=default
 Destructor.
 
 EntityManager (const EntityManager &)=delete
 Deleted copy constructor (non-copyable)
 
EntityManageroperator= (const EntityManager &)=delete
 Deleted copy assignment operator (non-copyable)
 
 EntityManager (EntityManager &&)=delete
 Deleted move constructor (non-movable)
 
EntityManageroperator= (EntityManager &&)=delete
 Deleted move assignment operator (non-movable)
 
ecs::Entity createPlayer (std::uint32_t sessionId, float x, float y)
 Create a new player entity.
 
void destroyPlayer (std::uint32_t sessionId)
 Destroy a player entity.
 
ecs::Entity getPlayer (std::uint32_t sessionId)
 Get player entity by session ID.
 
ecs::Entity getPlayerEntity (std::uint32_t sessionId) const
 Get player entity by session ID (const version)
 
bool hasPlayer (std::uint32_t sessionId) const
 Check if player exists.
 
void markPlayerAsDead (std::uint32_t sessionId)
 Mark a player as dead without destroying the entity.
 
std::uint32_t getAlivePlayerCount () const
 Get count of alive players.
 
const std::unordered_map< std::uint32_t, ecs::Entity > & getPlayers () const
 Get all player entities.
 
void addScore (std::uint32_t sessionId, int points)
 Add points to a player's score.
 
int getScore (std::uint32_t sessionId) const
 Get player's current score.
 
void resetScore (std::uint32_t sessionId)
 Reset player's score to zero.
 
ecs::Entity createBasicEnemy (float x, float y, float health=50.0f)
 Create a basic enemy entity.
 
ecs::Entity createAdvancedEnemy (float x, float y, float health=100.0f)
 Create an advanced enemy entity.
 
ecs::Entity createBoss (float x, float y, float health=1000.0f)
 Create a boss enemy entity.
 
void destroyEnemy (std::uint32_t enemyId)
 Destroy an enemy entity.
 
ecs::Entity getEnemy (std::uint32_t enemyId)
 Get enemy entity by network ID.
 
const std::unordered_map< std::uint32_t, ecs::Entity > & getEnemies () const
 Get all enemy entities.
 
ecs::Entity createPlayerProjectile (std::uint32_t playerId, float x, float y, float vx, float vy, bool isSupercharged=false)
 Create a player projectile entity.
 
ecs::Entity createEnemyProjectile (std::uint32_t enemyId, float x, float y, float vx, float vy)
 Create an enemy projectile entity.
 
void destroyProjectile (std::uint32_t projectileId)
 Destroy a projectile entity.
 
ecs::Entity getProjectile (std::uint32_t projectileId)
 Get projectile entity by network ID.
 
const std::unordered_map< std::uint32_t, ecs::Entity > & getProjectiles () const
 Get all projectile entities.
 
ecs::Entity createPowerup (float x, float y, uint8_t powerupType)
 Create a powerup entity.
 
void destroyPowerup (std::uint32_t powerupId)
 Destroy a powerup entity.
 
void updateLifetimes (float deltaTime)
 Update lifetime counters for temporary entities.
 
void cleanupDestroyedEntities ()
 Process destruction queue and remove destroyed entities.
 
EntityMetadatagetEntityMetadata (std::uint32_t networkId)
 Get entity metadata by network ID.
 
const EntityMetadatagetEntityMetadata (std::uint32_t networkId) const
 Get entity metadata by network ID (const version)
 
std::uint32_t getNetworkIdForEntity (ecs::Entity entity) const
 Get network ID for an entity handle.
 
std::vector< rnp::EntityStategetAllEntityStates () const
 Get network state for all entities.
 
rnp::EntityType getNetworkEntityType (ServerEntityType type) const
 Convert server entity type to network protocol entity type.
 
void clear ()
 Clear all entities and reset manager state.
 
size_t getTotalEntityCount () const
 Get total count of all managed entities.
 

Private Member Functions

void registerEntity (ecs::Entity entity, ServerEntityType type, std::uint32_t networkId, float lifetime=-1.0f, std::uint32_t ownerId=0)
 Register a new entity with the manager.
 
void unregisterEntity (std::uint32_t networkId)
 Unregister an entity from the manager.
 
void processDestroyQueue ()
 Process pending entity destructions from queue.
 

Private Attributes

ecs::Registrym_registry
 Reference to ECS registry.
 
std::unordered_map< std::uint32_t, ecs::Entitym_playerEntities
 Player entities by session ID.
 
std::unordered_map< std::uint32_t, ecs::Entitym_enemyEntities
 Enemy entities by network ID.
 
std::unordered_map< std::uint32_t, ecs::Entitym_projectileEntities
 Projectile entities by network ID.
 
std::unordered_map< std::uint32_t, ecs::Entitym_powerupEntities
 Powerup entities by network ID.
 
std::unordered_map< std::uint32_t, EntityMetadatam_entityMetadata
 Entity metadata by network ID.
 
std::unordered_set< std::uint32_t > m_deadPlayers
 Set of dead player session IDs.
 
std::unordered_map< std::uint32_t, int > m_playerScores
 Player scores by session ID.
 
std::unordered_map< ecs::Entity, std::uint32_t > m_entityToNetworkId
 Reverse lookup map.
 
std::uint32_t m_nextEnemyId = 2000
 Next available enemy network ID.
 
std::uint32_t m_nextProjectileId = 1000
 Next available projectile network ID.
 
std::uint32_t m_nextPowerupId = 5000
 Next available powerup network ID.
 
std::vector< std::uint32_t > m_destroyQueue
 Queue of network IDs pending destruction.
 

Detailed Description

Central entity lifecycle manager for the R-Type game server.

This class provides comprehensive entity management including:

  • Entity creation with proper component initialization
  • Entity destruction and cleanup
  • Network ID assignment and tracking
  • Lifetime management for temporary entities
  • Player score tracking
  • Network state synchronization
  • Reverse lookups (entity <-> network ID)

The manager maintains separate containers for different entity types and ensures proper cleanup of destroyed entities. All entities are assigned unique network IDs for client-server synchronization.

Definition at line 80 of file EntityManager.hpp.

Constructor & Destructor Documentation

◆ EntityManager() [1/3]

gme::EntityManager::EntityManager ( ecs::Registry & registry)
explicit

Constructor.

Parameters
registryReference to the ECS registry

Initializes the entity manager with a reference to the game's ECS registry

Definition at line 14 of file EntityManager.cpp.

◆ ~EntityManager()

gme::EntityManager::~EntityManager ( )
default

Destructor.

◆ EntityManager() [2/3]

gme::EntityManager::EntityManager ( const EntityManager & )
delete

Deleted copy constructor (non-copyable)

◆ EntityManager() [3/3]

gme::EntityManager::EntityManager ( EntityManager && )
delete

Deleted move constructor (non-movable)

Member Function Documentation

◆ addScore()

void gme::EntityManager::addScore ( std::uint32_t sessionId,
int points )

Add points to a player's score.

Parameters
sessionIdNetwork session ID of the player
pointsPoints to add (can be negative)

Definition at line 106 of file EntityManager.cpp.

References utl::INFO, utl::Logger::log(), and m_playerScores.

Referenced by gme::CollisionSystem::applyDamageToEnemy().

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

◆ cleanupDestroyedEntities()

void gme::EntityManager::cleanupDestroyedEntities ( )

Process destruction queue and remove destroyed entities.

Should be called after all systems have updated to safely remove entities

Definition at line 299 of file EntityManager.cpp.

References processDestroyQueue().

+ Here is the call graph for this function:

◆ clear()

void gme::EntityManager::clear ( )

Clear all entities and reset manager state.

Destroys all entities and resets ID generators

Definition at line 473 of file EntityManager.cpp.

References ecs::Registry::hasComponent(), m_deadPlayers, m_destroyQueue, m_enemyEntities, m_entityMetadata, m_entityToNetworkId, m_playerEntities, m_powerupEntities, m_projectileEntities, m_registry, and ecs::Registry::removeComponent().

+ Here is the call graph for this function:

◆ createAdvancedEnemy()

ecs::Entity gme::EntityManager::createAdvancedEnemy ( float x,
float y,
float health = 100.0f )

Create an advanced enemy entity.

Parameters
xSpawn X position
ySpawn Y position
healthInitial health (default: 100.0)
Returns
Created enemy entity handle

Creates advanced enemy with complex AI behavior

Definition at line 153 of file EntityManager.cpp.

References ecs::Registry::createEntity(), gme::ENEMY_ADVANCED, utl::INFO, utl::Logger::log(), m_enemyEntities, m_nextEnemyId, m_registry, registerEntity(), and ecs::Registry::EntityBuilder::with().

Referenced by gme::WaveManager::processSpawns(), and gme::EnemySpawnSystem::processWave().

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

◆ createBasicEnemy()

ecs::Entity gme::EntityManager::createBasicEnemy ( float x,
float y,
float health = 50.0f )

Create a basic enemy entity.

Parameters
xSpawn X position
ySpawn Y position
healthInitial health (default: 50.0)
Returns
Created enemy entity handle

Creates basic enemy with simple AI behavior

Definition at line 126 of file EntityManager.cpp.

References ecs::Registry::createEntity(), gme::ENEMY_BASIC, utl::INFO, utl::Logger::log(), m_enemyEntities, m_nextEnemyId, m_registry, registerEntity(), and ecs::Registry::EntityBuilder::with().

Referenced by gme::WaveManager::processSpawns(), and gme::EnemySpawnSystem::processWave().

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

◆ createBoss()

ecs::Entity gme::EntityManager::createBoss ( float x,
float y,
float health = 1000.0f )

Create a boss enemy entity.

Parameters
xSpawn X position
ySpawn Y position
healthInitial health (default: 1000.0)
Returns
Created boss entity handle

Creates boss with special AI and high durability

Definition at line 180 of file EntityManager.cpp.

References gme::BOSS, ecs::Registry::createEntity(), utl::INFO, utl::Logger::log(), m_enemyEntities, m_nextEnemyId, m_registry, registerEntity(), and ecs::Registry::EntityBuilder::with().

Referenced by gme::WaveManager::processSpawns(), and gme::EnemySpawnSystem::processWave().

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

◆ createEnemyProjectile()

ecs::Entity gme::EntityManager::createEnemyProjectile ( std::uint32_t enemyId,
float x,
float y,
float vx,
float vy )

Create an enemy projectile entity.

Parameters
enemyIdNetwork ID of the enemy who fired
xInitial X position
yInitial Y position
vxX velocity
vyY velocity
Returns
Created projectile entity handle

Definition at line 248 of file EntityManager.cpp.

References ecs::Projectile::BASIC, ecs::Registry::createEntity(), m_nextProjectileId, m_projectileEntities, m_registry, gme::PROJECTILE_ENEMY, registerEntity(), and ecs::Registry::EntityBuilder::with().

Referenced by gme::EnemyAISystem::tryShoot(), and gme::EnemyAISystem::updateBossAI().

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

◆ createPlayer()

ecs::Entity gme::EntityManager::createPlayer ( std::uint32_t sessionId,
float x,
float y )

Create a new player entity.

Parameters
sessionIdNetwork session ID of the player
xInitial X position
yInitial Y position
Returns
Created player entity handle

Creates a player entity with all required components (Transform, Velocity, Health, Hitbox, NetworkId) and registers it for tracking

Definition at line 16 of file EntityManager.cpp.

References ecs::Registry::createEntity(), hasPlayer(), utl::INFO, utl::Logger::log(), m_playerEntities, m_playerScores, m_registry, gme::PLAYER, registerEntity(), utl::GameConfig::Server::SCREEN_HEIGHT, utl::GameConfig::Server::SCREEN_WIDTH, utl::WARNING, and ecs::Registry::EntityBuilder::with().

+ Here is the call graph for this function:

◆ createPlayerProjectile()

ecs::Entity gme::EntityManager::createPlayerProjectile ( std::uint32_t playerId,
float x,
float y,
float vx,
float vy,
bool isSupercharged = false )

Create a player projectile entity.

Parameters
playerIdSession ID of the player who fired
xInitial X position
yInitial Y position
vxX velocity
vyY velocity
isSuperchargedWhether this is a powered-up shot (default: false)
Returns
Created projectile entity handle

Definition at line 223 of file EntityManager.cpp.

References ecs::Projectile::BASIC, ecs::Registry::createEntity(), m_nextProjectileId, m_projectileEntities, m_registry, gme::PROJECTILE_PLAYER, registerEntity(), ecs::Projectile::SUPERCHARGED, and ecs::Registry::EntityBuilder::with().

+ Here is the call graph for this function:

◆ createPowerup()

ecs::Entity gme::EntityManager::createPowerup ( float x,
float y,
uint8_t powerupType )

Create a powerup entity.

Parameters
xSpawn X position
ySpawn Y position
powerupTypeType of powerup (0-255)
Returns
Created powerup entity handle

◆ destroyEnemy()

void gme::EntityManager::destroyEnemy ( std::uint32_t enemyId)

Destroy an enemy entity.

Parameters
enemyIdNetwork ID of the enemy

Definition at line 207 of file EntityManager.cpp.

References getEntityMetadata(), and m_destroyQueue.

Referenced by gme::CollisionSystem::applyDamageToEnemy().

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

◆ destroyPlayer()

void gme::EntityManager::destroyPlayer ( std::uint32_t sessionId)

Destroy a player entity.

Parameters
sessionIdNetwork session ID of the player to destroy

Removes player from tracking and queues entity for destruction

Definition at line 52 of file EntityManager.cpp.

References getEntityMetadata(), utl::INFO, utl::Logger::log(), and m_destroyQueue.

+ Here is the call graph for this function:

◆ destroyPowerup()

void gme::EntityManager::destroyPowerup ( std::uint32_t powerupId)

Destroy a powerup entity.

Parameters
powerupIdNetwork ID of the powerup

◆ destroyProjectile()

void gme::EntityManager::destroyProjectile ( std::uint32_t projectileId)

Destroy a projectile entity.

Parameters
projectileIdNetwork ID of the projectile

Definition at line 267 of file EntityManager.cpp.

References getEntityMetadata(), and m_destroyQueue.

Referenced by gme::CollisionSystem::handleEnemyProjectilePlayerCollision(), and gme::CollisionSystem::handlePlayerProjectileEnemyCollision().

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

◆ getAlivePlayerCount()

std::uint32_t gme::EntityManager::getAlivePlayerCount ( ) const

Get count of alive players.

Returns
Number of players not marked as dead

Definition at line 91 of file EntityManager.cpp.

References m_deadPlayers, and m_playerEntities.

◆ getAllEntityStates()

◆ getEnemies()

const std::unordered_map< std::uint32_t, ecs::Entity > & gme::EntityManager::getEnemies ( ) const
inline

Get all enemy entities.

Returns
Const reference to map of network ID to enemy entity

Definition at line 231 of file EntityManager.hpp.

References m_enemyEntities.

Referenced by gme::CollisionSystem::handlePlayerEnemyCollision(), gme::CollisionSystem::handlePlayerProjectileEnemyCollision(), gme::WaveManager::isWaveCleared(), and gme::EnemyAISystem::update().

+ Here is the caller graph for this function:

◆ getEnemy()

ecs::Entity gme::EntityManager::getEnemy ( std::uint32_t enemyId)

Get enemy entity by network ID.

Parameters
enemyIdNetwork ID of the enemy
Returns
Enemy entity handle

Definition at line 217 of file EntityManager.cpp.

References ecs::INVALID_ENTITY, and m_enemyEntities.

Referenced by gme::CollisionSystem::applyDamageToEnemy().

+ Here is the caller graph for this function:

◆ getEntityMetadata() [1/2]

EntityMetadata * gme::EntityManager::getEntityMetadata ( std::uint32_t networkId)

Get entity metadata by network ID.

Parameters
networkIdNetwork ID of the entity
Returns
Pointer to metadata (nullptr if not found)

Definition at line 301 of file EntityManager.cpp.

References m_entityMetadata.

Referenced by gme::CollisionSystem::applyDamageToEnemy(), destroyEnemy(), destroyPlayer(), destroyProjectile(), getAllEntityStates(), gme::CollisionSystem::handleEnemyProjectilePlayerCollision(), gme::CollisionSystem::handlePlayerEnemyCollision(), gme::CollisionSystem::handlePlayerProjectileEnemyCollision(), and gme::EnemyAISystem::update().

+ Here is the caller graph for this function:

◆ getEntityMetadata() [2/2]

const EntityMetadata * gme::EntityManager::getEntityMetadata ( std::uint32_t networkId) const

Get entity metadata by network ID (const version)

Parameters
networkIdNetwork ID of the entity
Returns
Const pointer to metadata (nullptr if not found)

Definition at line 307 of file EntityManager.cpp.

References m_entityMetadata.

◆ getNetworkEntityType()

rnp::EntityType gme::EntityManager::getNetworkEntityType ( ServerEntityType type) const

Convert server entity type to network protocol entity type.

Parameters
typeServer entity type
Returns
Corresponding network protocol entity type

Definition at line 454 of file EntityManager.cpp.

References gme::BOSS, rnp::BOSS, rnp::ENEMY, gme::ENEMY_ADVANCED, gme::ENEMY_BASIC, gme::PLAYER, rnp::PLAYER, rnp::PROJECTILE, gme::PROJECTILE_ENEMY, and gme::PROJECTILE_PLAYER.

◆ getNetworkIdForEntity()

std::uint32_t gme::EntityManager::getNetworkIdForEntity ( ecs::Entity entity) const

Get network ID for an entity handle.

Parameters
entityECS entity handle
Returns
Network ID (0 if not found)

Definition at line 313 of file EntityManager.cpp.

References m_entityToNetworkId.

Referenced by gme::EnemyAISystem::updateBossAI().

+ Here is the caller graph for this function:

◆ getPlayer()

ecs::Entity gme::EntityManager::getPlayer ( std::uint32_t sessionId)

Get player entity by session ID.

Parameters
sessionIdNetwork session ID
Returns
Player entity handle (may be invalid if player doesn't exist)

Definition at line 68 of file EntityManager.cpp.

References ecs::INVALID_ENTITY, and m_playerEntities.

◆ getPlayerEntity()

ecs::Entity gme::EntityManager::getPlayerEntity ( std::uint32_t sessionId) const

Get player entity by session ID (const version)

Parameters
sessionIdNetwork session ID
Returns
Player entity handle

Definition at line 79 of file EntityManager.cpp.

References ecs::INVALID_ENTITY, and m_playerEntities.

Referenced by gme::CollisionSystem::applyDamageToPlayer().

+ Here is the caller graph for this function:

◆ getPlayers()

const std::unordered_map< std::uint32_t, ecs::Entity > & gme::EntityManager::getPlayers ( ) const
inline

Get all player entities.

Returns
Const reference to map of session ID to player entity

Definition at line 162 of file EntityManager.hpp.

References m_playerEntities.

Referenced by gme::EnemyAISystem::findNearestPlayer(), gme::EnemyAISystem::getDistanceToNearestPlayer(), gme::CollisionSystem::handleEnemyProjectilePlayerCollision(), and gme::CollisionSystem::handlePlayerEnemyCollision().

+ Here is the caller graph for this function:

◆ getProjectile()

ecs::Entity gme::EntityManager::getProjectile ( std::uint32_t projectileId)

Get projectile entity by network ID.

Parameters
projectileIdNetwork ID of the projectile
Returns
Projectile entity handle

Definition at line 277 of file EntityManager.cpp.

References ecs::INVALID_ENTITY, and m_projectileEntities.

◆ getProjectiles()

const std::unordered_map< std::uint32_t, ecs::Entity > & gme::EntityManager::getProjectiles ( ) const
inline

Get all projectile entities.

Returns
Const reference to map of network ID to projectile entity

Definition at line 274 of file EntityManager.hpp.

References m_projectileEntities.

Referenced by gme::CollisionSystem::handleEnemyProjectilePlayerCollision(), and gme::CollisionSystem::handlePlayerProjectileEnemyCollision().

+ Here is the caller graph for this function:

◆ getScore()

int gme::EntityManager::getScore ( std::uint32_t sessionId) const

Get player's current score.

Parameters
sessionIdNetwork session ID
Returns
Current score (0 if player not found)

Definition at line 114 of file EntityManager.cpp.

References m_playerScores.

Referenced by getAllEntityStates().

+ Here is the caller graph for this function:

◆ getTotalEntityCount()

size_t gme::EntityManager::getTotalEntityCount ( ) const

Get total count of all managed entities.

Returns
Total number of active entities

Definition at line 539 of file EntityManager.cpp.

References m_enemyEntities, m_playerEntities, m_powerupEntities, and m_projectileEntities.

◆ hasPlayer()

bool gme::EntityManager::hasPlayer ( std::uint32_t sessionId) const

Check if player exists.

Parameters
sessionIdNetwork session ID
Returns
True if player exists and is registered

Definition at line 74 of file EntityManager.cpp.

References m_playerEntities.

Referenced by createPlayer().

+ Here is the caller graph for this function:

◆ markPlayerAsDead()

void gme::EntityManager::markPlayerAsDead ( std::uint32_t sessionId)

Mark a player as dead without destroying the entity.

Parameters
sessionIdNetwork session ID

Adds player to dead players set, useful for game over detection

Definition at line 85 of file EntityManager.cpp.

References utl::INFO, utl::Logger::log(), and m_deadPlayers.

Referenced by gme::CollisionSystem::applyDamageToPlayer().

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

◆ operator=() [1/2]

EntityManager & gme::EntityManager::operator= ( const EntityManager & )
delete

Deleted copy assignment operator (non-copyable)

◆ operator=() [2/2]

EntityManager & gme::EntityManager::operator= ( EntityManager && )
delete

Deleted move assignment operator (non-movable)

◆ processDestroyQueue()

void gme::EntityManager::processDestroyQueue ( )
private

Process pending entity destructions from queue.

Safely removes entities that were queued for destruction

Definition at line 571 of file EntityManager.cpp.

References ecs::Registry::hasComponent(), utl::INFO, utl::Logger::log(), m_deadPlayers, m_destroyQueue, m_enemyEntities, m_playerEntities, m_playerScores, m_powerupEntities, m_projectileEntities, m_registry, ecs::Registry::removeComponent(), and unregisterEntity().

Referenced by cleanupDestroyedEntities().

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

◆ registerEntity()

void gme::EntityManager::registerEntity ( ecs::Entity entity,
ServerEntityType type,
std::uint32_t networkId,
float lifetime = -1.0f,
std::uint32_t ownerId = 0 )
private

Register a new entity with the manager.

Parameters
entityECS entity handle
typeEntity type classification
networkIdNetwork ID for synchronization
lifetimeMaximum lifetime in seconds (-1.0 for infinite)
ownerIdOwner entity ID (for projectiles)

Definition at line 545 of file EntityManager.cpp.

References gme::EntityMetadata::currentLife, gme::EntityMetadata::entity, gme::EntityMetadata::isActive, gme::EntityMetadata::lifetime, m_entityMetadata, m_entityToNetworkId, gme::EntityMetadata::networkId, gme::EntityMetadata::ownerId, and gme::EntityMetadata::type.

Referenced by createAdvancedEnemy(), createBasicEnemy(), createBoss(), createEnemyProjectile(), createPlayer(), and createPlayerProjectile().

+ Here is the caller graph for this function:

◆ resetScore()

void gme::EntityManager::resetScore ( std::uint32_t sessionId)

Reset player's score to zero.

Parameters
sessionIdNetwork session ID

Definition at line 120 of file EntityManager.cpp.

References utl::INFO, utl::Logger::log(), and m_playerScores.

+ Here is the call graph for this function:

◆ unregisterEntity()

void gme::EntityManager::unregisterEntity ( std::uint32_t networkId)
private

Unregister an entity from the manager.

Parameters
networkIdNetwork ID of the entity to unregister

Definition at line 561 of file EntityManager.cpp.

References m_entityMetadata, and m_entityToNetworkId.

Referenced by processDestroyQueue().

+ Here is the caller graph for this function:

◆ updateLifetimes()

void gme::EntityManager::updateLifetimes ( float deltaTime)

Update lifetime counters for temporary entities.

Parameters
deltaTimeTime elapsed since last frame (seconds)

Increments currentLife for entities with limited lifetime and destroys entities that have exceeded their lifetime

Definition at line 283 of file EntityManager.cpp.

References m_destroyQueue, and m_entityMetadata.

Member Data Documentation

◆ m_deadPlayers

std::unordered_set<std::uint32_t> gme::EntityManager::m_deadPlayers
private

Set of dead player session IDs.

Definition at line 369 of file EntityManager.hpp.

Referenced by clear(), getAlivePlayerCount(), markPlayerAsDead(), and processDestroyQueue().

◆ m_destroyQueue

std::vector<std::uint32_t> gme::EntityManager::m_destroyQueue
private

Queue of network IDs pending destruction.

Definition at line 383 of file EntityManager.hpp.

Referenced by clear(), destroyEnemy(), destroyPlayer(), destroyProjectile(), processDestroyQueue(), and updateLifetimes().

◆ m_enemyEntities

std::unordered_map<std::uint32_t, ecs::Entity> gme::EntityManager::m_enemyEntities
private

◆ m_entityMetadata

std::unordered_map<std::uint32_t, EntityMetadata> gme::EntityManager::m_entityMetadata
private

Entity metadata by network ID.

Definition at line 366 of file EntityManager.hpp.

Referenced by clear(), getEntityMetadata(), getEntityMetadata(), registerEntity(), unregisterEntity(), and updateLifetimes().

◆ m_entityToNetworkId

std::unordered_map<ecs::Entity, std::uint32_t> gme::EntityManager::m_entityToNetworkId
private

Reverse lookup map.

Definition at line 375 of file EntityManager.hpp.

Referenced by clear(), getNetworkIdForEntity(), registerEntity(), and unregisterEntity().

◆ m_nextEnemyId

std::uint32_t gme::EntityManager::m_nextEnemyId = 2000
private

Next available enemy network ID.

Definition at line 378 of file EntityManager.hpp.

Referenced by createAdvancedEnemy(), createBasicEnemy(), and createBoss().

◆ m_nextPowerupId

std::uint32_t gme::EntityManager::m_nextPowerupId = 5000
private

Next available powerup network ID.

Definition at line 380 of file EntityManager.hpp.

◆ m_nextProjectileId

std::uint32_t gme::EntityManager::m_nextProjectileId = 1000
private

Next available projectile network ID.

Definition at line 379 of file EntityManager.hpp.

Referenced by createEnemyProjectile(), and createPlayerProjectile().

◆ m_playerEntities

std::unordered_map<std::uint32_t, ecs::Entity> gme::EntityManager::m_playerEntities
private

◆ m_playerScores

std::unordered_map<std::uint32_t, int> gme::EntityManager::m_playerScores
private

Player scores by session ID.

Definition at line 372 of file EntityManager.hpp.

Referenced by addScore(), createPlayer(), getScore(), processDestroyQueue(), and resetScore().

◆ m_powerupEntities

std::unordered_map<std::uint32_t, ecs::Entity> gme::EntityManager::m_powerupEntities
private

Powerup entities by network ID.

Definition at line 363 of file EntityManager.hpp.

Referenced by clear(), getTotalEntityCount(), and processDestroyQueue().

◆ m_projectileEntities

std::unordered_map<std::uint32_t, ecs::Entity> gme::EntityManager::m_projectileEntities
private

◆ m_registry

ecs::Registry& gme::EntityManager::m_registry
private

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