···9090 */
9191 public id: number = Entity._ID++;
92929393- public name = `Entity#${this.id}`;
9393+ public name: string = `Entity#${this.id}`;
94949595 /**
9696 * Listen to or emit events for an entity
9797 */
9898- public events = new EventEmitter<EntityEvents>();
9898+ public events: EventEmitter<EntityEvents> = new EventEmitter<EntityEvents>();
9999 private _tags = new Set<string>();
100100- public componentAdded$ = new Observable<Component>();
101101- public componentRemoved$ = new Observable<Component>();
102102- public tagAdded$ = new Observable<string>();
103103- public tagRemoved$ = new Observable<string>();
100100+ public componentAdded$: Observable<Component> = new Observable<Component>();
101101+ public componentRemoved$: Observable<Component> = new Observable<Component>();
102102+ public tagAdded$: Observable<string> = new Observable<string>();
103103+ public tagRemoved$: Observable<string> = new Observable<string>();
104104 /**
105105 * Current components on the entity
106106 *
···108108 *
109109 * Use addComponent/removeComponent otherwise the ECS will not be notified of changes.
110110 */
111111- public readonly components = new Map<Function, Component>();
111111+ public readonly components: Map<Function, Component> = new Map<Function, Component>();
112112 public componentValues: Component[] = [];
113113 private _componentsToRemove: ComponentCtor[] = [];
114114···175175 this.emit('kill', new KillEvent(this));
176176 }
177177178178- public isKilled() {
178178+ public isKilled(): boolean {
179179 return !this.isActive;
180180 }
181181···265265 return this._parent;
266266 }
267267268268- public childrenAdded$ = new Observable<Entity>();
269269- public childrenRemoved$ = new Observable<Entity>();
268268+ public childrenAdded$: Observable<Entity> = new Observable<Entity>();
269269+ public childrenRemoved$: Observable<Entity> = new Observable<Entity>();
270270271271 private _children: Entity[] = [];
272272 /**
···279279 /**
280280 * Unparents this entity, if there is a parent. Otherwise it does nothing.
281281 */
282282- public unparent() {
282282+ public unparent(): void {
283283 if (this._parent) {
284284 this._parent.removeChild(this);
285285 this._parent = null;
+6-6
src/query.ts
···1414 */
1515export class Query<TKnownComponentCtors extends ComponentCtor<Component> = never> {
1616 public readonly id: string;
1717- public components = new Set<TKnownComponentCtors>();
1717+ public components: Set<TKnownComponentCtors> = new Set<TKnownComponentCtors>();
1818 public entities: Entity<ComponentInstance<TKnownComponentCtors>>[] = [];
1919 /**
2020 * This fires right after the component is added
2121 */
2222- public entityAdded$ = new Observable<Entity<ComponentInstance<TKnownComponentCtors>>>();
2222+ public entityAdded$: Observable<Entity<ComponentInstance<TKnownComponentCtors>>> = new Observable<Entity<ComponentInstance<TKnownComponentCtors>>>();
2323 /**
2424 * This fires right before the component is actually removed from the entity, it will still be available for cleanup purposes
2525 */
2626- public entityRemoved$ = new Observable<Entity<ComponentInstance<TKnownComponentCtors>>>();
2626+ public entityRemoved$: Observable<Entity<ComponentInstance<TKnownComponentCtors>>> = new Observable<Entity<ComponentInstance<TKnownComponentCtors>>>();
27272828 constructor(public readonly requiredComponents: TKnownComponentCtors[]) {
2929 if (requiredComponents.length === 0) {
···3636 this.id = Query.createId(requiredComponents);
3737 }
38383939- static createId(requiredComponents: Function[]) {
3939+ static createId(requiredComponents: Function[]): string {
4040 // TODO what happens if a user defines the same type name as a built in type
4141 // ! TODO this could be dangerous depending on the bundler's settings for names
4242 // Maybe some kind of hash function is better here?
···5151 * Potentially adds an entity to a query index, returns true if added, false if not
5252 * @param entity
5353 */
5454- checkAndAdd(entity: Entity) {
5454+ checkAndAdd(entity: Entity): boolean {
5555 if (!this.entities.includes(entity) && entity.hasAll(Array.from(this.components))) {
5656 this.entities.push(entity);
5757 this.entityAdded$.notifyAll(entity);
···6060 return false;
6161 }
62626363- removeEntity(entity: Entity) {
6363+ removeEntity(entity: Entity): void {
6464 const index = this.entities.indexOf(entity);
6565 if (index > -1) {
6666 this.entities.splice(index, 1);
+6-6
src/tag-query.ts
···3344export class TagQuery<TKnownTags extends string = never> {
55 public readonly id: string;
66- public tags = new Set<TKnownTags>();
66+ public tags: Set<TKnownTags> = new Set<TKnownTags>();
77 public entities: Entity<any>[] = [];
88 /**
99 * This fires right after the component is added
1010 */
1111- public entityAdded$ = new Observable<Entity<any>>();
1111+ public entityAdded$: Observable<Entity<any>> = new Observable<Entity<any>>();
1212 /**
1313 * This fires right before the component is actually removed from the entity, it will still be available for cleanup purposes
1414 */
1515- public entityRemoved$ = new Observable<Entity<any>>();
1515+ public entityRemoved$: Observable<Entity<any>> = new Observable<Entity<any>>();
16161717 constructor(public readonly requiredTags: TKnownTags[]) {
1818 if (requiredTags.length === 0) {
···2525 this.id = TagQuery.createId(requiredTags);
2626 }
27272828- static createId(requiredComponents: string[]) {
2828+ static createId(requiredComponents: string[]): string {
2929 return requiredComponents.slice().sort().join('-');
3030 }
31313232- checkAndAdd(entity: Entity) {
3232+ checkAndAdd(entity: Entity): boolean {
3333 if (!this.entities.includes(entity) && entity.hasAllTags(Array.from(this.tags))) {
3434 this.entities.push(entity);
3535 this.entityAdded$.notifyAll(entity);
···3838 return false;
3939 }
40404141- removeEntity(entity: Entity) {
4141+ removeEntity(entity: Entity): void {
4242 const index = this.entities.indexOf(entity);
4343 if (index > -1) {
4444 this.entities.splice(index, 1);
+2-2
src/world.ts
···7878 /**
7979 * Get a system out of the ECS world
8080 */
8181- get(system: SystemCtor<System>) {
8181+ get(system: SystemCtor<System>): System<TContext> | null {
8282 return this.systemManager.get(system);
8383 }
8484···110110 //);
111111 }
112112113113- get entities() {
113113+ get entities(): Entity<any, TContext>[] {
114114 return this.entityManager.entities;
115115 }
116116