ILevelHandler class
#include <Jazz2/ILevelHandler.h>
Base interface of a level handler.
Abstracts the running level for the rest of the engine, exposing the tile map, event map, event spawner and difficulty, together with queries about the session (local, server, pausable, reforged). Implemented by LevelHandler for local play and by the multiplayer variants.
Derived classes
- class LevelHandler
- Level handler of a local game session.
Public functions
- auto Initialize(const LevelInitialization& levelInit) -> bool pure virtual
- Initializes the level handler from LevelInitialization.
-
auto Initialize(Stream& src,
std::
uint16_t version) -> bool pure virtual - Initializes the level handler from resumable state.
-
auto EventSpawner() -> Events::
EventSpawner* pure virtual - Returns event spawner for the level.
-
auto EventMap() -> Events::
EventMap* pure virtual - Returns event map for the level.
-
auto TileMap() -> Tiles::
TileMap* pure virtual - Returns tile map for the level.
- auto GetDifficulty() const -> GameDifficulty pure virtual
- Return current difficulty.
- auto IsLocalSession() const -> bool pure virtual
- Returns
trueif the level handler is on a local session. - auto IsServer() const -> bool pure virtual
- Returns
trueif the level handler is on a server or a local session. - auto IsPausable() const -> bool pure virtual
- Returns
trueif the level handler is pausable. - auto IsReforged() const -> bool pure virtual
- Returns
trueif Reforged Gameplay is enabled. -
auto IsLedgeClimbEnabled(const Actors::
Player* player) const -> bool pure virtual - Returns
trueif a player may climb ledges, see PreferencesCache::EnableLedgeClimb. - auto CanActivateSugarRush() const -> bool pure virtual
- Returns
trueif sugar rush can be activated. - auto CanEventDisappear(EventType eventType) const -> bool pure virtual
- Returns
trueif event can be safely despawned. -
auto CanFreezeActor(Actors::
ActorBase* actor, Actors:: ActorBase* shooter) -> bool pure virtual - Returns
trueif a shot ofshooter(may benullptr) can freezeactor. - auto CanPlayersCollide() const -> bool pure virtual
- Returns
trueif players can collide with each other. - auto GetLevelBounds() const -> Recti pure virtual
- Returns level bounds including camera limits.
- auto GetElapsedFrames() const -> float pure virtual
- Returns number of elapsed frames.
- auto GetGravity() const -> float pure virtual
- Returns current gravity force.
- auto GetWaterLevel() const -> float pure virtual
- Returns current water level.
- auto GetPlayerWaterLevel() const -> float pure virtual
- Returns the water level the players swim by.
- auto GetHurtInvulnerableTime() const -> float pure virtual
- Returns default invulnerable time when a player is hurt.
-
auto GetActiveBossHealth(std::
int32_t& health, std:: int32_t& maxHealth) const -> bool pure virtual - Returns
trueif a boss health bar should be shown, together with the boss' health. -
auto GetActors() const -> ArrayView<const std::
shared_ptr<Actors:: ActorBase>> pure virtual - Returns list of actors (objects).
-
auto GetPlayers() const -> ArrayView<Actors::
Player* const> pure virtual - Returns list of players.
-
auto FindPlayerToStandOn(Actors::
Player* player, float timeMult) -> Actors:: ActorBase* pure virtual - Returns the player actor
playeris standing/landing on (one-way platform check), ornullptr. -
auto GetPlayerFurColor(const Actors::
Player* player, std:: uint32_t furColor) const -> std:: uint32_t pure virtual - Returns the fur color a player should actually be recolored with.
-
auto IsPlayerColorForced(const Actors::
Player* player) const -> bool pure virtual - Returns whether the level handler forces a fur color on the player, overriding local color preferences.
- auto GetCharacterProfile(PlayerType type) const -> CharacterProfile pure virtual
- Returns the abilities of a character.
- auto WarpsTransmuteCoins() const -> bool pure virtual
- Returns
trueif a bonus warp turns the coins lying in the level into gems. - auto AreCoinsTransmuted() const -> bool pure virtual
- Returns
trueif the coins lying in the level have turned into gems. - void TransmuteCoins() pure virtual
- Turns the coins lying in the level into gems, as a bonus warp that costs coins does.
- auto GetWaterInteraction() const -> WaterInteraction pure virtual
- Returns how players move under water.
- auto GetDefaultAmbientLight() const -> float pure virtual
- Returns default ambient light intensity.
-
auto GetAmbientLight(Actors::
Player* player) const -> float pure virtual - Returns current ambient light intensity.
-
void SetAmbientLight(Actors::
Player* player, float value) pure virtual - Sets current ambient light intensity.
-
void AddActor(std::
shared_ptr<Actors:: ActorBase> actor) pure virtual - Adds an actor (object) to the level.
-
auto PlaySfx(Actors::
ActorBase* self, StringView identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain = 1.0f, float pitch = 1.0f, SfxFlags flags = SfxFlags:: None) -> std:: shared_ptr<AudioBufferPlayer> pure virtual - Plays a sound effect for a given actor (object).
-
void StopSfx(Actors::
ActorBase* self, StringView identifier, AudioBufferPlayer* player) pure virtual - Stops a sound effect of a given actor (object) started with SfxFlags::
Exclusive. -
auto PlayCommonSfx(StringView identifier,
const Vector3f& pos,
float gain = 1.0f,
float pitch = 1.0f) -> std::
shared_ptr<AudioBufferPlayer> pure virtual - Plays a common sound effect.
-
void WarpCameraToTarget(Actors::
ActorBase* actor, bool fast = false) pure virtual - Warps a camera to its assigned target.
-
auto IsPositionEmpty(Actors::
ActorBase* self, const AABBf& aabb, Tiles:: TileCollisionParams& params, Actors:: ActorBase** collider) -> bool pure virtual - Returns
trueif a specified AABB is empty. -
auto IsPositionEmpty(Actors::
ActorBase* self, const AABBf& aabb, Tiles:: TileCollisionParams& params) -> bool -
void FindCollisionActorsByAABB(const Actors::
ActorBase* self, const AABBf& aabb, Function<bool(Actors:: ActorBase*)>&& callback) pure virtual - Calls the callback function for all colliding objects with specified AABB.
-
void FindCollisionActorsByRadius(float x,
float y,
float radius,
Function<bool(Actors::
ActorBase*)>&& callback) pure virtual - Calls the callback function for all colliding objects with specified circle.
-
void GetCollidingPlayers(const AABBf& aabb,
Function<bool(Actors::
ActorBase*)>&& callback) pure virtual - Calls the callback function for all colliding players with specified AABB.
-
void BroadcastTriggeredEvent(Actors::
ActorBase* initiator, EventType eventType, std:: uint8_t* eventParams) pure virtual - Broadcasts specified event to all other actors.
-
void BeginLevelChange(Actors::
ActorBase* initiator, ExitType exitType, StringView nextLevel = {}) pure virtual - Starts transition to change current level.
- auto CanTakeLevelExit(ExitType exitType, StringView nextLevel) const -> bool pure virtual
- Returns
trueif a level exit of the specified type leading to the specified level can be taken. -
void SendPacket(const Actors::
ActorBase* self, ArrayView<const std:: uint8_t> data) pure virtual - Sends a packet to the other side of a non-local session.
-
void HandleBossActivated(Actors::
Bosses:: BossBase* boss, Actors:: ActorBase* initiator = nullptr) pure virtual - Called when a boss is activated.
- void HandleLevelChange(LevelInitialization&& levelInit) pure virtual
- Called when the level is changed.
-
void HandleGameOver(Actors::
Player* player) pure virtual - Called when the game is over.
-
auto HandlePlayerDied(Actors::
Player* player) -> bool pure virtual - Called when a player dies.
-
void HandlePlayerWarped(Actors::
Player* player, Vector2f prevPos, WarpFlags flags) pure virtual - Called when a player warps.
-
void HandlePlayerPushed(Actors::
Player* player) pure virtual - Called after a server-side force/knockback is applied to a player.
-
auto HandlePlayerFire(Actors::
Player* player, WeaponType weaponType) -> bool pure virtual - Called when a player fires a weapon, returns
trueif its shots were fired by something else (a level script). - auto GetWeaponDefinition(WeaponType weaponType) const -> const WeaponDefinition& pure virtual
- Returns what the level makes of a weapon (see Formats::
WeaponsChunk). - auto GetWeapons() const -> const WeaponsDescription& pure virtual
- Returns the weapons of the level with the images they use.
-
void HandlePlayerCoins(Actors::
Player* player, std:: int32_t prevCount, std:: int32_t newCount) pure virtual - Called when a player collects or losts coins.
-
void HandlePlayerGems(Actors::
Player* player, std:: uint8_t gemType, std:: int32_t prevCount, std:: int32_t newCount) pure virtual - Called when a player collects or losts gems.
-
void SetCheckpoint(Actors::
Player* player, Vector2f pos) pure virtual - Sets checkpoint for a given player.
-
void RollbackToCheckpoint(Actors::
Player* player) pure virtual - Rolls back to the last checkpoint for a given player.
-
void HandleActivateSugarRush(Actors::
Player* player) pure virtual - Called when a player activates sugar rush.
-
void HandleCreateParticleDebrisOnPerish(const Actors::
ActorBase* self, Actors:: ParticleDebrisEffect effect, Vector2f speed) pure virtual - Called when an object creates a particle debris on perish.
-
void HandleCreateSpriteDebris(const Actors::
ActorBase* self, AnimState state, std:: int32_t count, float elasticity) pure virtual - Called when an object creates a sprite debris.
-
void ShowLevelText(StringView text,
Actors::
ActorBase* initiator = nullptr) pure virtual - Shows a text notification.
-
auto GetLevelText(std::
uint32_t textId, std:: int32_t index = -1, std:: uint32_t delimiter = 0) -> StringView pure virtual - Returns a level text.
-
void OverrideLevelText(std::
uint32_t textId, StringView value) pure virtual - Override specified level text.
-
auto GetCameraPos(Actors::
Player* player) const -> Vector2f pure virtual - Returns camera position of a given player.
-
void LimitCameraView(Actors::
Player* player, Vector2f playerPos, std:: int32_t left, std:: int32_t width) pure virtual - Limits camera viewport for a given player.
-
void OverrideCameraView(Actors::
Player* player, CameraOverride modeX, float x, CameraOverride modeY, float y, bool centered = false, bool instant = true) pure virtual - Fixes the camera of a given player at a position of the level, or lets it follow the player again, on each axis.
-
void ShakeCameraView(Actors::
Player* player, float duration) pure virtual - Shake camera for a given player.
- void ShakeCameraViewNear(Vector2f pos, float duration) pure virtual
- Shake camera for all players near a given position.
-
auto GetTrigger(std::
uint8_t triggerId) -> bool pure virtual - Returns state of a given trigger in the tile map.
-
void SetTrigger(std::
uint8_t triggerId, bool newState) pure virtual - Sets state of a given trigger in the tile map.
-
void SetWeather(WeatherType type,
std::
uint8_t intensity) pure virtual - Sets current level weather.
- auto BeginPlayMusic(StringView path, bool setDefault = false, bool forceReload = false) -> bool pure virtual
- Plays specified music.
-
auto PlayerActionPressed(Actors::
Player* player, PlayerAction action, bool includeGamepads = true) -> bool pure virtual - Returns
trueif player action is pressed. -
auto PlayerActionPressed(Actors::
Player* player, PlayerAction action, bool includeGamepads, bool& isGamepad) -> bool pure virtual -
auto PlayerActionHit(Actors::
Player* player, PlayerAction action, bool includeGamepads = true) -> bool pure virtual - Returns
trueif player action is hit (newly pressed). -
auto PlayerActionHit(Actors::
Player* player, PlayerAction action, bool includeGamepads, bool& isGamepad) -> bool pure virtual -
auto PlayerHorizontalMovement(Actors::
Player* player) -> float pure virtual - Returns value of desired horizontal player movement.
-
auto PlayerVerticalMovement(Actors::
Player* player) -> float pure virtual - Returns value of desired vertical player movement.
-
void PlayerExecuteRumble(Actors::
Player* player, StringView rumbleEffect) pure virtual - Executes a rumble effect.
Constants
-
static std::
int32_t MainPlaneZ constexpr - Layer of the main plane.
-
static std::
int32_t SpritePlaneZ constexpr - Layer of sprites.
-
static std::
int32_t PlayerZ constexpr - Layer of players.
Function documentation
float Jazz2:: ILevelHandler:: GetPlayerWaterLevel() const pure virtual
Returns the water level the players swim by.
The same as GetWaterLevel(), unless a level script changes the water in its ticks - the water as the script left it for the players then, before its objects (see LevelHandler::
bool Jazz2:: ILevelHandler:: GetActiveBossHealth(std:: int32_t& health,
std:: int32_t& maxHealth) const pure virtual
Returns true if a boss health bar should be shown, together with the boss' health.
Online clients never own the boss actor (boss activation is server-side only), so multiplayer reports the health synchronized from the server instead of reading the local boss actor.
Actors:: ActorBase* Jazz2:: ILevelHandler:: FindPlayerToStandOn(Actors:: Player* player,
float timeMult) pure virtual
Returns the player actor player is standing/landing on (one-way platform check), or nullptr.
Shared by local splitscreen co-op and online sessions to let players stand on top of each other. Local sessions search the player list; online sessions also search remote players on clients.
std:: uint32_t Jazz2:: ILevelHandler:: GetPlayerFurColor(const Actors:: Player* player,
std:: uint32_t furColor) const pure virtual
Returns the fur color a player should actually be recolored with.
Lets the level handler override a player's configured color; multiplayer team modes use this to force the team color.
bool Jazz2:: ILevelHandler:: IsPlayerColorForced(const Actors:: Player* player) const pure virtual
Returns whether the level handler forces a fur color on the player, overriding local color preferences.
Multiplayer team modes force the team color on every player so teams stay distinguishable; such a forced color applies regardless of the cosmetic "Apply Colors" preference.
void Jazz2:: ILevelHandler:: StopSfx(Actors:: ActorBase* self,
StringView identifier,
AudioBufferPlayer* player) pure virtual
Stops a sound effect of a given actor (object) started with SfxFlags::
Stops player, the instance playing here (may be nullptr), and the instance the remote peers play for the same actor and identifier, which the actor has no handle to.
bool Jazz2:: ILevelHandler:: IsPositionEmpty(Actors:: ActorBase* self,
const AABBf& aabb,
Tiles:: TileCollisionParams& params)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Jazz2:: ILevelHandler:: CanTakeLevelExit(ExitType exitType,
StringView nextLevel) const pure virtual
Returns true if a level exit of the specified type leading to the specified level can be taken.
A special level returns back to the level it was entered from once it's completed, and it cannot be entered from there again (see LevelInitialization::
void Jazz2:: ILevelHandler:: HandlePlayerPushed(Actors:: Player* player) pure virtual
Called after a server-side force/knockback is applied to a player.
Allows the change to be synchronized to the owning client in a non-local session.
void Jazz2:: ILevelHandler:: OverrideCameraView(Actors:: Player* player,
CameraOverride modeX,
float x,
CameraOverride modeY,
float y,
bool centered = false,
bool instant = true) pure virtual
Fixes the camera of a given player at a position of the level, or lets it follow the player again, on each axis.
The position is where the top left corner of the view is, or its center if centered is true. Unless instant is true, the camera takes half a second to get there, as jjPLAYER::cameraFreeze() of JJ2+.
bool Jazz2:: ILevelHandler:: PlayerActionPressed(Actors:: Player* player,
PlayerAction action,
bool includeGamepads,
bool& isGamepad) pure virtual
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Jazz2:: ILevelHandler:: PlayerActionHit(Actors:: Player* player,
PlayerAction action,
bool includeGamepads,
bool& isGamepad) pure virtual
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.