补充TypeDecorators文件对ComponentType参数类型的修改

This commit is contained in:
MirageTank
2025-09-30 12:53:23 +08:00
parent e92c0040b5
commit a7349bd360

View File

@@ -1,5 +1,6 @@
import type { Component } from '../Component'; import type {Component} from '../Component';
import type { EntitySystem } from '../Systems/EntitySystem'; import type {EntitySystem} from '../Systems';
import {ComponentType} from "../../Types";
/** /**
* 存储组件类型名称的Symbol键 * 存储组件类型名称的Symbol键
@@ -72,8 +73,8 @@ export function ECSSystem(typeName: string) {
* @param componentType 组件构造函数 * @param componentType 组件构造函数
* @returns 组件类型名称 * @returns 组件类型名称
*/ */
export function getComponentTypeName<T extends Component>( export function getComponentTypeName(
componentType: new (...args: any[]) => T componentType: ComponentType
): string { ): string {
// 优先使用装饰器指定的名称 // 优先使用装饰器指定的名称
const decoratorName = (componentType as any)[COMPONENT_TYPE_NAME]; const decoratorName = (componentType as any)[COMPONENT_TYPE_NAME];
@@ -111,7 +112,7 @@ export function getSystemTypeName<T extends EntitySystem>(
* @returns 组件类型名称 * @returns 组件类型名称
*/ */
export function getComponentInstanceTypeName(component: Component): string { export function getComponentInstanceTypeName(component: Component): string {
return getComponentTypeName(component.constructor as new (...args: any[]) => Component); return getComponentTypeName(component.constructor as ComponentType);
} }
/** /**