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 Jazz2::Multiplayer::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 GetSyncedTeamExtra(std::
uint8_t team, std:: uint32_t& value) const -> bool pure virtual - Returns the synchronized second number of the team (see IGameMode::
TryGetTeamExtra), also on clients. -
auto GetCtfFlagStateCount() const -> std::
uint8_t pure virtual - Returns the number of Capture The Flag flag states (one per team), or
0when 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
nullptrfor a draw). -
void EndGameWithTeam(std::
uint8_t team) pure virtual - Ends the round with the specified winning team.
-
auto GetPlayerName(Actors::
Player* player) -> StringView pure virtual - Returns the display name of the specified player.
-
auto FindPlayerByIndex(std::
uint32_t playerIndex) -> Actors:: Player* pure virtual - Returns the player with the specified player index, or
nullptrif it's not in the round. -
auto GetTeamBasePosition(std::
uint8_t team) -> Vector2f pure virtual - Returns the home base of the specified team (CTF base event, or a spawn point of the team).
- void ShowAlertToAllPlayers(const ServerMessage& message) pure virtual
- Shows a message to all players, each in their own language.
- void SendMessageToAllPlayers(const ServerMessage& message) pure virtual
- Writes a line to the console of all players, each in their own language.
-
void ShowCountdownToAllPlayers(std::
int32_t secsLeft) pure virtual - Shows a step of the big countdown in the middle of the screen of all players,
0shows "Go!". -
void SyncPlayerModeState(Actors::
Player* player) pure virtual - Synchronizes the mode fields of MpPlayerState of the specified player to all peers and re-applies its color.
- void SyncTeamScores() pure virtual
- Synchronizes the team scores to all peers.
- void CheckGameEnds() pure virtual
- Updates the standings and ends the round if the win condition is met, call it after a score changes.
- auto GetGameModeObjects() -> SmallVectorImpl<GameModeObject>& pure virtual
- Returns objects in the level owned by the game mode, see SyncGameModeObjects().
-
auto CreateGameModeObjectId() -> std::
uint32_t pure virtual - Returns a new identifier for GameModeObject::
Id. - void SyncGameModeObjects() pure virtual
- Synchronizes GetGameModeObjects() to all peers, call it after any change.
-
void FindEventPositions(EventType eventType,
SmallVectorImpl<Pair<Vector2f, std::
uint16_t>>& positions) pure virtual - Collects the positions of all event tiles of the specified type in the level, with their first two parameters (the second one in the high byte).
- void FindCapturePoints(SmallVectorImpl<CapturePointInfo>& points) pure virtual
- Collects the events marked as easy-only or hard-only, which are control points and capture points.
- void FindSpawnPoints(SmallVectorImpl<Vector2f>& positions) pure virtual
- Collects the positions of all multiplayer spawn points.
-
void FindOriginalEvents(std::
uint8_t jj2EventId, SmallVectorImpl<Pair<Vector2i, std:: uint32_t>>& events) pure virtual - Collects the tiles and the 20-bit parameters of all original JJ2 events of the specified ID the game keeps unconverted.
-
void WarpPlayer(Actors::
Player* player, Vector2f pos) pure virtual - Warps the player to the specified position.
-
void KillPlayer(Actors::
Player* player) pure virtual - Kills the player, it counts as a death by the environment.
-
auto GetPlayerGemCount(Actors::
Player* player) -> std:: int32_t pure virtual - Returns the number of gems the player holds, regardless of their color.
-
void ClearPlayerGems(Actors::
Player* player) pure virtual - Takes all gems from the player.
-
void AddPlayerGems(Actors::
Player* player, std:: int32_t count) pure virtual - Gives red gems to the player.
-
void SpawnGems(Vector2f pos,
std::
int32_t count, Actors:: Player* owner) pure virtual - Scatters the specified number of red gems around the position,
owner(if any) can't pick them up. -
auto CountPlayersWithRole(PlayerModeFlags flag,
std::
uint8_t team) -> std:: int32_t pure virtual - Counts the players of the team with the role (any role if
flagisNone), also on clients. - auto FindPlayerWithRole(PlayerModeFlags flag, Vector2f& pos) -> bool pure virtual
- Finds the position of a player with the role, also on clients, returns
falseif there's none. -
void SetTrigger(std::
uint8_t triggerId, bool newState) pure virtual - Sets the state of a trigger.
- auto IsOvertime() const -> bool pure virtual
- Returns
truewhile the round is in overtime. - auto CanStartOvertime() const -> bool pure virtual
- Returns
trueif the round may go into overtime now (enabled and not in overtime already). -
auto GetOvertimeScoreCap() const -> std::
uint32_t pure virtual - Returns the score that wins the overtime, or
0if it isn't capped. -
void SetOvertimeScoreCap(std::
uint32_t score) pure virtual - Sets the score that wins the overtime and announces it.
-
void SetPlayerOut(Actors::
Player* player, bool out) pure virtual - Moves the player to spectate mode until the next round, or brings it back.
Function documentation
void Jazz2:: Multiplayer:: GameModes:: IGameModeContext:: FindCapturePoints(SmallVectorImpl<CapturePointInfo>& points) pure virtual
Collects the events marked as easy-only or hard-only, which are control points and capture points.
Ordered from top to bottom and then from left to right. An easy one faces right (direction 1), a hard one left (direction -1). A Text event carries the help string it points to as the name.