diff options
Diffstat (limited to 'client/lib/entities/Entity.ts')
-rw-r--r-- | client/lib/entities/Entity.ts | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/client/lib/entities/Entity.ts b/client/lib/entities/Entity.ts deleted file mode 100644 index e57ccde..0000000 --- a/client/lib/entities/Entity.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { Component } from "../components"; -import { ComponentNotFoundError } from "../exceptions"; - -export abstract class Entity { - private static ID = 0; - - public readonly id: number; - public readonly components: Map<string, Component>; - - constructor() { - this.id = Entity.ID++; - this.components = new Map(); - } - - public addComponent(component: Component) { - this.components.set(component.name, component); - } - - public getComponent<T extends Component>(name: string): T { - if (!this.hasComponent(name)) { - throw new Error("Entity does not have component " + name); - } - return this.components.get(name) as T; - } - - public getComponents(): Component[] { - return Array.from(this.components.values()); - } - - public hasComponent(name: string): boolean { - return this.components.has(name); - } -} |