From a7349bd36003e546517729b83e2e1094b79103ec Mon Sep 17 00:00:00 2001 From: MirageTank <1455496974@qq.com> Date: Tue, 30 Sep 2025 12:53:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85TypeDecorators=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AF=B9ComponentType=E5=8F=82=E6=95=B0=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/ECS/Decorators/TypeDecorators.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/core/src/ECS/Decorators/TypeDecorators.ts b/packages/core/src/ECS/Decorators/TypeDecorators.ts index db18e058..5c82d0ee 100644 --- a/packages/core/src/ECS/Decorators/TypeDecorators.ts +++ b/packages/core/src/ECS/Decorators/TypeDecorators.ts @@ -1,5 +1,6 @@ -import type { Component } from '../Component'; -import type { EntitySystem } from '../Systems/EntitySystem'; +import type {Component} from '../Component'; +import type {EntitySystem} from '../Systems'; +import {ComponentType} from "../../Types"; /** * 存储组件类型名称的Symbol键 @@ -72,8 +73,8 @@ export function ECSSystem(typeName: string) { * @param componentType 组件构造函数 * @returns 组件类型名称 */ -export function getComponentTypeName( - componentType: new (...args: any[]) => T +export function getComponentTypeName( + componentType: ComponentType ): string { // 优先使用装饰器指定的名称 const decoratorName = (componentType as any)[COMPONENT_TYPE_NAME]; @@ -111,7 +112,7 @@ export function getSystemTypeName( * @returns 组件类型名称 */ export function getComponentInstanceTypeName(component: Component): string { - return getComponentTypeName(component.constructor as new (...args: any[]) => Component); + return getComponentTypeName(component.constructor as ComponentType); } /**