Class HazardMap

java.lang.Object
privbot.mechanics.HazardMap

public final class HazardMap extends Object
The tiles that hurt right now: timed ones (a graphic or a telegraphed attack that lasts a few ticks) and persistent ones (ground the fight never lets you stand on). Mutable, single-owner.

What it proves: only what the caller told it. It never reads the scene; "dangerous" means "someone added this tile and it has not expired at nowTick". A timed tile is dangerous while nowTick < addTick + ttl.

Unreadable looks like: a null tile is ignored on every write and is never dangerous. A tile the caller could not read is simply not added; the map cannot tell "safe" from "never reported".

Thread rule: not thread safe. Use it from the one thread that handles the game tick, and pass that tick in.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    How long add(WorldPoint, int) keeps a tile dangerous: two ticks.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(net.runelite.api.coords.WorldPoint tile, int nowTick)
    Marks tile dangerous for DEFAULT_TTL_TICKS ticks from nowTick.
    void
    add(net.runelite.api.coords.WorldPoint tile, int nowTick, int ttlTicks)
    Marks tile dangerous until nowTick + ttlTicks (exclusive).
    void
    addPersistent(net.runelite.api.coords.WorldPoint tile)
    Marks tile dangerous until removePersistent(WorldPoint) or clear().
    void
    Forgets everything, timed and persistent.
    boolean
    dangerous(net.runelite.api.coords.WorldPoint tile, int nowTick)
    True when tile is persistent, or timed and not yet expired at nowTick.
    void
    prune(int nowTick)
    Drops timed tiles that have expired at nowTick.
    void
    remove(net.runelite.api.coords.WorldPoint tile)
    Forgets a timed tile.
    void
    removePersistent(net.runelite.api.coords.WorldPoint tile)
    Forgets a persistent tile.
    Set<net.runelite.api.coords.WorldPoint>
    tiles(int nowTick)
    A copy of every tile that is dangerous at nowTick.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • HazardMap

      public HazardMap()
  • Method Details

    • add

      public void add(net.runelite.api.coords.WorldPoint tile, int nowTick)
      Marks tile dangerous for DEFAULT_TTL_TICKS ticks from nowTick.
    • add

      public void add(net.runelite.api.coords.WorldPoint tile, int nowTick, int ttlTicks)
      Marks tile dangerous until nowTick + ttlTicks (exclusive). A second add replaces the first.
    • addPersistent

      public void addPersistent(net.runelite.api.coords.WorldPoint tile)
      Marks tile dangerous until removePersistent(WorldPoint) or clear().
    • remove

      public void remove(net.runelite.api.coords.WorldPoint tile)
      Forgets a timed tile. A persistent entry for the same tile stays.
    • removePersistent

      public void removePersistent(net.runelite.api.coords.WorldPoint tile)
      Forgets a persistent tile. A timed entry for the same tile stays.
    • dangerous

      public boolean dangerous(net.runelite.api.coords.WorldPoint tile, int nowTick)
      True when tile is persistent, or timed and not yet expired at nowTick.
    • tiles

      public Set<net.runelite.api.coords.WorldPoint> tiles(int nowTick)
      A copy of every tile that is dangerous at nowTick.
    • prune

      public void prune(int nowTick)
      Drops timed tiles that have expired at nowTick. Persistent tiles stay.
    • clear

      public void clear()
      Forgets everything, timed and persistent.