hmm, im stumbling across this. Instead of a Hashmap, put an Arraylist in there and we’re done. I think its a good solution to the problem…
/**
* Detach an entity from the GameSystem
*
* @param entity,
* the entity to detach
*/
public void detachChild(Entity entity) {
entityRemovalList.add(entity);
}
/**
* Detach and entity from the GameSystem based on it's name
*
* @param name
*/
public void detachChild(String name) {
entityRemovalList.add(entityList.get(name));
}
And a loop in the update:
// now loop through all entities that are to be removed
for (int i = 0; i < entityRemovalList.size(); i++) {
entityList.remove(entityRemovalList.get(i));
}
DP