pub struct Query { /* private fields */ }Expand description
Represents how to pull specific entities and components out of the world for use by a System. Methods
in a Query can be chained to create more complex queries. All chains are treated like logical ANDs.
For example, the following Query:
use thomas::{Query, TerminalTransform, Identity, Component};
#[derive(Component)]
struct CustomComponent {}
Query::new()
.has::<TerminalTransform>()
.has_no::<CustomComponent>()
.has_where::<Identity>(|identity| identity.id == String::from("PLAYER"));Will match only for entities that have a TerminalTransform, AND do NOT have a CustomComponent, AND have an Identity
component where its id property equals "PLAYER", .
Implementations§
Source§impl Query
impl Query
pub fn new() -> Self
Sourcepub fn has<T: Component + 'static>(self) -> Self
pub fn has<T: Component + 'static>(self) -> Self
Specifies that a matching entity must have the provided component to be a match for the query.
Sourcepub fn has_no<T: Component + 'static>(self) -> Self
pub fn has_no<T: Component + 'static>(self) -> Self
Specifies that a matching entity may not have the provided component to be a match for the query.
Regardless of any potential matches from has, if an entity has any component specified by any
has_no calls on the query, that will entirely remove that entity from the ultimate list of matches.