Skip to content

Querying for multiple components at once #5

@pmrv

Description

@pmrv

Especially in the EntityManager.{pairs_for_type,components_for_entity} methods. As in

for entity, (instance1, instance2, …) in entity_manager.pairs_for_type (Component1, Component2, …):

or

instance1, instance2, … = entity_manager.component_for_entity (entity, Component1, Component2, …)

The former would only return entities and pairs which possess all of the given components.
The latter could still raise ecs.exceptions.NonexistentComponentTypeForEntity for the first component it failed to fetch for the entity.
I am often running into situations where I iterate over entities with a certain component but also need to fetch a couple of other components for that entity (though I am quite new to ECS and maybe I am just designing my components wrong) and being able to do this in one step would simplify stuff and make it "nicer".
Is something like this planed or would you accept patches implementing that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions