I noticed that there are no more components available in the set of removed components.
I see the point, since the components might not be available anymore. On the other side, it would save me a lot of hashmaps if i would have access to the components.
For example, i have a system that keeps track of players connecting and disconnecting.
Each entity has a component with SessionId,Name and so on.
I can easily track new players, but without a HashMap<EntityId,Name> i am not able to write a log message with the corresponding player name for disconnects.
The question is, if the usage of a local HashMap is the way to go, or am i just missing something?
You could also not remove the entity until you have sent the log message or fired all of the events or whatever. This implies that you have a “Leaving” component and a system that is interested in it. In my own cases, removing the entity is the last thing I do… once everything is done with it.
Technically it’s safer, I guess. There could be lots of reasons a component falls out of an entity set that may or may not leave it in a state that you’d want to see. For example, if could be leaving the entity set because the component you are interested in was really removed… in which case it’s state is only valid if that component is removed. Since removing the entity is just really removing all of its components then this is just an extension of that case.
This also makes sure that the ‘leaving’ events get fired even if the entity joined and left so fast that the naive entity set never even saw it. That’s a big problem with using entity removal (complete removal) as some kind of trigger to do something with the entity… since the entity doesn’t exist anymore. Better to do all logic while it exists.