refactor: plantAt
This commit is contained in:
parent
da22ef6cb4
commit
3b3920a939
|
@ -64,17 +64,6 @@ export default (Room) => class FarmableRoom extends Room {
|
|||
this.$$waterChanges = [];
|
||||
}
|
||||
|
||||
isPlantAt(target) {
|
||||
const entities = this.entityList.visibleEntities(Rectangle.centerOn(target, [1, 1]));
|
||||
for (let i = 0; i < entities.length; ++i) {
|
||||
const entity = entities[i];
|
||||
if (Vector.equals(entity.position, target) && entity.is('Plant')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async load(json) {
|
||||
await super.load(json);
|
||||
const {
|
||||
|
@ -100,7 +89,7 @@ export default (Room) => class FarmableRoom extends Room {
|
|||
return (
|
||||
'web' !== process.env.FLECKS_CORE_BUILD_TARGET
|
||||
&& TILLED === tiles.tileAt(target)
|
||||
&& !this.isPlantAt(center)
|
||||
&& !this.plantAt(center)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -112,6 +101,17 @@ export default (Room) => class FarmableRoom extends Room {
|
|||
return packets;
|
||||
}
|
||||
|
||||
plantAt(target) {
|
||||
const entities = this.entityList.visibleEntities(Rectangle.centerOn(target, [1, 1]));
|
||||
for (let i = 0; i < entities.length; ++i) {
|
||||
const entity = entities[i];
|
||||
if (Vector.equals(entity.position, target) && entity.is('Plant')) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
prepareSoilAt(target) {
|
||||
if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) {
|
||||
const tiles = this.tiles[1];
|
||||
|
|
Loading…
Reference in New Issue
Block a user