Skip to content

Utils: ecs

ECS convenience queries.

Provides cached queries for common ECS patterns, such as retrieving entities at a given position or with certain components.

Functions here leverage caching to optimize repeated queries within a single state instance.

build_mutable_position_index(position_store)

Build a mutable reverse index from position to entity IDs.

entities_at(state, pos, position_index=None)

Return entity IDs at the given position.

entities_with_components_at(state, pos, *component_stores)

Return entity IDs at pos that have all specified components.

update_mutable_position_index(index, entity_id, old_pos, new_pos)

Update a mutable reverse index when an entity moves.