bevy_ecs/world/
component_constants.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use super::*;
use crate::{self as bevy_ecs};
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::Reflect;
/// Internal components used by bevy with a fixed component id.
/// Constants are used to skip [`TypeId`] lookups in hot paths.

/// [`ComponentId`] for [`OnAdd`]
pub const ON_ADD: ComponentId = ComponentId::new(0);
/// [`ComponentId`] for [`OnInsert`]
pub const ON_INSERT: ComponentId = ComponentId::new(1);
/// [`ComponentId`] for [`OnRemove`]
pub const ON_REMOVE: ComponentId = ComponentId::new(2);

/// Trigger emitted when a component is added to an entity.
#[derive(Event)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
pub struct OnAdd;

/// Trigger emitted when a component is inserted on to to an entity.
#[derive(Event)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
pub struct OnInsert;

/// Trigger emitted when a component is removed from an entity.
#[derive(Event)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
pub struct OnRemove;