|
VR-Engage
2.2
|
DtScriptComponent loads and executes Lua scripts within the player component lifecycle, allowing custom behavior implementation through scripts rather than C++ code. Scripts have access to the player attribute store and can implement initialize, postInitialize, tick, and shutdown callbacks that align with the component lifecycle methods.
#include <scriptComponent.h>
Public Member Functions | |
| DtScriptComponent () | |
| virtual | ~DtScriptComponent () override |
| virtual bool | initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override |
| virtual bool | postInitialize () override |
| virtual void | tick (double dt) override |
| virtual void | shutdown () override |
| virtual const char * | type () const override |
| virtual void | reload () |
Public Member Functions inherited from makVre::DtPlayerComponent | |
| DtPlayerComponent () | |
| virtual | ~DtPlayerComponent () |
| virtual void | setName (const std::string &name) |
| virtual const std::string & | name () |
| virtual DtPlayerStation & | player () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () const |
Protected Member Functions | |
| virtual bool | setupVm () |
| virtual void | shutdownVm () |
Protected Member Functions inherited from makVre::DtPlayerComponent | |
| virtual void | initializeStateAttributes () |
Protected Attributes | |
| std::string | myScriptFilename |
| std::string | myScriptConfig |
| DtLuaState * | myVm |
Protected Attributes inherited from makVre::DtPlayerComponent | |
| std::string | myName |
| DtInitTable | myConfig |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
| makVre::DtScriptComponent::DtScriptComponent | ( | ) |
Constructor for DtScriptComponent.
Initializes the component with the name "DtScriptedUpdater"
|
overridevirtual |
Virtual destructor for DtScriptComponent.
|
overridevirtual |
Initializes the script component.
| player | Pointer to the player station this component belongs to |
| config | Configuration table containing script settings |
Loads the script file specified in the config and initializes the Lua VM. Serializes any scriptConfig table for passing to the script's initialize function.
Reimplemented from makVre::DtPlayerComponent.
References makVre::DtPlayerComponent::player().
|
overridevirtual |
Performs post-initialization after all components are initialized.
Calls the script's postInitialize function if it exists
Reimplemented from makVre::DtPlayerComponent.
|
overridevirtual |
Called every frame to update the script state.
| dt | Delta time since the last frame in seconds |
Calls the script's tick function, passing the delta time
Implements makVre::DtPlayerComponent.
|
overridevirtual |
Shuts down the script component.
Calls the script's shutdown function if it exists and cleans up the Lua VM
Reimplemented from makVre::DtPlayerComponent.
|
overridevirtual |
Returns the type identifier for this component.
Implements makVre::DtPlayerComponent.
|
virtual |
Reloads the script file.
Reinitializes the Lua VM and reloads the script file
|
protectedvirtual |
Sets up the Lua virtual machine.
Creates a new Lua VM, loads serialization library, installs VR bindings, loads the script file, and calls the script's initialize function
|
protectedvirtual |
Shuts down and cleans up the Lua virtual machine.
|
protected |
Path to the Lua script file to execute.
|
protected |
Serialized configuration table to pass to the script.
|
protected |
Pointer to the Lua virtual machine instance.