Added validation for serialization

This commit is contained in:
Antoine Pilote
2023-10-02 01:33:54 -04:00
parent 7dc4412dec
commit fbc1cee1f9
3 changed files with 13 additions and 12 deletions

View File

@@ -5,15 +5,5 @@
struct NativeScriptComponent
{
//ScriptableEntity* Instance = nullptr;
//
//ScriptableEntity *(*InstantiateScript)();
//void (*DestroyScript)(NativeScriptComponent*);
//
//template<typename T>
//void Bind()
//{
// InstantiateScript = []() { return static_cast<ScriptableEntity*>(new T()); };
// DestroyScript = [](NativeScriptComponent* nsc) { delete nsc->Instance; nsc->Instance = nullptr; };
//}
};

View File

@@ -14,7 +14,10 @@ namespace Nuake
SERIALIZE_VAL(GravityRandom);
SERIALIZE_VAL(Radius);
SERIALIZE_VAL(GlobalSpace);
SERIALIZE_OBJECT(ParticleMaterial);
if (ParticleMaterial)
{
SERIALIZE_OBJECT(ParticleMaterial);
}
SERIALIZE_VAL(LifeRandomness);
SERIALIZE_VAL(ScaleRandomness);
END_SERIALIZE();

View File

@@ -2,6 +2,7 @@
#include "src/Scripting/WrenScript.h"
#include "src/Resource/Serializable.h"
#include "src/Core/FileSystem.h"
#include "src/Core/Logger.h"
namespace Nuake
{
@@ -17,6 +18,13 @@ namespace Nuake
{
Script = path;
Ref<Nuake::File> nuakeFile = Nuake::FileSystem::GetFile(path);
if (!nuakeFile)
{
Logger::Log("Failed to load script: " + path, "script", CRITICAL);
return;
}
mWrenScript = CreateRef<Nuake::WrenScript>(nuakeFile, true);
auto modules = mWrenScript->GetModules();
if (modules.size() > 0)