示例#1
0
 public boolean open() {
   if (isOpen()) {
     return true;
   }
   GameObject box =
       ctx.objects.getNearest(
           new Filter<GameObject>() {
             @Override
             public boolean accept(GameObject element) {
               for (int id : DEPOSIT_BOX_IDS) {
                 if (id == element.getId()) {
                   return true;
                 }
               }
               return false;
             }
           });
   if (box != null) {
     box.interact("Deposit");
     Timer t = new Timer(3000);
     while (!isOpen() && t.isRunning()) {
       Utils.sleep(150);
     }
   }
   return isOpen();
 }
示例#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
  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;
  }