Closed JaimeGensler closed 9 months ago
Getting components from a query for a specific entity should be possible. This is especially useful when dealing with multiple queries:
export function moveCar( cars: Query<Car>, carPhysics: Query<[Entity, Transform], With<CarPhysics>>, carVisual: Query<[Entity, Transform], With<CarVisuals>> ) { for (const car of cars) { for (const [physicsEntity, physicsTransform] of carPhysics) { if (car.physicsId === entity.id) { for (const [visualEntity, visualTransform] of carVisual) { if (car.visualId == visualEntity.id) { // holy nesting! } } } } } }
could instead be
export function moveCar( cars: Query<Car>, carPhysics: Query<[Entity, Transform], With<CarPhysics>>, carVisual: Query<[Entity, Transform], With<CarVisuals>> ) { for (const car of cars) { const [physicsEntity, physicsTransform] = carPhysics.get(car.physicsId); const [visualEntity, visualTransform] = carVisual.get(car.visualId); // Much nicer! } }
The question of what happens when you call .get() with an entity that isn't in the query needs answering.
.get()
Queries will also need to know which group in the vector corresponds to which table.
Describe the problem this feature solves
Getting components from a query for a specific entity should be possible. This is especially useful when dealing with multiple queries:
could instead be
The question of what happens when you call
.get()
with an entity that isn't in the query needs answering.Queries will also need to know which group in the vector corresponds to which table.