Should I add a owner component on every entity that has parent? if yes, what is the right term for that component. Currently I am using AttachmentComponent
that consist of owner Entity
, and use it like in the below code.
AttachmentComponent ...
ItemComponent ...
entity.add(attachment);
entity.add(item);
If your entities can be hierarchical in nature, why introduce a component to represent the parent entity but instead represent it as an attribute on the entity itself?
You could also maintain a list on each
Entity
with all its relevant children should you need to traverse the entity hierarchy from top-down rather than bottom-up.