2023-06-06 14:44:32 +00:00
|
|
|
use bevy_ecs::{event::Event, prelude::Entity};
|
2024-11-19 01:28:42 +00:00
|
|
|
#[cfg(feature = "reflect")]
|
2024-10-20 13:51:41 +00:00
|
|
|
use bevy_reflect::Reflect;
|
2022-07-10 20:29:06 +00:00
|
|
|
|
2022-09-26 21:47:31 +00:00
|
|
|
/// An [`Event`] that is fired whenever there is a change in the world's hierarchy.
|
2022-07-10 20:29:06 +00:00
|
|
|
///
|
|
|
|
/// [`Event`]: bevy_ecs::event::Event
|
2023-06-06 14:44:32 +00:00
|
|
|
#[derive(Event, Debug, Clone, PartialEq, Eq)]
|
2024-10-20 13:51:41 +00:00
|
|
|
#[cfg_attr(feature = "reflect", derive(Reflect), reflect(Debug, PartialEq))]
|
2022-07-10 20:29:06 +00:00
|
|
|
pub enum HierarchyEvent {
|
2022-09-26 21:47:31 +00:00
|
|
|
/// Fired whenever an [`Entity`] is added as a child to a parent.
|
2022-07-10 20:29:06 +00:00
|
|
|
ChildAdded {
|
2022-09-26 21:47:31 +00:00
|
|
|
/// The child that was added
|
2022-07-10 20:29:06 +00:00
|
|
|
child: Entity,
|
|
|
|
/// The parent the child was added to
|
|
|
|
parent: Entity,
|
|
|
|
},
|
2022-09-26 21:47:31 +00:00
|
|
|
/// Fired whenever a child [`Entity`] is removed from its parent.
|
2022-07-10 20:29:06 +00:00
|
|
|
ChildRemoved {
|
2022-09-26 21:47:31 +00:00
|
|
|
/// The child that was removed
|
2022-07-10 20:29:06 +00:00
|
|
|
child: Entity,
|
|
|
|
/// The parent the child was removed from
|
|
|
|
parent: Entity,
|
|
|
|
},
|
2022-09-26 21:47:31 +00:00
|
|
|
/// Fired whenever a child [`Entity`] is moved to a new parent.
|
2022-07-10 20:29:06 +00:00
|
|
|
ChildMoved {
|
2022-09-26 21:47:31 +00:00
|
|
|
/// The child that was moved
|
2022-07-10 20:29:06 +00:00
|
|
|
child: Entity,
|
|
|
|
/// The parent the child was removed from
|
|
|
|
previous_parent: Entity,
|
|
|
|
/// The parent the child was added to
|
|
|
|
new_parent: Entity,
|
|
|
|
},
|
|
|
|
}
|