Пример #1
0
 /**
  * Returns an array of all game objects which satisfy the filter
  *
  * @param filter The filter
  * @return
  */
 public GameObject[] getAll(Filter<GameObject> filter, int mask) {
   Set<GameObject> objects = new LinkedHashSet<GameObject>();
   for (int x = 0; x < 104; x++) {
     for (int y = 0; y < 104; y++) {
       for (GameObject o : getAtLocal(x, y, mask)) {
         if (filter == null || filter.accept(o)) {
           objects.add(o);
         }
       }
     }
   }
   return objects.toArray(new GameObject[objects.size()]);
 }
Пример #2
0
  /**
   * Returns the nearest object from the local player which satisfies the filter
   *
   * @param filter The filter to accept objects, can be null
   * @return The nearest object
   */
  public GameObject getNearest(Filter<GameObject> filter) {
    GameObject[] objects = getAll(null, TYPE_ALL);
    GameObject nearest = null;
    Actor player = ctx.players.getLocalPlayer();
    for (GameObject obj : objects) {
      if (obj == null) continue;

      if (nearest == null
          || (player.getLocation().distanceTo(obj.getLocation())
                  < player.getLocation().distanceTo(nearest.getLocation())
              && (filter == null || filter.accept(obj)))) {
        nearest = obj;
      }
    }
    return nearest;
  }
Пример #3
0
  /**
   * Gets a filtered list of npcs.
   *
   * @param filter The filter.
   * @return The npcs.
   */
  public List<Npc> getNpcs(Filter<Npc> filter) {
    final List<Npc> npcs = new ArrayList<Npc>();
    final INpc[] rsnpcs = ctx.getClient().getNpcs();
    final int[] npcIndices = ctx.getClient().getNpcIndices();
    for (int i = 0; i < rsnpcs.length; i++) {
      INpc npc = rsnpcs[npcIndices[i]];
      if (npc != null) {
        Npc rsnpc = new Npc(ctx, npc);

        if (filter == null || filter.accept(rsnpc)) {
          npcs.add(rsnpc);
        }
      }
    }
    return npcs;
  }