22#include <unordered_map>
23#include <unordered_set>
143 bool hasPlayer(std::uint32_t sessionId)
const;
169 void addScore(std::uint32_t sessionId,
int points);
176 int getScore(std::uint32_t sessionId)
const;
244 bool isSupercharged =
false);
394 float lifetime = -1.0f, std::uint32_t ownerId = 0);
This file contains the component definitions.
This file contains the entity definitions.
This file contains the network protocol.
This file contains the Registry class declaration.
Class for managing entities and their components.
Central entity lifecycle manager for the R-Type game server.
ecs::Entity getPlayer(std::uint32_t sessionId)
Get player entity by session ID.
std::unordered_map< std::uint32_t, EntityMetadata > m_entityMetadata
Entity metadata by network ID.
ecs::Entity getProjectile(std::uint32_t projectileId)
Get projectile entity by network ID.
void addScore(std::uint32_t sessionId, int points)
Add points to a player's score.
std::uint32_t m_nextEnemyId
Next available enemy network ID.
bool hasPlayer(std::uint32_t sessionId) const
Check if player exists.
void cleanupDestroyedEntities()
Process destruction queue and remove destroyed entities.
void markPlayerAsDead(std::uint32_t sessionId)
Mark a player as dead without destroying the entity.
void destroyPlayer(std::uint32_t sessionId)
Destroy a player entity.
ecs::Entity createPlayerProjectile(std::uint32_t playerId, float x, float y, float vx, float vy, bool isSupercharged=false)
Create a player projectile entity.
void updateLifetimes(float deltaTime)
Update lifetime counters for temporary entities.
EntityManager(ecs::Registry ®istry)
Constructor.
std::unordered_map< std::uint32_t, ecs::Entity > m_powerupEntities
Powerup entities by network ID.
const std::unordered_map< std::uint32_t, ecs::Entity > & getEnemies() const
Get all enemy entities.
EntityManager(const EntityManager &)=delete
Deleted copy constructor (non-copyable)
std::vector< std::uint32_t > m_destroyQueue
Queue of network IDs pending destruction.
std::uint32_t getNetworkIdForEntity(ecs::Entity entity) const
Get network ID for an entity handle.
rnp::EntityType getNetworkEntityType(ServerEntityType type) const
Convert server entity type to network protocol entity type.
std::unordered_set< std::uint32_t > m_deadPlayers
Set of dead player session IDs.
ecs::Entity createBoss(float x, float y, float health=1000.0f)
Create a boss enemy entity.
void processDestroyQueue()
Process pending entity destructions from queue.
ecs::Entity createPowerup(float x, float y, uint8_t powerupType)
Create a powerup entity.
ecs::Entity getPlayerEntity(std::uint32_t sessionId) const
Get player entity by session ID (const version)
~EntityManager()=default
Destructor.
int getScore(std::uint32_t sessionId) const
Get player's current score.
ecs::Entity createAdvancedEnemy(float x, float y, float health=100.0f)
Create an advanced enemy entity.
std::unordered_map< ecs::Entity, std::uint32_t > m_entityToNetworkId
Reverse lookup map.
std::uint32_t m_nextPowerupId
Next available powerup network ID.
std::unordered_map< std::uint32_t, ecs::Entity > m_projectileEntities
Projectile entities by network ID.
ecs::Entity createPlayer(std::uint32_t sessionId, float x, float y)
Create a new player entity.
std::unordered_map< std::uint32_t, ecs::Entity > m_playerEntities
Player entities by session ID.
EntityMetadata * getEntityMetadata(std::uint32_t networkId)
Get entity metadata by network ID.
const std::unordered_map< std::uint32_t, ecs::Entity > & getPlayers() const
Get all player entities.
void destroyProjectile(std::uint32_t projectileId)
Destroy a projectile entity.
std::vector< rnp::EntityState > getAllEntityStates() const
Get network state for all entities.
ecs::Registry & m_registry
Reference to ECS registry.
void clear()
Clear all entities and reset manager state.
void destroyEnemy(std::uint32_t enemyId)
Destroy an enemy entity.
size_t getTotalEntityCount() const
Get total count of all managed entities.
const std::unordered_map< std::uint32_t, ecs::Entity > & getProjectiles() const
Get all projectile entities.
std::unordered_map< std::uint32_t, ecs::Entity > m_enemyEntities
Enemy entities by network ID.
EntityManager(EntityManager &&)=delete
Deleted move constructor (non-movable)
std::uint32_t getAlivePlayerCount() const
Get count of alive players.
ecs::Entity createBasicEnemy(float x, float y, float health=50.0f)
Create a basic enemy entity.
std::uint32_t m_nextProjectileId
Next available projectile network ID.
ecs::Entity createEnemyProjectile(std::uint32_t enemyId, float x, float y, float vx, float vy)
Create an enemy projectile entity.
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.
std::unordered_map< std::uint32_t, int > m_playerScores
Player scores by session ID.
EntityManager & operator=(const EntityManager &)=delete
Deleted copy assignment operator (non-copyable)
void destroyPowerup(std::uint32_t powerupId)
Destroy a powerup entity.
void resetScore(std::uint32_t sessionId)
Reset player's score to zero.
EntityManager & operator=(EntityManager &&)=delete
Deleted move assignment operator (non-movable)
void unregisterEntity(std::uint32_t networkId)
Unregister an entity from the manager.
ecs::Entity getEnemy(std::uint32_t enemyId)
Get enemy entity by network ID.
ServerEntityType
Enumeration of entity types managed by the server.
@ ENEMY_ADVANCED
Advanced enemy type (complex behavior)
@ PLAYER
Player-controlled entity.
@ PROJECTILE_PLAYER
Player-fired projectile.
@ ENEMY_BASIC
Basic enemy type (simple behavior)
@ PROJECTILE_ENEMY
Enemy-fired projectile.
@ POWERUP
Collectible powerup item.
@ BOSS
Boss enemy (high health, special patterns)
EntityType
Entity types for world state.