aery

A plugin that enables a subset of entity relationship features for bevy

APACHE-2.0 License

Downloads
8.8K
Stars
142
Committers
4

Bot releases are hidden (Show)

aery - 0.6.0 Latest Release

Published by iiYese 8 months ago

Support bevy 0.13

aery - 0.5.2

Published by iiYese 10 months ago

  • Fix missing RelationCommands impl for EntityCommands
  • Fix missing trait impls for RelationId conversion.
  • Add set & scope examples to API tour.
  • Add basic examples.
  • Add change detection filter for edges.
  • Tidy up scope docs.
aery - 0.5.1

Published by iiYese 12 months ago

  • Use only required deps to better support projects that only use a subset of bevy crates.
aery - 0.5

Published by iiYese 12 months ago

  • Update to bevy 0.12.
  • Add missing docs for Scope.
  • Scope now works with Commands and does not require a &mut World.
  • Added partial 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, _| {
        // ..
    })
}
aery - 0.4

Published by iiYese about 1 year ago

  • New filters for relations: Abstains, Branch, Leaf.
  • Internals completely reworked for better performance & memory footprint (SmallVecs like bevy_hierarchy now).
  • New 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, _| {
            // ..
        });
    }
    
  • Derive macro can handle generic types now.
  • Fold breadth API for multi pass algorithms.
    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, _| {
                // ..
            });
    }
    

Breaking:

  • Yeet cursed option hack for relation commands + scope APIs.
  • Completely reworked 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);
             });
    });
    
  • Improved macro hygiene. All property overrides are done through the aery attribute.
    • Available attributes: Counted, Recursive, Total, Poly (previously multi), Symmetric.
    #[derive(Relation)]
    #[aery(Recursive)]
    struct R;
    
  • Edge direction changes for all operations is now done through the 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, _| {
            // ..
        });
    }
    
  • Traversal are reworked to make sense with new operations. By default traversal visits each node & to get the old 2 arity ancestor descendant permutations use .track_self().
  • Rework how Joins work for consistent defaults + better composability:
    • Join on hosts not targets by default which is more common and makes for a consistent edge default direction. Use Up for targets.
    • Separate Joins from Traversals. Joins must be done through the Relations<R> world query Item. This adds some rightward drift but significantly reduces API complexity & allows joins to work on tracked query items.
    • Split ControlFlow into JCF and TCF.
aery - 0.3.1

Published by iiYese over 1 year ago

Doc fix

aery - 0.3

Published by iiYese over 1 year ago

Bevy version

  • Bump to bevy 0.11

New in 0.3

This is decently sized release with quite a few new things.

  • New ControlFlow variant: Probe.
  • ZSTs for relations are now enforced at compile time.
    ---- 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)]
       |          ^^^^^^^^
       |
    
  • New 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);
            });
        });
    
  • Symmetric Relations.
    #[derive(Relation)]
    #[symmetric]
    struct R;
    
  • Relation events for target changes and entity cleanup.
    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) {
                // ..
            }
        }
    }
    
  • Hierarchy ascent is now supported along side the existing descent.
    fn sys(query: Query<(A, Relations<R>)>, roots: Query<Entity, Root<R>>) {
        query.ops().traverse_targets::<R>().for_each(|a, a_ancestor| {
            // ..
        })
    }
    

Breaking

  • Module restructures if you're not using prelude.
  • .breadth_first::<R>(roots) -> .traverse::<R>(roots)
  • Recursive cleanup no longer triggers when unsetting. This never made sense.
  • RelationCommands reworked and no longer implemented for Commands and World. New implementation is for EntityMut<'_> with a new API.

Misc

  • Many doc improvements & with illustrations in documentation with aquamarine.
    image
aery - 0.2

Published by iiYese over 1 year ago

New in 0.2

  • Logging for Set command.
  • Derive macros for Relation.
// Change cleanup behavior
#[derive(Relation)]
#[cleanup(policy = "Recursive")]
struct R;
// Change arity
#[derive(Relation)]
#[multi]
struct R;
  • Ancestors now provided when traversing a hierarchy.
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.
  • More granular 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.

Breaking changes

  • For each arity changes.
  • Various type and module name changes.

Other

  • License is now dual MIT + Apache 2.0.
  • Various doc improvements.