Class LayeredPieceCollection

java.lang.Object
All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, PropertyNameSource, ComponentDescription, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget

public class LayeredPieceCollection extends AbstractConfigurable implements ComponentDescription
The optional "Game Piece Layers" component of a Map which allows pieces on the map to be assigned to an arbitrary number of visual layers according to a property setting. The (inauspiciously-named) Collection subclass becomes a CompoundPieceCollection override for the Map's default PieceCollection, in order to provide the additional functionality.

Unlike most "apparent properties of pieces", individual pieces know their layer only indirectly through providing the string property name -- they do not e.g. have a convenient way to check which relative layer they are in. Instead, the Map (through this class) maintains separate lists of the pieces in each visual layer, as well as a set of flags allowing individual layers to be hidden from view. When the Map is asked to draw pieces in a region, it only draws the ones for which the designated layer is currently visible.

Note that Stacks, since they often serve as drawing proxies for their member pieces, must also be aware of their proper layer, and since "in theory" Stacks are only formed from stackable units in the same visual layer, they take their layer cues from the first piece added to them.