Implement Serialize Mechanism
This commit is contained in:
@@ -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!");
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user