blob: 3de9cd500a5702f9516b7161b3e9362c1426b3dc (
plain)
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
29
30
31
32
|
use linkme::distributed_slice;
use crate::World;
#[allow(clippy::module_name_repetitions)]
#[macro_export]
macro_rules! static_entity {
($visibility: vis $ident: ident, $components: expr) => {
$visibility static $ident: ::std::sync::LazyLock<$crate::uid::Uid> =
::std::sync::LazyLock::new(|| {
$crate::uid::Uid::new_unique($crate::uid::Kind::Entity)
});
$crate::private::paste::paste! {
mod [<__ecs_ $ident:lower _static_entity_priv>] {
use super::*;
#[$crate::private::linkme::distributed_slice(
$crate::entity::CREATE_STATIC_ENTITIES
)]
#[linkme(crate=$crate::private::linkme)]
static CREATE_STATIC_ENTITY: fn(&$crate::World) = |world| {
world.create_entity_with_uid($components, *$ident);
};
}
}
}
}
#[distributed_slice]
#[doc(hidden)]
pub static CREATE_STATIC_ENTITIES: [fn(&World)];
|