silphius/app/ecs/systems/water.js
2024-07-20 05:07:39 -05:00

21 lines
406 B
JavaScript

import {System} from '@/ecs/index.js';
export default class Water extends System {
frequency = 1;
tick(elapsed) {
const {Water} = this.ecs.get(1);
if (!Water) {
return;
}
for (const tile in Water.water) {
Water.water[tile] = Math.max(0, Water.water[tile] - elapsed);
}
if (Object.keys(Water.water).length > 0) {
Water.water = {...Water.water};
}
}
}