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);
}
}
}
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;
}
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);
}
}
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);
}
}
}
}
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);
}
Aggregations