新增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

@@ -234,7 +234,6 @@ declare module es {
compare(self: Entity, other: Entity): number;
}
class Entity implements IEqualityComparable {
static _idGenerator: number;
static entityComparer: IComparer<Entity>;
/**
* 当前实体所属的场景
@@ -261,7 +260,7 @@ declare module es {
*/
updateInterval: number;
componentBits: Bits;
constructor(name: string);
constructor(name: string, id: number);
_isDestroyed: boolean;
/**
* 如果调用了destroy那么在下一次处理实体之前这将一直为true
@@ -651,6 +650,7 @@ declare module es {
*/
readonly entityProcessors: EntityProcessorList;
readonly _sceneComponents: SceneComponent[];
readonly identifierPool: IdentifierPool;
private _didSceneBegin;
constructor();
/**
@@ -1863,6 +1863,15 @@ declare module es {
static getHashCode(str: any): number;
}
}
declare module es {
class IdentifierPool {
private ids;
private nextAvailableId_;
constructor();
checkOut(): number;
checkIn(id: number): void;
}
}
declare module es {
class Matcher {
protected allSet: (new (...args: any[]) => Component)[];