-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript support #7
Comments
I have some rough typings. Feel free to use them or I can tidy up them up and make a PR if the author wants them? |
That link is dead now - here's the typings: // entity-component-system.d.ts
declare module "entity-component-system" {
export class EntityComponentSystem {
constructor();
add(system: System): void;
addEach(system: System, search: string): void;
run(entityPool: EntityPool, elapsedTime: number): void;
runs(): number;
timings(): { [key: string]: number };
resetTimings(): void;
}
export class EntityPool {
constructor();
create(): number;
destroy(id: number): void;
registerComponent<Component>(
component: string,
factory: () => Component,
reset?: (component: Component) => void,
size?: number,
): void;
addComponent<Component>(
id: number,
component: string,
): Component;
getComponent<Component>(
id: number,
component: string,
): Component;
setComponent<Component>(
id: number,
component: string,
value: Component
): void;
onAddComponent<Component>(
component: string,
callback: Callback<Component>
): void;
onRemoveComponent<Component>(
component: string,
callback: Callback<Component>
): void;
registerSearch(
search: string,
components: string[]
): void;
find(
search: string,
): number[];
load(entities: EntityJson[]): void;
save(): EntityJson[];
}
export interface System {
(entityPool: EntityPool, elapsedTime: number): void
}
export interface Callback<Component> {
(id: number, component: string, value: Component): void;
}
export interface EntityJson {
id: number,
[componentName: string]: any
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be great.
Also, would it be possible to define a component as a Typescript interface?
The text was updated successfully, but these errors were encountered: