Search in sources :

Example 16 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class VarbitMixin method getSetting.

@Inject
@Override
public int getSetting(Varbits varbit) {
    int varbitId = varbit.getId();
    RSVarbit v = varbitCache.getIfPresent(varbitId);
    if (v == null) {
        // load varbit into cache
        client.getVarbit(varbitId);
        RSNodeCache varbits = client.getVarbitCache();
        // get from cache
        v = (RSVarbit) varbits.get(varbitId);
        varbitCache.put(varbitId, v);
    }
    int[] varps = getVarps();
    int value = varps[v.getIndex()];
    int lsb = v.getLeastSignificantBit();
    int msb = v.getMostSignificantBit();
    int mask = (1 << ((msb - lsb) + 1)) - 1;
    return (value >> lsb) & mask;
}
Also used : RSVarbit(net.runelite.rs.api.RSVarbit) RSNodeCache(net.runelite.rs.api.RSNodeCache) Inject(net.runelite.api.mixins.Inject)

Example 17 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSItemContainerMixin method getItems.

@Inject
@Override
public Item[] getItems() {
    int[] itemIds = getItemIds();
    int[] stackSizes = getStackSizes();
    Item[] items = new Item[itemIds.length];
    for (int i = 0; i < itemIds.length; ++i) {
        RSItem item = client.createItem();
        item.setId(itemIds[i]);
        item.setQuantity(stackSizes[i]);
        items[i] = item;
    }
    return items;
}
Also used : RSItem(net.runelite.rs.api.RSItem) Item(net.runelite.api.Item) RSItem(net.runelite.rs.api.RSItem) Inject(net.runelite.api.mixins.Inject)

Example 18 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSDecorativeObjectMixin method getModel.

@Inject
private RSModel getModel() {
    RSRenderable renderable = getRenderable();
    if (renderable == null) {
        return null;
    }
    RSModel model;
    if (renderable instanceof Model) {
        model = (RSModel) renderable;
    } else {
        model = renderable.getModel();
    }
    return model;
}
Also used : RSRenderable(net.runelite.rs.api.RSRenderable) RSModel(net.runelite.rs.api.RSModel) Model(net.runelite.api.Model) RSModel(net.runelite.rs.api.RSModel) Inject(net.runelite.api.mixins.Inject)

Example 19 with Inject

use of net.runelite.api.mixins.Inject 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 20 with Inject

use of net.runelite.api.mixins.Inject in project runelite by runelite.

the class RSModelMixin method getConvexHull.

@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation) {
    List<Vertex> vertices = getVertices();
    // rotate vertices
    for (int i = 0; i < vertices.size(); ++i) {
        Vertex v = vertices.get(i);
        vertices.set(i, v.rotate(orientation));
    }
    List<Point> points = new ArrayList<Point>();
    for (Vertex v : vertices) {
        // Compute canvas location of vertex
        Point p = Perspective.worldToCanvas(client, localX - v.getX(), localY - v.getZ(), -v.getY());
        if (p != null) {
            points.add(p);
        }
    }
    // Run Jarvis march algorithm
    points = Jarvis.convexHull(points);
    if (points == null) {
        return null;
    }
    // Convert to a polygon
    Polygon p = new Polygon();
    for (Point point : points) {
        p.addPoint(point.getX(), point.getY());
    }
    return p;
}
Also used : Vertex(net.runelite.api.model.Vertex) ArrayList(java.util.ArrayList) Point(net.runelite.api.Point) Polygon(java.awt.Polygon) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Aggregations

Inject (net.runelite.api.mixins.Inject)57 Point (net.runelite.api.Point)20 FieldHook (net.runelite.api.mixins.FieldHook)20 ArrayList (java.util.ArrayList)14 LocalPoint (net.runelite.api.coords.LocalPoint)10 RSWidget (net.runelite.rs.api.RSWidget)6 Vertex (net.runelite.api.model.Vertex)5 Widget (net.runelite.api.widgets.Widget)5 Node (net.runelite.api.Node)4 RSNode (net.runelite.rs.api.RSNode)4 WidgetNode (net.runelite.api.WidgetNode)3 Triangle (net.runelite.api.model.Triangle)3 Polygon (java.awt.Polygon)2 MenuEntry (net.runelite.api.MenuEntry)2 Model (net.runelite.api.Model)2 NPC (net.runelite.api.NPC)2 Player (net.runelite.api.Player)2 Skill (net.runelite.api.Skill)2 WidgetItem (net.runelite.api.widgets.WidgetItem)2 RSCombatInfoList (net.runelite.rs.api.RSCombatInfoList)2