Commit 7fc458be authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Inform listeners if the end of the trajectory is reached

parent 84fd4c1b
......@@ -196,6 +196,10 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
routeSensor.setNewRoute(trajectory);
}
newPosition = trajectory.updateCurrentLocation(comp, getMovementSpeed(comp), tolerance);
if (trajectory.reachedDestination()) {
routeSensor.reachedDestination();
}
}
return new Left<PositionVector, Boolean>(newPosition);
}
......
......@@ -70,6 +70,8 @@ public class RouteImpl implements Route {
private int routeSegmentsLength;
private boolean reachedTarget;
/**
*
* @param start
......@@ -182,9 +184,25 @@ public class RouteImpl implements Route {
* TODO Segment handling (also inform listeners!)
*/
/*
* Reached target flag
*/
if (currentIndex >= routeLength) {
reachedTarget = true;
}
return newPosition;
}
/**
* True, if the trajectory is done and the node reached the target.s
*
* @return
*/
public boolean reachedDestination() {
return reachedTarget;
}
@Override
public String toString() {
return "\n\tfrom " + start.toString() + " to " + destination.toString()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment