feat: seeds

This commit is contained in:
cha0s 2021-04-19 06:54:38 -05:00
parent 0cd3d68098
commit dbd6091acc

View File

@ -0,0 +1,24 @@
import {Rectangle, Vector} from '@avocado/math';
import {Trait} from '@avocado/traits';
export default () => class Seeds extends Trait {
// eslint-disable-next-line class-methods-use-this
methods() {
return {
isPlantAt: (position, list) => {
const entities = list.visibleEntities(Rectangle.centerOn(position, [1, 1]));
for (let i = 0; i < entities.length; ++i) {
const entity = entities[i];
if (Vector.equals(entity.position, position) && entity.is('Plant')) {
return true;
}
}
return false;
},
};
}
};