API to retain bundle components on entities #10865
Labels
A-ECS
Entities, components, systems, and events
C-Feature
A new feature, making something new possible
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
What problem does this solve or what need does it fill?
Sometimes we want to remove all components except for a select few from an entity. One use case I've encountered this for is when trying to do events as entities. I want to remove/rest all the data from event entities while keeping the
Event
markers that annotates the entity is an event entity. This comes up for less experimental use cases too.What solution would you like?
A
fn retain<T: Bundle>(&mut self) -> &mut Self
API forEntityWorldMut
&EntityCommands
.What alternative(s) have you considered?
This will only work if the entity has all of the components in
B
. Theretain
API should work regardless of if all components inB
are present.The text was updated successfully, but these errors were encountered: