MQEngine
载入中...
搜索中...
未找到
MQEngine::ScriptSystem类 参考

#include <ScriptSystem.h>

MQEngine::ScriptSystem 的协作图:

Public 成员函数

 ScriptSystem ()
 ~ScriptSystem ()
void loadScripts ()
 加载并执行JavaScript脚本文件
std::vector< std::string > getFunctionNames () const
 获取当前JavaScript环境中的所有函数名
void update ()
 更新系统,执行所有ScriptComponent的脚本
void setLogicDeltaTime (float deltaTime)
 设置逻辑帧时间间隔

Private 成员函数

std::vector< std::string > loadJSFilesFromDirectory (const std::string &directory)
void registerEntityFunctions ()
ComponentValue convertJSObjectToComponentValue (const std::string &fieldType, FCT::JSAny &jsAny, const std::string &fieldName)
 通用类型转换函数:从JSObject转换为ComponentValue
ComponentValue convertJSObjectToComponentValue (const std::string &fieldType, const FCT::JSAny &fieldValue)
std::pair< entt::registry *, entt::entity > getEntityFromJS (FCT::NodeEnvironment &env)
v8::Local< v8::Value > convertComponentValueToJS (const ComponentValue &value)
std::string readFileContent (const std::string &filePath)
 读取文件内容

Private 属性

DataManagerm_dataManager
std::unique_ptr< FCT::NodeEnvironment > m_nodeEnv
std::unique_ptr< ComponentReflectionm_componentReflection
float m_logicDeltaTime = 0.0f

构造及析构函数说明

◆ ScriptSystem()

MQEngine::ScriptSystem::ScriptSystem ( )

◆ ~ScriptSystem()

MQEngine::ScriptSystem::~ScriptSystem ( )

成员函数说明

◆ convertComponentValueToJS()

v8::Local< v8::Value > MQEngine::ScriptSystem::convertComponentValueToJS ( const ComponentValue & value)
private

◆ convertJSObjectToComponentValue() [1/2]

ComponentValue MQEngine::ScriptSystem::convertJSObjectToComponentValue ( const std::string & fieldType,
const FCT::JSAny & fieldValue )
private

◆ convertJSObjectToComponentValue() [2/2]

ComponentValue MQEngine::ScriptSystem::convertJSObjectToComponentValue ( const std::string & fieldType,
FCT::JSAny & jsAny,
const std::string & fieldName )
private

通用类型转换函数:从JSObject转换为ComponentValue

参数
fieldType字段类型
jsObjectJavaScript对象
fieldName字段名称(同时用于错误输出)
返回
转换后的ComponentValue

◆ getEntityFromJS()

std::pair< entt::registry *, entt::entity > MQEngine::ScriptSystem::getEntityFromJS ( FCT::NodeEnvironment & env)
private

◆ getFunctionNames()

std::vector< std::string > MQEngine::ScriptSystem::getFunctionNames ( ) const

获取当前JavaScript环境中的所有函数名

返回
JavaScript函数名列表

◆ loadJSFilesFromDirectory()

std::vector< std::string > MQEngine::ScriptSystem::loadJSFilesFromDirectory ( const std::string & directory)
private

从指定目录加载所有JavaScript文件

参数
directory目录路径
返回
文件路径列表
这是这个函数的调用关系图:

◆ loadScripts()

void MQEngine::ScriptSystem::loadScripts ( )

加载并执行JavaScript脚本文件

从./res/scripts/dist/和./res/scripts/js目录下获取所有js文件, 然后使用NodeEnvironment执行所有的js文件

函数调用图:

◆ readFileContent()

std::string MQEngine::ScriptSystem::readFileContent ( const std::string & filePath)
private

读取文件内容

参数
filePath文件路径
返回
文件内容字符串
这是这个函数的调用关系图:

◆ registerEntityFunctions()

void MQEngine::ScriptSystem::registerEntityFunctions ( )
private

注册实体成员函数到JavaScript环境

这是这个函数的调用关系图:

◆ setLogicDeltaTime()

void MQEngine::ScriptSystem::setLogicDeltaTime ( float deltaTime)

设置逻辑帧时间间隔

参数
deltaTime帧时间间隔(秒)

◆ update()

void MQEngine::ScriptSystem::update ( )

更新系统,执行所有ScriptComponent的脚本

类成员变量说明

◆ m_componentReflection

std::unique_ptr<ComponentReflection> MQEngine::ScriptSystem::m_componentReflection
private

◆ m_dataManager

DataManager* MQEngine::ScriptSystem::m_dataManager
private

◆ m_logicDeltaTime

float MQEngine::ScriptSystem::m_logicDeltaTime = 0.0f
private

◆ m_nodeEnv

std::unique_ptr<FCT::NodeEnvironment> MQEngine::ScriptSystem::m_nodeEnv
private

该类的文档由以下文件生成: