From c6e9baa0009f7cce0f6ff156a3957ef04a8cb684 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 12 Aug 2023 13:49:16 -0600 Subject: the great engine refactor --- engine/systems/WallBounds.ts | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'engine/systems/WallBounds.ts') diff --git a/engine/systems/WallBounds.ts b/engine/systems/WallBounds.ts index 6ea2267..a0d4a9c 100644 --- a/engine/systems/WallBounds.ts +++ b/engine/systems/WallBounds.ts @@ -14,23 +14,16 @@ export class WallBounds extends System { } public update(_dt: number, game: Game) { - game.componentEntities - .get(ComponentNames.WallBounded) - ?.forEach((entityId) => { - const entity = game.entities.get(entityId); - if (!entity.hasComponent(ComponentNames.BoundingBox)) { - return; - } + game.forEachEntityWithComponent(ComponentNames.WallBounded, (entity) => { + const boundingBox = entity.getComponent( + ComponentNames.BoundingBox, + ); - const boundingBox = entity.getComponent( - ComponentNames.BoundingBox - ); - - boundingBox.center.x = clamp( - boundingBox.center.x, - boundingBox.dimension.width / 2, - this.screenWidth - boundingBox.dimension.width / 2 - ); - }); + boundingBox.center.x = clamp( + boundingBox.center.x, + boundingBox.dimension.width / 2, + this.screenWidth - boundingBox.dimension.width / 2, + ); + }); } } -- cgit v1.2.3-70-g09d2