mirror of
https://github.com/bevyengine/bevy
synced 2025-01-06 18:28:59 +00:00
8eb0440f1e
## Objective Implement absolute minimum viable product for the changes proposed in bevyengine/rfcs#53. ## Solution - Remove public mutative access to `Parent` (Children is already publicly read-only). This includes public construction methods like `Copy`, `Clone`, and `Default`. - Remove `PreviousParent` - Remove `parent_update_system` - Update all hierarchy related commands to immediately update both `Parent` and `Children` references. ## Remaining TODOs - [ ] Update documentation for both `Parent` and `Children`. Discourage using `EntityCommands::remove` - [x] Add `HierarchyEvent` to notify listeners of hierarchy updates. This is meant to replace listening on `PreviousParent` ## Followup - These changes should be best moved to the hooks mentioned in #3742. - Backing storage for both might be best moved to indexes mentioned in the same relations.
32 lines
971 B
Rust
32 lines
971 B
Rust
use bevy_ecs::prelude::Entity;
|
|
|
|
/// A [`Event`] that is fired whenever there is a change in the world's
|
|
/// hierarchy.
|
|
///
|
|
/// [`Event`]: bevy_ecs::event::Event
|
|
#[derive(Debug, Clone)]
|
|
pub enum HierarchyEvent {
|
|
/// Fired whenever an [`Entity`] is added as a child to a new parent.
|
|
ChildAdded {
|
|
/// The child that added
|
|
child: Entity,
|
|
/// The parent the child was added to
|
|
parent: Entity,
|
|
},
|
|
/// Fired whenever an child [`Entity`] is removed from is parent.
|
|
ChildRemoved {
|
|
/// The child that removed
|
|
child: Entity,
|
|
/// The parent the child was removed from
|
|
parent: Entity,
|
|
},
|
|
/// Fired whenever an child [`Entity`] is moved to a new parent.
|
|
ChildMoved {
|
|
/// The child that moved
|
|
child: Entity,
|
|
/// The parent the child was removed from
|
|
previous_parent: Entity,
|
|
/// The parent the child was added to
|
|
new_parent: Entity,
|
|
},
|
|
}
|