Search in sources :

Example 6 with LocalPoint

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

the class RoguesDenOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!plugin.isHasGem()) {
        return null;
    }
    LocalPoint playerLocation = client.getLocalPlayer().getLocalLocation();
    plugin.getObstaclesHull().forEach((obstacle, tile) -> {
        if (tile.getPlane() == client.getPlane() && obstacle.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE) {
            Polygon p = tile.getGameObjects()[0].getConvexHull();
            if (p != null) {
                graphics.setColor(Color.CYAN);
                graphics.drawPolygon(p);
            }
        }
    });
    plugin.getObstaclesTile().forEach((obstacle, tile) -> {
        if (tile.getPlane() == client.getPlane() && obstacle.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE) {
            Polygon p = obstacle.getCanvasTilePoly();
            if (p != null) {
                graphics.setColor(Color.CYAN);
                graphics.drawPolygon(p);
            }
        }
    });
    return null;
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Polygon(java.awt.Polygon)

Example 7 with LocalPoint

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

the class TileIndicatorsOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    LocalPoint dest = client.getLocalDestinationLocation();
    if (dest == null) {
        return null;
    }
    Polygon poly = Perspective.getCanvasTilePoly(client, dest);
    if (poly == null) {
        return null;
    }
    OverlayUtil.renderPolygon(graphics, poly, config.highlightDestinationColor());
    return null;
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) Polygon(java.awt.Polygon)

Example 8 with LocalPoint

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

the class Hooks method projectileMoved.

/**
 * Called when a projectile is set to move towards a point. For
 * projectiles that target the ground, like AoE projectiles from
 * Lizardman Shamans, this is only called once
 *
 * @param projectile The projectile being moved
 * @param targetX X position of where the projectile is being moved to
 * @param targetY Y position of where the projectile is being moved to
 * @param targetZ Z position of where the projectile is being moved to
 * @param cycle
 */
public static void projectileMoved(Projectile projectile, int targetX, int targetY, int targetZ, int cycle) {
    LocalPoint position = new LocalPoint(targetX, targetY);
    ProjectileMoved projectileMoved = new ProjectileMoved();
    projectileMoved.setProjectile(projectile);
    projectileMoved.setPosition(position);
    projectileMoved.setZ(targetZ);
    eventBus.post(projectileMoved);
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) ProjectileMoved(net.runelite.api.events.ProjectileMoved)

Example 9 with LocalPoint

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

the class AgilityOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    LocalPoint playerLocation = client.getLocalPlayer().getLocalLocation();
    Point mousePosition = client.getMouseCanvasPosition();
    plugin.getObstacles().forEach((object, tile) -> {
        if (tile.getPlane() == client.getPlane() && object.getLocalLocation().distanceTo(playerLocation) < MAX_DISTANCE) {
            Area objectClickbox = object.getClickbox();
            if (objectClickbox != null) {
                Color configColor = config.getOverlayColor();
                if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) {
                    graphics.setColor(configColor.darker());
                } else {
                    graphics.setColor(configColor);
                }
                graphics.draw(objectClickbox);
                graphics.setColor(new Color(configColor.getRed(), configColor.getGreen(), configColor.getBlue(), 50));
                graphics.fill(objectClickbox);
            }
        }
    });
    return null;
}
Also used : Area(java.awt.geom.Area) LocalPoint(net.runelite.api.coords.LocalPoint) Color(java.awt.Color) LocalPoint(net.runelite.api.coords.LocalPoint) Point(net.runelite.api.Point)

Example 10 with LocalPoint

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

the class TrapOverlay method drawTimerOnTrap.

/**
 * Draws a timer on a given trap.
 *
 * @param graphics
 * @param trap The trap on which the timer needs to be drawn
 * @param fill The fill color of the timer
 * @param border The border color of the timer
 * @param fillTimeLow The fill color of the timer when it is low
 * @param borderTimeLow The border color of the timer when it is low
 */
private void drawTimerOnTrap(Graphics2D graphics, HunterTrap trap, Color fill, Color border, Color fillTimeLow, Color borderTimeLow) {
    if (trap.getWorldLocation().getPlane() != client.getPlane()) {
        return;
    }
    LocalPoint localLoc = LocalPoint.fromWorld(client, trap.getWorldLocation());
    if (localLoc == null) {
        return;
    }
    net.runelite.api.Point loc = Perspective.worldToCanvas(client, localLoc.getX(), localLoc.getY(), trap.getWorldLocation().getPlane());
    double timeLeft = 1 - trap.getTrapTimeRelative();
    ProgressPie pie = new ProgressPie();
    pie.setFill(timeLeft > TIMER_LOW ? fill : fillTimeLow);
    pie.setBorderColor(timeLeft > TIMER_LOW ? border : borderTimeLow);
    pie.render(graphics, loc, timeLeft);
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) ProgressPie(net.runelite.client.ui.overlay.components.ProgressPie)

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