Description
What problem does this solve or what need does it fill?
Creating copies of an entity is a powerful but simple abstraction. It's obviously useful for prefab workflows, but I'm also running into it when trying to create multiple copies of attacks and in similar gameplay code.
What solution would you like?
Create a fn clone_entity(entity: Entity)
method for Commands
. It would create a new entity with the same components and the same value of those components as the entity passed in.
What alternative(s) have you considered?
You can copy-paste the entity cloning code, but this is a lot of boilerplate and doesn't work well at all if the components in the entity aren't constant.
Additional context
Solving this is one of the proposed steps to resolve #1446.
This would only work on entities whose components all implement Clone
, which is common and not onerous, but requires some cleverness to capture. Alternatively, it could clone only those components that do implement clone, although you'd want a warning there.
Initial discussion on solving this in Discord.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status