提供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

@@ -542,6 +542,26 @@ var es;
}
return this;
};
Component.prototype.addComponent = function (component) {
return this.entity.addComponent(component);
};
Component.prototype.getComponent = function (type) {
return this.entity.getComponent(type);
};
Component.prototype.getComponents = function (typeName, componentList) {
return this.entity.getComponents(typeName, componentList);
};
Component.prototype.hasComponent = function (type) {
return this.entity.hasComponent(type);
};
Component.prototype.removeComponent = function (component) {
if (component) {
this.entity.removeComponent(component);
}
else {
this.entity.removeComponent(this);
}
};
Component._idGenerator = 0;
return Component;
}());