Esempio n. 1
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;
  }
Esempio n. 2
0
 /**
  * Returns an array of all objects on a given tile
  *
  * @param tile The tile to lookup
  * @return
  */
 public GameObject[] getAllAt(Tile tile) {
   Set<GameObject> objects =
       getAtLocal(
           tile.getX() - ctx.getClient().getOriginX(),
           tile.getY() - ctx.getClient().getOriginY(),
           TYPE_INTERACTABLE);
   return objects.toArray(new GameObject[objects.size()]);
 }
Esempio n. 3
0
  public Set<GameObject> getAtLocal(int x, int y, int mask) {
    IClient client = ctx.getClient();
    Set<GameObject> objects = new LinkedHashSet<GameObject>();
    if (client.getScene().getSceneTiles() == null) {
      return objects;
    }

    try {
      int plane = client.getPlane();
      ISceneTile tile = client.getScene().getSceneTiles()[plane][x][y];

      if (tile != null) {

        x += client.getOriginX();
        y += client.getOriginY();

        // Interactable (e.g. Trees)
        if ((mask & TYPE_INTERACTABLE) != 0) {
          for (ISceneObject obj : tile.getInteractableObjects()) {
            if (obj != null) {
              GameObject gameobj =
                  new GameObject(
                      ctx,
                      obj,
                      GameObject.Type.INTERACTABLE,
                      plane,
                      new Tile(x, y, obj.getGridX(), obj.getGridY()));

              if (gameobj.getId() != -1) {
                objects.add(gameobj);
              }
            }
          }
        }

        if ((mask & TYPE_FLOOR_DECORATION) != 0) {
          if (tile.getFloorDecoration() != null) {
            IFloorDecoration dec = tile.getFloorDecoration();

            GameObject gameobj =
                new GameObject(
                    ctx,
                    dec,
                    GameObject.Type.FLOOR_DECORATION,
                    plane,
                    new Tile(x, y, dec.getGridX(), dec.getGridY()));
            if (gameobj.getId() != -1) {
              objects.add(gameobj);
            }
          }
        }

        if ((mask & TYPE_WALL_DECORATION) != 0) {
          if (tile.getWallDecoration() != null) {
            IWallDecoration dec = tile.getWallDecoration();
            GameObject gameobj =
                new GameObject(
                    ctx,
                    dec,
                    GameObject.Type.WALL_DECORATION,
                    plane,
                    new Tile(x, y, dec.getGridX(), dec.getGridY()));

            if (gameobj.getId() != -1) {
              objects.add(gameobj);
            }
          }
        }

        if ((mask & TYPE_BOUNDARY) != 0) {
          if (tile.getBoundary() != null) {
            IWall dec = tile.getBoundary();
            GameObject gameobj =
                new GameObject(
                    ctx,
                    dec,
                    GameObject.Type.BOUNDARY,
                    plane,
                    new Tile(x, y, dec.getGridX(), dec.getGridY()));

            if (gameobj.getId() != -1) {
              objects.add(gameobj);
            }
          }
        }
      }
    } catch (Exception ignored) {
    }
    return objects;
  }