jeffcampbellmakesgames / Entitas-Redux

An entity-component framework for Unity with code generation and visual debugging
MIT License
103 stars 13 forks source link

[FEATURE REQUEST] Modify CopyComponentTo code-gen for better copying #16

Closed jeffcampbellmakesgames closed 4 years ago

jeffcampbellmakesgames commented 4 years ago

Is your feature request related to a problem? Please describe. Currently the entity API CopyComponentTo performs a shallow copy of a component where a template instance's members's vales are assigned to a new component instance's members. This results in reference types being assigned directly, thus maintaining the reference instance of the same member between two different component instances. This includes members that are collections where the instance of the collection is assigned to both component instances. There is not currently an option that enables for deep copying a reference type member and/or copying the contents of a list to a new component collection member rather than assigning the collection itself.

Describe the solution you'd like Ideally, the outcome of a reference type member on a component being copied should be:

Describe alternatives you've considered I'd like to avoid heavy usage of runtime reflection as much as possible to reduce down on the performance hit this operation should take (especially since it has the capacity to be used in bulk for many entities from blueprints). Any reflection that takes place should either be small or cached for reuse.

Tasks

jeffcampbellmakesgames commented 4 years ago

Accomplished much of the implementation for a more nuanced copy logic for component members based on whether they are capable of supporting deep copy logic or not, looking to update/create unit tests and update documentation.

jeffcampbellmakesgames commented 4 years ago

This has been merged to develop.