21 lines
585 B
JavaScript
21 lines
585 B
JavaScript
export default function*({ecs, plant}) {
|
|
if (3 === plant.stage) {
|
|
return false;
|
|
}
|
|
const {TileLayers, Water} = ecs.get(1);
|
|
const layer = TileLayers.layer(0);
|
|
const {Position} = ecs.get(plant.entity);
|
|
const x = (Position.x - layer.tileSize.x * 0.5) / layer.tileSize.x;
|
|
const y = (Position.y - layer.tileSize.y * 0.5) / layer.tileSize.y;
|
|
const tileIndex = layer.area.x * y + x;
|
|
if (!Water.water[tileIndex]) {
|
|
return false;
|
|
}
|
|
if (Water.water[tileIndex] < 32) {
|
|
return false;
|
|
}
|
|
if (Water.water[tileIndex] > 224) {
|
|
return false;
|
|
}
|
|
return true;
|
|
} |