Search in sources :

Example 1 with Region

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

the class RegionTileManager method forEachTile.

/**
 * Iterates over each tile in current region if player is logged in
 * @param consumer consumer accepting tile as parameter
 */
public void forEachTile(Consumer<Tile> consumer) {
    final Client client = clientProvider.get();
    if (client == null || client.getGameState() != GameState.LOGGED_IN) {
        return;
    }
    final Region region = client.getRegion();
    final Tile[][][] tiles = region.getTiles();
    int z = client.getPlane();
    for (int x = 0; x < REGION_SIZE; ++x) {
        for (int y = 0; y < REGION_SIZE; ++y) {
            Tile tile = tiles[z][x][y];
            if (tile == null) {
                continue;
            }
            consumer.accept(tile);
        }
    }
}
Also used : Region(net.runelite.api.Region) Tile(net.runelite.api.Tile) Client(net.runelite.api.Client)

Example 2 with Region

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

the class TileObjectQuery method getTiles.

protected List<Tile> getTiles(Client client) {
    List<Tile> tilesList = new ArrayList<>();
    Region region = client.getRegion();
    Tile[][][] tiles = region.getTiles();
    int z = client.getPlane();
    for (int x = 0; x < REGION_SIZE; ++x) {
        for (int y = 0; y < REGION_SIZE; ++y) {
            Tile tile = tiles[z][x][y];
            if (tile == null) {
                continue;
            }
            tilesList.add(tile);
        }
    }
    return tilesList;
}
Also used : ArrayList(java.util.ArrayList) Tile(net.runelite.api.Tile) Region(net.runelite.api.Region) LocalPoint(net.runelite.api.coords.LocalPoint) WorldPoint(net.runelite.api.coords.WorldPoint)

Example 3 with Region

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

the class MapClue method makeWorldOverlayHint.

@Override
public void makeWorldOverlayHint(Graphics2D graphics, ClueScrollPlugin plugin) {
    LocalPoint localLocation = LocalPoint.fromWorld(plugin.getClient(), getLocation());
    if (localLocation == null) {
        return;
    }
    // Mark game object
    if (objectId != -1) {
        Region region = plugin.getClient().getRegion();
        Tile[][][] tiles = region.getTiles();
        Tile tile = tiles[plugin.getClient().getPlane()][localLocation.getRegionX()][localLocation.getRegionY()];
        net.runelite.api.Point mousePosition = plugin.getClient().getMouseCanvasPosition();
        for (GameObject gameObject : tile.getGameObjects()) {
            if (gameObject != null) {
                OverlayUtil.renderHoverableArea(graphics, gameObject.getClickbox(), mousePosition, CLICKBOX_FILL_COLOR, CLICKBOX_BORDER_COLOR, CLICKBOX_HOVER_BORDER_COLOR);
                OverlayUtil.renderImageLocation(plugin.getClient(), graphics, localLocation, CLUE_SCROLL_IMAGE, IMAGE_Z_OFFSET);
            }
        }
    } else {
        OverlayUtil.renderTileOverlay(plugin.getClient(), graphics, localLocation, SPADE_IMAGE, Color.ORANGE);
    }
}
Also used : LocalPoint(net.runelite.api.coords.LocalPoint) GameObject(net.runelite.api.GameObject) Region(net.runelite.api.Region) Tile(net.runelite.api.Tile)

Example 4 with Region

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

the class DevToolsOverlay method renderTileObjects.

private void renderTileObjects(Graphics2D graphics) {
    Region region = client.getRegion();
    Tile[][][] tiles = region.getTiles();
    int z = client.getPlane();
    for (int x = 0; x < REGION_SIZE; ++x) {
        for (int y = 0; y < REGION_SIZE; ++y) {
            Tile tile = tiles[z][x][y];
            if (tile == null) {
                continue;
            }
            Player player = client.getLocalPlayer();
            if (player == null) {
                continue;
            }
            if (plugin.isToggleGroundItems()) {
                renderGroundItems(graphics, tile, player);
            }
            if (plugin.isToggleGroundObjects()) {
                renderGroundObject(graphics, tile, player);
            }
            if (plugin.isToggleGameObjects()) {
                renderGameObjects(graphics, tile, player);
            }
            if (plugin.isToggleWalls()) {
                renderWallObject(graphics, tile, player);
            }
            if (plugin.isToggleDecor()) {
                renderDecorObject(graphics, tile, player);
            }
        }
    }
}
Also used : Player(net.runelite.api.Player) Region(net.runelite.api.Region) Tile(net.runelite.api.Tile) LocalPoint(net.runelite.api.coords.LocalPoint)

Example 5 with Region

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

the class GroundItemsPlugin method checkItems.

void checkItems() {
    final Player player = client.getLocalPlayer();
    if (!dirty || player == null || client.getViewportWidget() == null) {
        return;
    }
    dirty = false;
    final Region region = client.getRegion();
    final Tile[][][] tiles = region.getTiles();
    final int z = client.getPlane();
    final LocalPoint from = player.getLocalLocation();
    final int lowerX = Math.max(0, from.getRegionX() - MAX_RANGE);
    final int lowerY = Math.max(0, from.getRegionY() - MAX_RANGE);
    final int upperX = Math.min(from.getRegionX() + MAX_RANGE, REGION_SIZE - 1);
    final int upperY = Math.min(from.getRegionY() + MAX_RANGE, REGION_SIZE - 1);
    groundItems.clear();
    for (int x = lowerX; x <= upperX; ++x) {
        for (int y = lowerY; y <= upperY; ++y) {
            Tile tile = tiles[z][x][y];
            if (tile == null) {
                continue;
            }
            ItemLayer itemLayer = tile.getItemLayer();
            if (itemLayer == null) {
                continue;
            }
            Node current = itemLayer.getBottom();
            // adds the items on the ground to the ArrayList to be drawn
            while (current instanceof Item) {
                final Item item = (Item) current;
                // Continue iteration
                current = current.getNext();
                // Build ground item
                final GroundItem groundItem = buildGroundItem(tile, item);
                if (groundItem != null) {
                    groundItems.add(groundItem);
                }
            }
        }
    }
    // Group ground items together and sort them properly
    collectedGroundItems.clear();
    Lists.reverse(groundItems).stream().collect(groundItemMapCollector);
}
Also used : ItemLayer(net.runelite.api.ItemLayer) Item(net.runelite.api.Item) Player(net.runelite.api.Player) LocalPoint(net.runelite.api.coords.LocalPoint) Node(net.runelite.api.Node) Region(net.runelite.api.Region) Tile(net.runelite.api.Tile) LocalPoint(net.runelite.api.coords.LocalPoint)

Aggregations

Region (net.runelite.api.Region)6 Tile (net.runelite.api.Tile)6 LocalPoint (net.runelite.api.coords.LocalPoint)5 Item (net.runelite.api.Item)2 ItemLayer (net.runelite.api.ItemLayer)2 Node (net.runelite.api.Node)2 Player (net.runelite.api.Player)2 Subscribe (com.google.common.eventbus.Subscribe)1 Color (java.awt.Color)1 ArrayList (java.util.ArrayList)1 Client (net.runelite.api.Client)1 GameObject (net.runelite.api.GameObject)1 ItemComposition (net.runelite.api.ItemComposition)1 MenuEntry (net.runelite.api.MenuEntry)1 WorldPoint (net.runelite.api.coords.WorldPoint)1 ItemPrice (net.runelite.http.api.item.ItemPrice)1