class IScriptExportable

Interface to be implemented by types that are exported to scripting.

Such types should also be decorated with B3D_SCRIPT_EXPORT() macro, along with any fields or methods that should be exported.

Public

Constructors

IScriptExportable

IScriptExportable() noexcept = default

IScriptExportable

IScriptExportable(const IScriptExportable &other)

IScriptExportable

IScriptExportable(IScriptExportable &&other)

Methods

~IScriptExportable

virtual ~IScriptExportable() noexcept

GetScriptObjectWrapper

IScriptObjectWrapper *GetScriptObjectWrapper() const

Returns the script object wrapper associated with this object.

This will be null if the object was never passed to script world, or if was passed but has gone out of scope.

ShouldPersistScriptReload

virtual bool ShouldPersistScriptReload() const

If true, the object will be given an opportunity to back up its data before a script reload operation, and its script object will be automatically recreated once script reload ends, and given an opportunity to restore the backed up data.

If false, the script object and its wrapper will be destroyed on script reload.

NotifyScriptWillReload

virtual void NotifyScriptWillReload()

Called on all script objects before script object reload happens.

BackupDataBeforeScriptReload

virtual TOptional<ScriptObjectReloadPersistentData> BackupDataBeforeScriptReload()

RecreateScriptObjectAfterScriptReload

virtual bool RecreateScriptObjectAfterScriptReload()

Called on all script objects after script assemblies have been reloaded.

This needs to recreate the internal script object using the new assemblies, as the old one will have been destroyed during the reload. Only relevant for script objects that persist script reload (i.e. ShouldPersistScriptReload() returns true). Returns true if the script object was created, otherwise the responsibility will fall to the script object wrapper.

RestoreDataAfterScriptReload

virtual void RestoreDataAfterScriptReload(const ScriptObjectReloadPersistentData &data)

Called on all script objects after script objects have been created in RecreateScriptObjectAfterScriptReload().

Allows you to restore data backed up in BackupDataBeforeScriptReload() call to the newly created script object. Only relevant for script objects that persist script reload (i.e. ShouldPersistScriptReload() returns true).

NotifyScriptReloadFinished

virtual void NotifyScriptReloadFinished()

Called on all script object wrappers as the final step in script reload, after RestoreDataAfterScriptReload().

Allows you to perform actions that require the entire scripting world to be fully recreated.

Operators

operator=

IScriptExportable &operator=(const IScriptExportable &other)

operator=

Internal

Methods

ClearAssociatedScriptObjectWrapper

void ClearAssociatedScriptObjectWrapper()

Clears the currently associated script object wrapper.

Generally called before the script object is destroyed.

Private

Methods

AssociateWithScriptObjectWrapper

void AssociateWithScriptObjectWrapper(IScriptObjectWrapper *wrapper)

Notifies the object that a script object wrapper has been created for it, allowing a script object to access the native object through it.

Fields

mScriptObjectWrapper

IScriptObjectWrapper * mScriptObjectWrapper