8#ifndef RTYPE_GAME_ROOM_HPP_
9 #define RTYPE_GAME_ROOM_HPP_
19 #include <unordered_set>
21 #include "Systems/NetworkSyncSystem.hpp"
75 uint32_t maxPlayers,
float difficulty,
float speed,
RoomType type,
76 uint32_t creatorSessionId = 0, uint32_t levelId = 1, uint32_t seed = 0,
102 void removePlayer(uint32_t sessionId,
bool disconnected =
false);
108 const std::list<PlayerPtr>
getPlayers(
void)
const;
114 uint32_t
getId(
void)
const;
176 std::string
getName(
void)
const;
212 void update(uint32_t serverTick,
float dt);
220 void banUser(
const std::string &username);
221 bool isBanned(
const std::string &username)
const;
231 std::list<std::pair<PlayerPtr, PlayerType>>
237 std::pair<std::string, int>
Network packet implementation for R-Type protocol.
System to handle network-related operations on the server side.
Represents a game room in the server.
std::pair< std::string, int > _bestRoomScore
Best score achieved in the room.
float getDifficulty(void) const
Get the difficulty level of the room.
PlayerType
Enum representing the type of player in the room.
@ Spectator
Spectator player.
@ None
Undefined player type.
void banUser(const std::string &username)
std::list< std::pair< PlayerPtr, PlayerType > > _players
List of player ptr's in the room.
std::mutex _mutex
Mutex to protect access to room state.
bool hasActivePlayers() const
Check if there are any active players (non-spectators)
uint32_t _id
Unique room identifier.
uint32_t getLevelId(void) const
Get the level identifier of the room.
PlayerType getPlayerType(uint32_t sessionId) const
Get the type of a player in the room.
float _startedDt
Delta time accumulator since game start.
uint32_t getCurrentPlayerCount(void) const
Get the current number of players in the room.
void removePlayer(uint32_t sessionId, bool disconnected=false)
Remove a player from the room.
uint32_t durationMinutes
Duration of the game in minutes.
uint32_t _maxPlayers
Maximum number of players allowed.
RoomType _type
Type of the room.
RoomType getType(void) const
Get the type of the room.
const std::list< PlayerPtr > getPlayers(void) const
Get the list of players in the room.
uint32_t getDurationMinutes(void) const
Get the duration in minutes of the room.
void broadcastRoomState(uint32_t serverTick)
Broadcast the current room state to all connected players.
float getSpeed(void) const
Get the speed multiplier of the room.
std::string _name
Name of the room.
uint32_t getId(void) const
Get the unique identifier of the room.
bool addPlayer(const PlayerPtr &player, PlayerType type=PlayerType::Player)
Add a player to the room.
State
Enum representing the state of the room.
@ InGame
Game in progress.
@ Waiting
Waiting for players.
~Room()
Destructor for Room.
void broadcastSystemMessage(const std::string &message)
float _scoreTick
Score tick accumulator.
NetworkSyncSystem _network
Reference to the server network manager.
bool startGame(float dt)
Start the game in the room.
bool canJoin(void) const
Add a player to the room.
uint32_t _seed
Seed for random generation in the room.
uint32_t _levelId
Level identifier for the room.
void setPlayerType(uint32_t sessionId, PlayerType type)
Set the type of a player in the room.
State _state
Current state of the room.
float _speed
Speed multiplier for the room 0 -> 2.
std::string getName(void) const
Get the name of the room.
State getState(void) const
Get the current state of the room.
std::unordered_set< std::string > _bannedUsers
Banned usernames.
uint32_t getSeed(void) const
Get the random seed of the room.
void update(uint32_t serverTick, float dt)
Update the room state.
uint32_t _creatorSessionId
Session ID of the room creator (Administrator)
float _difficulty
Difficulty multiplier for the room 0 -> 1.
@ Private
Private room type, hosted by the player.
@ Public
Public room type, can be joined by anyone.
@ Lobby
Lobby room type, Only used for the principal Lobby.
void forceFinishGame(void)
Finish the game in the room.
bool isBanned(const std::string &username) const
ecs::Registry & _registry
Reference to the entity registry.
uint32_t getMaxPlayers(void) const
Get the maximum number of players allowed in the room.
uint32_t _currentTimeSeconds
Current time in seconds since the game started.
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
std::shared_ptr< Player > PlayerPtr
Shared pointer type for Player.