reformat code

This commit is contained in:
yhh
2020-07-28 16:25:20 +08:00
parent 5994f0bee3
commit 514572f291
103 changed files with 2896 additions and 2839 deletions

View File

@@ -1,80 +1,82 @@
module es {
export class EntitySystem {
private _scene: Scene;
private _entities: Entity[] = [];
private _matcher: Matcher;
public get matcher(){
return this._matcher;
constructor(matcher?: Matcher) {
this._matcher = matcher ? matcher : Matcher.empty();
}
public get scene(){
private _scene: Scene;
public get scene() {
return this._scene;
}
public set scene(value: Scene){
public set scene(value: Scene) {
this._scene = value;
this._entities = [];
}
constructor(matcher?: Matcher){
this._matcher = matcher ? matcher : Matcher.empty();
private _matcher: Matcher;
public get matcher() {
return this._matcher;
}
public initialize(){
public initialize() {
}
public onChanged(entity: Entity){
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)
else if (!interest && contains)
this.remove(entity);
}
public add(entity: Entity){
public add(entity: Entity) {
this._entities.push(entity);
this.onAdded(entity);
}
public onAdded(entity: Entity){
public onAdded(entity: Entity) {
}
public remove(entity: Entity){
public remove(entity: Entity) {
this._entities.remove(entity);
this.onRemoved(entity);
}
public onRemoved(entity: Entity){
public onRemoved(entity: Entity) {
}
public update(){
public update() {
this.begin();
this.process(this._entities);
}
public lateUpdate(){
public lateUpdate() {
this.lateProcess(this._entities);
this.end();
}
protected begin(){
protected begin() {
}
protected process(entities: Entity[]){
protected process(entities: Entity[]) {
}
protected lateProcess(entities: Entity[]){
protected lateProcess(entities: Entity[]) {
}
protected end(){
protected end() {
}
}