22#include "guillaume/components/hierarchy.hpp"
30 return _parentIdentifier;
36 if (_parentIdentifier != identifier) {
37 _parentIdentifier = identifier;
48 const std::vector<ecs::Entity::Identifier> &
51 return _childIdentifiers;
56 return std::find(_childIdentifiers.begin(), _childIdentifiers.end(),
58 != _childIdentifiers.end();
66 _childIdentifiers.push_back(identifier);
73 const auto iterator = std::find(_childIdentifiers.begin(),
74 _childIdentifiers.end(), identifier);
75 if (iterator == _childIdentifiers.end()) {
78 _childIdentifiers.erase(iterator);
90 if (_layer != layer) {
Place of an entity in the entity tree: its parent, its direct children and its depth.
bool hasParent(void) const noexcept
Check whether the entity has a parent.
bool removeChild(ecs::Entity::Identifier identifier)
Remove an entity from the direct children.
Hierarchy & setParentIdentifier(ecs::Entity::Identifier identifier)
Store the identifier of the parent entity.
std::int32_t getLayer(void) const noexcept
Get the depth of the entity in the tree.
Hierarchy & setLayer(std::int32_t layer)
Store the depth of the entity in the tree.
bool hasChild(ecs::Entity::Identifier identifier) const noexcept
Check whether an entity is a direct child of this one.
const std::vector< ecs::Entity::Identifier > & getChildIdentifiers(void) const noexcept
Get the direct children, in the order they were attached.
ecs::Entity::Identifier getParentIdentifier(void) const noexcept
Get the identifier of the parent entity.
bool addChild(ecs::Entity::Identifier identifier)
Append an entity to the direct children.
Hierarchy(void)=default
Construct the hierarchy of a root entity without children.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
State. Every class here is plain data attached to an entity.