Lua Wrapper component can now be serialized
This commit is contained in:
@@ -7,26 +7,14 @@
|
||||
#include <utility>
|
||||
|
||||
namespace ecs::lua {
|
||||
struct Wrapper : Component {
|
||||
Wrapper(std::string _name, sol::table _table) : name(_name), table(_table) {}
|
||||
Wrapper() {}
|
||||
struct Wrapper : TaggedComponent {
|
||||
// @todo Figure out a more elegant way
|
||||
Wrapper(sol::table _table) : TaggedComponent(get_typename<Wrapper>()), table(_table) {}
|
||||
Wrapper() : TaggedComponent(get_typename<Wrapper>()) {}
|
||||
|
||||
std::string name;
|
||||
sol::table table;
|
||||
};
|
||||
|
||||
template <typename T, typename... Constructor, typename... Args>
|
||||
void register_component(sol::state& lua, sol::table& table, Args... args) {
|
||||
table.new_usertype<T>(get_typename<T>(),
|
||||
"new", sol::factories([](Constructor... constructor) {
|
||||
return std::make_pair(new T(constructor...), get_typename<T>());
|
||||
}), args...
|
||||
);
|
||||
lua.set_function("_internal_to_" + get_typename<T>(), [] (Component* component) {
|
||||
return (T*)component;
|
||||
});
|
||||
}
|
||||
|
||||
void init(sol::state& lua);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user