Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Changed<T> and Without<T> to Query #38

Open
Exiled1 opened this issue Mar 21, 2023 · 2 comments
Open

Add Changed<T> and Without<T> to Query #38

Exiled1 opened this issue Mar 21, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Exiled1
Copy link
Contributor

Exiled1 commented Mar 21, 2023

Similar to what bevy does, the ability to query for entities that have some components but not others could be quite useful in the ECS api. (Without<Component>)

The same goes with knowing if any component attached to an entity has Changed. (Changed<Component>)

@Exiled1 Exiled1 changed the title Add Change<T> and Without<T> to Query Add Changed<T> and Without<T> to Query Mar 21, 2023
@Exiled1
Copy link
Contributor Author

Exiled1 commented Mar 26, 2023

In order of difficulty:
Change : Mid-Hard
Without: Medium
Or: Easy

@Masterchef365 Masterchef365 added the enhancement New feature or request label May 4, 2023
@Masterchef365
Copy link
Contributor

Thinking about the interface for this, maybe it could be like:

Query::new()
    .intersect::<Transform>()
    .exclude::<SomeComponent>() // Filters for entities without SomeComponent
    .changed() // Applies to the entire entity; if ANY component changed then the entity is included in the query result

We don't need union() because having multiple queries covers this use-case. Technically, we don't need exclude() either, since you could use two queries and the planned has_component() interface to acheive the same results - but it's less efficient and less ergonomic so I think we should still add exclude().

Note that the behavior for exclude() would be that it only applies to entities which have been included by other terms; I.e. Query::new().exclude::<AnyComponentHere>() would always return an empty query result because there is no .intersect().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants