diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-11 16:35:51 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-11 16:35:51 -0600 |
commit | de4f3fd2fe45478ffabc84f055592e11b119d0a4 (patch) | |
tree | ad2ce3b3e646d2d6bfbccb4b9c8962196a0ea8fe /src/engine/systems/Grid.ts | |
parent | 32879581e53fae5e684c24b44433172d8375d69e (diff) | |
download | the-abstraction-engine-de4f3fd2fe45478ffabc84f055592e11b119d0a4.tar.gz the-abstraction-engine-de4f3fd2fe45478ffabc84f055592e11b119d0a4.zip |
prettier, fix assets and css
Diffstat (limited to 'src/engine/systems/Grid.ts')
-rw-r--r-- | src/engine/systems/Grid.ts | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/engine/systems/Grid.ts b/src/engine/systems/Grid.ts index bb67a40..c504bfe 100644 --- a/src/engine/systems/Grid.ts +++ b/src/engine/systems/Grid.ts @@ -18,7 +18,7 @@ export class Grid extends System { constructor( { width: columns, height: rows }: Dimension2D, - dimension: Dimension2D + dimension: Dimension2D, ) { super(SystemNames.Grid); @@ -50,11 +50,11 @@ export class Grid extends System { const grid = entity.getComponent<GridComponent>(ComponentNames.Grid)!; const facingDirection = entity.getComponent<FacingDirection>( - ComponentNames.FacingDirection + ComponentNames.FacingDirection, )!; const lookingAt = this.getNewGridPosition( grid.gridPosition, - facingDirection.currentDirection + facingDirection.currentDirection, ); if ( facingDirection.currentDirection === Direction.NONE || @@ -66,14 +66,14 @@ export class Grid extends System { this.grid[lookingAt.y][lookingAt.x].forEach((id) => { highlightableEntities.push([id, facingDirection.currentDirection]); }); - } + }, ); highlightableEntities.forEach(([id, direction]) => { const entity = game.getEntity(id)!; if (entity.hasComponent(ComponentNames.Highlight)) { const highlight = entity.getComponent<Highlight>( - ComponentNames.Highlight + ComponentNames.Highlight, )!; highlight.highlight(direction); } @@ -82,7 +82,7 @@ export class Grid extends System { game.forEachEntityWithComponent(ComponentNames.Highlight, (entity) => { if (!highlightableEntities.find(([id]) => id === entity.id)) { const highlight = entity.getComponent<Highlight>( - ComponentNames.Highlight + ComponentNames.Highlight, )!; highlight.unhighlight(); } @@ -124,23 +124,23 @@ export class Grid extends System { const { x, y } = nextGridPosition; const entities = Array.from(this.grid[y][x]).map( - (id) => game.getEntity(id)! + (id) => game.getEntity(id)!, ); const collidingEntities = entities.filter((entity) => - entity.hasComponent(ComponentNames.Colliding) + entity.hasComponent(ComponentNames.Colliding), ); if (collidingEntities.length > 0) { // i.e. key going into a door or function going into an application const allEntitiesInPreviousCellCanCollide = Array.from( - this.grid[currentPosition.y][currentPosition.x] + this.grid[currentPosition.y][currentPosition.x], ) .map((id) => game.getEntity(id)!) .every((entity) => collidingEntities.every((collidingEntity) => - Collision.canCollide(entity.name, collidingEntity.name) - ) + Collision.canCollide(entity.name, collidingEntity.name), + ), ); if (allEntitiesInPreviousCellCanCollide) { break; @@ -153,7 +153,7 @@ export class Grid extends System { if (!entity.hasComponent(ComponentNames.Grid)) return false; const { movingDirection } = entity.getComponent<GridComponent>( - ComponentNames.Grid + ComponentNames.Grid, )!; const pushable = entity.hasComponent(ComponentNames.Pushable); return movingDirection === Direction.NONE && pushable; @@ -169,7 +169,7 @@ export class Grid extends System { currentPosition = nextGridPosition; nextGridPosition = this.getNewGridPosition( nextGridPosition, - movingDirection + movingDirection, ); } @@ -196,7 +196,7 @@ export class Grid extends System { } const boundingBox = entity.getComponent<BoundingBox>( - ComponentNames.BoundingBox + ComponentNames.BoundingBox, )!; boundingBox.center = this.gridToScreenPosition(grid.gridPosition); boundingBox.dimension = this.dimension; @@ -210,7 +210,7 @@ export class Grid extends System { private updateMovingEntities( dt: number, game: Game, - velocity = PhysicsConstants.GRID_MOVEMENT_VELOCITY + velocity = PhysicsConstants.GRID_MOVEMENT_VELOCITY, ) { game.forEachEntityWithComponent(ComponentNames.Grid, (entity) => { const grid = entity.getComponent<GridComponent>(ComponentNames.Grid)!; @@ -221,12 +221,12 @@ export class Grid extends System { grid.previousDirection = grid.movingDirection; const boundingBox = entity.getComponent<BoundingBox>( - ComponentNames.BoundingBox + ComponentNames.BoundingBox, )!; const newGridPosition = this.getNewGridPosition( grid.gridPosition, - grid.movingDirection + grid.movingDirection, ); if (this.isOutOfBounds(newGridPosition)) { grid.movingDirection = Direction.NONE; @@ -255,7 +255,7 @@ export class Grid extends System { const passedCenter = this.isEntityPastCenterWhenMoving( grid.movingDirection, newGridPosition, - nextPosition + nextPosition, ); if (passedCenter) { @@ -319,7 +319,7 @@ export class Grid extends System { private isEntityPastCenterWhenMoving( direction: Direction, gridPosition: Coord2D, - entityPosition: Coord2D + entityPosition: Coord2D, ) { const { x, y } = this.gridToScreenPosition(gridPosition); switch (direction) { @@ -368,7 +368,7 @@ export class Grid extends System { cell.delete(id); } } - }) + }), ); movedEntities.forEach((id) => { const entity = game.getEntity(id)!; |