bevy_hierarchy/events.rs
1use bevy_ecs::{event::Event, prelude::Entity};
2
3/// An [`Event`] that is fired whenever there is a change in the world's hierarchy.
4///
5/// [`Event`]: bevy_ecs::event::Event
6#[derive(Event, Debug, Clone, PartialEq, Eq)]
7pub enum HierarchyEvent {
8 /// Fired whenever an [`Entity`] is added as a child to a parent.
9 ChildAdded {
10 /// The child that was added
11 child: Entity,
12 /// The parent the child was added to
13 parent: Entity,
14 },
15 /// Fired whenever a child [`Entity`] is removed from its parent.
16 ChildRemoved {
17 /// The child that was removed
18 child: Entity,
19 /// The parent the child was removed from
20 parent: Entity,
21 },
22 /// Fired whenever a child [`Entity`] is moved to a new parent.
23 ChildMoved {
24 /// The child that was moved
25 child: Entity,
26 /// The parent the child was removed from
27 previous_parent: Entity,
28 /// The parent the child was added to
29 new_parent: Entity,
30 },
31}