diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-12 13:49:16 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-12 13:49:16 -0600 |
commit | c6e9baa0009f7cce0f6ff156a3957ef04a8cb684 (patch) | |
tree | 9766a4a33ad1c86aa71a5f92daf8917f3e5f5eed /engine/systems/WallBounds.ts | |
parent | b67ffb57c1bf6e9628339a3f43c71ccebdb46136 (diff) | |
download | jumpstorm-c6e9baa0009f7cce0f6ff156a3957ef04a8cb684.tar.gz jumpstorm-c6e9baa0009f7cce0f6ff156a3957ef04a8cb684.zip |
the great engine refactor
Diffstat (limited to 'engine/systems/WallBounds.ts')
-rw-r--r-- | engine/systems/WallBounds.ts | 27 |
1 files changed, 10 insertions, 17 deletions
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<BoundingBox>( + ComponentNames.BoundingBox, + ); - const boundingBox = entity.getComponent<BoundingBox>( - 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, + ); + }); } } |