新增identifierPool用于实体id复用

This commit is contained in:
yhh
2021-05-11 17:23:04 +08:00
parent e94b7b23e4
commit 63d307b95a
6 changed files with 65 additions and 11 deletions

View File

@@ -13,11 +13,13 @@ module es {
public readonly entityProcessors: EntityProcessorList;
public readonly _sceneComponents: SceneComponent[] = [];
public readonly identifierPool: IdentifierPool;
private _didSceneBegin: boolean;
constructor() {
this.entities = new EntityList(this);
this.entityProcessors = new EntityProcessorList();
this.identifierPool = new IdentifierPool();
this.initialize();
}
@@ -145,7 +147,7 @@ module es {
* @param name
*/
public createEntity(name: string) {
let entity = new Entity(name);
let entity = new Entity(name, this.identifierPool.checkOut());
return this.addEntity(entity);
}