A plugin that enables a subset of entity relationship features for bevy
APACHE-2.0 License
Bot releases are visible (Hide)
Support bevy 0.13
Published by iiYese 10 months ago
RelationCommands
impl for EntityCommands
RelationId
conversion.Published by iiYese 12 months ago
Published by iiYese 12 months ago
Scope
.Scope
now works with Commands
and does not require a &mut World
.bevy_hierarchy
compatibility. All of the query APIs can be used to perform operations with bevy_hierarchy
edges.fn sys(
query: Query<(&C, Relations<Hierarchy>)>,
roots: Query<Entity, (With<Children>, Without<Parent>)>
) {
query.traverse::<Hierarchy>(roots.iter()).for_each(|c, _| {
// ..
})
}
Published by iiYese about 1 year ago
Abstains
, Branch
, Leaf
.SmallVec
s like bevy_hierarchy now).Track
API to track the last seen item from a query when traversing an edge.
fn sys(
mut foos: Query<&mut Foo>,
tree: Query<(Option<&Bar>, Relations<R>)>,
roots: Query<Entity, Root<R>>
) {
tree.traverse::<R>(roots.iter()).track(&mut foos).for_each(|foo, bar, _| {
// ..
});
}
fn sys(
tree: Query<(Foo, Relations<R>)>,
roots: Query<Entity, Root<R>>
) {
tree.traverse::<R>(roots.iter())
.track_self()
.fold_breadth(|foo, _| /*init*/, |accum, foo, _| /*fold*/)
.for_each(|accum, parent_foo, _, child_foo, _| {
// ..
});
}
Scope
API to be more declarative. Not all previous functionality will be possible.
world.spawn(bundle).scope::<ChildOf>(|scope| {
// x, y, z are implicitly `ChildOf` the last spawned entity
scope.add(x)
.add(y)
.add(z)
.scope::<ChildOf>(|scope| {
// a, b are implicitly `ChildOf` the last spawned entity (z)
scope.add(a)
.add(b);
});
});
aery
attribute.
Counted
, Recursive
, Total
, Poly
(previously multi), Symmetric
.#[derive(Relation)]
#[aery(Recursive)]
struct R;
Up
modifier. All opereations use hosts by default. To use targets use Up
.
fn sys(foos: Query<(&Foo, Relation<R>)>, starts: Query<Entity, Root<R>>) {
// descent
foos.traverse::<R>(starts.iter()).for_each(|foo, _| {
// ..
});
// ascent
foos.traverse::<Up<R>>(starts.iter()).for_each(|foo, _| {
// ..
});
}
.track_self()
.Join
s work for consistent defaults + better composability:
Up
for targets.Relations<R>
world query Item. This adds some rightward drift but significantly reduces API complexity & allows joins to work on tracked query items.ControlFlow
into JCF
and TCF
.Published by iiYese over 1 year ago
Doc fix
Published by iiYese over 1 year ago
0.11
This is decently sized release with quite a few new things.
ControlFlow
variant: Probe
.---- src/lib.rs - (line 20) stdout ----
error[E0080]: evaluation of `<Likes as aery::relation::ZstOrPanic>::ZST_OR_PANIC` failed
--> /home/yogii/Repos/aery/src/relation.rs:142:13
|
142 | panic!("Not a ZST")
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Not a ZST', /home/yogii/Repos/aery/src/relation.rs:142:13
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
note: erroneous constant used
--> src/lib.rs:47:10
|
29 | #[derive(Relation)]
| ^^^^^^^^
|
Scope
API to spawn and manipulate hierarchies.
wrld.spawn(A)
.scope::<R>(|_, mut ent| {
ent.insert(B);
ent.scope::<R>(|_, mut ent| {
ent.insert(C);
});
});
#[derive(Relation)]
#[symmetric]
struct R;
fn sys(mut events: EventReader<TargetEvent>) {
for e in events.iter() {
// Did some entity set an `R` to some other entity?
if e.matches(Wc, TargetOp::Set, R, Wc) {
// ..
}
}
}
fn sys(query: Query<(A, Relations<R>)>, roots: Query<Entity, Root<R>>) {
query.ops().traverse_targets::<R>().for_each(|a, a_ancestor| {
// ..
})
}
prelude
..breadth_first::<R>(roots)
-> .traverse::<R>(roots)
RelationCommands
reworked and no longer implemented for Commands
and World
. New implementation is for EntityMut<'_>
with a new API.Published by iiYese over 1 year ago
Set
command.Relation
.// Change cleanup behavior
#[derive(Relation)]
#[cleanup(policy = "Recursive")]
struct R;
// Change arity
#[derive(Relation)]
#[multi]
struct R;
fn sys(a: Query<(&A, Relations<R>)>, roots: Query<Entity, Root<R>>) {
q.ops().breadth_first::<R>(roots.iter()).for_each(|a_ancestor, a| {
// ..
})
}
UnsetAll
command to remove all relation targets of a given type from an entity.Withdraw
command for entities to remove themselves as targets from relations of a given type.ControlFlow
options
ControlFlow::FastForward(n)
: Advance the nth join to the next valid permutation skipping any permutations in between.ControlFlow::Walk
: Walk to the next entity in a traversal, skipping any remaining permutations to iterate for the current entity.