Add more test coverage
This commit is contained in:
@@ -5,13 +5,16 @@ export class EntityManager {
|
||||
private grid: Map<number, EntityId[]> = new Map();
|
||||
private actors: Map<EntityId, Actor>;
|
||||
private world: World;
|
||||
private lastId: number = 0;
|
||||
|
||||
constructor(world: World) {
|
||||
this.world = world;
|
||||
this.actors = world.actors;
|
||||
this.lastId = Math.max(0, ...this.actors.keys());
|
||||
this.rebuildGrid();
|
||||
}
|
||||
|
||||
|
||||
rebuildGrid() {
|
||||
this.grid.clear();
|
||||
for (const actor of this.actors.values()) {
|
||||
@@ -77,6 +80,8 @@ export class EntityManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
getActorsAt(x: number, y: number): Actor[] {
|
||||
const i = idx(this.world, x, y);
|
||||
const ids = this.grid.get(i);
|
||||
@@ -93,6 +98,8 @@ export class EntityManager {
|
||||
}
|
||||
|
||||
getNextId(): EntityId {
|
||||
return Math.max(0, ...this.actors.keys()) + 1;
|
||||
this.lastId++;
|
||||
return this.lastId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user