MochiEngine
Loading...
Searching...
No Matches
Mochi::Scripting::ScriptingLayer Class Reference

This layer is automatically injected in the engine in the setup phase and is designed to bind several useful methods to the lua environment and take ownership of entities generated by lua. More...

#include <ScriptingLayer.h>

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

Public Member Functions

virtual void InitLayer () override
 Calls BindFactoryMethods and graphics, logic and audio bindings to lua.
virtual bool Update (const float &dt) override
 Updates owned sprites (for animations) and safely removes sprites marked for destruction.
virtual void Render () const override
 Renders owned sprites.
virtual void GUI () const override
 This class does not show any GUI.
virtual void Debug () const override
 This class does not show any debug data.
Public Member Functions inherited from Mochi::Layer
 Layer ()
 Default constructor. It initializes with references to the engine subsystems. Should only be constructed after the engine is setup.

Additional Inherited Members

Protected Attributes inherited from Mochi::Layer
FS::PackCatalogmCatalog
Scripting::ScriptingManagermScripting
Graphics::CameramCamera
Event::EventBusmEventBus
Graphics::AbstractGUImGUI
Input::IActionManagermActionManager
Audio::IAudioManagermAudioManager
Graphics::IRenderermRenderer
Debug::IGizmosmGizmos

Detailed Description

This layer is automatically injected in the engine in the setup phase and is designed to bind several useful methods to the lua environment and take ownership of entities generated by lua.

Check Lua Binding Modules for a description of submodule bindings.

Ownership:

  • Owner of graphical entities (SpriteBase) generated from lua scripts.
  • Has its own texture factory and animation factory to have its own cache.

Guarantees:

  • When doing the engine setup, the most common engine methods will be automatically binded in the lua global table.
  • This layer is automatically injected in the engine as the engine setups.
  • Sprites destroyed from lua will be safely destroyed in C++ on each frame.
  • Sprites created from lua will be updated (for animations) and rendered each frame.

Non responsible:

  • This class does not auto-load any user created lua script.
  • If manually injecting entities on the lua state, this class does not manage their lifetime nor has their ownership.

Member Function Documentation

◆ Debug()

void Mochi::Scripting::ScriptingLayer::Debug ( ) const
overridevirtual

This class does not show any debug data.

Reimplemented from Mochi::Layer.

◆ GUI()

void Mochi::Scripting::ScriptingLayer::GUI ( ) const
overridevirtual

This class does not show any GUI.

Reimplemented from Mochi::Layer.

◆ InitLayer()

void Mochi::Scripting::ScriptingLayer::InitLayer ( )
overridevirtual

Calls BindFactoryMethods and graphics, logic and audio bindings to lua.

Check Lua Binding Modules for a description of submodule bindings.

Reimplemented from Mochi::Layer.

◆ Render()

void Mochi::Scripting::ScriptingLayer::Render ( ) const
overridevirtual

Renders owned sprites.

Reimplemented from Mochi::Layer.

◆ Update()

bool Mochi::Scripting::ScriptingLayer::Update ( const float & dt)
overridevirtual

Updates owned sprites (for animations) and safely removes sprites marked for destruction.

Parameters
dtDelta time
Returns
Always true (continue game execution)

Reimplemented from Mochi::Layer.


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