summaryrefslogtreecommitdiff
path: root/engine/structures/Grid.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-21 14:19:02 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-21 14:19:02 -0600
commit8fce5a5f2530496e1390763364c01392a1a63640 (patch)
tree54d070d79acc95cab6ecbd1b361d325eba82f2b8 /engine/structures/Grid.ts
parent432ce5428f357f31ae090d55c5183b4eccd5a37c (diff)
downloadjumpstorm-8fce5a5f2530496e1390763364c01392a1a63640.tar.gz
jumpstorm-8fce5a5f2530496e1390763364c01392a1a63640.zip
fix some ts errors
Diffstat (limited to 'engine/structures/Grid.ts')
-rw-r--r--engine/structures/Grid.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/engine/structures/Grid.ts b/engine/structures/Grid.ts
index d359909..836aaf4 100644
--- a/engine/structures/Grid.ts
+++ b/engine/structures/Grid.ts
@@ -1,5 +1,5 @@
import type { Coord2D, Dimension2D } from "../interfaces";
-import type { RefreshingCollisionFinderBehavior } from ".";
+import type { BoxedEntry, RefreshingCollisionFinderBehavior } from ".";
export class Grid implements RefreshingCollisionFinderBehavior {
private cellEntities: Map<number, string[]>;
@@ -11,7 +11,7 @@ export class Grid implements RefreshingCollisionFinderBehavior {
constructor(
gridDimension: Dimension2D,
cellDimension: Dimension2D,
- topLeft = { x: 0, y: 0 },
+ topLeft = { x: 0, y: 0 }
) {
this.gridDimension = gridDimension;
this.cellDimension = cellDimension;
@@ -25,7 +25,7 @@ export class Grid implements RefreshingCollisionFinderBehavior {
if (!this.cellEntities.has(gridIdx)) {
this.cellEntities.set(gridIdx, []);
}
- this.cellEntities.get(gridIdx).push(boxedEntry.id);
+ this.cellEntities.get(gridIdx)!.push(boxedEntry.id);
});
}
@@ -33,7 +33,7 @@ export class Grid implements RefreshingCollisionFinderBehavior {
const neighborIds: Set<string> = new Set();
this.getOverlappingCells(boxedEntry).forEach((gridIdx) => {
if (this.cellEntities.has(gridIdx)) {
- this.cellEntities.get(gridIdx).forEach((id) => neighborIds.add(id));
+ this.cellEntities.get(gridIdx)!.forEach((id) => neighborIds.add(id));
}
});
return neighborIds;
@@ -58,10 +58,10 @@ export class Grid implements RefreshingCollisionFinderBehavior {
private getOverlappingCells(boxedEntry: BoxedEntry): number[] {
const { center, dimension } = boxedEntry;
const yBoxes = Math.ceil(
- this.gridDimension.height / this.cellDimension.height,
+ this.gridDimension.height / this.cellDimension.height
);
const xBoxes = Math.ceil(
- this.gridDimension.width / this.cellDimension.width,
+ this.gridDimension.width / this.cellDimension.width
);
const translated: Coord2D = {
@@ -71,18 +71,18 @@ export class Grid implements RefreshingCollisionFinderBehavior {
const topLeftBox = {
x: Math.floor(
- (translated.x - dimension.width / 2) / this.cellDimension.width,
+ (translated.x - dimension.width / 2) / this.cellDimension.width
),
y: Math.floor(
- (translated.y - dimension.height / 2) / this.cellDimension.height,
+ (translated.y - dimension.height / 2) / this.cellDimension.height
),
};
const bottomRightBox = {
x: Math.floor(
- (translated.x + dimension.width / 2) / this.cellDimension.width,
+ (translated.x + dimension.width / 2) / this.cellDimension.width
),
y: Math.floor(
- (translated.y + dimension.height / 2) / this.cellDimension.height,
+ (translated.y + dimension.height / 2) / this.cellDimension.height
),
};