* @zh 检查实体是否拥有指定类型的组件 * @en Check if entity has component of specified type * * @param type - @zh 组件类型构造函数 @en Component type constructor * @returns @zh 如果实体拥有该组件返回true @en Returns true if entity has the component * * @example * ```typescript * if (entity.hasC
(type: ComponentType<T>)
| 545 | * ``` |
| 546 | */ |
| 547 | public hasComponent<T extends Component>(type: ComponentType<T>): boolean { |
| 548 | const registry = this.scene?.componentRegistry ?? GlobalComponentRegistry; |
| 549 | if (!registry.isRegistered(type)) { |
| 550 | return false; |
| 551 | } |
| 552 | |
| 553 | const mask = registry.getBitMask(type); |
| 554 | return BitMask64Utils.hasAny(this._componentMask, mask); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * @zh 获取或创建指定类型的组件 |
no test coverage detected