Drives the per-frame lifecycle of all native scripts within a scene. More...
#include <ScriptRuntime.h>
Static Public Member Functions | |
| static void | OnRuntimeStart (Ref< Scene > scene) |
| Instantiates and initialises all enabled scripts in the scene. | |
| static void | OnRuntimeUpdate (Ref< Scene > scene, float ts) |
| Calls OnUpdate on every non-faulted, enabled script instance. | |
| static void | OnRuntimeStop (Ref< Scene > scene) |
| Destroys all script instances and clears the scene script context. | |
| static ScriptBase * | CreateInstance (std::string_view className) |
| Constructs a script instance by class name using the registered factory. | |
| static void | DestroyInstance (ScriptBase *instance) |
| Destroys a script instance created by CreateInstance. | |
| static void | OnCreate (ScriptBase *instance, ScriptComponent *script) |
Invokes ScriptBase::OnCreate on an instance, guarded by SEH. | |
| static void | OnUpdate (ScriptBase *instance, float dt, ScriptComponent *script) |
Invokes ScriptBase::OnUpdate on an instance, guarded by SEH. | |
| static void | OnDestroy (ScriptBase *instance, ScriptComponent *script) |
Invokes ScriptBase::OnDestroy on an instance, guarded by SEH. | |
| static std::vector< std::string_view > | GetRegisteredClassNames () |
| Returns the names of all script classes currently registered in the DLL. | |
Drives the per-frame lifecycle of all native scripts within a scene.
ScriptRuntime is stateless; every method is static and operates on the scene or script instance passed in. It bridges the ECS (iterating ScriptComponent entities) and the registered script types held by ScriptRegistry.
SEH (__try / __except) guards wrap every user-script call so that a faulting script is marked as Faulted and isolated without crashing the engine.
|
static |
Constructs a script instance by class name using the registered factory.
| className | Fully-qualified script class name as registered in the DLL. |
nullptr if the class is unknown or has no factory.
|
static |
Destroys a script instance created by CreateInstance.
| instance | Instance to destroy. No-op if nullptr. |
|
static |
Returns the names of all script classes currently registered in the DLL.
|
static |
Invokes ScriptBase::OnCreate on an instance, guarded by SEH.
If an unhandled exception is raised inside user code, the script is marked as Faulted and subsequent lifecycle calls are skipped.
| instance | Script instance to call. Must not be nullptr. |
| script | Component owning the instance; used for fault tracking. |
|
static |
Invokes ScriptBase::OnDestroy on an instance, guarded by SEH.
| instance | Script instance to call. Must not be nullptr. |
| script | Component owning the instance; used for fault tracking. |
Instantiates and initialises all enabled scripts in the scene.
For each entity with an enabled ScriptComponent:
ScriptFieldSerializer.EntityID and Scene context pointers.| scene | The scene entering play mode. |
Destroys all script instances and clears the scene script context.
For each entity with a live ScriptComponent instance:
| scene | The scene leaving play mode. |
|
static |
Invokes ScriptBase::OnUpdate on an instance, guarded by SEH.
| instance | Script instance to call. Must not be nullptr. |
| dt | Delta time in seconds. |
| script | Component owning the instance; used for fault tracking. |