bevy_ecs/world/
component_constants.rs

1use super::*;
2use crate::{self as bevy_ecs};
3#[cfg(feature = "bevy_reflect")]
4use bevy_reflect::Reflect;
5/// Internal components used by bevy with a fixed component id.
6/// Constants are used to skip [`TypeId`] lookups in hot paths.
7
8/// [`ComponentId`] for [`OnAdd`]
9pub const ON_ADD: ComponentId = ComponentId::new(0);
10/// [`ComponentId`] for [`OnInsert`]
11pub const ON_INSERT: ComponentId = ComponentId::new(1);
12/// [`ComponentId`] for [`OnRemove`]
13pub const ON_REMOVE: ComponentId = ComponentId::new(2);
14
15/// Trigger emitted when a component is added to an entity.
16#[derive(Event)]
17#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
18pub struct OnAdd;
19
20/// Trigger emitted when a component is inserted on to to an entity.
21#[derive(Event)]
22#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
23pub struct OnInsert;
24
25/// Trigger emitted when a component is removed from an entity.
26#[derive(Event)]
27#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
28pub struct OnRemove;