import {EntityComponentDataset} from "./EntityComponentDataset";

interface Type<T> extends Function {
    new(...args: any[]): T;
}

export default class Entity {
    public id: number;

    add<T>(component: T): Entity

    removeComponent<T>(componentType: Type<T>): T | null

    removeAllComponents(): void

    getComponent<T>(componentType: Type<T>): T | null

    getComponentSafe<T>(componentType: Type<T>): T

    hasComponent<T>(componentType: Type<T>): boolean

    build(dataset: EntityComponentDataset): number

    destroy(): boolean

    public readonly isBuilt: boolean

    sendEvent(eventName: string, event?: any): void

    addEventListener(eventName: string, listener: (data?: any) => void, context?: any): Entity

    removeEventListener(eventName: string, listener: (data?: any) => void, context?: any): Entity

    static readFromDataset(entity: number, dataset: EntityComponentDataset): Entity

    getFlag(flag: number): boolean

    setFlag(flag: number, value: number): void

    readonly isEntity:boolean
}
