Ukendio / jecs

A fast, portable Entity Component System for Luau
https://ukendio.github.io/jecs/
MIT License
121 stars 20 forks source link

Add backwards iteration #61

Closed Ukendio closed 2 months ago

Ukendio commented 2 months ago

Partial implementation for #62. A backwards iterator works for two of the more rudimentary cases which is you are adding an entity matching against the query. And the other when you are unmatching the currently iterated entity from the query.

This implementation have a few cases that are UB, such as moving an entity to a different archetype that also satisfies the conditions of the query, or unmatching an entity that is not at the current row of the iterator.

This is a short term solution that will not replace Stages, but this will prevent two of the more common issues that actively cause detrimental bugs, however some logical bugs may occur from seeing the same entity more than once.