Search in sources :

Example 1 with ComponentNode

use of org.powerbot.bot.rt6.client.ComponentNode 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

Point (java.awt.Point)1 HashTable (org.powerbot.bot.rt6.HashTable)1 Client (org.powerbot.bot.rt6.client.Client)1 ComponentNode (org.powerbot.bot.rt6.client.ComponentNode)1 Widget (org.powerbot.bot.rt6.client.Widget)1