Created basic ecs that has an optional lua module
This commit is contained in:
29
ecs-lua/include/ecs-lua.h
Normal file
29
ecs-lua/include/ecs-lua.h
Normal 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user