fix wx
This commit is contained in:
@@ -60,7 +60,7 @@ module es {
|
||||
}
|
||||
|
||||
public onChanged(entity: Entity) {
|
||||
let contains = entity.getSystemBits().get(this.systemIndex_);
|
||||
let contains = new es.List(this._entities).contains(entity);
|
||||
let interest = this._matcher.isInterestedEntity(entity);
|
||||
|
||||
if (interest && !contains)
|
||||
@@ -71,7 +71,6 @@ module es {
|
||||
|
||||
public add(entity: Entity) {
|
||||
this._entities.push(entity);
|
||||
entity.getSystemBits().set(this.systemIndex_);
|
||||
this.onAdded(entity);
|
||||
}
|
||||
|
||||
@@ -79,7 +78,6 @@ module es {
|
||||
|
||||
public remove(entity: Entity) {
|
||||
new es.List(this._entities).remove(entity);
|
||||
entity.getSystemBits().clear(this.systemIndex_);
|
||||
this.onRemoved(entity);
|
||||
}
|
||||
|
||||
|
||||
39
source/src/ECS/Utils/ComponentTypeFactory.ts
Normal file
39
source/src/ECS/Utils/ComponentTypeFactory.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
module es {
|
||||
interface IdentityHashMap {
|
||||
[key: string]: ComponentType;
|
||||
}
|
||||
|
||||
export class ComponentTypeFactory {
|
||||
private componentTypes_: IdentityHashMap;
|
||||
|
||||
private componentTypeCount_ = 0;
|
||||
|
||||
public types: Bag<ComponentType>;
|
||||
|
||||
constructor() {
|
||||
this.componentTypes_ = {};
|
||||
this.types = new Bag<ComponentType>();
|
||||
}
|
||||
|
||||
public getTypeFor(c): ComponentType {
|
||||
if ("number" === typeof c) {
|
||||
return this.types.get(c);
|
||||
}
|
||||
|
||||
let type: ComponentType = this.componentTypes_[getClassName(c)];
|
||||
|
||||
if (type == null) {
|
||||
const index: number = this.componentTypeCount_++;
|
||||
type = new ComponentType(c, index);
|
||||
this.componentTypes_[getClassName(c)] = type;
|
||||
this.types.set(index, type);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public getIndexFor(c): number {
|
||||
return this.getTypeFor(c).getIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user