bevy_hierarchy/
events.rs

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