Class TileObjectQuery

All Implemented Interfaces:
Predicate<ITileObject>

public class TileObjectQuery extends SceneEntityQuery<ITileObject,TileObjectQuery>
Query class for finding and filtering tile objects in the game world.

Tile objects are static objects placed on tiles in the game scene, such as trees, rocks, doors, and other interactable scenery. This class extends SceneEntityQuery with tile object-specific filtering capabilities:

  • Filter by specific tiles
  • Filter by object type (using instanceof checks)
  • IDs, names, actions, locations, distances (from SceneEntityQuery)

Example usage:


 // Find all bank booths within 5 tiles
 TileObjectQuery query = new TileObjectQuery(tileObjectSupplier)
     .names("Bank booth")
     .distance(player, 5);
 SceneEntityQueryResults<ITileObject> results = query.results();
 
  • Constructor Details

    • TileObjectQuery

      public TileObjectQuery(Supplier<List<ITileObject>> supplier)
      Constructs a new tile object query with the specified tile object supplier.
      Parameters:
      supplier - a supplier that provides the list of tile objects to query
  • Method Details

    • tiles

      public TileObjectQuery tiles(ITile... tiles)
      Filters tile objects by the tiles they are located on.

      Only tile objects located on one of the specified tiles will be included.

      Parameters:
      tiles - the tiles to filter by
      Returns:
      this query instance for method chaining
    • is

      @SafeVarargs public final TileObjectQuery is(Class<? extends ITileObject>... classes)
      Filters tile objects by their specific types.

      Only tile objects that are instances of at least one of the specified classes will be included. This allows filtering for specific subtypes of tile objects such as game objects, wall objects, ground objects, or decorative objects.

      Parameters:
      classes - the tile object types to filter by
      Returns:
      this query instance for method chaining
    • results

      Wraps the filtered list of tile objects in a SceneEntityQueryResults container.
      Specified by:
      results in class Query<ITileObject,TileObjectQuery,SceneEntityQueryResults<ITileObject>>
      Parameters:
      list - the list of tile objects that passed all filters
      Returns:
      the results wrapped in a SceneEntityQueryResults container
    • test

      public boolean test(ITileObject tileObject)
      Tests whether a tile object passes all accumulated filter criteria.

      This method checks the tile object against the tile filter, type filter, and all parent class filters.

      Specified by:
      test in interface Predicate<ITileObject>
      Overrides:
      test in class SceneEntityQuery<ITileObject,TileObjectQuery>
      Parameters:
      tileObject - the tile object to test
      Returns:
      true if the tile object passes all filters, false otherwise