Created basic ecs that has an optional lua module

This commit is contained in:
2019-01-30 00:23:32 +01:00
commit 49c1cacaa0
15 changed files with 934 additions and 0 deletions

29
ecs-lua/include/ecs-lua.h Normal file
View File

@@ -0,0 +1,29 @@
#pragma once
#include "sol.hpp"
#include "ecs.h"
#include <iostream>
namespace ecs::lua {
struct LuaWrapper : Component {
LuaWrapper(sol::object object) : _object(object) {}
sol::object _object;
};
template <typename T, typename... Constructor, typename... Args>
void register_component(sol::state& lua, Args... args) {
lua.new_usertype<T>(get_typename<T>(),
"new", sol::factories([](Constructor... constructor) {
return new T(constructor...);
}), args...
);
lua.set_function("_internal_to_" + get_typename<T>(), [] (Component* component) {
return (T*)component;
});
}
void init(sol::state& lua);
}