Skip to content

Commit 76369b7

Browse files
authored
Making the entityManager an opt in option (#29)
1 parent 1db75ce commit 76369b7

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/entity_manager.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ class EntityManager {
1414
#entitiesUpdated: Entity[] = [];
1515

1616
constructor() {
17+
game.on('frame', () => {
18+
this.#entities = this.#entitiesUpdated;
19+
this.#entitiesUpdated = [];
20+
});
21+
}
22+
23+
get entities(): Entity[] {
24+
return this.#entities;
25+
}
26+
27+
/**
28+
* Calling this method is mandatory to start recording entities.
29+
*/
30+
initialize(): void {
1731
this.#triangleHook();
1832

1933
this.#squareHook();
@@ -24,15 +38,6 @@ class EntityManager {
2438

2539
//when is a player being drawn?
2640
this.#playerHook();
27-
28-
game.on('frame', () => {
29-
this.#entities = this.#entitiesUpdated;
30-
this.#entitiesUpdated = [];
31-
});
32-
}
33-
34-
get entities(): Entity[] {
35-
return this.#entities;
3641
}
3742

3843
/**

0 commit comments

Comments
 (0)