|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
System to handle player-related operations on the server side. More...
#include <PlayerSystem.hpp>
Public Member Functions | |
| PlayerSystem (ServerNetwork &network, ecs::Registry ®istry) | |
| Constructor for PlayerSystem. | |
| void | update (float dt) override |
| Update system logic for one frame. | |
| PlayerPtr | createPlayer (uint32_t sessionId, const std::string &username) |
| Create a new player for the given session ID. | |
| uint32_t | removePlayer (uint32_t sessionId) |
| Remove a player by their session ID. | |
| void | updatePlayerUsername (uint32_t sessionId, const std::string &username) |
| Update the username of a player. | |
| PlayerPtr | getPlayer (uint32_t sessionId) const |
| Get a player by their session ID. | |
| PlayerPtr | getPlayerByUsername (const std::string &username) const |
| Get a player by their username. | |
Public Member Functions inherited from rtp::ecs::ISystem | |
| virtual | ~ISystem () noexcept=default |
Private Attributes | |
| ServerNetwork & | _network |
| Reference to the server network manager. | |
| ecs::Registry & | _registry |
| Reference to the entity registry. | |
| std::map< uint32_t, PlayerPtr > | _players |
| Map of session ID to Player instances. | |
System to handle player-related operations on the server side.
Definition at line 27 of file PlayerSystem.hpp.
| rtp::server::PlayerSystem::PlayerSystem | ( | ServerNetwork & | network, |
| ecs::Registry & | registry | ||
| ) |
Constructor for PlayerSystem.
| network | Reference to the server network manager |
| registry | Reference to the entity registry |
Definition at line 15 of file PlayerSystem.cpp.
| PlayerPtr rtp::server::PlayerSystem::createPlayer | ( | uint32_t | sessionId, |
| const std::string & | username | ||
| ) |
Create a new player for the given session ID.
| sessionId | ID of the network session |
| username | Username of the player |
Definition at line 23 of file PlayerSystem.cpp.
References _players, rtp::log::info(), and rtp::log::warning().
| PlayerPtr rtp::server::PlayerSystem::getPlayer | ( | uint32_t | sessionId | ) | const |
Get a player by their session ID.
| sessionId | ID of the network session |
Definition at line 58 of file PlayerSystem.cpp.
References _players.
| PlayerPtr rtp::server::PlayerSystem::getPlayerByUsername | ( | const std::string & | username | ) | const |
Get a player by their username.
| username | Username to look up |
Definition at line 67 of file PlayerSystem.cpp.
References _players.
| uint32_t rtp::server::PlayerSystem::removePlayer | ( | uint32_t | sessionId | ) |
Remove a player by their session ID.
| sessionId | ID of the network session |
Definition at line 36 of file PlayerSystem.cpp.
References _players, and rtp::log::info().
|
overridevirtual |
Update system logic for one frame.
| dt | Time elapsed since last update in seconds |
Implements rtp::ecs::ISystem.
Definition at line 18 of file PlayerSystem.cpp.
| void rtp::server::PlayerSystem::updatePlayerUsername | ( | uint32_t | sessionId, |
| const std::string & | username | ||
| ) |
Update the username of a player.
| sessionId | ID of the network session |
| username | New username of the player |
Definition at line 49 of file PlayerSystem.cpp.
References _players, and rtp::log::info().
|
private |
Reference to the server network manager.
Definition at line 79 of file PlayerSystem.hpp.
|
private |
Map of session ID to Player instances.
Definition at line 83 of file PlayerSystem.hpp.
Referenced by createPlayer(), getPlayer(), getPlayerByUsername(), removePlayer(), and updatePlayerUsername().
|
private |
Reference to the entity registry.
Definition at line 80 of file PlayerSystem.hpp.