mlange-42 / arche

Arche is an archetype-based Entity Component System (ECS) for Go.
https://mlange-42.github.io/arche/
MIT License
131 stars 8 forks source link

Ensure Assign() copies components before notifying listeners #426

Closed g-getsov closed 3 weeks ago

g-getsov commented 3 weeks ago

When calling Assign(), listeners get notified of a ComponentAdded event after the exchange() happens but before the component gets copied. This means that if that component gets fetched in the listener it will be a "zero" component.

The changes in this PR ensure that components are copied before notifying listeners. It splits the internal exchange() function into exchange(), exchangeNoNotify() and notifyExchange(). This allows us to perform the copyTo() in the Assign() before notifying the listeners.

coveralls commented 3 weeks ago

Pull Request Test Coverage Report for Build 10682540960

Details


Totals Coverage Status
Change from base Build 10613042955: 0.0%
Covered Lines: 6385
Relevant Lines: 6385

💛 - Coveralls
mlange-42 commented 3 weeks ago

Nice! Thanks for spotting and fixing this. Just let me read the diff carefully...