1.新增类型识别
2.EntitySystem新增initialize生命周期,构造函数后执行
This commit is contained in:
@@ -124,7 +124,7 @@ module es {
|
||||
* 获取类型为T的全局管理器
|
||||
* @param type
|
||||
*/
|
||||
public static getGlobalManager<T extends es.GlobalManager>(type): T {
|
||||
public static getGlobalManager<T extends es.GlobalManager>(type: new (...args) => T): T {
|
||||
for (let i = 0; i < this._instance._globalManagers.length; i++) {
|
||||
if (this._instance._globalManagers[i] instanceof type)
|
||||
return this._instance._globalManagers[i] as T;
|
||||
|
||||
@@ -7,6 +7,7 @@ module es {
|
||||
|
||||
constructor(matcher?: Matcher) {
|
||||
this._matcher = matcher ? matcher : Matcher.empty();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
private _scene: Scene;
|
||||
|
||||
@@ -2,7 +2,7 @@ module es {
|
||||
/**
|
||||
* 用于池任何对象
|
||||
*/
|
||||
export class Pool<T> {
|
||||
export class Pool {
|
||||
private static _objectQueue = [];
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,7 @@ module es {
|
||||
* @param type
|
||||
* @param cacheCount
|
||||
*/
|
||||
public static warmCache(type: any, cacheCount: number) {
|
||||
public static warmCache<T>(type: new (...args) => T, cacheCount: number) {
|
||||
cacheCount -= this._objectQueue.length;
|
||||
if (cacheCount > 0) {
|
||||
for (let i = 0; i < cacheCount; i++) {
|
||||
@@ -38,7 +38,7 @@ module es {
|
||||
/**
|
||||
* 如果可以的话,从堆栈中弹出一个项
|
||||
*/
|
||||
public static obtain<T>(type: any): T {
|
||||
public static obtain<T>(type: new (...args) => T): T {
|
||||
if (this._objectQueue.length > 0)
|
||||
return this._objectQueue.shift();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user