neighbors method
Get all of the cardinal neighbors of the tile at column x
row y
.
Implementation
List<T> neighbors(int x, int y) {
var neighbors = <T>[];
var start = Vec2(x, y);
for (var d in Direction.cardinals) {
var neigbor = start + d;
if (_tiles.isValid(neigbor)) {
neighbors.add(this[neigbor]);
}
}
return neighbors;
}