XII Release 0.1.0
Loading...
Searching...
No Matches
xiiFallbackGameState Class Reference

#include <FallbackGameState.h>

Inheritance diagram for xiiFallbackGameState:
[legend]

Public Member Functions

virtual void ProcessInput () override
 The xiiGameState doesn't implement any input logic, but it forwards to UpdateBackgroundSceneLoading().
virtual void OnActivation (xiiWorld *pWorld, xiiStringView sStartPosition, const xiiTransform &startPositionOffset) override
virtual bool IsFallbackGameState () const override
 Reports true for xiiFallbackGameState only, not for derived types.
Public Member Functions inherited from xiiGameState
xiiWorld * GetMainWorld ()
 Returns the xiiWorld that is currently the active one.
xiiCamera * GetMainCamera ()
 Gives access to the game state's main camera object.
xiiView * GetMainView ()
 Returns the xiiView that is currently the one used for rendering the main output.
bool IsLoadingSceneInBackground (float *out_pProgress=nullptr) const
 Whether a scene is currently being loaded.
bool IsInLoadingScreen () const
 Whether the game state currently displays a loading screen. This usually implies that a scene is being loaded as well.
virtual void OnDeactivation () override
 Cleans up the main window before the game is shut down.
virtual void RequestQuit (xiiStringView sRequestedBy) override
virtual bool WasQuitRequested () const override
 Whether WasQuitRequested() was called before.
void LoadScene (xiiStringView sSceneFile, xiiStringView sPreloadCollection, xiiStringView sStartPosition, const xiiTransform &startPositionOffset)
void SwitchToLoadingScreen (xiiStringView sTargetSceneFile)
void ChangeMainWorld (xiiWorld *pNewMainWorld, xiiStringView sStartPosition, const xiiTransform &startPositionOffset)
void StartBackgroundSceneLoading (xiiStringView sSceneFile, xiiStringView sPreloadCollection)
void CancelBackgroundSceneLoading ()
Public Member Functions inherited from xiiGameStateBase
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.
Public Member Functions inherited from xiiReflectedClass
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.

Protected Types

enum class  State {
  Ok , NoProject , BadProject , NoScene ,
  BadScene
}

Protected Member Functions

virtual void ConfigureInputActions () override
 Called by SwitchToLoadingScreen() to setup a new world that acts as the loading screen while waiting for another scene to finish loading.
virtual xiiResult SpawnPlayer (xiiStringView sStartPosition, const xiiTransform &startPositionOffset) override
virtual const xiiCameraComponent * FindActiveCameraComponent ()
void FindAvailableScenes ()
bool DisplayMenu ()
virtual void OnBackgroundSceneLoadingFinished (xiiUniquePtr< xiiWorld > &&pWorld) override
virtual void OnBackgroundSceneLoadingFailed (xiiStringView sReason) override
 Called by UpdateBackgroundSceneLoading() when a scene failed to load.
virtual void ConfigureMainCamera () override
Protected Member Functions inherited from xiiGameState
 xiiGameState ()
 This class cannot be instantiated directly.
virtual void CreateWindows ()
xiiView * CreateMainView ()
 Creates a default main view.
virtual void OnChangedMainWorld (xiiWorld *pPreviousWorld, xiiWorld *pNewWorld, xiiStringView sStartPosition, const xiiTransform &startPositionOffset)
virtual xiiUniquePtr< xiiWindow > CreateMainWindow ()
 Override this to modify the default window creation behavior. Called by CreateWindows().
virtual xiiUniquePtr< xiiWindowOutputTargetGAL > CreateMainOutputTarget (xiiWindow *pMainWindow)
 Override this to modify the default output target creation behavior. Called by CreateWindows().
virtual void SetupMainView (xiiGALSwapChain *pSwapChain, xiiSizeU32 viewportSize)
 Creates a default render view. Unless overridden, OnActivation() will do this for the main window.
virtual void ConfigureMainWindowInputDevices (xiiWindow *pWindow)
virtual void GetStartupOptions (xiiString &out_sScene, xiiString &out_sPreloadCollection)
virtual xiiUniquePtr< xiiWorld > CreateLoadingScreenWorld (xiiStringView sTargetSceneFile)
void UpdateBackgroundSceneLoading ()
virtual void OnBackgroundSceneLoadingCanceled ()
 Called by CancelBackgroundSceneLoading() when scene loading gets canceled.
virtual void OnWindowEvent (const xiiWindowEvent &e)
 Forwards window events from the platform window. Override this to react to window events, such as resizing.

Protected Attributes

