[SOLVED] Are entity changes order maintained in EntitySets? [Zay-ES]

Hello everyone!

Sorry if this question has already been asked on the forum before.

Suppose I have two entities: entityA, entityB

And I want to update a component on them respectively:

entityA.set(new ComponentA());
entityB.set(new ComponentA());

Will the EntitySet that listens to “ComponentA”, maintain the order in which these entities are added/changed when I make a call to entitySet.getAddedEntities() or entitySet.getChangedEntities()?

Thanks in advance


Looks like it won’t maintain the order. Looking at the source code I noticed it internally uses a HashSet for keeping addedEntities and changedEntities.

Probably if you need this then there may be design shift in your code that may achieve what you really want.

Edit: think about it this way, any of those entity’s components might have changed 100 times between calls to applyChanges(). “Which entity had componentA changed first?” is a difficult question to answer.

…but moreover, it should be an unnecessary question. I suspect there may be a missing system or component but I cannot tell without knowing why you needed it.

1 Like

Yeah, there was a missing component :wink:

Thanks for the hint.

1 Like