Added codegen to register components, and started reworking lua

This commit is contained in:
2019-06-07 15:52:57 +02:00
parent 53a0b98341
commit 7ff9e21b4d
14 changed files with 381 additions and 110 deletions

View File

@@ -1,3 +1,5 @@
#include <functional>
#include <ostream>
#pragma once
#include "ecs.h"
@@ -57,6 +59,17 @@ namespace ecs::serial {
internal::functions.insert({ComponentID::id<T>, {func1, func2, func3}});
}
template <typename T>
void register_component_custom(std::function<void(std::ostream&, ecs::Component*)> func1, std::function<void(std::istream&, Component*)> func2) {
auto func3 = [] () -> Component* {
return new T();
};
internal::functions.insert({ComponentID::id<T>, {func1, func2, func3}});
}
void serialize(std::ostream& os, Entity* entity);
void deserialize(std::istream& is, Manager& manager);
void serialize_ids(std::ostream& os);
}