@Override public void tick(TimeLapse timeLapse) { roadModel.get().moveTo(this, destination, timeLapse); }
@Override public void tick(TimeLapse timeLapse) { if (!destination.isPresent()) { nextDestination(); } final MoveProgress mp = roadModel.get().moveTo(this, destination.get(), timeLapse); if (roadModel.get().getPosition(this).equals(destination.get()) || stuckTickCount >= MAX_STUCK_TICK_COUNT) { nextDestination(); stuckTickCount = 0; } else if (mp.distance().getValue().doubleValue() == 0d) { stuckTickCount++; } else { stuckTickCount = 0; } }
@Override public void tick(TimeLapse timeLapse) { if (!destination.isPresent()) { nextDestination(); } final MoveProgress mp = roadModel.get().moveTo(this, destination.get(), timeLapse); if (roadModel.get().getPosition(this).equals(destination.get()) || stuckTickCount >= MAX_STUCK_TICK_COUNT) { nextDestination(); stuckTickCount = 0; } else if (mp.distance().getValue().doubleValue() == 0d) { stuckTickCount++; } else { stuckTickCount = 0; } }
@Override public void tick(TimeLapse timeLapse) { if (dest == null) { dest = roadModel.get().getRandomPosition(randomGenerator); } roadModel.get().moveTo(this, dest, timeLapse); if (roadModel.get().getPosition(this).equals(dest)) { dest = null; } }
model.addObjectAt(ru2, new Point(2.5, 1)); final MoveProgress mp = model.moveTo(ru1, new Point(2, 1), tick()); assertThat(Point.distance(model.getPosition(ru1), new Point(1.25, 1))) .isAtMost(PlaneRoadModel.DELTA); .isWithin(PlaneRoadModel.DELTA).of(.25); final MoveProgress mp2 = model.moveTo(ru1, new Point(2, 1), tick()); assertThat(Point.distance(model.getPosition(ru1), new Point(1.5, 1))) .isAtMost(PlaneRoadModel.DELTA); final MoveProgress mp1c = model.moveTo(ru1, new Point(2, 1), tick()); assertThat(Point.distance(model.getPosition(ru1), new Point(1.5, 1))) .isAtMost(PlaneRoadModel.DELTA); model.moveTo(ru3, new Point(2.5, 1), tick()); model.moveTo(ru3, new Point(2.5, 1), tick()); assertThat(Point.distance(model.getPosition(ru3), model.getPosition(ru2))) .isWithin(PlaneRoadModel.DELTA).of(1d); final MoveProgress mp3 = model.moveTo(ru3, new Point(2.5, 1), tick()); assertThat(mp3.distance().doubleValue(SI.METER)) .isWithin(PlaneRoadModel.DELTA).of(0d); final MoveProgress mp4 = model.moveTo(ru1, new Point(1, 1), tick());