pub trait SpawnRelated: RelationshipTarget {
// Required methods
fn spawn<L: SpawnableList<Self::Relationship>>(
list: L,
) -> SpawnRelatedBundle<Self::Relationship, L>;
fn spawn_one<B: Bundle>(bundle: B) -> SpawnOneRelated<Self::Relationship, B>;
}
Expand description
RelationshipTarget
methods that create a Bundle
with a DynamicBundle::Effect
that:
- Contains the
RelationshipTarget
component, pre-allocated with the necessary space for spawned entities. - Spawns an entity (or a list of entities) that relate to the entity the
Bundle
is added to via theRelationshipTarget::Relationship
.
Required Methods§
Sourcefn spawn<L: SpawnableList<Self::Relationship>>(
list: L,
) -> SpawnRelatedBundle<Self::Relationship, L>
fn spawn<L: SpawnableList<Self::Relationship>>( list: L, ) -> SpawnRelatedBundle<Self::Relationship, L>
Returns a Bundle
containing this RelationshipTarget
component. It also spawns a SpawnableList
of entities, each related to the bundle’s entity
via RelationshipTarget::Relationship
. The RelationshipTarget
(when possible) will pre-allocate space for the related entities.
Sourcefn spawn_one<B: Bundle>(bundle: B) -> SpawnOneRelated<Self::Relationship, B>
fn spawn_one<B: Bundle>(bundle: B) -> SpawnOneRelated<Self::Relationship, B>
Returns a Bundle
containing this RelationshipTarget
component. It also spawns a single entity containing Bundle
that is related to the bundle’s entity
via RelationshipTarget::Relationship
.
let mut world = World::new();
world.spawn((
Name::new("Root"),
Children::spawn_one(Name::new("Child")),
));
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.