Search in sources :

Example 1 with RSNode

use of net.runelite.rs.api.RSNode in project runelite by runelite.

the class RSActorMixin method getHealth.

@Inject
@Override
public int getHealth() {
    RSCombatInfoList combatInfoList = getCombatInfoList();
    if (combatInfoList != null) {
        RSNode node = combatInfoList.getNode();
        RSNode next = node.getNext();
        if (next instanceof RSCombatInfoListHolder) {
            RSCombatInfoListHolder combatInfoListWrapper = (RSCombatInfoListHolder) next;
            RSCombatInfo2 cf = combatInfoListWrapper.getCombatInfo2();
            return cf.getHealthScale();
        }
    }
    return -1;
}
Also used : RSCombatInfoList(net.runelite.rs.api.RSCombatInfoList) RSCombatInfoListHolder(net.runelite.rs.api.RSCombatInfoListHolder) RSNode(net.runelite.rs.api.RSNode) RSCombatInfo2(net.runelite.rs.api.RSCombatInfo2) Inject(net.runelite.api.mixins.Inject)

Example 2 with RSNode

use of net.runelite.rs.api.RSNode in project runelite by runelite.

the class RSActorMixin method getHealthRatio.

@Inject
@Override
public int getHealthRatio() {
    RSCombatInfoList combatInfoList = getCombatInfoList();
    if (combatInfoList != null) {
        RSNode node = combatInfoList.getNode();
        RSNode next = node.getNext();
        if (next instanceof RSCombatInfoListHolder) {
            RSCombatInfoListHolder combatInfoListWrapper = (RSCombatInfoListHolder) next;
            RSCombatInfoList combatInfoList1 = combatInfoListWrapper.getCombatInfo1();
            RSNode node2 = combatInfoList1.getNode();
            RSNode next2 = node2.getNext();
            if (next2 instanceof RSCombatInfo1) {
                RSCombatInfo1 combatInfo = (RSCombatInfo1) next2;
                return combatInfo.getHealthRatio();
            }
        }
    }
    return -1;
}
Also used : RSCombatInfoList(net.runelite.rs.api.RSCombatInfoList) RSCombatInfoListHolder(net.runelite.rs.api.RSCombatInfoListHolder) RSNode(net.runelite.rs.api.RSNode) RSCombatInfo1(net.runelite.rs.api.RSCombatInfo1) Inject(net.runelite.api.mixins.Inject)

Example 3 with RSNode

use of net.runelite.rs.api.RSNode 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 4 with RSNode

use of net.runelite.rs.api.RSNode 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)

Aggregations

Inject (net.runelite.api.mixins.Inject)4 RSNode (net.runelite.rs.api.RSNode)4 Node (net.runelite.api.Node)2 RSCombatInfoList (net.runelite.rs.api.RSCombatInfoList)2 RSCombatInfoListHolder (net.runelite.rs.api.RSCombatInfoListHolder)2 ArrayList (java.util.ArrayList)1 Point (net.runelite.api.Point)1 WidgetNode (net.runelite.api.WidgetNode)1 RSCombatInfo1 (net.runelite.rs.api.RSCombatInfo1)1 RSCombatInfo2 (net.runelite.rs.api.RSCombatInfo2)1 RSHashTable (net.runelite.rs.api.RSHashTable)1