-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
What problem does this solve or what need does it fill?
Working with dynamic collections of components (as might be used in advanced spawning patterns) is very painful at the moment: every straightforward path is blocked due to missing impls. This cannot be fixed in end user code, as they do not own the Component
trait, or the common wrapper types like Vec
and Box
.
What solution would you like?
- Implement
Component
forBox<dyn Component>
, which uses the box's data as the component. - Do similarly for
Rc
andArc
(and any other common smart pointers). - Implement
Bundle
forIntoIter<Item=Component>
, which combined with the above would allow us to use structs likeVec<Box<dyn Component>>
as bundles.
Notes:
- This will need to be done for each of the standard storage types, as we cannot vary the associated type found within the trait object.
- In practice, we may need
DynClone
for this pattern to actually work, which would probably force aDynComponent
trait layer.
What alternative(s) have you considered?
Other possible approaches:
- make
Bundle
itself object-safe, obviating 3. I don't think this will be feasible. - implement
Component
for&Component
, since we can get these out of our boxes. This doesn't work nicely though, due to the need to clone components out of a standard storage.
#1515 would provide an alternate path to some of the use cases.
Some very limited workarounds may exist using commands (and entity commands) in certain use cases.
Gingeh, minecrawler, ShawnClake, jwagner, dkharlan and 6 more
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Type
Projects
Status
Widget-ready