calculateOccupiedCells method
计算 Widget 占据的所有坐标
Implementation
List<HexCoordinate> calculateOccupiedCells(HexOrientation orientation) {
if (occupiedCells != null) {
return occupiedCells!;
}
final cells = <HexCoordinate>[];
final isPointy = orientation == HexOrientation.pointy;
for (var row = 0; row < spanHeight; row++) {
for (var col = 0; col < spanWidth; col++) {
final (baseCol, baseRow) = isPointy
? position.toOffsetPointy()
: position.toOffsetFlat();
final cellCoord = isPointy
? HexCoordinate.fromOffsetPointy(baseCol + col, baseRow + row)
: HexCoordinate.fromOffsetFlat(baseCol + col, baseRow + row);
cells.add(cellCoord);
}
}
return cells;
}