Hierarchy
Entities can be organized in hierarchies. When an entity is attached to another it becomes a child, while the entity nesting children is called a parent.Hierarchies are a convenient way to transform multiple entities from a single parent.
attach(child, parent)
Set an entity to be the child of another.
Arguments
child: Entity, the entity about to become a child.
parent: Entity, the entity that will be parent.
detach(entity)
Detach an entity from its parent, or do nothing if the entity has no parent.
Arguments
entity: Entity, a pointer to an entity in the world.
getParent(entity)
Get an entity's parent.
Arguments
entity: Entity, a pointer to an entity in the world.
Return
Entity , a pointer to an entity in the world, nil if the entity was not found.
getChildren(entity)
Get the children of an entity.
Arguments
entity: Entity, a pointer to an entity in the world.
Return
Table , a list of children.
findChildrenByTag(parent, tag)
Find child entities recursively by tag.
Arguments
parent: Entity
tag: string
Return
Table , a list of children.
findChildByName(parent, name)
Find child entities recursively by name.
Arguments
parent: Entity
name: string
Return
Table , a list of children.
cloneHierarchy(entity)
Clone an entity and all its children. Models in this hierarchy will be linked to the source.
Arguments
entity: Entity, a pointer to an entity in the world.
Return
Entity , a pointer to an entity in the world, nil if the entity was not found.
cloneEntities(entities)
Clone a list of entities. Children of the entities will be cloned only if they are part of the entities list.
Arguments
entities:
Return
Table , a list of entities.