#pragma once #include "src/Scripting/WrenScript.h" #include "src/Resource/Serializable.h" #include "src/Core/FileSystem.h" namespace Nuake { class WrenScriptComponent { public: std::string Script; unsigned int mModule = 0; Ref mWrenScript = nullptr; void LoadScript(const std::string& path) { Script = path; Ref nuakeFile = Nuake::FileSystem::GetFile(path); mWrenScript = CreateRef(nuakeFile, true); auto modules = mWrenScript->GetModules(); if (modules.size() > 0) { mModule = 0; } } json Serialize() { BEGIN_SERIALIZE(); SERIALIZE_VAL(Script); SERIALIZE_VAL(mModule) END_SERIALIZE(); } bool Deserialize(std::string str) { BEGIN_DESERIALIZE(); if (j.contains("Script")) { Script = j["Script"]; if(!Script.empty()) { LoadScript(Script); } } if (j.contains("mModule")) { mModule = j["mModule"]; } return true; } }; }