summaryrefslogtreecommitdiff
path: root/engine/structures
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-13 16:47:58 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-13 16:47:58 -0600
commit98e795029bcc404463ed151ff5255a72498bc641 (patch)
tree48e50d896d00761eae18c89f89e5dd0ef353b660 /engine/structures
parentc6e9baa0009f7cce0f6ff156a3957ef04a8cb684 (diff)
downloadjumpstorm-98e795029bcc404463ed151ff5255a72498bc641.tar.gz
jumpstorm-98e795029bcc404463ed151ff5255a72498bc641.zip
Create network component and system
Diffstat (limited to 'engine/structures')
-rw-r--r--engine/structures/QuadTree.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/engine/structures/QuadTree.ts b/engine/structures/QuadTree.ts
index d1ff3b1..a57c6e7 100644
--- a/engine/structures/QuadTree.ts
+++ b/engine/structures/QuadTree.ts
@@ -41,17 +41,16 @@ export class QuadTree {
this.dimension = dimension;
}
- public insert(id: number, dimension: Dimension2D, center: Coord2D): void {
- const box: BoxedEntry = { id, center, dimension };
+ public insert(boxedEntry: BoxedEntry): void {
if (this.hasChildren()) {
- this.getQuadrants(box).forEach((quadrant) => {
+ this.getQuadrants(boxedEntry).forEach((quadrant) => {
const quadrantBox = this.children.get(quadrant);
- quadrantBox?.insert(id, dimension, center);
+ quadrantBox?.insert(boxedEntry);
});
return;
}
- this.objects.push({ id, dimension, center });
+ this.objects.push(boxedEntry);
if (
this.objects.length > this.splitThreshold &&
@@ -66,6 +65,7 @@ export class QuadTree {
public clear(): void {
this.objects = [];
+
if (this.hasChildren()) {
this.children.forEach((child) => child.clear());
this.children.clear();