新增entitylist用于管理实体

This commit is contained in:
yhh
2020-06-08 20:11:58 +08:00
parent 57efc5b0e6
commit a048a8ac29
15 changed files with 936 additions and 38 deletions

View File

@@ -21,7 +21,34 @@ class EntitySystem {
}
public initialize(){
}
public onChanged(entity: Entity){
let contains = this._entities.contains(entity);
let interest = this._matcher.IsIntersted(entity);
if (interest && !contains)
this.add(entity);
else if(!interest && contains)
this.remove(entity);
}
public add(entity: Entity){
this._entities.push(entity);
this.onAdded(entity);
}
public onAdded(entity: Entity){
}
public remove(entity: Entity){
this._entities.remove(entity);
this.onRemoved(entity);
}
public onRemoved(entity: Entity){
}
public update(){