XII Release 0.1.0
Loading...
Searching...
No Matches
xiiGameStateBase Class Referenceabstract

xiiGameStateBase is the base class for all game states. Game states are used to implement custom high level game logic. More...

#include <GameStateBase.h>

Inheritance diagram for xiiGameStateBase:
[legend]

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.
 
- Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTIGetDynamicRTTI () 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 Public Member Functions inherited from xiiNoBase
static const xiiRTTIGetStaticRTTI ()
 

Detailed Description

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.

Member Function Documentation

◆ AddMainViewsToRender()

virtual void xiiGameStateBase::AddMainViewsToRender ( )
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.

◆ ConfigureMainCamera()

virtual void xiiGameStateBase::ConfigureMainCamera ( )
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.

◆ IsFallbackGameState()

virtual bool xiiGameStateBase::IsFallbackGameState ( ) const
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.

◆ OnActivation()

virtual void xiiGameStateBase::OnActivation ( xiiWorld * pWorld,
xiiStringView sStartPosition,
const xiiTransform & startPositionOffset )
pure virtual

A game state gets activated through this function.

Parameters
pWorldThe 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.
sStartPositionAn 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.
pStartPositionAn 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.

◆ OnDeactivation()

virtual void xiiGameStateBase::OnDeactivation ( )
pure virtual

Called when the game state is being shut down.

Override this to clean up or save data to disk.

Implemented in xiiGameState.

◆ ProcessInput()

virtual void xiiGameStateBase::ProcessInput ( )
inlinevirtual

Called once per game update, early in the frame. Should handle input updates here.

Reimplemented in xiiFallbackGameState, and xiiGameState.

◆ RequestQuit()

virtual void xiiGameStateBase::RequestQuit ( )
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.

◆ WasQuitRequested()

virtual bool xiiGameStateBase::WasQuitRequested ( ) const
pure virtual

Returns whether the game state wants to quit the application.

Implemented in xiiGameState.


The documentation for this class was generated from the following file: