Class
TraverseEntities
View sourceDefines the contract for a relationship that can expose related entities.
Implementations return child EntityHandle values from
TraverseEntities#visit so relationship queries can traverse them.
They also implement TraverseEntities#map to remap the packed
EntityId values held by the relationship when entities are copied
or restored.
This class is an interface-like base contract. Both methods throw the abstract-method error until an implementing class overrides them.
Examples
import { EntityHandle } from '@wimaengine/ecs'
import { TraverseEntities } from '@wimaengine/relationship'
class ChildLinks extends TraverseEntities {
constructor(children) {
super()
this.children = children
}
visit() {
return this.children
}
map(entityMap) {
this.children = this.children.map((child) =>
EntityHandle.from(entityMap.get(child.id()))
)
}
}Constructor
Methods
visit(): EntityHandle[]
View sourceReturns the child entities exposed by this relationship.
Relationship queries call this method to continue traversal. The returned
values are EntityHandle instances, not packed entity IDs.
map(_entityMap: Map<number, number>): void
View sourceRemaps the entity IDs held by this relationship.
The map contains packed source-to-target EntityId values.
Implementations should use it to replace each relationship target with the
corresponding EntityHandle for the copied or restored entity.
