int pointsCount = routeTemplate.getPointsCount();
if (pointsCount <= 0)
{
return false;
}
Route point = null;
int oldIndex = _routeIndex;
if (((_routeIndex + _direction) >= pointsCount) || ((_routeIndex + _direction) < 0))
{
if (LINEAR)
{
_direction *= -1;
_routeIndex += _direction;
point = routeTemplate.getPoints().get(_routeIndex);
}
else if (CYCLE)
{
_direction = 1;
_routeIndex = 0;
point = routeTemplate.getPoints().get(_routeIndex);
}
else if (TELEPORT)
{
_direction = 1;
_routeIndex = 0;
point = routeTemplate.getPoints().get(_routeIndex);
}
else if (RANDOM)
{
randomWalk();
}
}
else
{
_routeIndex += _direction;
point = routeTemplate.getPoints().get(_routeIndex);
}
Location nextLoc = point.getLoc();
long delay = (point.getDelay() <= 0) ? routeTemplate.getDelay() : point.getDelay();
if (_lastMove == 0)
{
_lastMove = System.currentTimeMillis() + delay;
_routeIndex = oldIndex;
return false;
}
else if (getActor().isMoving)
{
_routeIndex = oldIndex;
return false;
}
else if (RANDOM)
{
return false;
}
else if ((System.currentTimeMillis() - _lastMove) > delay)
{
getActor().moveToLocation(nextLoc, 0, true);
_lastMove = System.currentTimeMillis();
if (TELEPORT & point.getLastPoint())
{
getActor().teleToLocation(nextLoc);
_lastMove = System.currentTimeMillis();
}
}