export interface DirtCell { x: number; y: number; frame: number; } export function createDirtCells(cells: { x: number; y: number }[], random = Math.random): DirtCell[] { return cells.map(cell => ({ x: cell.x, y: cell.y, frame: Math.floor(random() * 4) })); } export function dirtIsCovered(block: any): boolean { return block.type === 4 || block.type === 16 || block.flowerType === 2 || !!(block.block_Info.floor && block.block_Info.floorTime); } export function washDirtCells(cells: DirtCell[], x: number, y: number, isWashCell: (x: number, y: number) => boolean): DirtCell[] { return cells.filter(cell => !isWashCell(x + cell.x, y + cell.y)); } export function remapDirtCells(dirt: DirtCell[], offset: { x: number; y: number }, cells: { x: number; y: number }[]): DirtCell[] { return dirt.map(cell => ({ x: cell.x - offset.x, y: cell.y - offset.y, frame: cell.frame })) .filter(cell => cells.some(remaining => remaining.x === cell.x && remaining.y === cell.y)); }