MochiEngine
Loading...
Searching...
No Matches
Mochi::Layer Class Reference

The layer class offers a simple way to organize domains of the application while having access to most of the Engine subsystems. Note that a layer is meant to be inherited from and can't be instantated as is. A layer will Update, Render and show the GUI as a small Engine class. So the layer is just a convenient responsability separator. Ownership: More...

#include <Layer.h>

Inheritance diagram for Mochi::Layer:
Mochi::DebugLayer Mochi::Scripting::ScriptingLayer

Public Member Functions

 Layer ()
 Default constructor. It initializes with references to the engine subsystems. Should only be constructed after the engine is setup.
virtual void InitLayer ()
 Override this to initialize members and data of your layer when the engine adds this layer to the layer list. This is useful if you want to create the layer and delay its inclusion on the engine.
virtual bool Update (const float &dt)
 Override this to give your layer a way to be updated each frame.
virtual void Render () const
 Override this to send the render commands to the engine. This task could be done on the update, but making it here its clearer.
virtual void GUI () const
 Override this to draw the GUI of your layer. Even if this could be done anywhere, doing it here ensure it to be drawn after all rendering is done.
virtual void Debug () const
 Override this to print, draw or show debug GUI's. This will be called after all renderings and other GUIs and will only be shown while in DEBUG configuration.

Protected Attributes

FS::PackCatalogmCatalog
Scripting::ScriptingManagermScripting
Graphics::CameramCamera
Event::EventBusmEventBus
Graphics::AbstractGUImGUI
Input::IActionManagermActionManager
Audio::IAudioManagermAudioManager
Graphics::IRenderermRenderer
Debug::IGizmosmGizmos

Detailed Description

The layer class offers a simple way to organize domains of the application while having access to most of the Engine subsystems. Note that a layer is meant to be inherited from and can't be instantated as is. A layer will Update, Render and show the GUI as a small Engine class. So the layer is just a convenient responsability separator. Ownership:

  • The layer class owns only what its children owns

Lifecycle:

  • It should be created on the heap manually and pushed onto the engine. The rest of the lifecycle is managed there.
  • The engine initializes it at the end of the frame, and when removed, it destroys it at the end of the frame too.

Guarantees:

  • Participation in the lifecycle when pushed to the engine.
  • Safe destruction after removing it or destroying the engine instance.

Thread safety:

  • Layers are thread safe if the implementation is thread safe.

Member Function Documentation

◆ Debug()

virtual void Mochi::Layer::Debug ( ) const
inlinevirtual

Override this to print, draw or show debug GUI's. This will be called after all renderings and other GUIs and will only be shown while in DEBUG configuration.

Reimplemented in Mochi::DebugLayer, and Mochi::Scripting::ScriptingLayer.

◆ GUI()

virtual void Mochi::Layer::GUI ( ) const
inlinevirtual

Override this to draw the GUI of your layer. Even if this could be done anywhere, doing it here ensure it to be drawn after all rendering is done.

Reimplemented in Mochi::DebugLayer, and Mochi::Scripting::ScriptingLayer.

◆ InitLayer()

virtual void Mochi::Layer::InitLayer ( )
inlinevirtual

Override this to initialize members and data of your layer when the engine adds this layer to the layer list. This is useful if you want to create the layer and delay its inclusion on the engine.

Reimplemented in Mochi::DebugLayer, and Mochi::Scripting::ScriptingLayer.

◆ Render()

virtual void Mochi::Layer::Render ( ) const
inlinevirtual

Override this to send the render commands to the engine. This task could be done on the update, but making it here its clearer.

Reimplemented in Mochi::DebugLayer, and Mochi::Scripting::ScriptingLayer.

◆ Update()

virtual bool Mochi::Layer::Update ( const float & dt)
inlinevirtual

Override this to give your layer a way to be updated each frame.

Parameters
dtThe delta time
Returns
true if the execution should continue, false if the execution should halt.

Reimplemented in Mochi::DebugLayer, and Mochi::Scripting::ScriptingLayer.


The documentation for this class was generated from the following files:
  • Engine/src/Layer.h
  • Engine/src/Layer.cpp