Search in sources :

Example 1 with TileObject

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

the class HerbiboarOverlay method render.

@Override
public Dimension render(Graphics2D graphics) {
    if (!plugin.isInHerbiboarArea()) {
        return null;
    }
    HerbiboarTrail currentTrail = plugin.getCurrentTrail();
    int finishId = plugin.getFinishId();
    // Draw start objects
    if (config.isStartShown() && (currentTrail == null && finishId == 0)) {
        plugin.getStarts().keySet().forEach((obj) -> {
            OverlayUtil.renderTileOverlay(graphics, obj, "", config.getStartColor());
        });
    }
    // Draw trails
    if (config.isTrailShown()) {
        Set<Integer> shownTrailIds = plugin.getShownTrails();
        plugin.getTrails().keySet().forEach((x) -> {
            int id = x.getId();
            if (shownTrailIds.contains(id) && (finishId > 0 || (currentTrail != null && currentTrail.getTrailId() != id && currentTrail.getTrailId() + 1 != id))) {
                OverlayUtil.renderTileOverlay(graphics, x, "", config.getTrailColor());
            }
        });
    }
    // Draw trail objects (mushrooms, mud, etc)
    if (config.isObjectShown() && currentTrail != null) {
        int currentPath = plugin.getCurrentPath();
        plugin.getTrailObjects().keySet().forEach((obj) -> {
            WorldPoint loc = obj.getWorldLocation();
            WorldPoint[] trailLocs = currentTrail.getObjectLocs(currentPath);
            for (WorldPoint trailLoc : trailLocs) {
                if (trailLoc == null) {
                    continue;
                }
                if (trailLoc.equals(loc)) {
                    if (config.showClickBoxes()) {
                        Area clickbox = obj.getClickbox();
                        graphics.setColor(config.getObjectColor());
                        graphics.draw(clickbox);
                        graphics.setColor(new Color(255, 0, 255, 20));
                        graphics.fill(clickbox);
                    } else {
                        OverlayUtil.renderTileOverlay(graphics, obj, "", config.getObjectColor());
                    }
                }
            }
        });
    }
    // Draw finish tunnels
    if (config.isTunnelShown() && finishId > 0) {
        WorldPoint finishLoc = plugin.getEndLocations().get(finishId - 1);
        Map<TileObject, Tile> tunnels = plugin.getTunnels();
        tunnels.keySet().forEach((obj) -> {
            WorldPoint loc = obj.getWorldLocation();
            if (finishLoc.equals(loc)) {
                if (config.showClickBoxes()) {
                    Area clickbox = obj.getClickbox();
                    Color col = config.getObjectColor();
                    graphics.setColor(col);
                    graphics.draw(clickbox);
                    graphics.setColor(new Color(col.getRed(), col.getGreen(), col.getBlue(), 20));
                    graphics.fill(clickbox);
                } else {
                    OverlayUtil.renderTileOverlay(graphics, obj, "", config.getTunnelColor());
                }
            }
        });
    }
    return null;
}
Also used : Area(java.awt.geom.Area) WorldPoint(net.runelite.api.coords.WorldPoint) Color(java.awt.Color) TileObject(net.runelite.api.TileObject) Tile(net.runelite.api.Tile) WorldPoint(net.runelite.api.coords.WorldPoint)

Aggregations

Color (java.awt.Color)1 Area (java.awt.geom.Area)1 Tile (net.runelite.api.Tile)1 TileObject (net.runelite.api.TileObject)1 WorldPoint (net.runelite.api.coords.WorldPoint)1