Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
PlayerSystem.hpp
Go to the documentation of this file.
1
8#ifndef RTYPE_PLAYER_SYSTEM_HPP_
9 #define RTYPE_PLAYER_SYSTEM_HPP_
10
11 #include "RType/ECS/ISystem.hpp"
12 #include "RType/ECS/Registry.hpp"
14 #include "Game/Player.hpp"
15
16 #include <map>
17
22namespace rtp::server {
27 class PlayerSystem : public ecs::ISystem {
28 public:
34 PlayerSystem(ServerNetwork& network, ecs::Registry& registry);
35
41 void update(float dt) override;
42
48 PlayerPtr createPlayer(uint32_t sessionId, const std::string& username);
49
55 uint32_t removePlayer(uint32_t sessionId);
56
62 void updatePlayerUsername(uint32_t sessionId, const std::string& username);
63
69 PlayerPtr getPlayer(uint32_t sessionId) const;
70
76 PlayerPtr getPlayerByUsername(const std::string& username) const;
77
78 private:
82 private:
83 std::map<uint32_t, PlayerPtr> _players;
84 };
85} // namespace rtp::server
86
87#endif /* !RTYPE_PLAYER_SYSTEM_HPP_ */
Interface for ECS systems.
Abstract base class for all ECS systems.
Definition ISystem.hpp:57
System to handle player-related operations on the server side.
PlayerPtr createPlayer(uint32_t sessionId, const std::string &username)
Create a new player for the given session ID.
PlayerPtr getPlayer(uint32_t sessionId) const
Get a player by their session ID.
void update(float dt) override
Update system logic for one frame.
ecs::Registry & _registry
Reference to the entity registry.
PlayerPtr getPlayerByUsername(const std::string &username) const
Get a player by their username.
std::map< uint32_t, PlayerPtr > _players
Map of session ID to Player instances.
ServerNetwork & _network
Reference to the server network manager.
void updatePlayerUsername(uint32_t sessionId, const std::string &username)
Update the username of a player.
uint32_t removePlayer(uint32_t sessionId)
Remove a player by their session ID.
Implementation ASIO du serveur réseau (TCP + UDP)
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
std::shared_ptr< Player > PlayerPtr
Shared pointer type for Player.
Definition Player.hpp:178