filter only colliding and pushable entities in collision test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Elizabeth Hunt 2024-03-24 22:40:51 -06:00
parent f6ffa422d9
commit c568a8e49a
Signed by: simponic
GPG Key ID: 52B3774857EB24B1

View File

@ -139,11 +139,17 @@ export class Grid extends System {
); );
if (collidingEntities.length > 0) { if (collidingEntities.length > 0) {
// i.e. key going into a door or function going into an application // ensure everything that is a "pushable" or "colliding" which will collide with the entity
// can actually continue moving in the direction
const allEntitiesInPreviousCellCanCollide = Array.from( const allEntitiesInPreviousCellCanCollide = Array.from(
this.grid[currentPosition.y][currentPosition.x], this.grid[currentPosition.y][currentPosition.x],
) )
.map((id) => game.getEntity(id)!) .map((id) => game.getEntity(id)!)
.filter(
(entity) =>
entity.hasComponent(ComponentNames.Colliding) ||
entity.hasComponent(ComponentNames.Pushable),
)
.every((entity) => .every((entity) =>
collidingEntities.every((collidingEntity) => collidingEntities.every((collidingEntity) =>
Collision.canCollide(entity.name, collidingEntity.name), Collision.canCollide(entity.name, collidingEntity.name),