Implement Serialize Mechanism

This commit is contained in:
2024-01-30 12:37:36 -05:00
parent 0606b866d5
commit c73f7562bf
2 changed files with 27 additions and 0 deletions

View File

@@ -28,6 +28,15 @@ public:
return nullptr;
}
std::vector<Entity> GetFlatEntityList();
template <class T>
void Serialize(T& archive)
{
Entity::SerializeMemberData(archive);
archive & GetFlatEntityList();
}
void SetParent(Entity *parent) override
{
throw std::runtime_error("Cannot set parent of Hierarchy Root!");

View File

@@ -4,6 +4,7 @@
#include <types/vertex.h>
#include <J3ML/LinearAlgebra/Matrix4x4.h>
#include <J3ML/LinearAlgebra/Vector3.h>
#include <archive.h>
class Entity {
private:
@@ -17,6 +18,23 @@ protected:
std::vector<Entity*> children;
public:
std::string name;
bool alive;
virtual std::vector<std::string> GetEntityUUIDList() const {}
template <class T>
void SerializeMemberData(T& archive)
{
archive & uuid.c_str() & name.c_str() & alive;
}
template <class T>
void Serialize(T& archive)
{
SerializeMemberData(archive);
archive & GetEntityUUIDList();
}
LinearAlgebra::Vector3 angle = {0,0,0}; //Pitch Yaw Roll, The orientation of the entity in the world,
GLuint getTextureID();