import type { Component } from "./component.ts"; // deno-lint-ignore no-explicit-any type ComponentConstructor = new (...args: any[]) => T; export class Entity { id: string; // deno-lint-ignore no-explicit-any components = new Map, Component>(); active = true; constructor(id: string = crypto.randomUUID()) { this.id = id; } add(component: T): T { this.components.set(component.constructor as ComponentConstructor, component); return component; } get(type: ComponentConstructor): T | undefined { return this.components.get(type) as T; } get_all(): Iterable { return this.components.values(); } }