Jazz2::Multiplayer::IGameModeContext class

Services a game mode needs from its host level handler.

Implemented by whichever level handler hosts an IGameMode (the online MpLevelHandler or a local splitscreen handler). It abstracts away whether the session is networked: the mode reads and writes per-player state through GetPlayerState and never touches peers, packets or sockets. The online host observes the state the mode produces and synchronizes it to clients; the local host just stores it.

Derived classes

class MpLevelHandler
Level handler of a multiplayer game session (online or local splitscreen).

Constructors, destructors, conversion operators

~IGameModeContext() virtual

Public functions

auto GetServerConfiguration() const -> const ServerConfiguration& pure virtual
Returns the active server configuration (win targets, elimination, invulnerability, ...).
auto GetPlayers() const -> ArrayView<Actors::Player* const> pure virtual
Returns all currently active players (matches ILevelHandler::GetPlayers).
auto GetPlayerState(Actors::Player* player) -> MpPlayerState& pure virtual
Returns the mutable mode state of the specified player.
auto IsSpectating(Actors::Player* player) const -> bool pure virtual
Returns whether the specified player is currently spectating.
auto GetTeamCount() const -> std::uint8_t pure virtual
Returns the number of teams (team-based modes only).
auto GetTeamScore(std::uint8_t team) -> std::uint32_t pure virtual
Returns the aggregate round score of the specified team (team-based modes only).
auto GetCtfFlagStateCount() const -> std::uint8_t pure virtual
Returns the number of Capture The Flag flag states (one per team), or 0 when not in CTF.
auto GetCtfFlagState(std::uint8_t team) const -> std::uint8_t pure virtual
Returns the flag state of the specified team in Capture The Flag (0 = home, 1 = taken, 2 = dropped).
auto GetSpawnPoint(Actors::Player* player) -> Vector2f pure virtual
Returns a spawn position appropriate for the specified player (its type and assigned team).
auto GetElapsedFrames() const -> float pure virtual
Returns the elapsed frames since the level started.
void EndGame(Actors::Player* winner) pure virtual
Ends the round with the specified winning player (may be nullptr for a draw).
void EndGameWithTeam(std::uint8_t team) pure virtual
Ends the round with the specified winning team.