}
if (weWouldLeaveArea(creature, Direction.STOP)) {
initArea(creature);
}
Direction currentDir = creature.getDirection();
if ((currentDir == Direction.STOP)
|| weWouldLeaveArea(creature, creature.getDirection())
|| creature.getZone().collides(creature, creature.getX() + currentDir.getdx(),
creature.getY() + currentDir.getdy())) {
for (int i = 0; i < 4; i++) {
currentDir = currentDir.nextDirection();
if (!weWouldLeaveArea(creature, currentDir)
&& !creature.getZone().collides(creature, creature.getX() + currentDir.getdx(),
creature.getY() + currentDir.getdy())) {
creature.setDirection(currentDir);
continue;
}
}
}