class
#include <Jazz2/LevelHandler.h>
LevelHandler Level handler of a local game session.
Base classes
- class ILevelHandler
- Base interface of a level handler.
- class IStateHandler
- Base interface of a state handler, only one handler runs at a time.
- class IResumable
- Base interface of a resumable object.
- class ITileMapOwner
- Interface used to notify tile map owner of various events.
Derived classes
- class MultiLevelHandler
- Level handler of an online multiplayer game session.
Public static variables
-
static std::
int32_t DefaultWidth constexpr - Default width of viewport.
-
static std::
int32_t DefaultHeight constexpr - Default height of viewport.
-
static std::
int32_t ActivateTileRange constexpr - Range of active tiles.
Constructors, destructors, conversion operators
- LevelHandler(IRootController* root)
- ~LevelHandler() override
Public functions
- auto Initialize(const LevelInitialization& levelInit) -> bool override
- Initializes the level handler from LevelInitialization.
-
auto Initialize(Stream& src,
std::
uint16_t version) -> bool override - Initializes the level handler from resumable state.
-
auto EventSpawner() -> Events::
EventSpawner* override - Returns event spawner for the level.
-
auto EventMap() -> Events::
EventMap* override - Returns event map for the level.
-
auto TileMap() -> Tiles::
TileMap* override - Returns tile map for the level.
- auto Difficulty() const -> GameDifficulty override
- Return current difficulty.
- auto IsLocalSession() const -> bool override
- Return
true
if the level handler is on a local session. - auto IsPausable() const -> bool override
- Return
true
if the level handler is pausable. - auto IsReforged() const -> bool override
- Returns
true
if Reforged Gameplay is enabled. - auto CanPlayersCollide() const -> bool override
- Returns
true
if players can collide with each other. - auto LevelBounds() const -> Recti override
- Returns level bounds including camera limits.
- auto ElapsedFrames() const -> float override
- Returns number of elapsed frames.
- auto Gravity() const -> float override
- Returns current gravity force.
- auto WaterLevel() const -> float override
- Returns current water level.
-
auto GetActors() const -> ArrayView<const std::
shared_ptr<Actors:: ActorBase>> override - Returns list of actors (objects)
-
auto GetPlayers() const -> ArrayView<Actors::
Player*const> override - Returns list of players.
- auto GetDefaultAmbientLight() const -> float override
- Returns default ambient light intensity.
-
auto GetAmbientLight(Actors::
Player* player) const -> float override - Returns current ambient light intensity.
-
void SetAmbientLight(Actors::
Player* player, float value) override - Sets current ambient light intensity.
- auto GetViewSize() const -> Vector2i override
- Returns viewport size of the handler.
- void OnBeginFrame() override
- Called at the beginning of each frame.
- void OnEndFrame() override
- Called at the end of each frame.
-
void OnInitializeViewport(std::
int32_t width, std:: int32_t height) override - Called when the viewport needs to be initialized (e.g., when the resolution is changed)
- auto OnConsoleCommand(StringView line) -> bool virtual
- Called when a console command is entered.
- void OnKeyPressed(const KeyboardEvent& event) override
- Called when a key is pressed.
- void OnKeyReleased(const KeyboardEvent& event) override
- Called when a key is released.
- void OnTextInput(const TextInputEvent& event) override
- Called when a text input is detected.
- void OnTouchEvent(const TouchEvent& event) override
- Called when a touch event is triggered.
-
void AddActor(std::
shared_ptr<Actors:: ActorBase> actor) override - Adds an actor (object) to the level.
-
auto PlaySfx(Actors::
ActorBase* self, StringView identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain, float pitch) -> std:: shared_ptr<AudioBufferPlayer> override - Plays a sound effect for a given actor (object)
-
auto PlayCommonSfx(StringView identifier,
const Vector3f& pos,
float gain = 1.0f,
float pitch = 1.0f) -> std::
shared_ptr<AudioBufferPlayer> override - Plays a common sound effect.
-
void WarpCameraToTarget(Actors::
ActorBase* actor, bool fast = false) override - Warps a camera to its assigned target.
-
auto IsPositionEmpty(Actors::
ActorBase* self, const AABBf& aabb, Tiles:: TileCollisionParams& params, Actors:: ActorBase** collider) -> bool override - Returns
true
if a specified AABB is empty. -
void FindCollisionActorsByAABB(const Actors::
ActorBase* self, const AABBf& aabb, Function<bool(Actors:: ActorBase*)>&& callback) override - Calls the callback function for all colliding objects with specified AABB.
-
void FindCollisionActorsByRadius(float x,
float y,
float radius,
Function<bool(Actors::
ActorBase*)>&& callback) override - Calls the callback function for all colliding objects with specified circle.
-
void GetCollidingPlayers(const AABBf& aabb,
Function<bool(Actors::
ActorBase*)>&& callback) override - Calls the callback function for all colliding players with specified AABB.
-
void BroadcastTriggeredEvent(Actors::
ActorBase* initiator, EventType eventType, std:: uint8_t* eventParams) override - Broadcasts specified event to all other actors.
-
void BeginLevelChange(Actors::
ActorBase* initiator, ExitType exitType, StringView nextLevel = {}) override - Starts transition to change current level.
-
void HandleGameOver(Actors::
Player* player) override - Called when the game is over.
-
auto HandlePlayerDied(Actors::
Player* player, Actors:: ActorBase* collider) -> bool override - Called when a player dies.
-
void HandlePlayerWarped(Actors::
Player* player, Vector2f prevPos, WarpFlags flags) override - Called when a player warps.
-
void HandlePlayerCoins(Actors::
Player* player, std:: int32_t prevCount, std:: int32_t newCount) override - 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) override - Called when a player collects or losts gems.
-
void SetCheckpoint(Actors::
Player* player, Vector2f pos) override - Sets checkpoint for a given player.
-
void RollbackToCheckpoint(Actors::
Player* player) override - Rolls back to the last checkpoint for a given player.
-
void HandleActivateSugarRush(Actors::
Player* player) override - Called when a player activates sugar rush.
-
void ShowLevelText(StringView text,
Actors::
ActorBase* initiator = nullptr) override - Shows a text notification.
-
auto GetLevelText(std::
uint32_t textId, std:: int32_t index = -1, std:: uint32_t delimiter = 0) -> StringView override - Returns a level text.
-
void OverrideLevelText(std::
uint32_t textId, StringView value) override - Override specified level text.
-
auto GetCameraPos(Actors::
Player* player) const -> Vector2f override - Returns camera position of a given player.
-
void LimitCameraView(Actors::
Player* player, std:: int32_t left, std:: int32_t width) override - Limits camera viewport for a given player.
-
void OverrideCameraView(Actors::
Player* player, float x, float y, bool topLeft = false) override - Override camera viewport for a given player.
-
void ShakeCameraView(Actors::
Player* player, float duration) override - Shake camera for a given player.
- void ShakeCameraViewNear(Vector2f pos, float duration) override
- Shake camera for all players near a given position.
-
auto GetTrigger(std::
uint8_t triggerId) -> bool override - Returns state of a given trigger in the tile map.
-
void SetTrigger(std::
uint8_t triggerId, bool newState) override - Sets state of a given trigger in the tile map.
-
void SetWeather(WeatherType type,
std::
uint8_t intensity) override - Sets current level weather.
- auto BeginPlayMusic(StringView path, bool setDefault = false, bool forceReload = false) -> bool override
- Plays specified music.
-
auto PlayerActionPressed(std::
int32_t index, PlayerActions action, bool includeGamepads = true) -> bool override - Returns
true
if player action is pressed. -
auto PlayerActionPressed(std::
int32_t index, PlayerActions action, bool includeGamepads, bool& isGamepad) -> bool override -
auto PlayerActionHit(std::
int32_t index, PlayerActions action, bool includeGamepads = true) -> bool override - Returns
true
if player action is hit (newly pressed) -
auto PlayerActionHit(std::
int32_t index, PlayerActions action, bool includeGamepads, bool& isGamepad) -> bool override -
auto PlayerHorizontalMovement(std::
int32_t index) -> float override - Returns value of desired horizontal player movement.
-
auto PlayerVerticalMovement(std::
int32_t index) -> float override - Returns value of desired vertical player movement.
-
void PlayerExecuteRumble(std::
int32_t index, StringView rumbleEffect) override - Executes a rumble effect.
- auto SerializeResumableToStream(Stream& dest) -> bool override
- Serializes object state to a stream.
-
void OnAdvanceDestructibleTileAnimation(std::
int32_t tx, std:: int32_t ty, std:: int32_t amount) override - Called when a destructible tile animation is advanced.
-
void OnTileFrozen(std::
int32_t x, std:: int32_t y) override - Called when a tile is frozen.
Protected types
- struct PlayerInput
- Describes current input state of a player.
Protected functions
- void AttachComponents(LevelDescriptor&& descriptor) virtual
- Attaches all required level components to the handler.
- void SpawnPlayers(const LevelInitialization& levelInit) virtual
- Spawns all players.
- void OnInitialized() virtual
- Called after the level is loaded and all players were spawned.
-
void BeforeActorDestroyed(Actors::
ActorBase* actor) virtual - Called before an actor (object) is destroyed.
- void ProcessEvents(float timeMult) virtual
- Processes events.
- void ProcessQueuedNextLevel() virtual
- Processes transition to the next level if queued.
- void PrepareNextLevelInitialization(LevelInitialization& levelInit) virtual
- Prepares LevelInitialization for transition to the next level.
-
auto GetPlayerViewportBounds(std::
int32_t w, std:: int32_t h, std:: int32_t index) -> Recti - Returns player viewport bounds.
- void ProcessWeather(float timeMult)
- Processes weather.
- void ResolveCollisions(float timeMult)
- Resolves collisions.
-
void AssignViewport(Actors::
Player* player) - Assigns viewport.
-
void InitializeCamera(Rendering::
PlayerViewport& viewport) - Initializes camera for specified viewport.
- void UpdatePressedActions()
- Updates pressed actions.
- void UpdateRichPresence()
- Updates rich presence.
- void InitializeRumbleEffects()
- Initializes common rumble effects.
- auto RegisterRumbleEffect(StringView name) -> RumbleDescription*
- Registers a rumple effect.
- void PauseGame()
- Pauses the game.
- void ResumeGame()
- Resumes the paused game.
Function documentation
bool Jazz2:: LevelHandler:: PlayerActionPressed(std:: int32_t index,
PlayerActions action,
bool includeGamepads,
bool& isGamepad) override
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Jazz2:: LevelHandler:: PlayerActionHit(std:: int32_t index,
PlayerActions action,
bool includeGamepads,
bool& isGamepad) override
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.