|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Represents a player in the game server. More...
#include <Player.hpp>
Public Member Functions | |
| Player (uint32_t sessionId) | |
| Constructor for Player. | |
| ~Player () | |
| Destructor for Player. | |
| void | setUsername (const std::string &username) |
| Set the username of the player. | |
| std::string | getUsername () const |
| Get the username of the player. | |
| void | setRoomId (uint32_t roomId) |
| Set the room ID the player is in. | |
| uint32_t | getRoomId () const |
| Get the room ID the player is in. | |
| bool | isInRoom () const |
| Check if the player is in a room. | |
| void | setState (PlayerState state) |
| Set the state of the player. | |
| PlayerState | getState () const |
| Get the state of the player. | |
| void | setReady (bool ready) |
| Set the readiness status of the player. | |
| bool | isReady () const |
| Get the readiness status of the player. | |
| void | setEntityId (uint32_t entityId) |
| Set the entity ID associated with the player. | |
| uint32_t | getId () const |
| Get the unique identifier of the Session. | |
| uint32_t | getEntityId () const |
| Get the associated entity ID. | |
| void | setMuted (bool muted) |
| bool | isMuted () const |
| void | setWeaponKind (rtp::ecs::components::WeaponKind weapon) |
| Set the selected weapon kind for this player. | |
| rtp::ecs::components::WeaponKind | getWeaponKind () const |
| Get the selected weapon kind for this player. | |
| void | addScore (int delta) |
| Add to player's score (can be negative) | |
| void | setScore (int score) |
| Set player's score. | |
| int | getScore () const |
| Get player's score. | |
Private Attributes | |
| uint32_t | _sessionId |
| Unique player identifier. | |
| std::string | _username |
| Player username. | |
| uint32_t | _roomId |
| ID of the room the player is in ; by default 0 (no room) | |
| PlayerState | _state |
| Current state of the player. | |
| bool | _isReady |
| Readiness status of the player. | |
| uint32_t | _entityId = 0 |
| Associated entity ID in the ECS. | |
| std::mutex | _mutex |
| Mutex to protect access to player state. | |
| bool | _isMuted = false |
| Mute status of the player. | |
| rtp::ecs::components::WeaponKind | _weaponKind {rtp::ecs::components::WeaponKind::Classic} |
| Selected weapon. | |
| int | _score {0} |
| Player score. | |
Represents a player in the game server.
Definition at line 41 of file Player.hpp.
| rtp::server::Player::Player | ( | uint32_t | sessionId | ) |
Constructor for Player.
| id | Unique identifier for the player |
| username | Username of the player |
Definition at line 17 of file Player.cpp.
| rtp::server::Player::~Player | ( | ) |
Destructor for Player.
Definition at line 24 of file Player.cpp.
| void rtp::server::Player::addScore | ( | int | delta | ) |
Add to player's score (can be negative)
| delta | Score delta |
Definition at line 124 of file Player.cpp.
| uint32_t rtp::server::Player::getEntityId | ( | ) | const |
| uint32_t rtp::server::Player::getId | ( | ) | const |
Get the unique identifier of the Session.
Definition at line 88 of file Player.cpp.
References _mutex, and _sessionId.
| uint32_t rtp::server::Player::getRoomId | ( | ) | const |
| int rtp::server::Player::getScore | ( | ) | const |
| PlayerState rtp::server::Player::getState | ( | ) | const |
| std::string rtp::server::Player::getUsername | ( | ) | const |
| rtp::ecs::components::WeaponKind rtp::server::Player::getWeaponKind | ( | ) | const |
Get the selected weapon kind for this player.
Definition at line 118 of file Player.cpp.
References _mutex, and _weaponKind.
| bool rtp::server::Player::isInRoom | ( | ) | const |
Check if the player is in a room.
Definition at line 52 of file Player.cpp.
| bool rtp::server::Player::isMuted | ( | ) | const |
Definition at line 106 of file Player.cpp.
| bool rtp::server::Player::isReady | ( | ) | const |
Get the readiness status of the player.
Definition at line 76 of file Player.cpp.
| void rtp::server::Player::setEntityId | ( | uint32_t | entityId | ) |
Set the entity ID associated with the player.
| entityId | New entity ID |
Definition at line 82 of file Player.cpp.
| void rtp::server::Player::setMuted | ( | bool | muted | ) |
Definition at line 100 of file Player.cpp.
| void rtp::server::Player::setReady | ( | bool | ready | ) |
Set the readiness status of the player.
| ready | New readiness status |
Definition at line 70 of file Player.cpp.
| void rtp::server::Player::setRoomId | ( | uint32_t | roomId | ) |
Set the room ID the player is in.
| roomId | New room ID |
Definition at line 40 of file Player.cpp.
| void rtp::server::Player::setScore | ( | int | score | ) |
| void rtp::server::Player::setState | ( | PlayerState | state | ) |
Set the state of the player.
| state | New player state |
Definition at line 58 of file Player.cpp.
| void rtp::server::Player::setUsername | ( | const std::string & | username | ) |
Set the username of the player.
| username | New username |
Definition at line 28 of file Player.cpp.
| void rtp::server::Player::setWeaponKind | ( | rtp::ecs::components::WeaponKind | weapon | ) |
Set the selected weapon kind for this player.
| weapon | Weapon kind |
Definition at line 112 of file Player.cpp.
References _mutex, and _weaponKind.
|
private |
Associated entity ID in the ECS.
Definition at line 167 of file Player.hpp.
Referenced by getEntityId(), and setEntityId().
|
private |
Mute status of the player.
Definition at line 169 of file Player.hpp.
Referenced by isMuted(), and setMuted().
|
private |
Readiness status of the player.
Definition at line 165 of file Player.hpp.
Referenced by Player(), isReady(), and setReady().
|
mutableprivate |
Mutex to protect access to player state.
Definition at line 168 of file Player.hpp.
Referenced by addScore(), getEntityId(), getId(), getRoomId(), getScore(), getState(), getUsername(), getWeaponKind(), isInRoom(), isMuted(), isReady(), setEntityId(), setMuted(), setReady(), setRoomId(), setScore(), setState(), setUsername(), and setWeaponKind().
|
private |
ID of the room the player is in ; by default 0 (no room)
Definition at line 163 of file Player.hpp.
Referenced by Player(), getRoomId(), isInRoom(), and setRoomId().
|
private |
Player score.
Definition at line 171 of file Player.hpp.
Referenced by addScore(), getScore(), and setScore().
|
private |
|
private |
Current state of the player.
Definition at line 164 of file Player.hpp.
Referenced by getState(), and setState().
|
private |
Player username.
Definition at line 162 of file Player.hpp.
Referenced by getUsername(), and setUsername().
|
private |
Selected weapon.
Definition at line 170 of file Player.hpp.
Referenced by getWeaponKind(), and setWeaponKind().