Entity Queries
doonv opened this issue · 10 comments
Currently, you cannot access entities properties. In order to access entities properties we will need entity queries. Entity queries will be a built-in parser feature that will allow you to query the entities you choose and modify them.
Design
Todo list for the design of the entity queries.
- Design the syntax.
- Id queries
- This should probably be just the entity id, very simple.
- Single queries
- Queries for a single entity and provides access to all of their components.
- For-each queries
- Queries for a group of entities based on their components and executes a command on each of them.
- Id queries
- Figure out how to create dynamic reflection-based queries at runtime.
Implementation
After the design has been finished, we can start the implementation.
- Parsing
- Id Queries
- Single queries
- For-each queries
- Execution
- Id Queries
- Single queries
- For-each queries
I've designed a DSL for querying here https://github.com/nicopap/bevy_mod_dynamic_query/tree/main/examples/query_interpreter#query-grammar if you need some inspiration. You can always re-use the bevy type DSL though.
That looks cool, How will I go from the regular built-in parser to the DSL though?
I mean, you write a grammar that supports the rust syntax. The full parser for both syntax is defined here https://github.com/nicopap/bevy_mod_dynamic_query/blob/149b5d4a5a3611373b99b83bc9075cbd7d03b01e/examples/query_interpreter/src/query_parser.rs. Similarly to video game FX, no need to support all the intricacies of the rust syntax, it just need to look like it :P
I meant something like $( insert query here ).MyProperty = 5.4
. The $( ... )
transitions from the built-in parser's language to the Querying DSL. I kinda like the $( ... )
syntax what do you think?
Always can use a keyword that it a rust keyword, so that you are sure to avoid overlapping with pre-existing field names. For example for ( bindings ) in <query> { … }
. Or terser yet: for(<query>).…
(yield
?). I also like the functional style, swapping for
with map
.
@nicopap I'd like to use your bevy_mod_dynamic_query
library for this, and I have a few issues with it. but it looks like issues are disabled. Can you re-enable them?
Issues are now re-enabled on bevy_mod_dynamic_query
.
Thanks!
Ah turns out my issue is actually not a problem.
This is currently blocked by either of the following:
bevy_mod_dynamic_query
isnt updated for Bevy 0.12.- Bevy 0.13 has dynamic querying,
but it isn't released yet.