Suppose you are making a strategy game, and an attack hits all tiles in a cross pattern. This attack is used on the tile at row 2, column 3. You want to check each tile that was affected to see if any unit was hit:
// cross pattern ubyte[][] attackPattern = [ [0,1,0] [1,1,1] [0,1,0] ]; // get tiles contained by a cross pattern centered at (2,3) auto tilesHit = map.maskTilesAround((RowCol(2, 3), attackPattern)); // now do something with those tiles auto unitsHit = tilesHit.map!(tile => tile.unitOnTile).filter!(unit => unit !is null); foreach(unit ; unitsHit) unit.applySomeEffect;
Select specific tiles from this slice based on a mask.
The upper left corner of the mask is positioned at the given offset. Each map tile that is overlaid with a 'true' value is included in the result. The mask is allowed to extend out of bounds - out of bounds coordinates are ignored