|
| 1 | +import { ObjectPool } from "./ObjectPool.js"; |
| 2 | +import QueryManager from "./QueryManager.js"; |
| 3 | +import EventDispatcher from "./EventDispatcher.js"; |
| 4 | +import { SystemStateComponent } from "./SystemStateComponent.js"; |
| 5 | + |
| 6 | +export class EntityManager { |
| 7 | + |
| 8 | + constructor(world); |
| 9 | + |
| 10 | + getEntityByName(name); |
| 11 | + |
| 12 | + /** |
| 13 | + * Create a new entity |
| 14 | + */ |
| 15 | + createEntity(name); |
| 16 | + |
| 17 | + entityAddComponent(entity, Component, values); |
| 18 | + |
| 19 | + /** |
| 20 | + * Remove a component from an entity |
| 21 | + * @param {Entity} entity Entity which will get removed the component |
| 22 | + * @param {*} Component Component to remove from the entity |
| 23 | + * @param {Bool} immediately If you want to remove the component immediately instead of deferred (Default is false) |
| 24 | + */ |
| 25 | + entityRemoveComponent(entity, Component, immediately); |
| 26 | + |
| 27 | + _entityRemoveComponentSync(entity, Component, index); |
| 28 | + |
| 29 | + /** |
| 30 | + * Remove all the components from an entity |
| 31 | + * @param {Entity} entity Entity from which the components will be removed |
| 32 | + */ |
| 33 | + entityRemoveAllComponents(entity, immediately); |
| 34 | + |
| 35 | + /** |
| 36 | + * Remove the entity from this manager. It will clear also its components |
| 37 | + * @param {Entity} entity Entity to remove from the manager |
| 38 | + * @param {Bool} immediately If you want to remove the component immediately instead of deferred (Default is false) |
| 39 | + */ |
| 40 | + removeEntity(entity, immediately); |
| 41 | + |
| 42 | + /** |
| 43 | + * Remove all entities from this manager |
| 44 | + */ |
| 45 | + removeAllEntities(); |
| 46 | + |
| 47 | + processDeferredRemoval(); |
| 48 | + |
| 49 | + /** |
| 50 | + * Get a query based on a list of components |
| 51 | + * @param {Array(Component)} Components List of components that will form the query |
| 52 | + */ |
| 53 | + queryComponents(Components); |
| 54 | + |
| 55 | + /** |
| 56 | + * Return number of entities |
| 57 | + */ |
| 58 | + count(); |
| 59 | + |
| 60 | + /** |
| 61 | + * Return some stats |
| 62 | + */ |
| 63 | + stats(); |
| 64 | +} |
0 commit comments