Class DefaultPieceCollection
java.lang.Object
VASSAL.build.module.map.CompoundPieceCollection
VASSAL.build.module.map.DefaultPieceCollection
- All Implemented Interfaces:
PieceCollection
Maps now start with a Game Piece Layers component (i.e. LayeredPieceCollection) by default, and so
will use that more complex implementation of visual layers. However, the LayeredPieceCollection can be deleted, in
which case this simpler implementation is used. This fallback implementation of PieceCollection separates
pieces into two visual layers: stacking pieces always drawn above non-stacking pieces-
Field Summary
Fields inherited from class CompoundPieceCollection
bottomLayer, enabled, layersModifier and TypeFieldDescriptionprotected intprotected boolean[]protected SimplePieceCollection[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintDefault implementation is "degenerate", having only a single layer -- when extending this class, this method takes a piece and determines which of several layers it belongs in, returning an index.Methods inherited from class CompoundPieceCollection
add, canMerge, canPiecesMerge, canStackAndPieceMerge, canStacksMerge, clear, getAllPieces, getBottomLayer, getCollectionForPiece, getLayerCount, getLayerForName, getLayerNameForPiece, getPieces, getPieces, getTopLayer, indexOf, initLayers, moveToBack, moveToFront, remove, reset, rotate, rotate, setBottomLayer, setLayerEnabled, setLayerEnabled, toggleLayerEnabled, toggleLayerEnabledModifier and TypeMethodDescriptionvoidAdds a piece to the overall collection, by adding it to the simple collection for the layer it belongs in.booleanUsed when moving a piece on top of another piece to determine whether they can be merged together (e.g. can this Piece be added to that Stack, can this Stack be added to that Deck, can these two Stacks be combined together into one).protected booleancanPiecesMerge(GamePiece p1, GamePiece p2) Two pieces can merge in the default case as long as neither is presently invisible and neither has a Does Not Stack (Hideable) trait.protected booleanA piece can be merged into a stack if it is merge-compatible with the first piece in the stack.protected booleancanStacksMerge(Stack s1, Stack s2) Stacks can merge if their component pieces can mergevoidclear()Clears the whole collection.Return all pieces in the collection, regardless of visibilityintprotected PieceCollectionGiven a game piece, returns the simple piece collection for the layer that it belongs inintintgetLayerForName(String layerName) Default implementation is "degenerate", having only a single layer -- when extending this class, this method takes layer name and returns the index for that layer, or -1 if the string does not name a valid layer.Default implementation is "degenerate", having only a single layer -- when extending this class, this method takes a piece and determines which of several layers it belongs in, returning the layer name.Return all currently-visible pieces in the collection as a read-only arrayprotected GamePiece[]getPieces(boolean includeDisabled) intintReturns the index of a piece.protected voidinitLayers(int layerCount) voidReposition a piece to the back of all others in the same visual layervoidReposition a piece to the front of all others in the same visual layervoidRemoves the piecevoidreset()voidrotate(boolean rotateUp) voidrotate(boolean rotateUp, boolean skipNullLayers) voidsetBottomLayer(int layer) voidsetLayerEnabled(int layer, boolean b) Enable/Disable layersvoidsetLayerEnabled(String layer, boolean b) Enable/Disable layersvoidtoggleLayerEnabled(int layer) Toggle for Enable/Disable of layersvoidtoggleLayerEnabled(String layer) Toggle for Enable/Disable of layers
-
Constructor Details
-
DefaultPieceCollection
public DefaultPieceCollection()
-
-
Method Details
-
getLayerForPiece
Description copied from class:CompoundPieceCollectionDefault implementation is "degenerate", having only a single layer -- when extending this class, this method takes a piece and determines which of several layers it belongs in, returning an index.- Overrides:
getLayerForPiecein classCompoundPieceCollection- Parameters:
p- A game piece- Returns:
- Index for the visual layer the piece should be drawn with.
-