Class VassalMapQuadTree

java.lang.Object
VASSAL.tools.qtree.QuadTree
VASSAL.build.module.index.VassalMapQuadTree
All Implemented Interfaces:
Cloneable

public class VassalMapQuadTree extends QuadTree
A Quadtree index of pieces on the playable area of the Map. Each node of the Quadtree holds an Arraylist of the Game Pieces at that Map location Pieces that do not reside on the actual map (i.e. in the edge buffer, or off map) will not be indexed and NOT be found by a Ranged GKC
  • Constructor Details

    • VassalMapQuadTree

      public VassalMapQuadTree(Map map)
      Create a QuadTree to cover the entire map
      Parameters:
      map -
    • VassalMapQuadTree

      public VassalMapQuadTree(VassalMapQuadTree qtree, int x1, int y1, int x2, int y2)
      Create a new Quadtree with larger bounds from an existing Quadtree
      Parameters:
      qtree - Existing Quadtree
      x1 - New left margin
      y1 - New top margin
      x2 - New right margin
      y2 - New bottom margin
  • Method Details

    • getBounds

      public Rectangle getBounds()
      Return the bounds of the current Quadtree
      Returns:
      bounds
    • addOrUpdatePiece

      public void addOrUpdatePiece(GamePiece p)
      Add a piece to the Qtree, or change it's location
      Parameters:
      p - Piece to add/move
    • removePiece

      public void removePiece(GamePiece p)
      Remove a piece from the Qtree and the cross-reference
      Parameters:
      p - Piece to remove
    • getPiecesInRange

      public List<GamePiece> getPiecesInRange(Point pos, int range)
      Return a list of all pieces within range of a given Point NOTE: This is just a pre-selection, we are seacrchign a box, not a circle so extra pieces will be returned that are not in range. This will be handled at the level above which will post-process our selection.
      Parameters:
      pos - Position
      range - range in pixels to search
      Returns:
      List of pieces