优化component add/remove效率

This commit is contained in:
yhh
2021-04-20 15:46:18 +08:00
parent 17b36f01b0
commit b5d0fc6d0d
7 changed files with 209 additions and 220 deletions

View File

@@ -8,11 +8,20 @@ module es {
* - onRemovedFromEntity
*/
export abstract class Component {
public static _idGenerator: number = 0;
/**
* 此组件的唯一标识
*/
public readonly id: number;
/**
* 此组件附加的实体
*/
public entity: Entity;
constructor() {
this.id = Component._idGenerator++;
}
/**
* 快速访问 this.entity.transform
*/