mirror of
https://github.com/BlackMATov/ecs.hpp.git
synced 2025-12-14 02:56:42 +07:00
fix overriding components in prototype
This commit is contained in:
@@ -1914,7 +1914,7 @@ namespace ecs_hpp
|
|||||||
auto applier = std::make_unique<applier_t>(
|
auto applier = std::make_unique<applier_t>(
|
||||||
std::make_tuple(std::forward<Args>(args)...));
|
std::make_tuple(std::forward<Args>(args)...));
|
||||||
const auto family = detail::type_family<T>::id();
|
const auto family = detail::type_family<T>::id();
|
||||||
appliers_.emplace(family, std::move(applier));
|
appliers_.insert_or_assign(family, std::move(applier));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -586,6 +586,15 @@ TEST_CASE("registry") {
|
|||||||
REQUIRE(e2.component_count() == 1u);
|
REQUIRE(e2.component_count() == 1u);
|
||||||
REQUIRE(e2.get_component<position_c>() == position_c(1,2));
|
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()
|
const auto p = ecs::prototype()
|
||||||
.component<position_c>(1,2)
|
.component<position_c>(1,2)
|
||||||
|
|||||||
Reference in New Issue
Block a user