Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::server::EntitySystem Class Reference

Base class for systems that operate on entities in the ECS. More...

#include <EntitySystem.hpp>

Inheritance diagram for rtp::server::EntitySystem:
Collaboration diagram for rtp::server::EntitySystem:

Public Member Functions

 EntitySystem (ecs::Registry &registry, ServerNetwork &network, NetworkSyncSystem &networkSync)
 Constructor for EntitySystem.
 
void update (float dt) override
 Update movement system logic for one frame.
 
ecs::Entity createPlayerEntity (PlayerPtr player)
 Create a new player entity in the ECS.
 
ecs::Entity createPlayerEntity (PlayerPtr player, const Vec2f &spawnPos)
 
ecs::Entity createEnemyEntity (uint32_t roomId, const Vec2f &pos, ecs::components::Patterns pattern, float speed, float amplitude, float frequency, net::EntityType type=net::EntityType::Scout)
 Create a new enemy entity in the ECS.
 
ecs::Entity creaetEnemyEntity (uint32_t roomId, const Vec2f &pos, ecs::components::Patterns pattern, float speed, float amplitude, float frequency)
 Create a new enemy entity in the ECS with default type Scout.
 
ecs::Entity createPowerupEntity (uint32_t roomId, const Vec2f &pos, ecs::components::PowerupType type, float value, float duration)
 Create a new powerup entity in the ECS.
 
ecs::Entity createObstacleEntity (uint32_t roomId, const Vec2f &pos, const Vec2f &size, int health, net::EntityType type=net::EntityType::Obstacle)
 Create a new obstacle entity in the ECS.
 
void applyWeaponToEntity (ecs::Entity entity, ecs::components::WeaponKind weaponKind)
 Apply a weapon configuration to an existing entity (player)
 
- Public Member Functions inherited from rtp::ecs::ISystem
virtual ~ISystem () noexcept=default
 

Protected Attributes

ecs::Registry_registry
 Reference to the entity registry.
 
ServerNetwork_network
 Reference to the server network manager.
 
NetworkSyncSystem_networkSync
 Reference to the network sync system.
 

Detailed Description

Base class for systems that operate on entities in the ECS.

Definition at line 44 of file EntitySystem.hpp.

Constructor & Destructor Documentation

◆ EntitySystem()

rtp::server::EntitySystem::EntitySystem ( ecs::Registry registry,
ServerNetwork network,
NetworkSyncSystem networkSync 
)

Constructor for EntitySystem.

Parameters
registryReference to the entity registry

Definition at line 18 of file EntitySystem.cpp.

Member Function Documentation

◆ applyWeaponToEntity()

◆ creaetEnemyEntity()

ecs::Entity rtp::server::EntitySystem::creaetEnemyEntity ( uint32_t  roomId,
const Vec2f pos,
ecs::components::Patterns  pattern,
float  speed,
float  amplitude,
float  frequency 
)

Create a new enemy entity in the ECS with default type Scout.

Parameters
roomIdID of the room the enemy belongs to
posPosition to spawn the enemy at
patternMovement pattern for the enemy
speedMovement speed of the enemy
amplitudeAmplitude for movement patterns that require it
frequencyFrequency for movement patterns that require it
Returns
The ID of the created enemy entity

Definition at line 268 of file EntitySystem.cpp.

References createEnemyEntity(), and rtp::net::Scout.

◆ createEnemyEntity()

◆ createObstacleEntity()

ecs::Entity rtp::server::EntitySystem::createObstacleEntity ( uint32_t  roomId,
const Vec2f pos,
const Vec2f size,
int  health,
net::EntityType  type = net::EntityType::Obstacle 
)

Create a new obstacle entity in the ECS.

Parameters
roomIdID of the room the obstacle belongs to
posPosition to spawn the obstacle at
sizeSize of the obstacle
healthHealth points of the obstacle
typeType of the obstacle entity
Returns
The ID of the created obstacle entity

Definition at line 323 of file EntitySystem.cpp.

References _registry, rtp::ecs::Registry::add(), rtp::log::error(), rtp::ecs::Entity::index(), rtp::ecs::Registry::spawn(), rtp::Vec2< T >::x, and rtp::Vec2< T >::y.

Referenced by rtp::server::LevelSystem::update().

◆ createPlayerEntity() [1/2]

ecs::Entity rtp::server::EntitySystem::createPlayerEntity ( PlayerPtr  player)

Create a new player entity in the ECS.

Returns
The ID of the created player entity

Definition at line 32 of file EntitySystem.cpp.

References createPlayerEntity().

Referenced by createPlayerEntity().

◆ createPlayerEntity() [2/2]

◆ createPowerupEntity()

ecs::Entity rtp::server::EntitySystem::createPowerupEntity ( uint32_t  roomId,
const Vec2f pos,
ecs::components::PowerupType  type,
float  value,
float  duration 
)

Create a new powerup entity in the ECS.

Parameters
roomIdID of the room the powerup belongs to
posPosition to spawn the powerup at
typeType of the powerup
valueValue associated with the powerup
durationDuration the powerup effect lasts
Returns
The ID of the created powerup entity

Definition at line 277 of file EntitySystem.cpp.

References _registry, rtp::ecs::Registry::add(), rtp::log::error(), rtp::ecs::Entity::index(), rtp::net::PowerupHeal, rtp::net::PowerupSpeed, rtp::ecs::Registry::spawn(), rtp::ecs::components::Speed, rtp::Vec2< T >::x, and rtp::Vec2< T >::y.

Referenced by rtp::server::LevelSystem::update().

◆ update()

void rtp::server::EntitySystem::update ( float  dt)
overridevirtual

Update movement system logic for one frame.

Parameters
dtTime elapsed since last update in seconds

Implements rtp::ecs::ISystem.

Definition at line 27 of file EntitySystem.cpp.

Member Data Documentation

◆ _network

ServerNetwork& rtp::server::EntitySystem::_network
protected

Reference to the server network manager.

Definition at line 141 of file EntitySystem.hpp.

◆ _networkSync

NetworkSyncSystem& rtp::server::EntitySystem::_networkSync
protected

Reference to the network sync system.

Definition at line 142 of file EntitySystem.hpp.

◆ _registry

ecs::Registry& rtp::server::EntitySystem::_registry
protected

Reference to the entity registry.

Definition at line 140 of file EntitySystem.hpp.

Referenced by applyWeaponToEntity(), createEnemyEntity(), createObstacleEntity(), createPlayerEntity(), and createPowerupEntity().


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