Switched back to using ids instead of names, added uuids to entities and started work on serialization

This commit is contained in:
2019-02-05 22:23:38 +00:00
parent 92f8fdd510
commit a6e5deb502
8 changed files with 259 additions and 40 deletions

View File

@@ -79,6 +79,11 @@ int main() {
print("v_y: " .. vel.vy)
end)
-- @todo Implement this
-- for uuid,entity in pairs(view) do
-- print "TEST"
-- end
manager:view("Random"):for_each(function(ent)
wrapped = ent:get_component("Random").object
@@ -123,16 +128,17 @@ int main() {
std::cout << "Y: " << pos->_y << '\n';
});
manager.view({"Random"}).for_each([](ecs::Entity* entity) {
sol::table random = ((ecs::lua::LuaWrapper*)entity->get_component("Random"))->_object;
// These are really just an internal api that should not be used
for (auto [uuid, entity] : manager.view(ecs::ComponentID::get_id({"Random"}))) {
sol::table random = ((ecs::lua::LuaWrapper*)entity->get_component(ecs::ComponentID::get_id({"Random"})[0]))->_object;
random["a"] = 21;
std::cout << random["a"].get<std::string>() << '\n';
});
};
manager.view({"Random"}).for_each([](ecs::Entity* entity) {
sol::table random = ((ecs::lua::LuaWrapper*)entity->get_component("Random"))->_object;
for (auto [uuid, entity] : manager.view(ecs::ComponentID::get_id({"Random"}))) {
sol::table random = ((ecs::lua::LuaWrapper*)entity->get_component(ecs::ComponentID::get_id({"Random"})[0]))->_object;
std::cout << random["a"].get<std::string>() << '\n';
});
};
}