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 { ...@@ -196,6 +196,10 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
routeSensor.setNewRoute(trajectory); routeSensor.setNewRoute(trajectory);
} }
newPosition = trajectory.updateCurrentLocation(comp, getMovementSpeed(comp), tolerance); newPosition = trajectory.updateCurrentLocation(comp, getMovementSpeed(comp), tolerance);
if (trajectory.reachedDestination()) {
routeSensor.reachedDestination();
}
} }
return new Left<PositionVector, Boolean>(newPosition); return new Left<PositionVector, Boolean>(newPosition);
} }
......
...@@ -70,6 +70,8 @@ public class RouteImpl implements Route { ...@@ -70,6 +70,8 @@ public class RouteImpl implements Route {
private int routeSegmentsLength; private int routeSegmentsLength;
private boolean reachedTarget;
/** /**
* *
* @param start * @param start
...@@ -182,9 +184,25 @@ public class RouteImpl implements Route { ...@@ -182,9 +184,25 @@ public class RouteImpl implements Route {
* TODO Segment handling (also inform listeners!) * TODO Segment handling (also inform listeners!)
*/ */
/*
* Reached target flag
*/
if (currentIndex >= routeLength) {
reachedTarget = true;
}
return newPosition; return newPosition;
} }
/**
* True, if the trajectory is done and the node reached the target.s
*
* @return
*/
public boolean reachedDestination() {
return reachedTarget;
}
@Override @Override
public String toString() { public String toString() {
return "\n\tfrom " + start.toString() + " to " + destination.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