Search in sources :

Example 1 with NodeDeque

use of org.powerbot.bot.rt4.client.NodeDeque in project powerbot by powerbot.

the class GroundItem method valid.

@Override
public boolean valid() {
    final Client c = ctx.client();
    if (c == null || node.isNull()) {
        return false;
    }
    final NodeDeque[][][] nd = c.getGroundItems();
    if (nd != null) {
        final int f = c.getFloor();
        if (f < 0 || f >= nd.length || nd[f] == null) {
            return false;
        }
        final Tile t = tile.tile().derive(-c.getOffsetX(), -c.getOffsetY());
        if (t.x() < 0 || t.y() < 0 || t.x() >= nd[f].length) {
            return false;
        }
        final NodeDeque[] nd2 = nd[f][t.x()];
        if (nd2 == null || t.y() >= nd2.length) {
            return false;
        }
        final NodeDeque d = nd2[t.y()];
        return d != null && NodeQueue.get(d, ItemNode.class).contains(node);
    }
    return false;
}
Also used : Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt4.client.Client) NodeDeque(org.powerbot.bot.rt4.client.NodeDeque) Point(java.awt.Point)

Example 2 with NodeDeque

use of org.powerbot.bot.rt4.client.NodeDeque in project powerbot by powerbot.

the class GroundItems method get.

private List<GroundItem> get(int radius, final int floor) {
    if (radius < 1) {
        radius = 110;
    }
    final List<GroundItem> r = new CopyOnWriteArrayList<GroundItem>();
    final Client client = ctx.client();
    final NodeDeque[][][] dequeArray;
    if (client == null || (dequeArray = client.getGroundItems()) == null) {
        return r;
    }
    final NodeDeque[][] rows;
    if (floor > -1 && floor < dequeArray.length) {
        rows = dequeArray[floor];
    } else {
        rows = null;
    }
    if (rows == null) {
        return r;
    }
    final List<GroundItem> list = new LinkedList<GroundItem>();
    final Tile tile = new Tile(client.getOffsetX(), client.getOffsetY(), floor);
    final Tile ct = ctx.players.local().tile().derive(-tile.x(), -tile.y());
    for (int x = Math.max(0, ct.x() - radius); x < Math.min(rows.length, ct.x() + radius + 1); x++) {
        final NodeDeque[] row = rows[x];
        if (row == null) {
            continue;
        }
        for (int y = Math.max(0, ct.y() - radius); y < Math.min(row.length, ct.y() + radius + 1); y++) {
            for (final ItemNode n : NodeQueue.get(row[y], ItemNode.class)) {
                list.add(new GroundItem(ctx, tile.derive(x, y), n));
            }
        }
    }
    return list;
}
Also used : ItemNode(org.powerbot.bot.rt4.client.ItemNode) Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt4.client.Client) NodeDeque(org.powerbot.bot.rt4.client.NodeDeque) LinkedList(java.util.LinkedList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)2 NodeDeque (org.powerbot.bot.rt4.client.NodeDeque)2 Tile (org.powerbot.script.Tile)2 Point (java.awt.Point)1 LinkedList (java.util.LinkedList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ItemNode (org.powerbot.bot.rt4.client.ItemNode)1