Scarab's own game engine: the state machine (init/ run-stage/fatal-error handlers), the ScriptProcessor/LuaEngine wiring, and the small amount of per-frame bookkeeping (BGM looping, sp_wait_queue_empty resolution) that isn't Lua's job. Used to be split across WorldBase (a reusable base class) and WorldEngine (Scarab's state machine subclassing it) - merged since nothing else ever subclassed WorldBase and the split no longer served polymorphism, just indirection. Renamed from WorldEngine/Caravellius::World once the Lua refactor left it owning no "world" state at all (no tile map pointer, no sprite queues, no camera) - it's a lifecycle/Lua-bridge host, not a world model.
More...
#include <enginehost.h>
|
| | EngineHost (Scarab ::Host ::RendererProvider *pRendererProvider, std ::string strEntryArg, std ::string strEntryOverride=std ::string()) |
| |
| virtual | ~EngineHost (void) |
| |
| void | RunEntryScript (void) |
| | Run the entry script (main.lua, or whatever the entry argument resolves to) - BEFORE the window exists, called by main() ahead of the frame loop. The script may create the renderer itself (renderer_create); anything that needs a window before it has done so creates the default renderer on the spot (see RendererProvider), and a script that never needs one gets the default when it finishes, so the loop always has a renderer to run on.
|
| |
| void | UseVirtualTime (void) |
| | Headless (–headless) only - make Lua's os.time()/ os.clock() follow the null renderer's virtual clock. Called by main() right after construction, before Start() (so before any Lua script has run); a no-op for a real-window run, which never calls it.
|
| |
| void | OnUpdate (SunLight ::TileMap ::ITileMap &tileMap) |
| |
| void | OnStop (void) |
| | Perform world listener cleaning before world window closing. Runs while TileMapRenderer's window/GL context is still alive (see TileMapRenderer::Stop(), which calls every listener's OnStop() before CloseWindow()) - releasing the sprite pool's textures here, rather than leaving it to ~SpritePool() at program exit, avoids unloading GPU textures after the context is already gone.
|
| |
| void | OnCommand (SunLight ::Scripting ::Commands cmd, uint16_t nEventId) |
| | Must be implemented to respond STOP_SONG_CMD command;.
|
| |
| void | OnError (std ::string strError) |
| | Runtime error handling.
|
| |
Scarab's own game engine: the state machine (init/ run-stage/fatal-error handlers), the ScriptProcessor/LuaEngine wiring, and the small amount of per-frame bookkeeping (BGM looping, sp_wait_queue_empty resolution) that isn't Lua's job. Used to be split across WorldBase (a reusable base class) and WorldEngine (Scarab's state machine subclassing it) - merged since nothing else ever subclassed WorldBase and the split no longer served polymorphism, just indirection. Renamed from WorldEngine/Caravellius::World once the Lua refactor left it owning no "world" state at all (no tile map pointer, no sprite queues, no camera) - it's a lifecycle/Lua-bridge host, not a world model.
◆ EngineHost()
| Scarab::Host::EngineHost::EngineHost |
( |
Scarab ::Host ::RendererProvider * |
pRendererProvider, |
|
|
std ::string |
strEntryArg, |
|
|
std ::string |
strEntryOverride = std :: string() |
|
) |
| |
Constructor. Initialize all class data.
- Parameters
-
| pRendererProvider | The provider the renderer is created through (lazily - it does not exist yet); this registers itself as the tile-map listener of whatever renderer it creates; |
| strEntryArg | The entry argument main.cpp requires on the command line (a .lua script path or a .json project file) - resolved later, from RunEntryScript, since a failure there already has a normal fatal-error path to report through. |
◆ ~EngineHost()
| Scarab::Host::EngineHost::~EngineHost |
( |
void |
| ) |
|
|
virtual |
Destructor. Finalize all class data.
◆ OnCommand()
| void Scarab::Host::EngineHost::OnCommand |
( |
SunLight ::Scripting ::Commands |
cmd, |
|
|
uint16_t |
nEventId |
|
) |
| |
Must be implemented to respond STOP_SONG_CMD command;.
- Parameters
-
| cmd | The command received/ |
| nEventId | The event id; |
◆ OnError()
| void Scarab::Host::EngineHost::OnError |
( |
std ::string |
strError | ) |
|
Runtime error handling.
- Parameters
-
| strError | The engine error message received; |
◆ OnStop()
| void Scarab::Host::EngineHost::OnStop |
( |
void |
| ) |
|
Perform world listener cleaning before world window closing. Runs while TileMapRenderer's window/GL context is still alive (see TileMapRenderer::Stop(), which calls every listener's OnStop() before CloseWindow()) - releasing the sprite pool's textures here, rather than leaving it to ~SpritePool() at program exit, avoids unloading GPU textures after the context is already gone.
◆ OnUpdate()
| void Scarab::Host::EngineHost::OnUpdate |
( |
SunLight ::TileMap ::ITileMap & |
tileMap | ) |
|
Provide action on each frame update.
- Parameters
-
◆ RunEntryScript()
| void Scarab::Host::EngineHost::RunEntryScript |
( |
void |
| ) |
|
Run the entry script (main.lua, or whatever the entry argument resolves to) - BEFORE the window exists, called by main() ahead of the frame loop. The script may create the renderer itself (renderer_create); anything that needs a window before it has done so creates the default renderer on the spot (see RendererProvider), and a script that never needs one gets the default when it finishes, so the loop always has a renderer to run on.
A failure is a normal fatal error: reported and the process exits, exactly as it used to from the first frame of the loop - just without a window having flashed open first.
◆ UseVirtualTime()
| void Scarab::Host::EngineHost::UseVirtualTime |
( |
void |
| ) |
|
Headless (–headless) only - make Lua's os.time()/ os.clock() follow the null renderer's virtual clock. Called by main() right after construction, before Start() (so before any Lua script has run); a no-op for a real-window run, which never calls it.
The documentation for this class was generated from the following files: