#pragma once #include "sol.hpp" #include "ecs.h" #include #include namespace ecs::lua { struct Wrapper : Component { Wrapper(std::string _name, sol::table _table) : name(_name), table(_table) {} Wrapper() {} std::string name; sol::table table; }; template void register_component(sol::state& lua, sol::table& table, Args... args) { table.new_usertype(get_typename(), "new", sol::factories([](Constructor... constructor) { return std::make_pair(new T(constructor...), get_typename()); }), args... ); lua.set_function("_internal_to_" + get_typename(), [] (Component* component) { return (T*)component; }); } void init(sol::state& lua); }