movedObjects.clear();
final Set<String> ids = gameObjects.keySet();
synchronized (gameObjects) {
for(String id : ids) {
final GameObject gameObject = gameObjects.get(id);
if (!gameObject.alive()) {
gameObjects.remove(gameObject);
notifyClientRemoved(new ClientRemovedEvent(null, gameObject.getId()));
continue;
}
synchronized (gameObject) {
final GameObjectLocation oldLocation = gameObject.getLocation();
// move to new location
gameObject.doMove(STEP_DELAY);
detectWallCollisions(gameObject);
final GameObjectLocation newLocation = gameObject.getLocation();
if (!newLocation.equals(oldLocation)) {
movedObjects.add(newLocation);
}
}
}