fix: more efficient seesEntity

This commit is contained in:
cha0s 2019-05-08 23:53:26 -05:00
parent 9fa44709b9
commit dc9a26268c

View File

@ -268,9 +268,13 @@ export class Informed extends decorate(Trait) {
seesEntity: (entity) => {
const areaToInform = this.entity.areaToInform;
const room = this.entity.room;
const visibleEntities = room.visibleEntities(areaToInform);
return -1 !== visibleEntities.indexOf(entity);
return Rectangle.isTouching(
Rectangle.translated(
areaToInform,
Vector.scale(Rectangle.size(areaToInform), -0.5),
),
entity.visibleAabb
);
}
};