Jazz2::Multiplayer::GameModes::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. Modes derive from GameModeBase, which implements the optional parts.

Derived classes

class GameModeBase
Base of all game modes.

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 pure 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).
void OnPlayerTeamChanged(IGameModeContext& ctx, Actors::Player* player) pure virtual
Called when a living player changed the team, right before the player respawns on the new team.
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.
auto CanDamagePlayer(IGameModeContext& ctx, Actors::Player* victim, Actors::Player* attacker) -> bool pure virtual
Returns whether attacker may hurt victim.
auto CanPlayersPush(IGameModeContext& ctx, Actors::Player* a, Actors::Player* b) -> bool pure virtual
Returns true if players a and b push each other when they touch.
auto PreventsHazardDeath(IGameModeContext& ctx, Actors::Player* player) -> bool pure virtual
Called before a pit nobody caused roasts the player, returns true to keep it alive at 1 heart instead.
auto CanFreezeActor(IGameModeContext& ctx, Actors::ActorBase* actor, Actors::Player* shooter) -> bool pure virtual
Returns true if a shot of shooter (may be nullptr) can freeze actor, it's called also on clients.
auto HasDamageAmplifierInOvertime() const -> bool pure virtual
Returns true if the damage amplifier turns on in the overtime of this mode.
auto ProcessCommand(IGameModeContext& ctx, StringView command) -> bool pure virtual
Processes an admin command of the mode (without the leading slash), returns true if it was one.
void OnOvertimeStarted(IGameModeContext& ctx) pure virtual
Called when the round goes into overtime.
auto GetDamage(IGameModeContext& ctx, Actors::Player* victim, Actors::Player* attacker, std::int32_t amount) -> std::int32_t pure virtual
Returns the damage attacker deals to victim by one hit of amount.
void OnPlayerHit(IGameModeContext& ctx, Actors::Player* victim, Actors::Player* attacker) pure virtual
Called when attacker hurt victim, also when the hit roasted it (after OnPlayerKilled then).
auto CountsAsKill(IGameModeContext& ctx, Actors::Player* victim, Actors::Player* attacker) -> bool pure virtual
Returns whether a kill of victim by attacker counts as a kill of the attacker and of its team.
auto IsEliminated(IGameModeContext& ctx, Actors::Player* player) -> bool pure virtual
Returns whether the specified player is out of the round for good.
auto TryGetTeamScore(IGameModeContext& ctx, std::uint8_t team, std::uint32_t& score) -> bool pure virtual
Returns the score of the specified team if the mode keeps it on its own, otherwise false.
auto TryGetTeamExtra(IGameModeContext& ctx, std::uint8_t team, std::uint32_t& value) -> bool pure virtual
Returns a second number of the specified team the HUD shows (synchronized), otherwise false.
auto OnTimeOut(IGameModeContext& ctx) -> GameEndResult pure virtual
Decides the round when its time runs out, if GameEndResult::ShouldEnd is false, the host decides by the score.
auto GetStateScore(const MpPlayerState& state) const -> std::uint32_t pure virtual
Returns the ranking metric stored in the specified state, a player with more ranks higher.
auto GetScoreboardLabel() const -> StringView pure virtual
Returns label of the mode-specific column of the scoreboard, which shows GetStateScore(), or empty.
auto GetForcedFurColor(std::uint8_t modeFlags) const -> std::uint32_t pure virtual
Returns fur color forced on the player by its role in the mode, or 0 to keep it.
auto GetRoleLabel(std::uint8_t modeFlags) const -> StringView pure virtual
Returns a short label shown next to the name of a player with the specified role, or empty.

Function documentation

bool Jazz2::Multiplayer::GameModes::IGameMode::OwnsRoundLogic() const pure 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.

bool Jazz2::Multiplayer::GameModes::IGameMode::CanDamagePlayer(IGameModeContext& ctx, Actors::Player* victim, Actors::Player* attacker) pure virtual

Returns whether attacker may hurt victim.

Called on top of the friendly-fire rule of the host, so a mode only restricts it further.