Component now stores whether or not it is a runtime component
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
#include <utility>
|
||||
|
||||
namespace ecs::lua {
|
||||
struct Wrapper : TaggedComponent {
|
||||
struct Wrapper : Component {
|
||||
// @todo Figure out a more elegant way
|
||||
Wrapper(sol::table _table) : TaggedComponent(get_typename<Wrapper>()), table(_table) {}
|
||||
Wrapper() : TaggedComponent(get_typename<Wrapper>()) {}
|
||||
Wrapper(sol::table _table) : Component(ComponentID::id<Wrapper>), table(_table) {}
|
||||
Wrapper() : Component(ComponentID::id<Wrapper>) {}
|
||||
|
||||
sol::table table;
|
||||
};
|
||||
|
||||
@@ -31,15 +31,15 @@ namespace ecs::lua {
|
||||
"get_component", [&lua] (Entity* thiz, std::string name) -> sol::object {
|
||||
// Convert to the correct component type
|
||||
Component* component = thiz->get_component(ComponentID::get_id({name})[0]);
|
||||
if (!component->_tagged()) {
|
||||
if (!component->_runtime) {
|
||||
// @todo Figure out a more elegant way to convert
|
||||
auto f1 = lua["_internal_to_" + name];
|
||||
if (f1.valid()) {
|
||||
return f1(component);
|
||||
}
|
||||
} else {
|
||||
TaggedComponent* tagged_component = (TaggedComponent*)component;
|
||||
auto f1 = lua["_internal_to_" + tagged_component->_tag];
|
||||
// @todo This call is not very fast...
|
||||
auto f1 = lua["_internal_to_" + ComponentID::get_name(component->_id)];
|
||||
if (f1.valid()) {
|
||||
return f1(component);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user