fix overriding components in prototype

This commit is contained in:
2019-05-15 04:51:49 +07:00
parent 55ab81dc93
commit 8108fe2ab9
2 changed files with 10 additions and 1 deletions

View File

@@ -1914,7 +1914,7 @@ namespace ecs_hpp
auto applier = std::make_unique<applier_t>(
std::make_tuple(std::forward<Args>(args)...));
const auto family = detail::type_family<T>::id();
appliers_.emplace(family, std::move(applier));
appliers_.insert_or_assign(family, std::move(applier));
return *this;
}

View File

@@ -586,6 +586,15 @@ TEST_CASE("registry") {
REQUIRE(e2.component_count() == 1u);
REQUIRE(e2.get_component<position_c>() == position_c(1,2));
}
{
ecs::prototype p;
p.component<position_c>(1, 2);
p.component<position_c>(11, 22);
ecs::registry w;
const auto e1 = w.create_entity(p);
REQUIRE(e1.get_component<position_c>() == position_c(11,22));
}
{
const auto p = ecs::prototype()
.component<position_c>(1,2)