XII Release 0.1.0
Loading...
Searching...
No Matches
xiiScriptWorldModule Class Reference

#include <ScriptWorldModule.h>

Inheritance diagram for xiiScriptWorldModule:
[legend]

Classes

struct  FunctionContext
 Context information for scheduled script functions. More...
 

Public Member Functions

 xiiScriptWorldModule (xiiWorld *pWorld)
 
virtual void Initialize () override
 This method is called after the constructor. A derived type can override this method to do initialization work. Typically this is the method where updates function are registered.
 
virtual void WorldClear () override
 Called by xiiWorld::Clear(). Can be used to clear cached data when a world is completely cleared of objects (but not deleted).
 
void AddUpdateFunctionToSchedule (const xiiAbstractFunctionProperty *pFunction, void *pInstance, xiiTime updateInterval, bool bOnlyWhenSimulating)
 Schedules a script function to be called at regular intervals.
 
void RemoveUpdateFunctionToSchedule (const xiiAbstractFunctionProperty *pFunction, void *pInstance)
 Removes a previously scheduled script function from the scheduler.
 
xiiExpressionVMGetSharedExpressionVM ()
 
Coroutine Functions
xiiScriptCoroutineHandle CreateCoroutine (const xiiRTTI *pCoroutineType, xiiStringView sName, xiiScriptInstance &inout_instance, xiiScriptCoroutineCreationMode::Enum creationMode, xiiScriptCoroutine *&out_pCoroutine)
 
void StartCoroutine (xiiScriptCoroutineHandle hCoroutine, xiiArrayPtr< xiiVariant > arguments)
 
void StopAndDeleteCoroutine (xiiScriptCoroutineHandle hCoroutine)
 
void StopAndDeleteCoroutine (xiiStringView sName, xiiScriptInstance *pInstance)
 Stops and deletes all coroutines with the given name on the specified instance.
 
void StopAndDeleteAllCoroutines (xiiScriptInstance *pInstance)
 Stops and deletes all coroutines on the specified instance.
 
bool IsCoroutineFinished (xiiScriptCoroutineHandle hCoroutine) const
 Returns whether the coroutine has finished or been stopped.
 
- Public Member Functions inherited from xiiWorldModule
xiiWorldGetWorld ()
 Returns the corresponding world to this module.
 
const xiiWorldGetWorld () const
 Returns the corresponding world to this module.
 
xiiUInt32 GetWorldIndex () const
 Same as GetWorld()->GetIndex(). Needed to break circular include dependencies.
 
- Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const xiiRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T>
XII_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Additional Inherited Members

- Static Public Member Functions inherited from xiiNoBase
static const xiiRTTIGetStaticRTTI ()
 
- Protected Types inherited from xiiWorldModule
using UpdateFunction = xiiDelegate<void(const UpdateContext&)>
 Update function delegate.
 
- Protected Member Functions inherited from xiiWorldModule
 xiiWorldModule (xiiWorld *pWorld)
 
void RegisterUpdateFunction (const UpdateFunctionDesc &desc)
 Registers the given update function at the world.
 
void DeregisterUpdateFunction (const UpdateFunctionDesc &desc)
 De-registers the given update function from the world. Note that only the m_Function and the m_Phase of the description have to be valid for de-registration.
 
xiiAllocatorBaseGetAllocator ()
 Returns the allocator used by the world.
 
xiiInternal::WorldLargeBlockAllocatorGetBlockAllocator ()
 Returns the block allocator used by the world.
 
bool GetWorldSimulationEnabled () const
 Returns whether the world simulation is enabled.
 
virtual void Deinitialize ()
 This method is called before the destructor. A derived type can override this method to do deinitialization work.
 
virtual void OnSimulationStarted ()
 This method is called at the start of the next world update when the world is simulated. This method will be called after the initialization method.
 
- Protected Attributes inherited from xiiWorldModule
xiiWorldm_pWorld
 

Detailed Description

World module responsible for script execution and coroutine management.

Handles the execution of script functions, manages script coroutines, and provides scheduling for script update functions. This module ensures scripts are properly integrated with the world update cycle.

Member Function Documentation

◆ CreateCoroutine()

xiiScriptCoroutineHandle xiiScriptWorldModule::CreateCoroutine ( const xiiRTTI * pCoroutineType,
xiiStringView sName,
xiiScriptInstance & inout_instance,
xiiScriptCoroutineCreationMode::Enum creationMode,
xiiScriptCoroutine *& out_pCoroutine )

Creates a new coroutine of the specified type with the given name.

Returns an invalid handle if the creationMode prevents creating a new coroutine and there is already a coroutine running with the same name on the given instance.

◆ GetSharedExpressionVM()

xiiExpressionVM & xiiScriptWorldModule::GetSharedExpressionVM ( )
inline

Returns a shared expression VM for custom script implementations.

The VM is NOT thread safe - only execute one expression at a time.

◆ Initialize()

void xiiScriptWorldModule::Initialize ( )
overridevirtual

This method is called after the constructor. A derived type can override this method to do initialization work. Typically this is the method where updates function are registered.

Reimplemented from xiiWorldModule.

◆ StartCoroutine()

void xiiScriptWorldModule::StartCoroutine ( xiiScriptCoroutineHandle hCoroutine,
xiiArrayPtr< xiiVariant > arguments )

Starts the coroutine with the given arguments.

Calls the Start() function and then UpdateAndSchedule() once on the coroutine object.

◆ StopAndDeleteCoroutine()

void xiiScriptWorldModule::StopAndDeleteCoroutine ( xiiScriptCoroutineHandle hCoroutine)

Stops and deletes the coroutine.

Calls the Stop() function and deletes the coroutine on the next update cycle.

◆ WorldClear()

void xiiScriptWorldModule::WorldClear ( )
overridevirtual

Called by xiiWorld::Clear(). Can be used to clear cached data when a world is completely cleared of objects (but not deleted).

Reimplemented from xiiWorldModule.


The documentation for this class was generated from the following files: