Add remove bundle to bevy_ecs commands (#579)
add remove bundle to bevy_ecs commands
This commit is contained in:
parent
85a7f883d1
commit
74ad1c3752
@ -112,6 +112,23 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Remove<T>
|
||||||
|
where
|
||||||
|
T: Bundle + Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
entity: Entity,
|
||||||
|
phantom: PhantomData<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> WorldWriter for Remove<T>
|
||||||
|
where
|
||||||
|
T: Bundle + Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
fn write(self: Box<Self>, world: &mut World) {
|
||||||
|
world.remove::<T>(self.entity).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait ResourcesWriter: Send + Sync {
|
pub trait ResourcesWriter: Send + Sync {
|
||||||
fn write(self: Box<Self>, resources: &mut Resources);
|
fn write(self: Box<Self>, resources: &mut Resources);
|
||||||
}
|
}
|
||||||
@ -319,6 +336,16 @@ impl Commands {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove<T>(&mut self, entity: Entity) -> &mut Self
|
||||||
|
where
|
||||||
|
T: Bundle + Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
self.write_world(Remove::<T> {
|
||||||
|
entity,
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_entity_reserver(&self, entity_reserver: EntityReserver) {
|
pub fn set_entity_reserver(&self, entity_reserver: EntityReserver) {
|
||||||
self.commands.lock().entity_reserver = Some(entity_reserver);
|
self.commands.lock().entity_reserver = Some(entity_reserver);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user