Jazz2::Multiplayer::IGameMode class

Rules of a single multiplayer game mode.

Encapsulates everything that differs between game modes — win conditions, scoring, respawn rules, team assignment and what happens at the level exit — so the same rules can run on top of either the networked MpLevelHandler or a local splitscreen handler. A mode only ever talks to its host through IGameModeContext; it never references networking, peers or the concrete handler type.

Derived classes

class BattleMode
Battle game mode (free-for-all).
class CaptureTheFlagMode
Capture The Flag game mode.
class CooperationMode
Cooperation game mode.
class RaceMode
Race game mode.
class TreasureHuntMode
Treasure Hunt game mode.

Constructors, destructors, conversion operators

~IGameMode() virtual

Public functions

auto GetMode() const -> MpGameMode pure virtual
Returns the game mode identifier.
auto IsTeamBased() const -> bool pure virtual
Returns whether players are split into teams.
auto SkipsPreGameCountdown() const -> bool pure virtual
Returns whether the pre-game wait and countdown are skipped (Cooperation starts immediately).
auto HasUnlimitedHealth() const -> bool pure virtual
Returns whether players have unlimited health in this mode.
auto LowerScoreWins() const -> bool pure virtual
Returns whether a lower round score ranks higher (Race finishes first).
auto OwnsRoundLogic() const -> bool virtual
Returns whether this mode computes its own win condition (CheckGameEnds).
void OnRoundStarted(IGameModeContext& ctx) pure virtual
Called when the round starts (after the countdown) to reset/initialize mode state.
void OnUpdate(IGameModeContext& ctx, float timeMult) pure virtual
Called every host tick while the round is running.
void OnPlayerSpawned(IGameModeContext& ctx, Actors::Player* player) pure virtual
Called after a player (re)spawns.
void OnPlayerKilled(IGameModeContext& ctx, Actors::Player* victim, Actors::Player* killer) pure virtual
Called when a player dies, for mode-specific reactions (e.g. dropping a carried flag); kill/death counts are maintained by the host. killer may be nullptr (environmental death).
auto DecideRespawn(IGameModeContext& ctx, Actors::Player* player) -> RespawnDecision pure virtual
Decides whether and where the specified player should respawn.
void OnCoinsCollected(IGameModeContext& ctx, Actors::Player* player, std::int32_t prevCount, std::int32_t newCount) pure virtual
Called when a player's coin count changes.
void OnGemsCollected(IGameModeContext& ctx, Actors::Player* player, std::uint8_t gemType, std::int32_t prevCount, std::int32_t newCount) pure virtual
Called when a player's gem count changes.
auto OnLevelExitReached(IGameModeContext& ctx, Actors::Player* player) -> LevelExitAction pure virtual
Decides what happens when the specified player reaches the level exit.
auto CheckGameEnds(IGameModeContext& ctx) -> GameEndResult pure virtual
Checks whether the round should end now, and who won.
void AssignTeams(IGameModeContext& ctx) pure virtual
(Re)assigns players to teams (free-for-all modes assign one team per player)
auto GetRoundScore(IGameModeContext& ctx, Actors::Player* player) -> std::uint32_t pure virtual
Returns the ranking metric of the specified player (kills / laps / treasure / ...).
void OnDrawHUD(IGameModeContext& ctx, IGameModeHUD& hud, Actors::Player* player, const Rectf& view) pure virtual
Draws the mode-specific part of the HUD for the given player's split-screen view.

Function documentation

bool Jazz2::Multiplayer::IGameMode::OwnsRoundLogic() const virtual

Returns whether this mode computes its own win condition (CheckGameEnds).

Returns true once the mode owns its win-condition check. While false — used during the staged migration — the host runs its legacy win-condition logic for this mode instead. Level-exit (OnLevelExitReached), respawn (DecideRespawn) and the HUD (OnDrawHUD) are always driven by the mode regardless of this flag.