World
Holds entities and their components. Entities are cheap handles; components are plain objects stored per ComponentType in dense arrays, so iterating one component type touches contiguous memory and a two-type query costs one array lookup per entity.
The world starts with room for initialCapacity entities, which must be positive, and grows as needed.
Not thread-safe.
Throws
if initialCapacity is not positive.
Functions
Returns the number of entities that have a type component.
Calls action for every entity that has an a component. Iterates the a components in storage order; do not add or remove components of this type inside action.
Calls action for every entity that has both an a and a b component. Iterates the a components in storage order; do not add or remove components of these types inside action.
Returns the parent of child, or null if it has none or is not alive.
Computes the WorldTransform of every entity that has a parent and a Transform.
Detaches child from its parent, making it a root whose Transform is in world space. Removes its WorldTransform right away, since only entities with a parent have one; its own children keep theirs. Does nothing if child has no parent.
Makes parent the parent of child, so child's Transform becomes relative to parent and destroy on parent also destroys child. If child already has a different parent it moves: it leaves the old parent's childrenOf and is appended to the end of parent's. Does nothing if parent already is the parent of child.