diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-23 19:44:59 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-23 19:44:59 -0600 |
commit | dec7b614d895a1b507137e4a96a8999ff63aa179 (patch) | |
tree | 827437755bf9674db51818ee59d919c74a4ea2fc /engine/entities/Entity.ts | |
parent | d64ffb5016119e54f0e20d05ae8ac9c96955d9d5 (diff) | |
download | jumpstorm-dec7b614d895a1b507137e4a96a8999ff63aa179.tar.gz jumpstorm-dec7b614d895a1b507137e4a96a8999ff63aa179.zip |
holy fuck we actually got somewhere
Diffstat (limited to 'engine/entities/Entity.ts')
-rw-r--r-- | engine/entities/Entity.ts | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/engine/entities/Entity.ts b/engine/entities/Entity.ts index 4e9df78..88982cb 100644 --- a/engine/entities/Entity.ts +++ b/engine/entities/Entity.ts @@ -1,10 +1,13 @@ +import { EntityNames, Player } from "."; import type { Component } from "../components"; export abstract class Entity { - public readonly id: string; - public readonly components: Map<string, Component>; + public id: string; + public components: Map<string, Component>; + public name: string; - constructor(id: string = crypto.randomUUID()) { + constructor(name: string, id: string = crypto.randomUUID()) { + this.name = name; this.id = id; this.components = new Map(); } @@ -27,4 +30,13 @@ export abstract class Entity { public hasComponent(name: string): boolean { return this.components.has(name); } + + static from(entityName: string, args: any): Entity { + switch (entityName) { + case EntityNames.Player: + return new Player(args.playerId); + default: + throw new Error(".from() Entity type not implemented: " + entityName); + } + } } |