UNPKG

@dcl/ecs

Version:
33 lines (32 loc) 1.28 kB
import { Entity } from '../../engine/entity'; import { ComponentDefinition, IEngine } from '../../engine'; /** * Get an iterator of entities that follow a tree structure for a component * @public * @param engine - the engine running the entities * @param entity - the root entity of the tree * @param component - the parenting component to filter by * @returns An iterator of an array as [entity, entity2, ...] * * Example: * ```ts * const TreeComponent = engine.defineComponent('custom::TreeComponent', { * label: Schemas.String, * parent: Schemas.Entity * }) * * for (const entity of getComponentEntityTree(engine, entity, TreeComponent)) { * // entity in the tree * } * ``` */ export declare function getComponentEntityTree<T>(engine: Pick<IEngine, 'getEntitiesWith'>, entity: Entity, component: ComponentDefinition<T & { parent?: Entity; }>): Generator<Entity>; /** * Remove all components of each entity in the tree made with Transform parenting * @param engine - the engine running the entities * @param firstEntity - the root entity of the tree * @public */ export declare function removeEntityWithChildren(engine: Pick<IEngine, 'getEntitiesWith' | 'defineComponentFromSchema' | 'removeEntity' | 'defineComponent'>, entity: Entity): void;