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

ComponentHook based Parent/Children Management #15635

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4d76fd3
Use `ComponentHooks` for `Parent` & `Children`
bushrat011899 Oct 3, 2024
e460c27
Merge remote-tracking branch 'upstream/main' into HookBasedRelationships
bushrat011899 Oct 3, 2024
c81436a
Fix docs
bushrat011899 Oct 3, 2024
f6b83c6
Fix documentation
bushrat011899 Oct 4, 2024
0e1844d
Remove needless allocation
bushrat011899 Oct 4, 2024
85e1beb
Refactored event types to be more ergonomic
bushrat011899 Oct 5, 2024
ed19f97
Silly Typo
bushrat011899 Oct 5, 2024
b3acfe4
Clippy
bushrat011899 Oct 5, 2024
cc676f6
Fix documentation
bushrat011899 Oct 5, 2024
e2bc4b9
Generalised `depsawn_recursive`
bushrat011899 Oct 6, 2024
c3ffe42
Fix benchmark
bushrat011899 Oct 6, 2024
add4631
Add inadvertently removed sorting methods
bushrat011899 Oct 6, 2024
8ae6ab2
Merge remote-tracking branch 'upstream/main' into HookBasedRelationships
bushrat011899 Oct 7, 2024
3a8f35c
Rename `OneToManyOne` and `OneToManyMany`
bushrat011899 Oct 17, 2024
4493faa
Remove redundant `on_remove` hooks
bushrat011899 Oct 19, 2024
0aad673
Updated documentation on `Parent` and `Children`
bushrat011899 Oct 19, 2024
ec1543c
Refactored Relationships into a new trait
bushrat011899 Oct 19, 2024
4932a93
Simplified `DespawnRecursive` Builder Pattern
bushrat011899 Oct 19, 2024
4c4cde5
Add Warning to `swap` methods
bushrat011899 Oct 19, 2024
60a08ec
Replaced references to `a` and `b` entities with `primary` and `foreign`
bushrat011899 Oct 19, 2024
f4c0adb
Formatting
bushrat011899 Oct 19, 2024
0080d67
Fixed Documentation
bushrat011899 Oct 19, 2024
a11fcc2
Updated crate documentation to call out invariant footguns
bushrat011899 Oct 19, 2024
acde0c8
Update crates/bevy_hierarchy/src/many_to_many.rs
bushrat011899 Oct 20, 2024
10b620b
Update crates/bevy_hierarchy/src/one_to_many.rs
bushrat011899 Oct 20, 2024
fa430a3
Merge remote-tracking branch 'upstream/main' into HookBasedRelationships
bushrat011899 Oct 20, 2024
794d460
Removed Generic Relationships
bushrat011899 Oct 20, 2024
402b010
Fix CI
bushrat011899 Oct 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
503 changes: 177 additions & 326 deletions crates/bevy_hierarchy/src/child_builder.rs

Large diffs are not rendered by default.

168 changes: 0 additions & 168 deletions crates/bevy_hierarchy/src/components/children.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/bevy_hierarchy/src/components/mod.rs

This file was deleted.

91 changes: 0 additions & 91 deletions crates/bevy_hierarchy/src/components/parent.rs

This file was deleted.

31 changes: 0 additions & 31 deletions crates/bevy_hierarchy/src/events.rs

This file was deleted.

38 changes: 38 additions & 0 deletions crates/bevy_hierarchy/src/family.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use crate::{OneToManyEvent, OneToManyMany, OneToManyOne};

/// A familial relationship
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
pub struct Family;

/// Holds a reference to the parent entity of this entity.
/// This component should only be present on entities that actually have a parent entity.
///
/// Parent entity must have this entity stored in its [`Children`] component.
/// It is hard to set up parent/child relationships manually,
/// consider using higher level utilities like [`BuildChildren::with_children`].
bushrat011899 marked this conversation as resolved.
Show resolved Hide resolved
///
/// See [`HierarchyQueryExt`] for hierarchy related methods on [`Query`].
///
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
/// [`Query`]: bevy_ecs::system::Query
/// [`BuildChildren::with_children`]: crate::child_builder::BuildChildren::with_children
pub type Parent = OneToManyOne<Family>;

/// Contains references to the child entities of this entity.
///
/// Each child must contain a [`Parent`] component that points back to this entity.
/// This component rarely needs to be created manually,
/// consider using higher level utilities like [`BuildChildren::with_children`]
/// which are safer and easier to use.
bushrat011899 marked this conversation as resolved.
Show resolved Hide resolved
///
/// See [`HierarchyQueryExt`] for hierarchy related methods on [`Query`].
///
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
/// [`Query`]: bevy_ecs::system::Query
/// [`BuildChildren::with_children`]: crate::child_builder::BuildChildren::with_children
pub type Children = OneToManyMany<Family>;

/// An [`Event`] that is fired whenever there is a change in the world's hierarchy.
///
/// [`Event`]: bevy_ecs::event::Event
pub type HierarchyEvent = OneToManyEvent<Family>;
Loading