archetype!() { /* proc-macro */ }
Expand description
Declares archetypes.
§Example
use std::collections::BTreeSet;
use std::num::NonZeroU16;
dynec::archetype! {
/// This is an example archetype.
/// We can document it and apply attributes on it.
#[allow(dead_code)]
pub Foo;
/// Multiple archetypes can be declared in the same block
/// separated by semicolons.
/// The trailing semicolon is optional.
pub(crate) Bar;
/// Options can be applied in parentheses.
pub Qux(raw_entity = NonZeroU16, recycler = BTreeSet<NonZeroU16>);
}
static_assertions::assert_impl_all!(Foo: dynec::Archetype);
static_assertions::assert_impl_all!(Bar: dynec::Archetype);
Since documentation, attributes, visibility and the trailing semicolon are optional, a private undocumented archetype can be declared in a single line as well:
dynec::archetype!(Foo);
static_assertions::assert_impl_all!(Foo: dynec::Archetype);
§Options
Options are applied in parentheses after an archetype identifier. Multiple options are separated by commas.
§raw_entity = $ty
Selects the backing type for entity ID for entities of this archetype.
The default value is NonZeroU32
.
§recycler = $ty
Selects the data structure used in the recycling entity allocator to
recycle freed IDs.
The default value is Vec<#raw_entity>
.
§shard_assigner = $ty
Selects the strategy to assign available entity IDs
to different hsards.
The default value is ThreadRngShardAssigner
.