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
16#include <unordered_set>
17
18namespace MQEngine {
20 public:
23
29 void loadScripts();
30
35 std::vector<std::string> getFunctionNames() const;
36
40 void start();
41
45 void update();
46
50 void cleanUp();
51
56 void setLogicDeltaTime(float deltaTime);
57
58 private:
60 std::unique_ptr<FCT::NodeEnvironment> m_nodeEnv;
61 std::unique_ptr<ComponentReflection> m_componentReflection;
62 float m_logicDeltaTime = 0.0f;
63 std::unordered_set<entt::entity> m_startedEntities;
64
70 std::vector<std::string> loadJSFilesFromDirectory(const std::string& directory);
71
76
84 ComponentValue convertJSObjectToComponentValue(const std::string& fieldType, FCT::JSAny& jsAny, const std::string& fieldName);
85
86 ComponentValue convertJSObjectToComponentValue(const std::string& fieldType, const FCT::JSAny& fieldValue);
87 std::pair<entt::registry*, entt::entity> getEntityFromJS(FCT::NodeEnvironment& env);
88 v8::Local<v8::Value> convertComponentValueToJS(const ComponentValue& value);
89
95 std::string readFileContent(const std::string& filePath);
96 };
97} // MQEngine
98
99#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:333
v8::Local< v8::Value > convertComponentValueToJS(const ComponentValue &value)
定义 ScriptSystem.cpp:308
void start()
执行所有OnStart类型的脚本
定义 ScriptSystem.cpp:204
void cleanUp()
清理已启动的实体记录
定义 ScriptSystem.cpp:234
DataManager * m_dataManager
定义 ScriptSystem.h:59
std::unique_ptr< ComponentReflection > m_componentReflection
定义 ScriptSystem.h:61
void setLogicDeltaTime(float deltaTime)
设置逻辑帧时间间隔
定义 ScriptSystem.cpp:147
ScriptSystem()
定义 ScriptSystem.cpp:11
std::vector< std::string > getFunctionNames() const
获取当前JavaScript环境中的所有函数名
定义 ScriptSystem.cpp:134
std::pair< entt::registry *, entt::entity > getEntityFromJS(FCT::NodeEnvironment &env)
定义 ScriptSystem.cpp:287
std::vector< std::string > loadJSFilesFromDirectory(const std::string &directory)
定义 ScriptSystem.cpp:79
float m_logicDeltaTime
定义 ScriptSystem.h:62
std::unordered_set< entt::entity > m_startedEntities
定义 ScriptSystem.h:63
std::unique_ptr< FCT::NodeEnvironment > m_nodeEnv
定义 ScriptSystem.h:60
ComponentValue convertJSObjectToComponentValue(const std::string &fieldType, FCT::JSAny &jsAny, const std::string &fieldName)
通用类型转换函数:从JSObject转换为ComponentValue
定义 ScriptSystem.cpp:239
void update()
更新系统,执行所有Ticker类型的脚本
定义 ScriptSystem.cpp:161
std::string readFileContent(const std::string &filePath)
读取文件内容
定义 ScriptSystem.cpp:106
void loadScripts()
加载并执行JavaScript脚本文件
定义 ScriptSystem.cpp:29
Entrypoint for the program.
定义 application.h:5
std::variant< bool, int, float, double, std::string, FCT::Vec3 > ComponentValue
定义 ComponentReflection.h:18