feat: seeds
This commit is contained in:
parent
0cd3d68098
commit
dbd6091acc
24
packages/farm/src/traits/seeds.js
Normal file
24
packages/farm/src/traits/seeds.js
Normal 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;
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user