Search in sources :

Example 1 with HashTable

use of org.powerbot.bot.rt6.client.HashTable in project powerbot by powerbot.

the class GroundItems method get.

protected List<GroundItem> get(int radius) {
    if (radius < 1) {
        radius = 110;
    }
    final List<GroundItem> items = new ArrayList<GroundItem>();
    final Client client = ctx.client();
    if (client == null) {
        return items;
    }
    final HashTable table = client.getItemTable();
    if (table.isNull()) {
        return items;
    }
    final int plane = client.getFloor();
    long id;
    NodeListCache cache;
    final Tile base = ctx.game.mapOffset();
    final Tile player = ctx.players.local().tile();
    if (base == Tile.NIL || player == Tile.NIL || !player.matrix(ctx).valid()) {
        return items;
    }
    final int bx = base.x(), mx = bx + 103, by = base.y(), my = by + 103;
    for (int x = Math.max(bx, player.x() - radius); x <= Math.min(mx, player.x() + radius); x++) {
        for (int y = Math.max(by, player.y() - radius); y <= Math.min(my, player.y() + radius); y++) {
            id = x | y << 14 | plane << 28;
            cache = org.powerbot.bot.rt6.HashTable.lookup(table, id, NodeListCache.class);
            if (cache.isNull()) {
                continue;
            }
            for (final ItemNode item : NodeQueue.get(cache.getDeque(), ItemNode.class)) {
                items.add(new GroundItem(ctx, new Tile(x, y, plane), item));
            }
        }
    }
    return items;
}
Also used : ItemNode(org.powerbot.bot.rt6.client.ItemNode) HashTable(org.powerbot.bot.rt6.client.HashTable) ArrayList(java.util.ArrayList) NodeListCache(org.powerbot.bot.rt6.client.NodeListCache) Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt6.client.Client)

Example 2 with HashTable

use of org.powerbot.bot.rt6.client.HashTable in project powerbot by powerbot.

the class Component method parentId.

public int parentId() {
    final Client client = ctx.client();
    final Widget component = getInternalComponent();
    if (client == null || component == null) {
        return -1;
    }
    final int pId = component.getParentId();
    if (pId != -1) {
        return pId;
    }
    final int uid = id() >>> 16;
    int i = 0;
    for (final ComponentNode node : new HashTable<ComponentNode>(client.getWidgetTable(), ComponentNode.class)) {
        if (uid == node.getUid()) {
            return (int) node.getId();
        }
        if (i++ >= 1500) {
            System.out.printf("WARNING: parentId operation killed -- beyond depth of %d.%n", 1500);
            break;
        }
    }
    return -1;
}
Also used : HashTable(org.powerbot.bot.rt6.HashTable) Widget(org.powerbot.bot.rt6.client.Widget) Client(org.powerbot.bot.rt6.client.Client) ComponentNode(org.powerbot.bot.rt6.client.ComponentNode) Point(java.awt.Point)

Aggregations

Client (org.powerbot.bot.rt6.client.Client)2 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 HashTable (org.powerbot.bot.rt6.HashTable)1 ComponentNode (org.powerbot.bot.rt6.client.ComponentNode)1 HashTable (org.powerbot.bot.rt6.client.HashTable)1 ItemNode (org.powerbot.bot.rt6.client.ItemNode)1 NodeListCache (org.powerbot.bot.rt6.client.NodeListCache)1 Widget (org.powerbot.bot.rt6.client.Widget)1 Tile (org.powerbot.script.Tile)1