Allow the creation of Query directly from the World #3887
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
Uh oh!
There was an error while loading. Please reload this page.
What problem does this solve or what need does it fill?
Querying the world directly always the creation of
QueryState
, rather than returning aQuery
that can be worked with directly.This is directly relevant to:
Local
, but this is rarely done in practice.The existing approach is confusing to beginners, heavy on boilerplate and directly exposes end users to
QueryState
, which should largely be engine-internal.What solution would you like?
Create two core methods on
World
, replacing the currentWorld::query
andWorld::query_filtered
:World::query
: returns a stateless Query directly from the world. This is used in commands and integration tests.World::query_state
: returns aQueryState
. This is used in engine internals, and exclusive systems.In order to get this to work we need to:
Query
to store a&QueryState
or a newInternalQueryState
value, rather than just aQueryState
.Added
orChanged
are used with aInternalQueryState
.The example above becomes the much more direct and familiar:
What alternative(s) have you considered?
QueryState
when writing integration tests and custom commands. Very boilerplate heavy and confusing to new users.Additional context
Closely related to #3774.
The text was updated successfully, but these errors were encountered: