EcsRx / ecsrx.unity

A simple framework for unity using the ECS paradigm but with unirx for fully reactive systems.
MIT License
417 stars 65 forks source link

Pool.RemoveEntity should call Entity.RemoveAllComponents(). #24

Closed gregee123 closed 7 years ago

gregee123 commented 7 years ago

Pool.RemoveEntity should call Entity.RemoveAllComponents().

Not only it's a little code cleanup but the real reason is it would fire component removed event. That way I can still find out if a given instance of a component was removed even if it's because of removing the whole entity. Would simplify disposing of some subscriptions to component property changes.

Also, this would add functionality through removing code.

grofit commented 7 years ago

sounds reasonable, will add this in. I think the original reason was as you say it would avoid triggering component removed for the entity, but if there are use cases where you need that then it will at least provide more use-case support for people. Will try to get this into the next release.

gregee123 commented 7 years ago

Maybe it would be more "canonical" if entity would implement IDisposable an then call its RemoveAllComponents() from Dispose()

grofit commented 7 years ago

This has been released in 0.8.0 feel free to re-open if there are any issues with this