diff options
Diffstat (limited to 'src/engine/systems')
-rw-r--r-- | src/engine/systems/Collision.ts | 6 | ||||
-rw-r--r-- | src/engine/systems/FacingDirection.ts | 8 | ||||
-rw-r--r-- | src/engine/systems/Grid.ts | 40 | ||||
-rw-r--r-- | src/engine/systems/Input.ts | 20 | ||||
-rw-r--r-- | src/engine/systems/Music.ts | 2 | ||||
-rw-r--r-- | src/engine/systems/Render.ts | 8 |
6 files changed, 42 insertions, 42 deletions
diff --git a/src/engine/systems/Collision.ts b/src/engine/systems/Collision.ts index 0bc6f5c..7771ba3 100644 --- a/src/engine/systems/Collision.ts +++ b/src/engine/systems/Collision.ts @@ -28,7 +28,7 @@ export class Collision extends System { return; } const collidingBox = entity.getComponent<BoundingBox>( - ComponentNames.BoundingBox, + ComponentNames.BoundingBox ); let collidingGrid = entity.hasComponent(ComponentNames.Grid) ? entity.getComponent<Grid>(ComponentNames.Grid) @@ -39,7 +39,7 @@ export class Collision extends System { ComponentNames.BoundingBox, (otherEntity) => { const otherBoundingBox = otherEntity.getComponent<BoundingBox>( - ComponentNames.BoundingBox, + ComponentNames.BoundingBox ); let otherGrid = otherEntity.hasComponent(ComponentNames.Grid) ? otherEntity.getComponent<Grid>(ComponentNames.Grid) @@ -58,7 +58,7 @@ export class Collision extends System { if (collidingBox.isCollidingWith(otherBoundingBox)) { collidingWith.push(otherEntity); } - }, + } ); for (const collision of collidingWith) { diff --git a/src/engine/systems/FacingDirection.ts b/src/engine/systems/FacingDirection.ts index 042484a..ee80c67 100644 --- a/src/engine/systems/FacingDirection.ts +++ b/src/engine/systems/FacingDirection.ts @@ -32,16 +32,16 @@ export class FacingDirection extends System { } const boundingBox = entity.getComponent<BoundingBox>( - ComponentNames.BoundingBox, + ComponentNames.BoundingBox )!; const facingDirection = entity.getComponent<FacingDirectionComponent>( - ComponentNames.FacingDirection, + ComponentNames.FacingDirection ); const { center } = boundingBox; const angle = Math.atan2( mousePosition.y - center.y, - mousePosition.x - center.x, + mousePosition.x - center.x ); const mouseInBoundingBox = @@ -58,7 +58,7 @@ export class FacingDirection extends System { sprite.fillTimingsFromSprite(oldSprite); entity.addComponent(sprite); - }, + } ); } } diff --git a/src/engine/systems/Grid.ts b/src/engine/systems/Grid.ts index c504bfe..bb67a40 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)!; diff --git a/src/engine/systems/Input.ts b/src/engine/systems/Input.ts index c527f29..9199c89 100644 --- a/src/engine/systems/Input.ts +++ b/src/engine/systems/Input.ts @@ -32,20 +32,20 @@ export class Input extends System { public update(_dt: number, game: Game) { game.forEachEntityWithComponent(ComponentNames.Control, (entity) => - this.handleMovement(entity, game), + this.handleMovement(entity, game) ); game.forEachEntityWithComponent(ComponentNames.Interactable, (entity) => - this.handleInteraction(entity), + this.handleInteraction(entity) ); } private handleInteraction(entity: Entity) { const interactable = entity.getComponent<Interactable>( - ComponentNames.Interactable, + ComponentNames.Interactable ); const interact = this.hasSomeKey( - KeyConstants.ActionKeys.get(Action.INTERACT), + KeyConstants.ActionKeys.get(Action.INTERACT) ); if (!interact) { @@ -54,13 +54,13 @@ export class Input extends System { interactable.interact(); KeyConstants.ActionKeys.get(Action.INTERACT)!.forEach((key) => - this.keyReleased(key), + this.keyReleased(key) ); } public handleMovement(entity: Entity, game: Game) { const controlComponent = entity.getComponent<Control>( - ComponentNames.Control, + ComponentNames.Control ); if (!controlComponent.isControllable) return; @@ -85,22 +85,22 @@ export class Input extends System { if (moveUp) { gridComponent.movingDirection = Direction.UP; KeyConstants.ActionKeys.get(Action.MOVE_UP)!.forEach((key) => - this.keyReleased(key), + this.keyReleased(key) ); } else if (moveLeft) { gridComponent.movingDirection = Direction.LEFT; KeyConstants.ActionKeys.get(Action.MOVE_LEFT)!.forEach((key) => - this.keyReleased(key), + this.keyReleased(key) ); } else if (moveRight) { gridComponent.movingDirection = Direction.RIGHT; KeyConstants.ActionKeys.get(Action.MOVE_RIGHT)!.forEach((key) => - this.keyReleased(key), + this.keyReleased(key) ); } else if (moveDown) { gridComponent.movingDirection = Direction.DOWN; KeyConstants.ActionKeys.get(Action.MOVE_DOWN)!.forEach((key) => - this.keyReleased(key), + this.keyReleased(key) ); } diff --git a/src/engine/systems/Music.ts b/src/engine/systems/Music.ts index 6e2004d..bdfa790 100644 --- a/src/engine/systems/Music.ts +++ b/src/engine/systems/Music.ts @@ -9,7 +9,7 @@ export class Music extends System { super(SystemNames.Music); this.songs = Array.from(GameMusic.states!.values()).map( - (state) => state.name, + (state) => state.name ); } diff --git a/src/engine/systems/Render.ts b/src/engine/systems/Render.ts index 2dd35e2..c730cec 100644 --- a/src/engine/systems/Render.ts +++ b/src/engine/systems/Render.ts @@ -26,7 +26,7 @@ export class Render extends System { sprite.update(dt); const boundingBox = entity.getComponent<BoundingBox>( - ComponentNames.BoundingBox, + ComponentNames.BoundingBox ); // don't render if we're outside the screen @@ -34,12 +34,12 @@ export class Render extends System { clamp( boundingBox.center.y, -boundingBox.dimension.height / 2, - this.ctx.canvas.height + boundingBox.dimension.height / 2, + this.ctx.canvas.height + boundingBox.dimension.height / 2 ) != boundingBox.center.y || clamp( boundingBox.center.x, -boundingBox.dimension.width / 2, - this.ctx.canvas.width + boundingBox.dimension.width / 2, + this.ctx.canvas.width + boundingBox.dimension.width / 2 ) != boundingBox.center.x ) { return; @@ -52,7 +52,7 @@ export class Render extends System { }; if (entity.hasComponent(ComponentNames.Highlight)) { const highlight = entity.getComponent<Highlight>( - ComponentNames.Highlight, + ComponentNames.Highlight ); drawArgs.tint = highlight.isHighlighted ? "red" : undefined; } |