/gg-entities.d.ts Secret
Created
May 17, 2017 23:19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'gg-entities' { | |
type Component = any | |
type Id = number | |
type ComponentsMask = number | |
type Entity = { components: ComponentsMask } | |
enum SystemType { | |
Logic, | |
Render, | |
Init, | |
} | |
export class EntityManager { | |
constructor(capacity?: number) | |
increaseCapacity() | |
newEntity(components: ComponentsMask | Array<Id>): { id: Id, entity: Entity | null } | |
deleteEntity(id: Id) | |
getEntities(components?: ComponentsMask): Generator | |
registerConfiguration(): Id | |
registerComponent(name: string, component: any): Id | |
addComponent(entityId: Id, component) | |
removeComponent(entityId: Id, component) | |
registerSystem(type: SystemType, components: ComponentsMask | Array<Id>, callback: Function): Id | |
registerLogicSystem(components: ComponentsMask | Array<Id>, callback: Function): Id | |
registerRenderSystem(components: ComponentsMask | Array<Id>, callback: Function): Id | |
registerInitSystem(components: ComponentsMask | Array<Id>, callback: Function): Id | |
removeSystem(systemId: Id): boolean | |
onLogic(opts: any) | |
onRender(opts: any) | |
onInit(opts: any) | |
// Entity Factory | |
registerInitializer(component, initializer) | |
build() | |
withComponent(component, initializer) | |
create(count, configurationId) | |
// Event Handler | |
listen(event: string, callback: Function): number | |
stopListen(eventId: number): boolean | |
trigger(): Promise<any> | |
triggerDelayed(): Promise<any> | |
} | |
export class EntityFactory { | |
registerInitializer(id: number, initializer: Function) | |
build(): EntityFactory | |
withComponent(componentId: Id, initializer: Function): EntityFactory | |
createConfiguration(): Map<any, any> | |
create(entityManager: EntityManager, count?: number, configuration?: Map<any, any>) | |
} | |
export class ComponentManager { | |
newComponent(componentId: Id): Component | |
registerComponent(component: Component): Id | |
getComponents(): Map<Id, Component> | |
} | |
export class EventHandler { | |
listen(event: string, callback: Function): number | |
stopListen(eventId: number): boolean | |
trigger(): Promise<any> | |
triggerDelayed(): Promise<any> | |
} | |
export class SystemManager { | |
registerSystem(type: SystemType, components: ComponentsMask, callback: Function): Id | |
removeSystem(systemId: Id): boolean | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment