summaryrefslogtreecommitdiff
path: root/engine/entities/Entity.ts
diff options
context:
space:
mode:
Diffstat (limited to 'engine/entities/Entity.ts')
-rw-r--r--engine/entities/Entity.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/engine/entities/Entity.ts b/engine/entities/Entity.ts
index 88982cb..b016fc0 100644
--- a/engine/entities/Entity.ts
+++ b/engine/entities/Entity.ts
@@ -1,5 +1,5 @@
-import { EntityNames, Player } from ".";
-import type { Component } from "../components";
+import { EntityNames, Player } from '.';
+import type { Component } from '../components';
export abstract class Entity {
public id: string;
@@ -18,7 +18,7 @@ export abstract class Entity {
public getComponent<T extends Component>(name: string): T {
if (!this.hasComponent(name)) {
- throw new Error("Entity does not have component " + name);
+ throw new Error('Entity does not have component ' + name);
}
return this.components.get(name) as T;
}
@@ -34,9 +34,11 @@ export abstract class Entity {
static from(entityName: string, args: any): Entity {
switch (entityName) {
case EntityNames.Player:
- return new Player(args.playerId);
+ const player = new Player(args.playerId);
+ player.id = args.id;
+ return player;
default:
- throw new Error(".from() Entity type not implemented: " + entityName);
+ throw new Error('.from() Entity type not implemented: ' + entityName);
}
}
}