Class IndexManager

java.lang.Object
VASSAL.build.module.index.IndexManager

public class IndexManager extends Object
The IndexManager maintains a set of indexes on GamePieces that will primarily be used by the GKC Fast-match mechanism to quickly find sets of pieces that meet certain critera. It maintains the following indexes: o A per-map quadtree of piece locations o A per-map cross-reference of values of the Currentzone and LocationName properties The indexes for each Map are stored in a VassalMapPieceIndex object NOTE: Pieces not on Maps are NOT included in any index.
  • Constructor Details

    • IndexManager

      public IndexManager()
  • Method Details

    • rebuild

      public void rebuild()
      Clear and rebuild all indexes using pieces currently existing on boards. Will usually only be called at the start of a game session after initial load of gamestate is complete.
    • clearAll

      public void clearAll()
      Clear all indexes
    • pieceMoved

      public void pieceMoved(GamePiece piece, Map map)
      A piece has just moved or been placed on the board, update any location based indexes and create any property based indexes if we have not seen this piece before
      Parameters:
      piece - Piece that moved
      map - Map that the piece has arrived on
    • pieceRemoved

      public void pieceRemoved(GamePiece piece, Map map)
      A piece has been removed from a Map
      Parameters:
      piece - Removed piece
      map - Map piece was removed from
    • getPieces

      public List<GamePiece> getPieces(GamePiece piece, int range, boolean forceAsPixels)
      Return a list of pieces within a given range of another piece
      Parameters:
      piece - Piece to use as origin
      range - range in units appropriate to the grid at the pieces location
      forceAsPixels - Force the range check to be in pixels, overriding any grid at the target point
      Returns:
      List of pieces (not including the souurce piece)
    • getPieces

      public List<GamePiece> getPieces(GamePiece piece, int range)
    • getPieces

      public List<GamePiece> getPieces(Map map, Point point, int range, boolean forceAsPixels)
      Return a list of pieces within a given range of a specified point
      Parameters:
      map - Map
      point - Position to search from
      range - Range in units appropriate to the grid at the search point.
      forceAsPixels - Force the range check to be in pixels, overriding any grid at the target point
      Returns:
      List of pieces
    • getPieces

      public List<GamePiece> getPieces(Map map, Point point, int range)
    • getPieces

      public List<GamePiece> getPieces(Map map, Point point)
      Return a list of pieces at a specific point on a specific map
      Parameters:
      map - Map to check
      point - Point to check
      Returns:
      Pieces at that Map.Point
    • getPieces

      public List<GamePiece> getPieces(Map map, String propertyName, String propertyValue)
      Return a list of pieces on a Map with a specified value for the specified property
      Parameters:
      map - Map
      propertyName - Propertyname to lookup
      propertyValue - Property value to look for
      Returns:
      List of pieces with that property value