use of org.powerbot.script.Targetable in project powerbot by powerbot.
the class Movement method step.
/**
* Attempts to use the mini-map to step towards the {@link Locatable}.
*
* @param locatable The location of where to step towards.
* @return {@code true} if successfully clicked the mini-map, {@code false} otherwise.
*/
public boolean step(final Locatable locatable) {
Tile loc = locatable.tile();
if (!new TileMatrix(ctx, loc).onMap()) {
loc = closestOnMap(loc);
if (!new TileMatrix(ctx, loc).onMap()) {
return false;
}
}
final Tile t = loc;
final Filter<Point> f = new Filter<Point>() {
@Override
public boolean accept(final Point point) {
return ctx.input.click(true);
}
};
return ctx.input.apply(new Targetable() {
private final TileMatrix tile = new TileMatrix(ctx, t);
@Override
public Point nextPoint() {
return tile.mapPoint();
}
@Override
public boolean contains(final Point point) {
final Point p = tile.mapPoint();
final Rectangle t = new Rectangle(p.x - 2, p.y - 2, 4, 4);
return t.contains(point);
}
}, f);
}
use of org.powerbot.script.Targetable in project powerbot by powerbot.
the class Movement method step.
/**
* Steps towards the provided {@link Locatable}.
*
* @param locatable the locatable to step towards
* @return {@code true} if stepped; otherwise {@code false}
*/
public boolean step(final Locatable locatable) {
Tile loc = locatable.tile();
if (!new TileMatrix(ctx, loc).onMap()) {
loc = closestOnMap(loc);
}
final Tile t = loc;
final Filter<Point> f = new Filter<Point>() {
@Override
public boolean accept(final Point point) {
return ctx.input.click(true);
}
};
return ctx.input.apply(new Targetable() {
private final TileMatrix tile = new TileMatrix(ctx, t);
@Override
public Point nextPoint() {
return tile.mapPoint();
}
@Override
public boolean contains(final Point point) {
final Point p = tile.mapPoint();
final Rectangle t = new Rectangle(p.x - 2, p.y - 2, 4, 4);
return t.contains(point);
}
}, f);
}
Aggregations