-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I have two complains about the current edict API:
- There is no way to get entities if one or another component is modified. The current
query::<(Modified<&A>, Modified<&B>)>()
means that both components are modified; - The tracked query without
Modified
likequery::<(&A, &B)>.tracked(&mut tracks)
is meaningless; - Mutation of
tracks
by query is not intuitive. I have to clonetracks
to pass it to multiple queries.
I propose this changes:
- Remove
Modified
query; - Remove methods like
World::for_each_tracked
andQueryRef::tracked_iter
; - Move
skip_chunk
andskip_item
fromQuery
toFilter
; - Add
Modified<T>
which owns it's tracks andModifiedSince<T>
which refers the tracks from outside. - Add
Or
andAnd
filters; - Add constructors
with::<T>()
,without::<T>()
,modified_since::<T>(tracks)
andmodified::<T>()
; - Add
.or(filter)
and.and(filter)
methods toFilter
trait; - Add methods like
World::for_each_filtered
andQueryRef::filter
or eventWorld::query_filtered
like bevy_ecs does.
Query with this changes will look like:
// the stateful filter is created outside the loop
let mut my_filter = with::<Foo>().or(with::<Bar>()).and(modified::<Baz>());
loop {
for _, (bar, baz) in world.query_filtered<(&Bar, &Baz)>(&mut my_filter) {
// do something
}
}
and with passing the tracks manually:
let mut tracks = world.tracks_now()
loop {
world.for_each_filtered::<(&Bar, &Baz)>(
&mut with::<Foo>()
.or(with::<Bar>())
.and(modified_since::<Baz>(tracks)),
|_, (bar. baz)| { ... } );
tracks = world.tracks_now(); // tracks is updated explicitly
}
Solves #10
Metadata
Metadata
Assignees
Labels
No labels