提供component的快捷操作

This commit is contained in:
yhh
2021-08-20 19:05:40 +08:00
parent 6adea240e2
commit d54ccaf629
5 changed files with 52 additions and 3 deletions

View File

@@ -118,5 +118,29 @@ module es {
return this;
}
public addComponent<T extends Component>(component: T) {
return this.entity.addComponent(component);
}
public getComponent(type: new (...args: any[])=>Component) {
return this.entity.getComponent(type);
}
public getComponents(typeName: any, componentList?: any[]) {
return this.entity.getComponents(typeName, componentList);
}
public hasComponent(type: new (...args: any[])=>Component) {
return this.entity.hasComponent(type);
}
public removeComponent(component?: Component) {
if (component) {
this.entity.removeComponent(component);
} else {
this.entity.removeComponent(this);
}
}
}
}