fix: 修改命名错误

Change-Id: I2d3ca13dec39dbcd2befb050d887116cb01df997
This commit is contained in:
denglang 2022-04-14 16:47:26 +08:00
parent bad7227eec
commit 8a2274fb5b
3 changed files with 9 additions and 8 deletions

View File

@ -1,7 +1,7 @@
import { ComType, EntityIndex } from "./Const"; import { ComType, EntityIndex } from "./Const";
import { ECSWorld } from "./ECSWorld"; import { ECSWorld } from "./ECSWorld";
export class ECSFillter { export class ECSFilter {
private _world: ECSWorld = null; private _world: ECSWorld = null;
private _entitiesMap = new Map<EntityIndex, boolean>(); private _entitiesMap = new Map<EntityIndex, boolean>();
@ -21,7 +21,7 @@ export class ECSFillter {
public onEntityEnter(entity: EntityIndex) { public onEntityEnter(entity: EntityIndex) {
if(this._entitiesMap.has(entity)) { if(this._entitiesMap.has(entity)) {
console.warn(`[ECSFillter]: addEntity entity is had ${entity}`); console.warn(`[ECSFilter]: addEntity entity is had ${entity}`);
return true; return true;
} }
this._entitiesMap.set(entity, true); this._entitiesMap.set(entity, true);
@ -30,7 +30,7 @@ export class ECSFillter {
public onEntityLeave(entity: EntityIndex) { public onEntityLeave(entity: EntityIndex) {
if(!this._entitiesMap.has(entity)) { if(!this._entitiesMap.has(entity)) {
console.warn(`[ECSFillter]: removeEntity entity not had ${entity}`); console.warn(`[ECSFilter]: removeEntity entity not had ${entity}`);
return true; return true;
} }
this._entitiesMap.delete(entity); this._entitiesMap.delete(entity);

View File

@ -1,6 +1,6 @@
{ {
"ver": "1.1.0", "ver": "1.1.0",
"uuid": "a2265ecd-3751-461b-9d2f-755ccc56c3da", "uuid": "9d20cc25-61b9-4be8-9e89-47bdcac35a5b",
"importer": "typescript", "importer": "typescript",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,

View File

@ -1,4 +1,4 @@
import { ECSFillter } from "./ECSFillter" import { ECSFilter } from "./ECSFilter"
import { ECSComConstructor, GetComConstructor as GetComConstructor, GetComConstructorType } from "./ECSComponent"; import { ECSComConstructor, GetComConstructor as GetComConstructor, GetComConstructorType } from "./ECSComponent";
import { ECSSystem } from "./ECSSystem"; import { ECSSystem } from "./ECSSystem";
import { ComPoolIndex, ComType, EntityIndex } from "./Const"; import { ComPoolIndex, ComType, EntityIndex } from "./Const";
@ -12,7 +12,7 @@ export class ECSWorld {
private _reservedIds: number[] = []; // 缓存 private _reservedIds: number[] = []; // 缓存
private _entityToComponents: number[][] = []; private _entityToComponents: number[][] = [];
private _componentPools: ECSComponentPool<any>[] = []; private _componentPools: ECSComponentPool<any>[] = [];
private _fillters = new Map<string, ECSFillter>(); private _fillters = new Map<string, ECSFilter>();
private _entitiesToDelete: Set<EntityIndex> = new Set(); private _entitiesToDelete: Set<EntityIndex> = new Set();
/** 获取ComponentPool */ /** 获取ComponentPool */
@ -148,14 +148,15 @@ export class ECSWorld {
}); });
} }
public getFilter(fillterKey: string): ECSFillter {
public getFilter(fillterKey: string): ECSFilter {
if(this._fillters.has(fillterKey)) { if(this._fillters.has(fillterKey)) {
return this._fillters.get(fillterKey); return this._fillters.get(fillterKey);
} }
let [acceptStr, rejectStr] = fillterKey.split("-"); let [acceptStr, rejectStr] = fillterKey.split("-");
let accept = acceptStr && acceptStr.length > 0 ? acceptStr.split(',').map(Number) : null; let accept = acceptStr && acceptStr.length > 0 ? acceptStr.split(',').map(Number) : null;
let reject = rejectStr && rejectStr.length > 0 ? rejectStr.split(',').map(Number) : null; let reject = rejectStr && rejectStr.length > 0 ? rejectStr.split(',').map(Number) : null;
let fillter = new ECSFillter(this, accept, reject); let fillter = new ECSFilter(this, accept, reject);
this._fillters.set(fillterKey, fillter); this._fillters.set(fillterKey, fillter);
// 将当期的entity放入fillter // 将当期的entity放入fillter
for(let i=1; i<this._entityToComponents.length; i++) { for(let i=1; i<this._entityToComponents.length; i++) {