![]() |
vkmEngine 1.0.0
A C++ game engine · vkmengine.com
|
Loads the hot-reloadable gameplay module and swaps it at runtime. More...
#include <script_module.h>
Public Member Functions | |
| bool | load (const std::filesystem::path &modulePath, EventBus *events) |
| Load the gameplay module and register its behaviors. | |
| bool | reload (Scene &scene, BehaviorSystem &behaviors, EventBus &events) |
| Hot-reload from the same path: serialize, swap module, recreate. | |
| bool | buildScene (Scene &scene, ResourceManager &resources) |
Let the module seed scene through the optional vkmBuildScene, if it has one. | |
| bool | setupNetwork (NetSession &session) |
| Let the module say what a player is, through the optional vkmSetupNetwork. | |
| void | unload (EventBus &events) |
| Drop the loaded module and the behavior types it registered. | |
| void | expect (const std::filesystem::path &modulePath, EventBus &events) |
Unload whatever is loaded and remember modulePath for a project not yet built. | |
| const std::filesystem::path & | modulePath () const |
| The built module this loaded from, not the mapped copy: the file to watch for a build. | |
Loads the hot-reloadable gameplay module and swaps it at runtime.
reload() rebuilds only the behavior objects; entities and other components are untouched. Reloaded behaviors run onStart again next tick.
| bool Vkm::Engine::ScriptModule::load | ( | const std::filesystem::path & | modulePath, |
| EventBus * | events ) |
Load the gameplay module and register its behaviors.
Loads a copy, keeping the original writable for rebuilds. A read-only directory (an installed game) loads in place; any other copy failure refuses the load.
| modulePath | Path to the built module (.dll/.so) to load. |
| events | The host's bus, so a replaced module is released fully; null for a host with no Engine yet, which has nothing to replace. |
| bool Vkm::Engine::ScriptModule::reload | ( | Scene & | scene, |
| BehaviorSystem & | behaviors, | ||
| EventBus & | events ) |
Hot-reload from the same path: serialize, swap module, recreate.
The new build is checked before anything is torn down; a refused one leaves the running module untouched. With none loaded, this is a plain load. scene must hold no component set the outgoing module created (its vtable is module code); see docs/reference/scripting.md, "Nothing may hold module code across the swap".
| scene | Scene whose behaviors are saved across the swap. |
| behaviors | The system running them, whose session the swap ends. |
| events | Bus to clear the outgoing module's event types from. |
| bool Vkm::Engine::ScriptModule::buildScene | ( | Scene & | scene, |
| ResourceManager & | resources ) |
Let the module seed scene through the optional vkmBuildScene, if it has one.
| scene | Scene to seed. |
| resources | Asset graph the built world's assets go into. |
| bool Vkm::Engine::ScriptModule::setupNetwork | ( | NetSession & | session | ) |
Let the module say what a player is, through the optional vkmSetupNetwork.
Sets spawn callbacks and registers replicated components. Harmless offline: an empty session behaves as no session.
| session | Session the host will host or join with. |
| void Vkm::Engine::ScriptModule::unload | ( | EventBus & | events | ) |
Drop the loaded module and the behavior types it registered.
Safe when nothing is loaded. Clear the scene first: behaviors outlive this only as dangling objects.
| events | Bus to clear the outgoing module's event types from. |
| void Vkm::Engine::ScriptModule::expect | ( | const std::filesystem::path & | modulePath, |
| EventBus & | events ) |
Unload whatever is loaded and remember modulePath for a project not yet built.
| modulePath | Where the project's build writes its module. |
| events | Bus to clear the outgoing module's event types from. |
|
inline |