gamedev-patterns-ts icon indicating copy to clipboard operation
gamedev-patterns-ts copied to clipboard

Small bug where Entity._components can never fully be empty

Open Joaqim opened this issue 3 years ago • 1 comments

Since index=0 evaluates as false, the last element will never be removed in _components.

https://github.com/soloschenko-grigoriy/gamedev-patterns-ts/blob/148f337040b8285a3debf032e137a9441591ed23/src/utils/ecs/entity.ts#L42

should be:

if (toRemove && index !== undefined) {

See: https://github.com/joaqim/gamedev-patterns-ts/commit/e84cbd06485dca97804ab5b47b358dbc2df9302d Where I also added test that would fail without this fix.

Joaqim avatar Jun 27 '21 18:06 Joaqim

Hello there! Good catch, thank you for sharing!

soloschenko-grigoriy avatar Jul 31 '21 17:07 soloschenko-grigoriy