|
MochiEngine
|
Main class of the MochiEngine. It owns and coordinates all subsystems and layers, and drives the application lifecycle. More...
#include <Engine.h>
Public Member Functions | |
| Engine () | |
| Constructs the Engine class without initializing some core systems to allow the user to use Setup to initialize them manually. Doesn't initialize: | |
| Engine (const char *appName, const char *appVersion, const char *appId, const char *windowName) | |
| Constructs the Engine class and setups it with default core subsystems. | |
| void | Run () |
| Runs the engine, starting the per-frame lifecycle. Once called, it won't stop until receiving ApplicationQuitEvent or getting "false" when updating a layer. | |
| void | Setup (std::unique_ptr< Graphics::IRenderer > &&renderer, std::unique_ptr< Input::IActionManager > &&actionManager, std::unique_ptr< Audio::IAudioManager > &&audioManager) |
| Manually setups some subsystems for the engine. Setup should only be called once, and it will keep ownership of the subsystems. | |
| void | PushLayer (Layer *layer) |
| Pushes a layer in the list of layers to initialize. Then initializes it at the end of the frame and gets ownership of it to update it each frame. The same layer should only be pushed once. However, several instances of the same layer type can be pushed safely. | |
| void | PopLayer (Layer *layer) |
| Pushes a layer in the list of layers to deactivate. At the end of the frame (when it is safe) the layer is removed from the list and destroyed. | |
| float | GetLastRealDelta () const |
| void | AddRenderCommand (const Graphics::RenderCommand &command) |
| Adds a single render command to be rendered this frame. | |
| void | AddRenderCommands (const std::vector< Graphics::RenderCommand > &commands) |
| Adds a range of render commands to be rendered this frame. | |
| Graphics::IRenderer * | GetRenderer () const |
| Audio::IAudioManager * | GetAudio () const |
| Input::IActionManager * | GetActionManager () const |
| FS::PackCatalog * | GetCatalog () const |
| Graphics::Camera * | GetCamera () const |
| Graphics::AbstractGUI * | GetGUI () const |
| Event::EventBus * | GetEventBus () const |
| Scripting::ScriptingManager * | GetScriptingManager () const |
| Debug::IGizmos * | GetGizmos () const |
| void | SwapAudioManager (std::unique_ptr< Audio::IAudioManager > &&) |
| void | SwapActionManager (std::unique_ptr< Input::IActionManager > &&) |
| void | SwapCamera (std::unique_ptr< Graphics::Camera > &&) |
| void | SwapRenderer (std::unique_ptr< Graphics::IRenderer > &&) |
| void | Pause () |
| Pauses the engine setting the delta time scale to 0. Pause can be called several times in succession, but it will only be applied once. | |
| void | Resume () |
| Resumes the game setting the delta time scale to the last value it was before it was paused. Resume can be called several times in succession, but it will only be applied once. | |
Static Public Member Functions | |
| static Engine & | Get () |
| Access Engine from anywhere Access is only available after default construction or after setup. Otherwise, it returns nullptr. | |
Main class of the MochiEngine. It owns and coordinates all subsystems and layers, and drives the application lifecycle.
Ownership:
Lifecycle:
Guarantees:
Thread safety:
Non responsible:
| Mochi::Engine::Engine | ( | ) |
Constructs the Engine class without initializing some core systems to allow the user to use Setup to initialize them manually. Doesn't initialize:
| Mochi::Engine::Engine | ( | const char * | appName, |
| const char * | appVersion, | ||
| const char * | appId, | ||
| const char * | windowName ) |
Constructs the Engine class and setups it with default core subsystems.
| appName | The name of the application. |
| appVersion | The version of the application. |
| appId | A unique string in reverse order identifying the application. |
| windowName | The name the window will receive in the OS. |
| void Mochi::Engine::AddRenderCommand | ( | const Graphics::RenderCommand & | command | ) |
Adds a single render command to be rendered this frame.
| command | The render command |
| void Mochi::Engine::AddRenderCommands | ( | const std::vector< Graphics::RenderCommand > & | commands | ) |
Adds a range of render commands to be rendered this frame.
| commands | The vector of commands |
| void Mochi::Engine::PopLayer | ( | Layer * | layer | ) |
Pushes a layer in the list of layers to deactivate. At the end of the frame (when it is safe) the layer is removed from the list and destroyed.
| layer | The pointer to the layer to remove. |
| void Mochi::Engine::PushLayer | ( | Layer * | layer | ) |
Pushes a layer in the list of layers to initialize. Then initializes it at the end of the frame and gets ownership of it to update it each frame. The same layer should only be pushed once. However, several instances of the same layer type can be pushed safely.
| layer | A pointer to the layer. Note that several layers of the same type can be active at a time and is the user responsability to manage which layers to push. |
| void Mochi::Engine::Setup | ( | std::unique_ptr< Graphics::IRenderer > && | renderer, |
| std::unique_ptr< Input::IActionManager > && | actionManager, | ||
| std::unique_ptr< Audio::IAudioManager > && | audioManager ) |
Manually setups some subsystems for the engine. Setup should only be called once, and it will keep ownership of the subsystems.
| renderer | The renderer. It will have rendering and UI responsabilities. |
| actionManager | The action manager that will define how input will be interpreted. |
| audioManager | The audio manager. |