listpool根据type划分池

This commit is contained in:
yhh
2021-08-06 11:10:45 +08:00
parent 0beadf8e5a
commit f533186c8d
10 changed files with 71 additions and 51 deletions

View File

@@ -223,7 +223,7 @@ module es {
public entitiesWithTag(tag: number) {
let list = this.getTagList(tag);
let returnList = ListPool.obtain<Entity>();
let returnList = ListPool.obtain<Entity>(Entity);
if (list.size > 0) {
for (let entity of list) {
returnList.push(entity);
@@ -286,7 +286,7 @@ module es {
* @param type
*/
public findComponentsOfType<T extends Component>(type): T[] {
let comps = ListPool.obtain<T>();
let comps = ListPool.obtain<T>(type);
if (this._entities.length > 0) {
for (let i = 0, s = this._entities.length; i < s; i++) {
let entity = this._entities[i];