remember to auto by reference

This commit is contained in:
Hartmut Seichter 2020-12-09 00:17:36 +01:00
parent 1f390f5a4d
commit 523d1d7668

View file

@ -26,11 +26,11 @@ void entity::add_child(entity& child)
// TODO: check circular dependencies
// declare child relationship
auto r = get_or_create_component<relationship>();
auto& r = get_or_create_component<relationship>();
r.children.push_back(child._entity);
// declare parent
auto p_r = child.get_or_create_component<relationship>();
auto& p_r = child.get_or_create_component<relationship>();
p_r.parent = _entity;
}
@ -45,13 +45,13 @@ void entity::remove_child(entity& child)
if (has_component<relationship>() && child.has_component<relationship>())
{
// we need to check if the child is related to the parent
auto r_p = child.get_component<relationship>();
auto& r_p = child.get_component<relationship>();
if (r_p.parent == _entity)
{
// now go ahead
r_p.parent = entt::null;
auto r = get_component<relationship>();
auto& r = get_component<relationship>();
std::remove(r.children.begin(),r.children.end(),child._entity);
}