Class LayeredPieceCollection.Collection
java.lang.Object
VASSAL.build.module.map.CompoundPieceCollection
VASSAL.build.module.map.LayeredPieceCollection.Collection
- All Implemented Interfaces:
PieceCollection,DeckVisitor,PieceVisitor
- Enclosing class:
LayeredPieceCollection
public static class LayeredPieceCollection.Collection
extends CompoundPieceCollection
implements DeckVisitor
The PieceCollection class used by the
Map to which a LayeredPieceCollection has been added. This replaces the
simpler DefaultPieceCollection that the map would ordinarily use. Here we extend CompoundPieceCollection
which maintains a list of pieces currently on each layer as well as a set of flags for whether each layer is presently
enabled/visible. We simply provide the methods needed to determine which relative layer (i.e. internally-maintained
drawing order) a particular piece (or stack) should be grouped with, by querying the designated property of the
piece. In the case of a Stack we use its memory of the most recent layer it was in, if a piece is not
available.-
Field Summary
Fields inherited from class VASSAL.build.module.map.CompoundPieceCollection
bottomLayer, enabled, layers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.intgetLayerForName(String layer) 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.intGets the appropriate layer for the given piece (or Stack or Deck).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.String[]voidsetLayerOrder(String[] layerOrder) voidsetPropertyName(String propertyName) Decks are always displayed in the highest possible layerOrdinary pieces are queried for their value of the designated layer property, and this value is then checked against the list of layer names.visitStack(Stack s) Stacks are first checked for the "topPiece()", but since this method actually hides from us pieces hidden from the currently active player by theHideable("Invisible") trait, we fall back on the Stack's own memory of what layer it has been in.Methods inherited from class VASSAL.build.module.map.CompoundPieceCollection
add, canMerge, canStackAndPieceMerge, canStacksMerge, clear, getAllPieces, getBottomLayer, getCollectionForPiece, getLayerCount, getPieces, getPieces, getTopLayer, indexOf, initLayers, moveToBack, moveToFront, remove, reset, rotate, rotate, setBottomLayer, setLayerEnabled, setLayerEnabled, toggleLayerEnabled, toggleLayerEnabled
-
Constructor Details
-
Collection
-
-
Method Details
-
getLayerOrder
-
setLayerOrder
-
getPropertyName
-
setPropertyName
-
getLayerForPiece
Gets the appropriate layer for the given piece (or Stack or Deck). Will call one of the dispatcher methods below, as appropriate:visitDeck(VASSAL.counters.Deck),visitStack(VASSAL.counters.Stack), orvisitDefault(VASSAL.counters.GamePiece).- Overrides:
getLayerForPiecein classCompoundPieceCollection- Parameters:
p- Piece (possibly a Deck or Stack) to obtain layer for- Returns:
- visual layer
-
getLayerForName
Description copied from class:CompoundPieceCollectionDefault 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.- Overrides:
getLayerForNamein classCompoundPieceCollection- Parameters:
layer- the name of a layer- Returns:
- the index for the layer
-
getLayerNameForPiece
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 the layer name.- Overrides:
getLayerNameForPiecein classCompoundPieceCollection- Parameters:
p- A game piece- Returns:
- the layer name it belongs in.
-
canPiecesMerge
Description copied from class:CompoundPieceCollectionTwo pieces can merge in the default case as long as neither is presently invisible and neither has a Does Not Stack (Hideable) trait.- Overrides:
canPiecesMergein classCompoundPieceCollection- Parameters:
p1- a piecep2- another piece- Returns:
- WonderTwin powers activate?
-
visitDeck
Decks are always displayed in the highest possible layer- Specified by:
visitDeckin interfaceDeckVisitor- Parameters:
d- Deck- Returns:
- layer - the highest possible one
-
visitDefault
Ordinary pieces are queried for their value of the designated layer property, and this value is then checked against the list of layer names. If there is no match, the "highest possible layer" is used as the default.- Specified by:
visitDefaultin interfacePieceVisitor- Parameters:
p- ordinary piece- Returns:
- layer index for this piece
-
visitStack
Stacks are first checked for the "topPiece()", but since this method actually hides from us pieces hidden from the currently active player by theHideable("Invisible") trait, we fall back on the Stack's own memory of what layer it has been in.- Specified by:
visitStackin interfacePieceVisitor- Parameters:
s- Stack to check layer- Returns:
- layer index
-