Look at these examples
public boolean walkToDestination(final Position dest, final BooleanSupplier bc, final boolean walkExact){
WalkingEvent walkingEvent = new WalkingEvent(dest);
walkingEvent.setEnergyThreshold(10);
walkingEvent.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return bc.getAsBoolean();
}
});
if (walkExact)
walkingEvent.setMinDistanceThreshold(0);
return getScript().execute(walkingEvent).hasFinished();
}
public boolean walkToDestination(final Position[] positions, final BooleanSupplier bc, final boolean walkExact){
WalkingEvent walkingEvent = new WalkingEvent();
walkingEvent.setPath(new LinkedList<>(Arrays.asList(positions)));
walkingEvent.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return bc.getAsBoolean();
}
});
if (walkExact)
walkingEvent.setMinDistanceThreshold(0);
walkingEvent.setMiniMapDistanceThreshold(0);
walkingEvent.setEnergyThreshold(random(5, 15));
return getScript().execute(walkingEvent).hasFinished();
}
public boolean walkToDestination(LinkedList<Position> path, BooleanSupplier bc, boolean walkExact) {
WalkingEvent walkingEvent = new WalkingEvent();
walkingEvent.setPath(path);
walkingEvent.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return bc.getAsBoolean();
}
});
if (walkExact)
walkingEvent.setMinDistanceThreshold(0);
walkingEvent.setMiniMapDistanceThreshold(0);
return getScript().execute(walkingEvent).hasFinished();
}