21 lines
406 B
JavaScript
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};
|
|
}
|
|
}
|
|
|
|
}
|