* @zh 获取或创建指定类型的组件 * @en Get or create component of specified type * * @zh 如果组件已存在则返回现有组件,否则创建新组件并添加到实体 * @en Returns existing component if present, otherwise creates and adds new component * * @param type - @zh 组件类型构造函数 @en Component type constructor * @param args
(
type: ComponentType<T>,
...args: ConstructorParameters<ComponentType<T>>
)
| 573 | * ``` |
| 574 | */ |
| 575 | public getOrCreateComponent<T extends Component>( |
| 576 | type: ComponentType<T>, |
| 577 | ...args: ConstructorParameters<ComponentType<T>> |
| 578 | ): T { |
| 579 | let component = this.getComponent(type); |
| 580 | if (!component) { |
| 581 | // eslint-disable-next-line @typescript-eslint/no-unsafe-argument |
| 582 | component = this.createComponent(type, ...args); |
| 583 | } |
| 584 | return component; |
| 585 | } |
| 586 | |
| 587 | /** |
| 588 | * @zh 标记组件为已修改 |
nothing calls this directly
no test coverage detected