summaryrefslogtreecommitdiff
path: root/engine/entities/Entity.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-25 16:48:17 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-25 16:48:17 -0600
commit773ce84f4bf559337e132edd7fcce02a0a2598fd (patch)
tree5fd0b452b459cc5a5b6a1ed98f2d7b9af950864d /engine/entities/Entity.ts
parentdec7b614d895a1b507137e4a96a8999ff63aa179 (diff)
downloadjumpstorm-773ce84f4bf559337e132edd7fcce02a0a2598fd.tar.gz
jumpstorm-773ce84f4bf559337e132edd7fcce02a0a2598fd.zip
prettier formatting
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);
}
}
}