Skip to content

Commit

Permalink
Migrate to bevy 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
iiYese committed Feb 18, 2024
1 parent 9b3b06c commit 081dc66
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 123 deletions.
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aery"
version = "0.5.2"
version = "0.6.0"
edition = "2021"
authors = ["iiYese iiyese@outlook.com"]
repository = "https://github.com/iiYese/aery"
Expand All @@ -12,19 +12,19 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy_app = "0.12"
bevy_derive = "0.12"
bevy_ecs = "0.12"
bevy_hierarchy = "0.12"
bevy_log = "0.12"
bevy_utils = "0.12"
bevy_app = "0.13"
bevy_derive = "0.13"
bevy_ecs = "0.13"
bevy_hierarchy = "0.13"
bevy_log = "0.13"
bevy_utils = "0.13"
smallvec = "1.11.0"
aery_macros = { path = "macros", version = "0.3.0-dev" }
aquamarine = "0.3.2"

[dev-dependencies]
bevy = "0.12"
bevy_vector_shapes = "0.6"
bevy = "0.13"
bevy_vector_shapes = "0.7"

[features]
default = ["aery"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ fn tick_devices(
### Version table
| Bevy version | Aery verison |
|--------------|--------------|
| 0.13 | 0.6 |
| 0.12 | 0.5 |
| 0.11 | 0.3 - 0.4 |
| 0.10 | 0.1 - 0.2 |
Expand Down
2 changes: 1 addition & 1 deletion examples/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn draw(mut painter: ShapePainter, tree: Query<&Pos>) {

fn input(
mut cmds: Commands,
mouse_buttons: Res<Input<MouseButton>>,
mouse_buttons: Res<ButtonInput<MouseButton>>,
windows: Query<&Window, With<PrimaryWindow>>,
nodes: Query<(Entity, &Pos)>,
) {
Expand Down
24 changes: 12 additions & 12 deletions src/edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
component::Component,
entity::Entity,
query::{Changed, Or, With, Without, WorldQuery},
query::{AnyOf, Changed, NopWorldQuery, Or, QueryData, QueryFilter, With, Without},
system::{Command, CommandQueue, EntityCommands, Resource},
world::{EntityWorldMut, World},
};
Expand Down Expand Up @@ -85,19 +85,19 @@ impl<R: Relation> Default for Targets<R> {
pub type EdgeIter<'a> = std::iter::Copied<std::slice::Iter<'a, Entity>>;

/// Edges world query for hierarchy compatibility
#[derive(WorldQuery)]
#[derive(QueryData)]
pub struct HierarchyEdges {
pub(crate) hosts: Option<&'static Children>,
pub(crate) target: Option<&'static Parent>,
pub(crate) _filter: Or<(With<Children>, With<Parent>)>,
pub(crate) _filter: NopWorldQuery<AnyOf<(&'static Children, &'static Parent)>>,
}

/// World query to get the edge info of a Relation.
#[derive(WorldQuery)]
#[derive(QueryData)]
pub struct Edges<R: Relation> {
pub(crate) hosts: Option<&'static Hosts<R>>,
pub(crate) targets: Option<&'static Targets<R>>,
pub(crate) _filter: Or<(With<Hosts<R>>, With<Targets<R>>)>,
pub(crate) _filter: NopWorldQuery<AnyOf<(&'static Hosts<R>, &'static Targets<R>)>>,
}

/// Get information from a single edge bucket.
Expand Down Expand Up @@ -167,33 +167,33 @@ pub(crate) struct OnDelete {
/// An entity is a root of `R` if:
/// - It is targeted by atleast one other entity via `R`.
/// - It does not target any other entity via `R`.
#[derive(WorldQuery)]
#[derive(QueryFilter)]
pub struct Root<R: Relation>((With<Hosts<R>>, Without<Targets<R>>));

/// Filter to find branches of a relationship graph.
/// A branch of `R` has **both** hosts and targets.
#[derive(WorldQuery)]
#[derive(QueryFilter)]
pub struct Branch<R: Relation>((With<Hosts<R>>, With<Targets<R>>));

/// Filter to find leaves of a relationship graph.
/// An entity is a leaf of `R` if:
/// - It targets atleast 1 other entity via `R`.
/// - It is not targeted by any other entity via `R`.
#[derive(WorldQuery)]
#[derive(QueryFilter)]
pub struct Leaf<R: Relation>((Without<Hosts<R>>, With<Targets<R>>));

/// Filter to find participants of a relationship.
/// A participant of `R` has **either** hosts or targets.
#[derive(WorldQuery)]
#[derive(QueryFilter)]
pub struct Participates<R: Relation>(Or<(With<Hosts<R>>, With<Targets<R>>)>);

/// Filter to find entities that do not participante in a relationship.
/// Ie. have no edges comming in or out.
#[derive(WorldQuery)]
#[derive(QueryFilter)]
pub struct Abstains<R: Relation>((Without<Hosts<R>>, Without<Targets<R>>));

/// Filter to check entities that recently had a relation changed.
#[derive(WorldQuery)]
#[derive(QueryFilter)]
pub struct EdgeChanged<R: Relation>(Or<(Changed<Hosts<R>>, Changed<Targets<R>>)>);

#[derive(Resource, Default, Deref, DerefMut)]
Expand Down Expand Up @@ -758,7 +758,7 @@ impl RelationCommands for EntityWorldMut<'_> {
}
}

impl RelationCommands for EntityCommands<'_, '_, '_> {
impl RelationCommands for EntityCommands<'_> {
fn set<R: Relation>(&mut self, target: Entity) -> &mut Self {
let _ = R::ZST_OR_PANIC;

Expand Down
2 changes: 1 addition & 1 deletion src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl TargetEvent {
/// let (foo, _) = a.single();
/// let (bar, _) = b.single();
///
/// for event in events.iter() {
/// for event in events.read() {
/// // Anything Set anything to anything else
/// if event.matches(Wc, Op::Set, Wc, Wc) {
/// if let Ok(a) = a.get(event.host) {
Expand Down
93 changes: 45 additions & 48 deletions src/for_each.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::tuple_traits::*;

use bevy_ecs::{
entity::Entity,
query::{ReadOnlyWorldQuery, WorldQuery},
query::{QueryData, QueryFilter, WorldQuery},
system::Query,
};

Expand Down Expand Up @@ -282,18 +282,18 @@ pub trait TraversalForEach<RS: RelationSet> {
Func: for<'a> FnMut(&mut Self::WQ<'a>, &RelationsItem<'a, RS>) -> Ret;
}

impl<Q, RS, F, Edge, E, Starts> TraversalForEach<RS>
for TraverseAnd<&'_ Query<'_, '_, (Q, Relations<RS>), F>, Edge, Starts>
impl<D, RS, F, Edge, E, Starts> TraversalForEach<RS>
for TraverseAnd<&'_ Query<'_, '_, (D, Relations<RS>), F>, Edge, Starts>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
{
type WQ<'wq> = <<Q as WorldQuery>::ReadOnly as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D::ReadOnly as WorldQuery>::Item<'wq>;

fn for_each<Func, Ret>(self, mut func: Func)
where
Expand Down Expand Up @@ -327,18 +327,18 @@ where
}
}

impl<Q, RS, F, Edge, E, Starts> TraversalForEach<RS>
for TraverseAnd<&'_ mut Query<'_, '_, (Q, Relations<RS>), F>, Edge, Starts>
impl<D, RS, F, Edge, E, Starts> TraversalForEach<RS>
for TraverseAnd<&'_ mut Query<'_, '_, (D, Relations<RS>), F>, Edge, Starts>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
{
type WQ<'wq> = <Q as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D as WorldQuery>::Item<'wq>;

fn for_each<Func, Ret>(self, mut func: Func)
where
Expand Down Expand Up @@ -388,19 +388,19 @@ pub trait RemoteTrackingTraversalForEach<RS: RelationSet, const N: usize> {
for<'t, 'a> FnMut(Self::Tracked<'t>, &mut Self::WQ<'a>, &RelationsItem<'a, RS>) -> Ret;
}

impl<Q, RS, F, Edge, E, Starts, Tracked, const N: usize> RemoteTrackingTraversalForEach<RS, N>
for TraverseAnd<&'_ Query<'_, '_, (Q, Relations<RS>), F>, Edge, Starts, Tracked>
impl<D, RS, F, Edge, E, Starts, Tracked, const N: usize> RemoteTrackingTraversalForEach<RS, N>
for TraverseAnd<&'_ Query<'_, '_, (D, Relations<RS>), F>, Edge, Starts, Tracked>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
Tracked: for<'a> Trackable<'a, N>,
{
type WQ<'wq> = <<Q as WorldQuery>::ReadOnly as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D::ReadOnly as WorldQuery>::Item<'wq>;
type Tracked<'t> = <Tracked as Trackable<'t, N>>::Out;

fn for_each<Func, Ret>(mut self, mut func: Func)
Expand Down Expand Up @@ -441,19 +441,19 @@ where
}
}

impl<Q, RS, F, Edge, E, Starts, Tracked, const N: usize> RemoteTrackingTraversalForEach<RS, N>
for TraverseAnd<&'_ mut Query<'_, '_, (Q, Relations<RS>), F>, Edge, Starts, Tracked>
impl<D, RS, F, Edge, E, Starts, Tracked, const N: usize> RemoteTrackingTraversalForEach<RS, N>
for TraverseAnd<&'_ mut Query<'_, '_, (D, Relations<RS>), F>, Edge, Starts, Tracked>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
Tracked: for<'a> Trackable<'a, N>,
{
type WQ<'wq> = <Q as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D as WorldQuery>::Item<'wq>;
type Tracked<'t> = <Tracked as Trackable<'t, N>>::Out;

fn for_each<Func, Ret>(mut self, mut func: Func)
Expand Down Expand Up @@ -513,18 +513,18 @@ pub trait SelfTrackingTraversalForEach<RS: RelationSet> {
) -> Ret;
}

impl<Q, RS, F, Edge, E, Starts> SelfTrackingTraversalForEach<RS>
for TraverseAnd<&'_ Query<'_, '_, (Q, Relations<RS>), F>, Edge, Starts, SelfTracking>
impl<D, RS, F, Edge, E, Starts> SelfTrackingTraversalForEach<RS>
for TraverseAnd<&'_ Query<'_, '_, (D, Relations<RS>), F>, Edge, Starts, SelfTracking>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
{
type WQ<'wq> = <<Q as WorldQuery>::ReadOnly as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D::ReadOnly as WorldQuery>::Item<'wq>;

fn for_each<Func, Ret>(self, mut func: Func)
where
Expand Down Expand Up @@ -571,18 +571,18 @@ where
}
}

impl<Q, RS, F, Edge, E, Starts> SelfTrackingTraversalForEach<RS>
for TraverseAnd<&'_ mut Query<'_, '_, (Q, Relations<RS>), F>, Edge, Starts, SelfTracking>
impl<D, RS, F, Edge, E, Starts> SelfTrackingTraversalForEach<RS>
for TraverseAnd<&'_ mut Query<'_, '_, (D, Relations<RS>), F>, Edge, Starts, SelfTracking>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
{
type WQ<'wq> = <Q as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D as WorldQuery>::Item<'wq>;

fn for_each<Func, Ret>(self, mut func: Func)
where
Expand Down Expand Up @@ -655,34 +655,31 @@ pub trait FoldingSelfTrackingTraversalForEach<RS: RelationSet> {
) -> Ret;
}

impl<Q, RS, F, Edge, E, Starts, Init, Fold, Acc, Err> FoldingSelfTrackingTraversalForEach<RS>
impl<D, RS, F, Edge, E, Starts, Init, Fold, Acc, Err> FoldingSelfTrackingTraversalForEach<RS>
for TraverseAnd<
&'_ Query<'_, '_, (Q, Relations<RS>), F>,
&'_ Query<'_, '_, (D, Relations<RS>), F>,
Edge,
Starts,
SelfTracking,
Init,
Fold,
>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
Init: for<'a> FnMut(
&mut <<Q as WorldQuery>::ReadOnly as WorldQuery>::Item<'a>,
&RelationsItem<'a, RS>,
) -> Acc,
Init: for<'a> FnMut(&mut <D::ReadOnly as WorldQuery>::Item<'a>, &RelationsItem<'a, RS>) -> Acc,
Fold: for<'a> FnMut(
Acc,
&mut <<Q as WorldQuery>::ReadOnly as WorldQuery>::Item<'a>,
&mut <D::ReadOnly as WorldQuery>::Item<'a>,
&RelationsItem<'a, RS>,
) -> Result<Acc, Err>,
{
type WQ<'wq> = <<Q as WorldQuery>::ReadOnly as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D::ReadOnly as WorldQuery>::Item<'wq>;
type Res = Result<Acc, Err>;

fn for_each<Func, Ret>(mut self, mut func: Func)
Expand Down Expand Up @@ -753,31 +750,31 @@ where
}
}

impl<Q, RS, F, Edge, E, Starts, Init, Fold, Acc, Err> FoldingSelfTrackingTraversalForEach<RS>
impl<D, RS, F, Edge, E, Starts, Init, Fold, Acc, Err> FoldingSelfTrackingTraversalForEach<RS>
for TraverseAnd<
&'_ mut Query<'_, '_, (Q, Relations<RS>), F>,
&'_ mut Query<'_, '_, (D, Relations<RS>), F>,
Edge,
Starts,
SelfTracking,
Init,
Fold,
>
where
Q: WorldQuery,
D: QueryData,
RS: RelationSet,
F: ReadOnlyWorldQuery,
F: QueryFilter,
Edge: EdgeSide,
E: Borrow<Entity>,
Starts: IntoIterator<Item = E>,
for<'i> RelationsItem<'i, RS>: RelationEntries,
Init: for<'a> FnMut(&mut <Q as WorldQuery>::Item<'a>, &RelationsItem<'a, RS>) -> Acc,
Init: for<'a> FnMut(&mut <D as WorldQuery>::Item<'a>, &RelationsItem<'a, RS>) -> Acc,
Fold: for<'a> FnMut(
Acc,
&mut <Q as WorldQuery>::Item<'a>,
&mut <D as WorldQuery>::Item<'a>,
&RelationsItem<'a, RS>,
) -> Result<Acc, Err>,
{
type WQ<'wq> = <Q as WorldQuery>::Item<'wq>;
type WQ<'wq> = <D as WorldQuery>::Item<'wq>;
type Res = Result<Acc, Err>;

fn for_each<Func, Ret>(mut self, mut func: Func)
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
//! // Set an items position to the position of the character that last had the item
//! // in their inventory when they drop it.
//! for event in events
//! .iter()
//! .read()
//! .filter(|event| event.matches(Wc, Op::Unset, Inventory, Wc))
//! {
//! let Ok(pos) = characters.get(event.target) else { return };
Expand Down
Loading

0 comments on commit 081dc66

Please sign in to comment.