Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 47a4dcb

Browse files
committed
typescript: entity-manager: fix missing return types
1 parent b6a1263 commit 47a4dcb

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

src/EntityManager.d.ts

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,86 @@
1-
import { ObjectPool } from "./ObjectPool.js";
2-
import QueryManager from "./QueryManager.js";
3-
import EventDispatcher from "./EventDispatcher.js";
4-
import { SystemStateComponent } from "./SystemStateComponent.js";
1+
import { ComponentConstructor } from "./Component.js";
2+
import { Entity } from "./Entity";
53

64
export class EntityManager {
75

86
constructor(world);
97

10-
getEntityByName(name);
8+
getEntityByName(name): Entity | undefined;
119

1210
/**
1311
* Create a new entity
1412
*/
15-
createEntity(name);
13+
createEntity(name): Entity;
1614

17-
entityAddComponent(entity, Component, values);
15+
entityAddComponent(entity, Component, values): void;
1816

1917
/**
2018
* Remove a component from an entity
2119
* @param {Entity} entity Entity which will get removed the component
2220
* @param {*} Component Component to remove from the entity
2321
* @param {Bool} immediately If you want to remove the component immediately instead of deferred (Default is false)
2422
*/
25-
entityRemoveComponent(entity, Component, immediately);
23+
entityRemoveComponent(entity, Component, immediately): void;
2624

27-
_entityRemoveComponentSync(entity, Component, index);
25+
_entityRemoveComponentSync(entity, Component, index): void;
2826

2927
/**
3028
* Remove all the components from an entity
3129
* @param {Entity} entity Entity from which the components will be removed
3230
*/
33-
entityRemoveAllComponents(entity, immediately);
31+
entityRemoveAllComponents(entity, immediately): void;
3432

3533
/**
3634
* Remove the entity from this manager. It will clear also its components
3735
* @param {Entity} entity Entity to remove from the manager
3836
* @param {Bool} immediately If you want to remove the component immediately instead of deferred (Default is false)
3937
*/
40-
removeEntity(entity, immediately);
38+
removeEntity(entity, immediately): void;
4139

4240
/**
4341
* Remove all entities from this manager
4442
*/
45-
removeAllEntities();
43+
removeAllEntities(): void;
4644

47-
processDeferredRemoval();
45+
processDeferredRemoval(): void;
4846

4947
/**
5048
* Get a query based on a list of components
5149
* @param {Array(Component)} Components List of components that will form the query
5250
*/
53-
queryComponents(Components);
51+
queryComponents(Components): [ ComponentConstructor<any> ];
5452

5553
/**
5654
* Return number of entities
5755
*/
58-
count();
56+
count(): number;
5957

6058
/**
6159
* Return some stats
6260
*/
63-
stats();
61+
stats(): Stats;
62+
}
63+
64+
interface EventDispatcherStats {
65+
fired: number;
66+
handled: number;
67+
}
68+
69+
interface PoolStats {
70+
used: number;
71+
size: number;
72+
}
73+
74+
interface QueryStats {
75+
numComponents: number;
76+
numEntities: number;
77+
}
78+
79+
interface Stats {
80+
numEntities: number;
81+
numQueries: number;
82+
queries: { [ key: string ]: QueryStats };
83+
numComponentPool: number;
84+
componentPool: { [ key: string ]: PoolStats };
85+
eventDispatcher: EventDispatcherStats;
6486
}

0 commit comments

Comments
 (0)