@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
78 lines (65 loc) • 1.54 kB
JavaScript
import { assert } from "../../core/assert.js";
import DataType from "../../core/parser/simple/DataType.js";
export class CellFilter {
/**
*
* @type {boolean}
* @protected
*/
__initialized = false;
/**
*
* @returns {DataType}
*/
get dataType() {
return DataType.Number;
}
/**
*
* @returns {boolean}
*/
get initialized() {
return this.__initialized;
}
/**
*
* @param {GridData} grid
* @param {number} seed
*/
ensureInitialized(grid, seed) {
if (!this.__initialized) {
this.initialize(grid, seed);
// make sure initialization flag is set
this.__initialized = true;
}
}
/**
*
* @param {GridData} grid
* @param {number} seed
*/
initialize(grid, seed) {
assert.equal(grid.isGridData, true, 'grid.isGridData !== true');
assert.isNumber(seed, 'seed');
this.__initialized = true;
}
finalize() {
this.__initialized = false;
}
/**
*
* @param {GridData} grid
* @param {number} x Grid coordinate X
* @param {number} y Grid coordinate Y
* @param {number} rotation
* @returns {number}
*/
execute(grid, x, y, rotation) {
throw new Error('Must be overridden in the subclass');
}
}
/**
* @readonly
* @type {boolean}
*/
CellFilter.prototype.isCellFilter = true;