remember to auto by reference
This commit is contained in:
parent
1f390f5a4d
commit
523d1d7668
1 changed files with 4 additions and 4 deletions
|
@ -26,11 +26,11 @@ void entity::add_child(entity& child)
|
||||||
// TODO: check circular dependencies
|
// TODO: check circular dependencies
|
||||||
|
|
||||||
// declare child relationship
|
// declare child relationship
|
||||||
auto r = get_or_create_component<relationship>();
|
auto& r = get_or_create_component<relationship>();
|
||||||
r.children.push_back(child._entity);
|
r.children.push_back(child._entity);
|
||||||
|
|
||||||
// declare parent
|
// declare parent
|
||||||
auto p_r = child.get_or_create_component<relationship>();
|
auto& p_r = child.get_or_create_component<relationship>();
|
||||||
p_r.parent = _entity;
|
p_r.parent = _entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ void entity::remove_child(entity& child)
|
||||||
if (has_component<relationship>() && child.has_component<relationship>())
|
if (has_component<relationship>() && child.has_component<relationship>())
|
||||||
{
|
{
|
||||||
// we need to check if the child is related to the parent
|
// 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)
|
if (r_p.parent == _entity)
|
||||||
{
|
{
|
||||||
// now go ahead
|
// now go ahead
|
||||||
r_p.parent = entt::null;
|
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);
|
std::remove(r.children.begin(),r.children.end(),child._entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue