R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::Player Class Reference

Component identifying an entity as a player with game statistics. More...

#include <Player.hpp>

Inheritance diagram for ecs::Player:
Inheritance graph
Collaboration diagram for ecs::Player:
Collaboration graph

Public Member Functions

 Player (int score, int lives, uint32_t playerId)
 Constructor with all player data.
 
 ~Player () override=default
 
int getScore () const
 Get player's score.
 
int getLives () const
 Get remaining lives.
 
int getPlayerId () const
 Get player ID.
 
void setScore (int score)
 Set player's score.
 
void setLives (int lives)
 Set remaining lives.
 
void setPlayerId (int playerId)
 Set player ID.
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

int _score
 Player's current score.
 
int _lives
 Remaining lives.
 
int _playerId
 Unique player identifier.
 

Detailed Description

Component identifying an entity as a player with game statistics.

Stores player-specific data such as score, remaining lives, and player ID for multiplayer identification.

Definition at line 20 of file Player.hpp.

Constructor & Destructor Documentation

◆ Player()

ecs::Player::Player ( int  score,
int  lives,
uint32_t  playerId 
)
inline

Constructor with all player data.

Parameters
scoreInitial score
livesNumber of lives
playerIdUnique player identifier (for multiplayer)

Definition at line 28 of file Player.hpp.

◆ ~Player()

ecs::Player::~Player ( )
overridedefault

Member Function Documentation

◆ getLives()

int ecs::Player::getLives ( ) const
inline

Get remaining lives.

Returns
int Number of lives left.

Definition at line 41 of file Player.hpp.

References _lives.

◆ getPlayerId()

int ecs::Player::getPlayerId ( ) const
inline

Get player ID.

Returns
int Unique player identifier.

Definition at line 47 of file Player.hpp.

References _playerId.

Referenced by Server::_serializeEntity(), and server::GameStateSerializer::serializeEntity().

◆ getScore()

int ecs::Player::getScore ( ) const
inline

Get player's score.

Returns
int Current score value.

Definition at line 35 of file Player.hpp.

References _score.

Referenced by ecs::CollisionSystem::handlePickup().

◆ getType()

ComponentType ecs::Player::getType ( ) const
inlineoverridevirtual

Get the component type ID.

Returns
ComponentType Unique ID for Player component.

Implements ecs::IComponent.

Definition at line 71 of file Player.hpp.

◆ setLives()

void ecs::Player::setLives ( int  lives)
inline

Set remaining lives.

Parameters
livesNew lives count

Definition at line 59 of file Player.hpp.

References _lives.

◆ setPlayerId()

void ecs::Player::setPlayerId ( int  playerId)
inline

Set player ID.

Parameters
playerIdNew player identifier

Definition at line 65 of file Player.hpp.

References _playerId.

◆ setScore()

void ecs::Player::setScore ( int  score)
inline

Set player's score.

Parameters
scoreNew score value

Definition at line 53 of file Player.hpp.

References _score.

Referenced by ecs::CollisionSystem::handlePickup().

Member Data Documentation

◆ _lives

int ecs::Player::_lives
private

Remaining lives.

Definition at line 75 of file Player.hpp.

Referenced by getLives(), and setLives().

◆ _playerId

int ecs::Player::_playerId
private

Unique player identifier.

Definition at line 76 of file Player.hpp.

Referenced by getPlayerId(), and setPlayerId().

◆ _score

int ecs::Player::_score
private

Player's current score.

Definition at line 74 of file Player.hpp.

Referenced by getScore(), and setScore().


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