2017-11-17 01:08:58 +00:00
|
|
|
var GetTilesWithin = require('./GetTilesWithin');
|
2017-11-15 22:36:41 +00:00
|
|
|
|
2017-11-26 15:33:19 +00:00
|
|
|
/**
|
|
|
|
* For each tile in the given rectangular area (in tile coordinates) of the layer, run the given
|
|
|
|
* callback.
|
|
|
|
*
|
|
|
|
* @param {number} callback - The callback. Each tile in the given area will be passed to this
|
|
|
|
* callback as the first and only parameter.
|
|
|
|
* @param {number} context - The context under which the callback should be run.
|
|
|
|
* @param {number} [tileX=0]
|
|
|
|
* @param {number} [tileY=0]
|
|
|
|
* @param {number} [width=max width based on tileX] - [description]
|
|
|
|
* @param {number} [height=max height based on tileY] - [description]
|
|
|
|
* @param {object} [filteringOptions] - Optional filters to apply when getting the tiles.
|
|
|
|
* @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have
|
|
|
|
* -1 for an index.
|
|
|
|
* @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on
|
|
|
|
* at least one side.
|
|
|
|
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that
|
|
|
|
* have at least one interesting face.
|
|
|
|
* @param {LayerData} layer - [description]
|
|
|
|
*/
|
|
|
|
|
2017-11-26 00:03:21 +00:00
|
|
|
var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
|
2017-11-15 22:36:41 +00:00
|
|
|
{
|
2017-11-26 00:03:21 +00:00
|
|
|
var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer);
|
2017-11-15 22:36:41 +00:00
|
|
|
tiles.forEach(callback, context);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ForEachTile;
|