private void resetEntityPositionLookup() { entityPosLookup.clear(); for (Entity e : entities) { updateEntityPositionLookup(e, null); } }
public synchronized void setEntity(int id, Entity entity, Vector<UnitLocation> movePath) { final Entity oldEntity = getEntity(id); if (oldEntity == null) { addEntity(entity); } else { entity.setGame(this); entities.set(entities.indexOf(oldEntity), entity); entityIds.put(id, entity); // Get the collection of positions HashSet<Coords> oldPositions = oldEntity.getOccupiedCoords(); // Update position lookup table updateEntityPositionLookup(entity, oldPositions); // Not sure if this really required if (id > lastEntityId) { lastEntityId = id; } processGameEvent( new GameEntityChangeEvent(this, entity, movePath, oldEntity)); } assert (entities.size() == entityIds.size()) : "Set Entity Failed"; }
updateEntityPositionLookup(entity, null);