-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Ended up needing this on a new project...
/// [`Effect`] that inserts a component recursively on relationship targets.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect)]
pub struct EntityCommandInsertRecursive<RT, B>
where
RT: RelationshipTarget,
B: Bundle + Clone,
{
pub entity: Entity,
pub bundle: B,
_phantom: PhantomData<RT>,
}
impl<RT, B> EntityCommandInsertRecursive<RT, B>
where
B: Bundle + Clone,
RT: RelationshipTarget,
{
/// Construct a new [`EntityCommandInsertRecursive`].
fn new(entity: Entity, bundle: B) -> Self {
Self {
entity,
bundle,
_phantom: PhantomData,
}
}
}
impl<RT, B> Effect for EntityCommandInsertRecursive<RT, B>
where
RT: RelationshipTarget,
B: Bundle + Clone,
{
type MutParam = Commands<'static, 'static>;
fn affect(self, param: &mut <Self::MutParam as bevy::ecs::system::SystemParam>::Item<'_, '_>) {
param
.entity(self.entity)
.insert_recursive::<RT>(self.bundle);
}
}Metadata
Metadata
Assignees
Labels
No labels