Plasma Engine  2.0
Loading...
Searching...
No Matches
FallbackGameState.h
1#pragma once
2
3#include <Core/Graphics/Camera.h>
4#include <Foundation/Types/UniquePtr.h>
5#include <GameEngine/GameState/GameState.h>
6#include <GameEngine/Utils/SceneLoadUtil.h>
7
9
11
20class PL_GAMEENGINE_DLL plFallbackGameState : public plGameState
21{
22 PL_ADD_DYNAMIC_REFLECTION(plFallbackGameState, plGameState)
23
24public:
26
28 void EnableSceneSelectionMenu(bool bEnable);
29
33 void EnableFreeCameras(bool bEnable);
34
37 void EnableAutoSwitchToLoadedScene(bool bEnable);
38
39 virtual void ProcessInput() override;
40 virtual void AfterWorldUpdate() override;
41
43 virtual plGameStatePriority DeterminePriority(plWorld* pWorld) const override;
44
45 virtual void OnActivation(plWorld* pWorld, const plTransform* pStartPosition) override;
46 virtual void OnDeactivation() override;
47
49 virtual plString GetStartupSceneFile();
50
54 void SwitchToLoadingScreen();
55
61 plResult StartSceneLoading(plStringView sSceneFile, plStringView sPreloadCollection);
62
64 void CancelSceneLoading();
65
67 bool IsLoadingScene() const;
68
70 bool IsInLoadingScreen() const;
71
73 void SwitchToLoadedScene();
74
76 plStringView GetActiveSceneName() const { return m_sTitleOfActiveScene; }
77
79 plStringView GetLoadingSceneName() const { return m_sTitleOfLoadingScene; }
80
81protected:
83 virtual plUniquePtr<plWorld> CreateLoadingScreenWorld();
84 virtual void ConfigureInputActions() override;
85 virtual plResult SpawnPlayer(const plTransform* pStartPosition) override;
86
87 virtual const plCameraComponent* FindActiveCameraComponent();
88
89 plInt32 m_iActiveCameraComponentIndex;
90
91 plUniquePtr<plWorld> m_pActiveWorld;
92
94
96
97 enum class State
98 {
99 Ok,
100 NoProject,
101 BadProject,
102 NoScene,
103 BadScene,
104 };
105
106 State m_State = State::Ok;
107 bool m_bShowMenu = false;
108 bool m_bEnableSceneSelectionMenu = true;
109 bool m_bEnableFreeCameras = true;
110 bool m_bIsInLoadingScreen = false;
111 bool m_bAutoSwitchToLoadedScene = true;
112
113 void FindAvailableScenes();
114 bool DisplayMenu();
115
116 bool m_bCheckedForScenes = false;
117 plDynamicArray<plString> m_AvailableScenes;
118 plUInt32 m_uiSelectedScene = 0;
119 plString m_sTitleOfLoadingScene;
120 plString m_sTitleOfActiveScene;
121};
Adds a camera to the scene.
Definition CameraComponent.h:57
Definition DynamicArray.h:81
plFallbackGameState is an plGameState that can handle existing worlds when no other game state is ava...
Definition FallbackGameState.h:21
plStringView GetLoadingSceneName() const
Returns the name of the plWorld that is currently being loaded.
Definition FallbackGameState.h:79
plStringView GetActiveSceneName() const
Returns the name of the plWorld that is currently active.
Definition FallbackGameState.h:76
virtual void AfterWorldUpdate()
Called once each frame after the worlds have been updated.
Definition GameStateBase.cpp:17
virtual void ProcessInput()
Called once per game update. Should handle input updates here.
Definition GameStateBase.cpp:13
virtual plGameStatePriority DeterminePriority(plWorld *pWorld) const =0
Called by plGameApplication to determine which game state is best suited to handle a situation.
plGameState is the base class to build custom game logic upon. It works closely together with plGameA...
Definition GameState.h:44
virtual void OnActivation(plWorld *pWorld, const plTransform *pStartPosition) override
When a game state was chosen, it gets activated through this function.
Definition GameState.cpp:40
virtual void OnDeactivation() override
Called when the game state is being shut down.
Definition GameState.cpp:54
virtual void ConfigureInputActions()
Adds custom input actions, if necessary. Unless overridden OnActivation() will call this.
Definition GameState.cpp:193
virtual plResult SpawnPlayer(const plTransform *pStartPosition)
Overridable function that may create a player object.
Definition GameState.cpp:244
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54