![]() |
XII Release 0.1.0
|
xiiGameStateBase 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 (xiiWorld *pWorld, xiiStringView sStartPosition, const xiiTransform &startPositionOffset)=0 |
A game state gets activated through this function. | |
virtual void | OnDeactivation ()=0 |
Called when the game state is being shut down. | |
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. | |
virtual void | AddMainViewsToRender ()=0 |
Has to call xiiRenderLoop::AddMainView for all views that need to be rendered. | |
virtual void | RequestQuit ()=0 |
Call this to signal that a game state requested the application to quit. | |
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. | |
![]() | |
virtual const xiiRTTI * | GetDynamicRTTI () const |
bool | IsInstanceOf (const xiiRTTI *pType) const |
Returns whether the type of this instance is of the given type or derived from it. | |
template<typename T> | |
XII_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 xiiRTTI * | GetStaticRTTI () |
xiiGameStateBase 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://xiiengine.net/pages/docs/runtime/application/game-state.html
Note that you would typically derive custom game states from xiiGameState, not xiiGameStateBase, since the former provides much more functionality out of the box.
|
pure virtual |
Has to call xiiRenderLoop::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 xiiGameState.
|
inlinevirtual |
Called once each frame to configure the main camera position and rotation.
Note that xiiCameraComponent 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 xiiGameState implementation searches for an xiiCameraComponent in the world that is set to "Main View" and uses it's transform for the main camera.
Reimplemented in xiiFallbackGameState, and xiiGameState.
|
inlinevirtual |
Should be overridden by game states that are only meant as a fallback solution.
See the implementation for xiiFallbackGameState for details.
Reimplemented in xiiFallbackGameState.
|
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 xiiFallbackGameState, and xiiGameState.
|
pure virtual |
Called when the game state is being shut down.
Override this to clean up or save data to disk.
Implemented in xiiGameState.
|
inlinevirtual |
Called once per game update, early in the frame. Should handle input updates here.
Reimplemented in xiiFallbackGameState, and xiiGameState.
|
pure virtual |
Call this to signal that a game state requested the application to quit.
xiiGameApplication will shut down when this happens. xiiEditor will stop play-the-game mode when it is running.
Implemented in xiiGameState.
|
pure virtual |
Returns whether the game state wants to quit the application.
Implemented in xiiGameState.