新增系统debug使用时间

This commit is contained in:
yhh
2021-04-07 15:24:37 +08:00
parent abb5d10a54
commit e1365ed343
5 changed files with 53 additions and 11 deletions
+6 -1
View File
@@ -1291,6 +1291,11 @@ declare module es {
scene: Scene;
private _matcher;
readonly matcher: Matcher;
private _startTime;
private _endTime;
private _useTime;
/** 获取系统在当前帧所消耗的时间 仅在debug模式下生效 */
readonly useTime: number;
initialize(): void;
onChanged(entity: Entity): void;
add(entity: Entity): void;
@@ -1816,7 +1821,7 @@ declare module es {
}
declare module es {
class EntityProcessorList {
protected _processors: EntitySystem[];
_processors: EntitySystem[];
add(processor: EntitySystem): void;
remove(processor: EntitySystem): void;
onComponentAdded(entity: Entity): void;
+24 -6
View File
@@ -2913,6 +2913,9 @@ var es;
var EntitySystem = /** @class */ (function () {
function EntitySystem(matcher) {
this._entities = [];
this._startTime = 0;
this._endTime = 0;
this._useTime = 0;
this._matcher = matcher ? matcher : es.Matcher.empty();
this.initialize();
}
@@ -2937,6 +2940,14 @@ var es;
enumerable: true,
configurable: true
});
Object.defineProperty(EntitySystem.prototype, "useTime", {
/** 获取系统在当前帧所消耗的时间 仅在debug模式下生效 */
get: function () {
return this._useTime;
},
enumerable: true,
configurable: true
});
EntitySystem.prototype.initialize = function () {
};
EntitySystem.prototype.onChanged = function (entity) {
@@ -2973,13 +2984,22 @@ var es;
* 在系统处理开始前调用
* 在下一个系统开始处理或新的处理回合开始之前以先到者为准使用此方法创建的任何实体都不会激活
*/
EntitySystem.prototype.begin = function () { };
EntitySystem.prototype.begin = function () {
if (!es.Core.Instance.debug)
return;
this._startTime = Date.now();
};
EntitySystem.prototype.process = function (entities) { };
EntitySystem.prototype.lateProcess = function (entities) { };
/**
* 系统处理完毕后调用
*/
EntitySystem.prototype.end = function () { };
EntitySystem.prototype.end = function () {
if (!es.Core.Instance.debug)
return;
this._endTime = Date.now();
this._useTime = this._endTime - this._startTime;
};
/**
* 系统是否需要处理
*
@@ -4045,10 +4065,8 @@ var es;
ComponentList.prototype.update = function () {
this.updateLists();
for (var i = 0; i < this._updatableComponents.length; i++) {
var component = this._updatableComponents[i];
if (component.enabled) {
component.update();
}
if (this._updatableComponents[i].enabled)
this._updatableComponents[i].update();
}
};
ComponentList.prototype.onEntityTransformChanged = function (comp) {
+1 -1
View File
File diff suppressed because one or more lines are too long