Search in sources :

Example 6 with Tile

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

the class RSRegionMixin method rl$addBoundary.

@Replace("addBoundary")
public void rl$addBoundary(int plane, int x, int y, int hash, Renderable var5, Renderable var6, int var7, int var8, int var9, int var10) {
    rs$addBoundary(plane, x, y, hash, var5, var6, var7, var8, var9, var10);
    Tile tile = getTiles()[plane][x][y];
    if (tile != null) {
        RSWallObject wallObject = (RSWallObject) tile.getWallObject();
        if (wallObject != null) {
            wallObject.setPlane(plane);
        }
    }
}
Also used : Tile(net.runelite.api.Tile) RSWallObject(net.runelite.rs.api.RSWallObject) Replace(net.runelite.api.mixins.Replace)

Example 7 with Tile

use of net.runelite.api.Tile 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 8 with Tile

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

the class HunterPlugin method onGameTick.

/**
 * Iterates over all the traps that were placed by the local player and
 * checks if the trap is still there. If the trap is gone, it removes
 * the trap from the local players trap collection.
 */
@Subscribe
public void onGameTick(GameTick event) {
    // Check if all traps are still there, and remove the ones that are not.
    Iterator<Map.Entry<WorldPoint, HunterTrap>> it = traps.entrySet().iterator();
    Tile[][][] tiles = client.getRegion().getTiles();
    Instant expire = Instant.now().minus(HunterTrap.TRAP_TIME.multipliedBy(2));
    while (it.hasNext()) {
        Map.Entry<WorldPoint, HunterTrap> entry = it.next();
        HunterTrap trap = entry.getValue();
        WorldPoint world = entry.getKey();
        LocalPoint local = LocalPoint.fromWorld(client, world);
        // Not within the client's viewport
        if (local == null) {
            // Cull very old traps
            if (trap.getPlacedOn().isBefore(expire)) {
                log.debug("Trap removed from personal trap collection due to timeout, {} left", traps.size());
                it.remove();
                continue;
            }
            continue;
        }
        Tile tile = tiles[world.getPlane()][local.getRegionX()][local.getRegionY()];
        GameObject[] objects = tile.getGameObjects();
        boolean containsBoulder = false;
        boolean containsAnything = false;
        for (GameObject object : objects) {
            if (object != null) {
                containsAnything = true;
                if (object.getId() == ObjectID.BOULDER_19215 || object.getId() == ObjectID.LARGE_BOULDER) {
                    containsBoulder = true;
                    break;
                }
            }
        }
        if (!containsAnything) {
            it.remove();
            log.debug("Trap removed from personal trap collection, {} left", traps.size());
        } else if (// For traps like deadfalls. This is different because when the trap is gone, there is still a GameObject (boulder)
        containsBoulder) {
            it.remove();
            log.debug("Special trap removed from personal trap collection, {} left", traps.size());
            // Case we have notifications enabled and the action was not manual, throw notification
            if (config.maniacalMonkeyNotify() && trap.getObjectId() == ObjectID.MONKEY_TRAP && !trap.getState().equals(HunterTrap.State.FULL) && !trap.getState().equals(HunterTrap.State.OPEN)) {
                notifier.notify("The monkey escaped.");
            }
        }
    }
}
Also used : Instant(java.time.Instant) Tile(net.runelite.api.Tile) LocalPoint(net.runelite.api.coords.LocalPoint) WorldPoint(net.runelite.api.coords.WorldPoint) GameObject(net.runelite.api.GameObject) HashMap(java.util.HashMap) Map(java.util.Map) Subscribe(com.google.common.eventbus.Subscribe)

Example 9 with Tile

use of net.runelite.api.Tile 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 10 with Tile

use of net.runelite.api.Tile 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)

Aggregations

Tile (net.runelite.api.Tile)13 Region (net.runelite.api.Region)6 LocalPoint (net.runelite.api.coords.LocalPoint)6 Replace (net.runelite.api.mixins.Replace)4 WorldPoint (net.runelite.api.coords.WorldPoint)3 Subscribe (com.google.common.eventbus.Subscribe)2 Color (java.awt.Color)2 GameObject (net.runelite.api.GameObject)2 Item (net.runelite.api.Item)2 ItemLayer (net.runelite.api.ItemLayer)2 Node (net.runelite.api.Node)2 Player (net.runelite.api.Player)2 Area (java.awt.geom.Area)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Client (net.runelite.api.Client)1 ItemComposition (net.runelite.api.ItemComposition)1 MenuEntry (net.runelite.api.MenuEntry)1