Package VASSAL.build.module.map
Interface PieceCollection
- All Known Implementing Classes:
CompoundPieceCollection,DefaultPieceCollection,LayeredPieceCollection.Collection,SimplePieceCollection
public interface PieceCollection
A PieceCollection generally holds a list of
In addition to providing a means to maintain a list of all the pieces in a map, this interface provides a means to manage the draw order of pieces, in part by grouping pieces into different visual layers for e.g. Game Piece Layer Control and Game Piece Layer components of a Map. Within each layer, pieces are also listed in the order they should be drawn (i.e. lowest index at the back/bottom, highest index at the front/top).
GamePieces on a Map.
Each Map has a master CompoundPieceCollection that contains all of its pieces, stacks, and decks -- usually
this will be a LayeredPieceCollection but possibly a simpler DefaultPieceCollection. Within a
CompoundPieceCollection, there may be several SimplePieceCollections, each containing the pieces in a single
visual layer.
In addition to providing a means to maintain a list of all the pieces in a map, this interface provides a means to manage the draw order of pieces, in part by grouping pieces into different visual layers for e.g. Game Piece Layer Control and Game Piece Layer components of a Map. Within each layer, pieces are also listed in the order they should be drawn (i.e. lowest index at the back/bottom, highest index at the front/top).
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a piecebooleanReturn true if the two pieces can be merged into a single stackvoidclear()Remove all piecesReturn all pieces in the collection, regardless of visibilityReturn all currently-visible pieces in the collection as a read-only arrayintReturns the index of a piece.voidmoveToBack(GamePiece p)Reposition a piece to the back of all others in the same visual layervoidmoveToFront(GamePiece p)Reposition a piece to the front of all others in the same visual layervoidRemoves the piece
-
Method Details
-
moveToFront
Reposition a piece to the front of all others in the same visual layer -
moveToBack
Reposition a piece to the back of all others in the same visual layer -
getPieces
GamePiece[] getPieces()Return all currently-visible pieces in the collection as a read-only array -
getAllPieces
GamePiece[] getAllPieces()Return all pieces in the collection, regardless of visibility -
canMerge
Return true if the two pieces can be merged into a single stack -
indexOf
Returns the index of a piece. When painting the map, pieces are drawn in order of index -- lowest index drawn first and therefore appearing "below" later pieces which are drawn on top of it. -
remove
Removes the piece -
add
Adds a piece -
clear
void clear()Remove all pieces
-