EntityList.updateList效率提升10倍
This commit is contained in:
@@ -2695,30 +2695,29 @@ var es;
|
|||||||
EntityList.prototype.updateLists = function () {
|
EntityList.prototype.updateLists = function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
if (this._entitiesToRemove.getCount() > 0) {
|
if (this._entitiesToRemove.getCount() > 0) {
|
||||||
for (var i = 0; i < this._entitiesToRemove.getCount(); i++) {
|
this._entitiesToRemove.toArray().forEach(function (entity) {
|
||||||
var entity = this._entitiesToRemove[i];
|
|
||||||
// 处理标签列表
|
// 处理标签列表
|
||||||
this.removeFromTagList(entity);
|
_this.removeFromTagList(entity);
|
||||||
// 处理常规实体列表
|
// 处理常规实体列表
|
||||||
this._entities.remove(entity);
|
_this._entities.remove(entity);
|
||||||
entity.onRemovedFromScene();
|
entity.onRemovedFromScene();
|
||||||
entity.scene = null;
|
entity.scene = null;
|
||||||
if (es.Core.entitySystemsEnabled)
|
if (es.Core.entitySystemsEnabled)
|
||||||
this.scene.entityProcessors.onEntityRemoved(entity);
|
_this.scene.entityProcessors.onEntityRemoved(entity);
|
||||||
}
|
});
|
||||||
this._entitiesToRemove.clear();
|
this._entitiesToRemove.clear();
|
||||||
}
|
}
|
||||||
if (this._entitiesToAdded.getCount() > 0) {
|
if (this._entitiesToAdded.getCount() > 0) {
|
||||||
for (var i = 0; i < this._entitiesToAdded.getCount(); i++) {
|
this._entitiesToAdded.toArray().forEach(function (entity) {
|
||||||
var entity = this._entitiesToAdded.toArray()[i];
|
_this._entities.add(entity);
|
||||||
this._entities.add(entity);
|
entity.scene = _this.scene;
|
||||||
entity.scene = this.scene;
|
_this.addToTagList(entity);
|
||||||
this.addToTagList(entity);
|
|
||||||
if (es.Core.entitySystemsEnabled)
|
if (es.Core.entitySystemsEnabled)
|
||||||
this.scene.entityProcessors.onEntityAdded(entity);
|
_this.scene.entityProcessors.onEntityAdded(entity);
|
||||||
}
|
});
|
||||||
for (var i = 0; i < this._entitiesToAdded.getCount(); i++)
|
this._entitiesToAdded.toArray().forEach(function (entity) {
|
||||||
this._entitiesToAdded.toArray()[i].onAddedToScene();
|
entity.onAddedToScene();
|
||||||
|
});
|
||||||
this._entitiesToAdded.clear();
|
this._entitiesToAdded.clear();
|
||||||
this._isEntityListUnsorted = true;
|
this._isEntityListUnsorted = true;
|
||||||
}
|
}
|
||||||
@@ -2727,7 +2726,7 @@ var es;
|
|||||||
this._isEntityListUnsorted = false;
|
this._isEntityListUnsorted = false;
|
||||||
}
|
}
|
||||||
// 根据需要对标签列表进行排序
|
// 根据需要对标签列表进行排序
|
||||||
if (this._unsortedTags.size == 0) {
|
if (this._unsortedTags.size > 0) {
|
||||||
this._unsortedTags.forEach(function (value) { return _this._entityDict.get(value).sort(function (a, b) { return a.compareTo(b); }); });
|
this._unsortedTags.forEach(function (value) { return _this._entityDict.get(value).sort(function (a, b) { return a.compareTo(b); }); });
|
||||||
this._unsortedTags.clear();
|
this._unsortedTags.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -136,26 +136,23 @@ module es {
|
|||||||
|
|
||||||
public updateLists() {
|
public updateLists() {
|
||||||
if (this._entitiesToRemove.getCount() > 0) {
|
if (this._entitiesToRemove.getCount() > 0) {
|
||||||
for (let i = 0; i< this._entitiesToRemove.getCount(); i ++) {
|
this._entitiesToRemove.toArray().forEach(entity => {
|
||||||
let entity = this._entitiesToRemove[i];
|
// 处理标签列表
|
||||||
// 处理标签列表
|
this.removeFromTagList(entity);
|
||||||
this.removeFromTagList(entity);
|
|
||||||
|
|
||||||
// 处理常规实体列表
|
|
||||||
this._entities.remove(entity);
|
|
||||||
entity.onRemovedFromScene();
|
|
||||||
entity.scene = null;
|
|
||||||
|
|
||||||
if (Core.entitySystemsEnabled)
|
|
||||||
this.scene.entityProcessors.onEntityRemoved(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 处理常规实体列表
|
||||||
|
this._entities.remove(entity);
|
||||||
|
entity.onRemovedFromScene();
|
||||||
|
entity.scene = null;
|
||||||
|
|
||||||
|
if (Core.entitySystemsEnabled)
|
||||||
|
this.scene.entityProcessors.onEntityRemoved(entity);
|
||||||
|
});
|
||||||
this._entitiesToRemove.clear();
|
this._entitiesToRemove.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._entitiesToAdded.getCount() > 0) {
|
if (this._entitiesToAdded.getCount() > 0) {
|
||||||
for (let i = 0; i < this._entitiesToAdded.getCount(); i ++) {
|
this._entitiesToAdded.toArray().forEach(entity => {
|
||||||
let entity = this._entitiesToAdded.toArray()[i];
|
|
||||||
this._entities.add(entity);
|
this._entities.add(entity);
|
||||||
entity.scene = this.scene;
|
entity.scene = this.scene;
|
||||||
|
|
||||||
@@ -163,10 +160,11 @@ module es {
|
|||||||
|
|
||||||
if (Core.entitySystemsEnabled)
|
if (Core.entitySystemsEnabled)
|
||||||
this.scene.entityProcessors.onEntityAdded(entity);
|
this.scene.entityProcessors.onEntityAdded(entity);
|
||||||
}
|
});
|
||||||
|
|
||||||
for (let i = 0; i < this._entitiesToAdded.getCount(); i ++)
|
this._entitiesToAdded.toArray().forEach(entity => {
|
||||||
this._entitiesToAdded.toArray()[i].onAddedToScene();
|
entity.onAddedToScene();
|
||||||
|
})
|
||||||
|
|
||||||
this._entitiesToAdded.clear();
|
this._entitiesToAdded.clear();
|
||||||
this._isEntityListUnsorted = true;
|
this._isEntityListUnsorted = true;
|
||||||
@@ -178,7 +176,7 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据需要对标签列表进行排序
|
// 根据需要对标签列表进行排序
|
||||||
if (this._unsortedTags.size == 0) {
|
if (this._unsortedTags.size > 0) {
|
||||||
this._unsortedTags.forEach(value => this._entityDict.get(value).sort((a, b) => a.compareTo(b)));
|
this._unsortedTags.forEach(value => this._entityDict.get(value).sort((a, b) => a.compareTo(b)));
|
||||||
|
|
||||||
this._unsortedTags.clear();
|
this._unsortedTags.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user