![]() |
ezEngine
Release 25.03
|
ezGameStateBase is the base class for all game states. Game states are used to implement custom high level game logic. More...
#include <GameStateBase.h>
Public Member Functions | |
virtual void | OnActivation (ezWorld *pWorld, ezStringView sStartPosition, const ezTransform &startPositionOffset)=0 |
A game state gets activated through this function. More... | |
virtual void | OnDeactivation ()=0 |
Called when the game state is being shut down. More... | |
virtual void | ProcessInput () |
Called once per game update, early in the frame. Should handle input updates here. | |
virtual void | BeforeWorldUpdate () |
Called once each frame before the worlds are updated. | |
virtual void | AfterWorldUpdate () |
Called once each frame after the worlds have been updated. | |
virtual void | ConfigureMainCamera () |
Called once each frame to configure the main camera position and rotation. More... | |
virtual void | AddMainViewsToRender ()=0 |
Has to call ezRenderLoop::AddMainView for all views that need to be rendered. More... | |
virtual void | RequestQuit ()=0 |
Call this to signal that a game state requested the application to quit. More... | |
virtual bool | WasQuitRequested () const =0 |
Returns whether the game state wants to quit the application. | |
virtual bool | IsFallbackGameState () const |
Should be overridden by game states that are only meant as a fallback solution. More... | |
![]() | |
virtual const ezRTTI * | GetDynamicRTTI () const |
bool | IsInstanceOf (const ezRTTI *pType) const |
Returns whether the type of this instance is of the given type or derived from it. | |
template<typename T > | |
EZ_ALWAYS_INLINE bool | IsInstanceOf () const |
Returns whether the type of this instance is of the given type or derived from it. | |
Additional Inherited Members | |
![]() | |
static const ezRTTI * | GetStaticRTTI () |
ezGameStateBase is the base class for all game states. Game states are used to implement custom high level game logic.
See the online documentation for details: https://ezengine.net/pages/docs/runtime/application/game-state.html
Note that you would typically derive custom game states from ezGameState, not ezGameStateBase, since the former provides much more functionality out of the box.
|
pure virtual |
Has to call ezRenderLoop::AddMainView for all views that need to be rendered.
This will be called every frame by the editor, to ensure that only the relevant views are rendered, but during stand-alone game execution this may never be called.
Implemented in ezGameState.
|
inlinevirtual |
Called once each frame to configure the main camera position and rotation.
Note that ezCameraComponent may already apply set general options like field-of-view, so don't override these values, if you want to use that component. The default ezGameState implementation searches for an ezCameraComponent in the world that is set to "Main View" and uses it's transform for the main camera.
Reimplemented in ezGameState, and ezFallbackGameState.
|
inlinevirtual |
Should be overridden by game states that are only meant as a fallback solution.
See the implementation for ezFallbackGameState for details.
Reimplemented in ezFallbackGameState.
|
pure virtual |
A game state gets activated through this function.
pWorld | The game state is supposed to operate on the given world. In a stand-alone application pWorld will always be nullptr and the game state is expected to create worlds itself. When run inside the editor, pWorld will already exist and the game state is expected to work on it. |
sStartPosition | An optional string to identify where the player should spawn. This may, for instance, be the unique name of an object. It is up to the game state how the string is used, if at all. |
pStartPosition | An optional transform for the 'player object' to start at. Usually nullptr, but may be set by the editor to relocate or create the player object at the given destination. |
Implemented in ezGameState, and ezFallbackGameState.
|
pure virtual |
Called when the game state is being shut down.
Override this to clean up or save data to disk.
Implemented in ezGameState.
|
pure virtual |
Call this to signal that a game state requested the application to quit.
ezGameApplication will shut down when this happens. ezEditor will stop play-the-game mode when it is running.
Implemented in ezGameState.