Beispiel #1
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;
  }