Search in sources :

Example 1 with Node

use of net.runelite.api.Node in project runelite by runelite.

the class RSHashTableMixin method getNodes.

@Inject
@Override
public Collection<Node> getNodes() {
    // Copied in RSWidgetMixin.getParentId to reduce allocations
    List<Node> nodes = new ArrayList<Node>();
    RSNode[] buckets = getBuckets();
    for (int i = 0; i < buckets.length; ++i) {
        Node node = buckets[i];
        // It looks like the first node in the bucket is always
        // a sentinel
        Node cur = node.getNext();
        while (cur != node) {
            nodes.add(cur);
            cur = cur.getNext();
        }
    }
    return nodes;
}
Also used : RSNode(net.runelite.rs.api.RSNode) Node(net.runelite.api.Node) RSNode(net.runelite.rs.api.RSNode) ArrayList(java.util.ArrayList) Inject(net.runelite.api.mixins.Inject)

Example 2 with Node

use of net.runelite.api.Node in project runelite by runelite.

the class RSWidgetMixin method getNestedChildren.

@Inject
@Override
public Widget[] getNestedChildren() {
    RSHashTable componentTable = client.getComponentTable();
    int group = -1;
    // iteration here...
    for (Node node : componentTable.getNodes()) {
        WidgetNode wn = (WidgetNode) node;
        if (wn.getHash() == getId()) {
            group = wn.getId();
            break;
        }
    }
    if (group == -1) {
        return new Widget[0];
    }
    List<Widget> widgets = new ArrayList<Widget>();
    for (Widget widget : client.getGroup(group)) {
        if (widget != null && widget.getParentId() == getId()) {
            widgets.add(widget);
        }
    }
    return widgets.toArray(new Widget[widgets.size()]);
}
Also used : RSNode(net.runelite.rs.api.RSNode) Node(net.runelite.api.Node) WidgetNode(net.runelite.api.WidgetNode) Widget(net.runelite.api.widgets.Widget) RSWidget(net.runelite.rs.api.RSWidget) ArrayList(java.util.ArrayList) WidgetNode(net.runelite.api.WidgetNode) RSHashTable(net.runelite.rs.api.RSHashTable) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 3 with Node

use of net.runelite.api.Node in project runelite by runelite.

the class RSClientMixin method getProjectiles.

@Inject
@Override
public List<Projectile> getProjectiles() {
    List<Projectile> projectiles = new ArrayList<Projectile>();
    RSDeque projectileDeque = this.getProjectilesDeque();
    Node head = projectileDeque.getHead();
    for (Node node = head.getNext(); node != head; node = node.getNext()) {
        projectiles.add((Projectile) node);
    }
    return projectiles;
}
Also used : RSDeque(net.runelite.rs.api.RSDeque) Node(net.runelite.api.Node) WidgetNode(net.runelite.api.WidgetNode) ArrayList(java.util.ArrayList) Projectile(net.runelite.api.Projectile) Inject(net.runelite.api.mixins.Inject)

Example 4 with Node

use of net.runelite.api.Node in project runelite by runelite.

the class RSWidgetMixin method getParentId.

@Inject
@Override
public int getParentId() {
    int parentId = getRSParentId();
    if (parentId != -1) {
        return parentId;
    }
    int groupId = TO_GROUP(getId());
    RSHashTable componentTable = client.getComponentTable();
    RSNode[] buckets = componentTable.getBuckets();
    for (int i = 0; i < buckets.length; ++i) {
        Node node = buckets[i];
        // It looks like the first node in the bucket is always
        // a sentinel
        Node cur = node.getNext();
        while (cur != node) {
            WidgetNode wn = (WidgetNode) cur;
            if (groupId == wn.getId()) {
                return (int) wn.getHash();
            }
            cur = cur.getNext();
        }
    }
    return -1;
}
Also used : RSNode(net.runelite.rs.api.RSNode) RSNode(net.runelite.rs.api.RSNode) Node(net.runelite.api.Node) WidgetNode(net.runelite.api.WidgetNode) WidgetNode(net.runelite.api.WidgetNode) RSHashTable(net.runelite.rs.api.RSHashTable) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 5 with Node

use of net.runelite.api.Node in project runelite by runelite.

the class DevToolsOverlay method renderGroundItems.

private void renderGroundItems(Graphics2D graphics, Tile tile, Player player) {
    ItemLayer itemLayer = tile.getItemLayer();
    if (itemLayer != null) {
        if (player.getLocalLocation().distanceTo(itemLayer.getLocalLocation()) <= MAX_DISTANCE) {
            Node current = itemLayer.getBottom();
            while (current instanceof Item) {
                Item item = (Item) current;
                OverlayUtil.renderTileOverlay(graphics, itemLayer, "ID: " + item.getId() + " Qty:" + item.getQuantity(), RED);
                current = current.getNext();
            }
        }
    }
}
Also used : ItemLayer(net.runelite.api.ItemLayer) WidgetItem(net.runelite.api.widgets.WidgetItem) Item(net.runelite.api.Item) Node(net.runelite.api.Node)

Aggregations

Node (net.runelite.api.Node)7 Inject (net.runelite.api.mixins.Inject)4 ArrayList (java.util.ArrayList)3 Item (net.runelite.api.Item)3 ItemLayer (net.runelite.api.ItemLayer)3 WidgetNode (net.runelite.api.WidgetNode)3 RSNode (net.runelite.rs.api.RSNode)3 Point (net.runelite.api.Point)2 Region (net.runelite.api.Region)2 Tile (net.runelite.api.Tile)2 LocalPoint (net.runelite.api.coords.LocalPoint)2 RSHashTable (net.runelite.rs.api.RSHashTable)2 Subscribe (com.google.common.eventbus.Subscribe)1 Color (java.awt.Color)1 ItemComposition (net.runelite.api.ItemComposition)1 MenuEntry (net.runelite.api.MenuEntry)1 Player (net.runelite.api.Player)1 Projectile (net.runelite.api.Projectile)1 Widget (net.runelite.api.widgets.Widget)1 WidgetItem (net.runelite.api.widgets.WidgetItem)1