xiiInt32 m_iActiveCameraComponentIndex = -3
State m_State = State::Ok
bool m_bShowMenu = false
bool m_bCheckedForScenes = false
xiiDynamicArray< xiiString > m_AvailableScenes
xiiUInt32 m_uiSelectedScene = 0
xiiString m_sTitleOfScene
Protected Attributes inherited from xiiGameState
xiiWorld * m_pMainWorld = nullptr
xiiCamera m_MainCamera
xiiViewHandle m_hMainView
bool m_bStateWantsToQuit = false
bool m_bTransitionWhenReady = false
xiiUniquePtr< xiiSceneLoadUtility > m_pBackgroundSceneLoad
xiiUniquePtr< xiiWorld > m_pLoadingScreenWorld
xiiUniquePtr< xiiWorld > m_pLoadedWorld
xiiString m_sTargetSceneSpawnPoint
xiiTransform m_TargetSceneSpawnOffset = xiiTransform::MakeIdentity()

Additional Inherited Members

Static Public Member Functions inherited from xiiGameState
static xiiGameState * GetActiveGameState ()
 Returns the active xiiGameState. Only one xiiGameState is allowed to exist.
Static Public Member Functions inherited from xiiNoBase
static const xiiRTTI * GetStaticRTTI ()
Static Protected Attributes inherited from xiiGameState
static xiiGameState * s_pActiveGameState = nullptr

Detailed Description

xiiFallbackGameState is an xiiGameState that can handle existing worlds when no other game state is available.

This game state returns a priority of 'Fallback' in DeterminePriority() and therefore only takes over when no other game state is available. It implements a simple first person camera to fly around a scene.

This game state cannot be used in stand-alone applications that require the game state to create a new world. It is mainly for xiiEditor and xiiPlayer which make sure that a world already exists.

Member Function Documentation

◆ ConfigureInputActions()

void xiiFallbackGameState::ConfigureInputActions ( )
overrideprotectedvirtual

Called by SwitchToLoadingScreen() to setup a new world that acts as the loading screen while waiting for another scene to finish loading.

Reimplemented from xiiGameState.

◆ ConfigureMainCamera()

void xiiFallbackGameState::ConfigureMainCamera ( )
overrideprotectedvirtual

Searches for a "Main View" xiiCameraComponent in the world and uses that for the camera position, if available.

Override this for custom camera logic.

Reimplemented from xiiGameState.

◆ IsFallbackGameState()

bool xiiFallbackGameState::IsFallbackGameState ( ) const
overridevirtual

Reports true for xiiFallbackGameState only, not for derived types.

Reimplemented from xiiGameStateBase.

◆ OnActivation()

void xiiFallbackGameState::OnActivation ( xiiWorld * pWorld,
xiiStringView sStartPosition,
const xiiTransform & startPositionOffset )
overridevirtual

Called upon game startup.

Calls CreateWindows() to create the game's main window and setup input devices. Calls ConfigureInputActions() to setup input actions. Finally switches to pWorld (if available) or starts loading the scene that GetStartupOptions() returns.

Override any of the above functions to customize them.

Reimplemented from xiiGameState.

◆ OnBackgroundSceneLoadingFailed()

void xiiFallbackGameState::OnBackgroundSceneLoadingFailed ( xiiStringView sReason)
overrideprotectedvirtual

Called by UpdateBackgroundSceneLoading() when a scene failed to load.

Reimplemented from xiiGameState.

◆ OnBackgroundSceneLoadingFinished()

void xiiFallbackGameState::OnBackgroundSceneLoadingFinished ( xiiUniquePtr< xiiWorld > && pWorld)
overrideprotectedvirtual

Called by UpdateBackgroundSceneLoading() when a scene is finished loading.

May switch to the scene immediately or wait, for example for a user to confirm.

Reimplemented from xiiGameState.

◆ ProcessInput()

void xiiFallbackGameState::ProcessInput ( )
overridevirtual

The xiiGameState doesn't implement any input logic, but it forwards to UpdateBackgroundSceneLoading().

Reimplemented from xiiGameState.

◆ SpawnPlayer()

xiiResult xiiFallbackGameState::SpawnPlayer ( xiiStringView sStartPosition,
const xiiTransform & startPositionOffset )
overrideprotectedvirtual

Overrideable function that may create a player object.

By default called by OnChangedMainWorld() when switching to a non-loading screen world. The default implementation will search the world for xiiPlayerStartComponent's and instantiate the given player prefab at one of those locations. If pStartPosition is not nullptr, it will be used as the spawn position for the player prefab, otherwise the location of the xiiPlayerStartComponent will be used.

sStartPosition allows to spawn the player at another named location, but there is no default implementation for such logic.

Returns XII_SUCCESS if a prefab was spawned, XII_FAILURE if nothing was done.

Reimplemented from xiiGameState.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/GameEngine/GameState/FallbackGameState.h
  • /home/runner/work/XII/XII/Source/Engine/GameEngine/GameState/Implementation/FallbackGameState.cpp