Search in sources :

Example 1 with LocalPoint

use of net.runelite.api.coords.LocalPoint in project runelite by runelite.

the class CannonOverlay method drawDoubleHitSpots.

/**
 * Draw the double hit spots on a 6 by 6 grid around the cannon
 * @param startTile The position of the cannon
 */
private void drawDoubleHitSpots(Graphics2D graphics, LocalPoint startTile, Color color) {
    for (int x = -3; x <= 3; x++) {
        for (int y = -3; y <= 3; y++) {
            if (y != 1 && x != 1 && y != -1 && x != -1) {
                continue;
            }
            // Ignore center square
            if (y >= -1 && y <= 1 && x >= -1 && x <= 1) {
                continue;
            }
            int xPos = startTile.getX() - (x * LOCAL_TILE_SIZE);
            int yPos = startTile.getY() - (y * LOCAL_TILE_SIZE);
            LocalPoint marker = new LocalPoint(xPos, yPos);
            Polygon poly = Perspective.getCanvasTilePoly(client, marker);
            if (poly == null) {
                continue;
            }
            OverlayUtil.renderPolygon(graphics, poly, color);
        }
    }
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Polygon(java.awt.Polygon) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point)

Example 2 with LocalPoint

use of net.runelite.api.coords.LocalPoint in project runelite by runelite.

the class CannonOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!plugin.isCannonPlaced() || plugin.getCannonPosition() == null) {
        return null;
    }
    LocalPoint cannonPoint = LocalPoint.fromWorld(client, plugin.getCannonPosition());
    if (cannonPoint == null) {
        return null;
    }
    LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
    if (localLocation.distanceTo(cannonPoint) <= MAX_DISTANCE) {
        Point cannonLoc = Perspective.getCanvasTextLocation(client, graphics, cannonPoint, String.valueOf(plugin.getCballsLeft()), 200);
        if (cannonLoc != null) {
            textComponent.setText(String.valueOf(plugin.getCballsLeft()));
            textComponent.setPosition(new java.awt.Point(cannonLoc.getX(), cannonLoc.getY()));
            textComponent.setColor(plugin.getStateColor());
            textComponent.render(graphics);
        }
        if (config.showDoubleHitSpot()) {
            Color color = config.highlightDoubleHitColor();
            drawDoubleHitSpots(graphics, cannonPoint, color);
        }
    }
    return null;
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Color(java.awt.Color) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point)

Example 3 with LocalPoint

use of net.runelite.api.coords.LocalPoint in project runelite by runelite.

the class CannonSpotOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!config.showCannonSpots() || plugin.isCannonPlaced()) {
        return null;
    }
    for (WorldPoint spot : plugin.getSpotPoints()) {
        if (spot.getPlane() != client.getPlane()) {
            continue;
        }
        LocalPoint spotPoint = LocalPoint.fromWorld(client, spot);
        LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
        if (spotPoint != null && localLocation.distanceTo(spotPoint) <= MAX_DISTANCE) {
            renderCannonSpot(graphics, client, spotPoint, itemManager.getImage(CANNONBALL), Color.RED);
        }
    }
    return null;
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) WorldPoint(net.runelite.api.coords.WorldPoint)

Example 4 with LocalPoint

use of net.runelite.api.coords.LocalPoint in project runelite by runelite.

the class EmoteClue method makeWorldOverlayHint.

@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin) {
    LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
    if (localLocation == null) {
        return;
    }
    OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, EMOTE_IMAGE, Color.ORANGE);
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint)

Example 5 with LocalPoint

use of net.runelite.api.coords.LocalPoint in project runelite by runelite.

the class ConveyorBeltOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!config.showConveyorBelt() || plugin.getConveyorBelt() == null) {
        return null;
    }
    LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
    Point mousePosition = client.getMouseCanvasPosition();
    GameObject object = plugin.getConveyorBelt();
    LocalPoint location = object.getLocalLocation();
    if (localLocation.distanceTo(location) <= MAX_DISTANCE) {
        Area objectClickbox = object.getClickbox();
        if (objectClickbox != null) {
            if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) {
                graphics.setColor(Color.RED.darker());
            } else {
                graphics.setColor(Color.RED);
            }
            graphics.draw(objectClickbox);
            graphics.setColor(new Color(0xFF, 0, 0, 20));
            graphics.fill(objectClickbox);
        }
    }
    return null;
}
Also used : Area(java.awt.geom.Area) LocalPoint(net.runelite.api.coords.LocalPoint) GameObject(net.runelite.api.GameObject) Color(java.awt.Color) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point)

Aggregations

LocalPoint (net.runelite.api.coords.LocalPoint)33 Point (net.runelite.api.Point)8 Polygon (java.awt.Polygon)7 Color (java.awt.Color)5 WorldPoint (net.runelite.api.coords.WorldPoint)5 FontMetrics (java.awt.FontMetrics)4 GameObject (net.runelite.api.GameObject)4 Rectangle2D (java.awt.geom.Rectangle2D)3 Player (net.runelite.api.Player)3 Tile (net.runelite.api.Tile)3 Area (java.awt.geom.Area)2 Region (net.runelite.api.Region)2 ProgressPie (net.runelite.client.ui.overlay.components.ProgressPie)2 Subscribe (com.google.common.eventbus.Subscribe)1 Inject (com.google.inject.Inject)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 Rectangle (java.awt.Rectangle)1 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1