Search in sources :

Example 6 with GameObject

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

the class MotherlodePlugin method onGameObjectDespawned.

@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event) {
    GameObject gameObject = event.getGameObject();
    rocks.remove(gameObject);
}
Also used : GameObject(net.runelite.api.GameObject) Subscribe(com.google.common.eventbus.Subscribe)

Example 7 with GameObject

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

the class PohPlugin method onGameObjectDespawned.

@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event) {
    GameObject gameObject = event.getGameObject();
    pohObjects.remove(gameObject);
}
Also used : GameObject(net.runelite.api.GameObject) Subscribe(com.google.common.eventbus.Subscribe)

Example 8 with GameObject

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

the class BarrowsPlugin method onGameObjectDespawned.

@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event) {
    GameObject gameObject = event.getGameObject();
    ladders.remove(gameObject);
}
Also used : GameObject(net.runelite.api.GameObject) Subscribe(com.google.common.eventbus.Subscribe)

Example 9 with GameObject

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

the class BarrowsPlugin method onGameObjectChanged.

@Subscribe
public void onGameObjectChanged(GameObjectChanged event) {
    GameObject previous = event.getPrevious();
    GameObject gameObject = event.getGameObject();
    ladders.remove(previous);
    if (BARROWS_LADDERS.contains(gameObject.getId())) {
        ladders.add(gameObject);
    }
}
Also used : GameObject(net.runelite.api.GameObject) Subscribe(com.google.common.eventbus.Subscribe)

Example 10 with GameObject

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

Aggregations

GameObject (net.runelite.api.GameObject)13 Subscribe (com.google.common.eventbus.Subscribe)9 LocalPoint (net.runelite.api.coords.LocalPoint)4 Player (net.runelite.api.Player)2 Tile (net.runelite.api.Tile)2 Color (java.awt.Color)1 Area (java.awt.geom.Area)1 Instant (java.time.Instant)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Actor (net.runelite.api.Actor)1 NPC (net.runelite.api.NPC)1 Point (net.runelite.api.Point)1 Region (net.runelite.api.Region)1 WorldPoint (net.runelite.api.coords.WorldPoint)1 GameObjectChanged (net.runelite.api.events.GameObjectChanged)1 GameObjectDespawned (net.runelite.api.events.GameObjectDespawned)1 GameObjectSpawned (net.runelite.api.events.GameObjectSpawned)1 FieldHook (net.runelite.api.mixins.FieldHook)1 Inject (net.runelite.api.mixins.Inject)1