MQEngine
载入中...
搜索中...
未找到
ScriptSystem.h
浏览该文件的文档.
1//
2// Created by Administrator on 2025/8/31.
3//
4
5#ifndef SCRIPTSYSTEM_H
6#define SCRIPTSYSTEM_H
7
8#include "../EnginePCH.h"
11#include "ComponentReflection.h"
12#include <memory>
13#include <vector>
14#include <string>
15
16namespace MQEngine {
18 public:
21
27 void loadScripts();
28
33 std::vector<std::string> getFunctionNames() const;
34
38 void update();
39
44 void setLogicDeltaTime(float deltaTime);
45
46 private:
48 std::unique_ptr<FCT::NodeEnvironment> m_nodeEnv;
49 std::unique_ptr<ComponentReflection> m_componentReflection;
50 float m_logicDeltaTime = 0.0f;
51
57 std::vector<std::string> loadJSFilesFromDirectory(const std::string& directory);
58
63
71 ComponentValue convertJSObjectToComponentValue(const std::string& fieldType, FCT::JSAny& jsAny, const std::string& fieldName);
72
73 ComponentValue convertJSObjectToComponentValue(const std::string& fieldType, const FCT::JSAny& fieldValue);
74 std::pair<entt::registry*, entt::entity> getEntityFromJS(FCT::NodeEnvironment& env);
75 v8::Local<v8::Value> convertComponentValueToJS(const ComponentValue& value);
76
82 std::string readFileContent(const std::string& filePath);
83 };
84} // MQEngine
85
86#endif //SCRIPTSYSTEM_H
A header file containing third party libraries and macros for platform
#define ENGINE_API
定义 EnginePCH.h:14
定义 DataManager.h:58
void registerEntityFunctions()
定义 ScriptSystem.cpp:296
v8::Local< v8::Value > convertComponentValueToJS(const ComponentValue &value)
定义 ScriptSystem.cpp:271
DataManager * m_dataManager
定义 ScriptSystem.h:47
std::unique_ptr< ComponentReflection > m_componentReflection
定义 ScriptSystem.h:49
void setLogicDeltaTime(float deltaTime)
设置逻辑帧时间间隔
定义 ScriptSystem.cpp:145
ScriptSystem()
定义 ScriptSystem.cpp:11
std::vector< std::string > getFunctionNames() const
获取当前JavaScript环境中的所有函数名
定义 ScriptSystem.cpp:132
std::pair< entt::registry *, entt::entity > getEntityFromJS(FCT::NodeEnvironment &env)
定义 ScriptSystem.cpp:250
std::vector< std::string > loadJSFilesFromDirectory(const std::string &directory)
定义 ScriptSystem.cpp:77
float m_logicDeltaTime
定义 ScriptSystem.h:50
std::unique_ptr< FCT::NodeEnvironment > m_nodeEnv
定义 ScriptSystem.h:48
ComponentValue convertJSObjectToComponentValue(const std::string &fieldType, FCT::JSAny &jsAny, const std::string &fieldName)
通用类型转换函数:从JSObject转换为ComponentValue
定义 ScriptSystem.cpp:202
void update()
更新系统,执行所有ScriptComponent的脚本
定义 ScriptSystem.cpp:159
std::string readFileContent(const std::string &filePath)
读取文件内容
定义 ScriptSystem.cpp:104
void loadScripts()
加载并执行JavaScript脚本文件
定义 ScriptSystem.cpp:27
定义 application.h:5
std::variant< bool, int, float, double, std::string, FCT::Vec3 > ComponentValue
定义 ComponentReflection.h:18