From f448fa48c443758580e88dfe473b16a9e0bb2905 Mon Sep 17 00:00:00 2001 From: MirageTank <1455496974@qq.com> Date: Tue, 30 Sep 2025 11:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=BB=84=E4=BB=B6=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=AE=A1=E7=90=86=E5=99=A8=E7=9B=B8=E5=85=B3=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=8F=82=E6=95=B0=E4=BB=A5=E4=BD=BF=E7=94=A8Component?= =?UTF-8?q?Type,=E8=80=8C=E4=B8=8D=E6=98=AFComponent.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/ECS/Utils/ComponentTypeManager.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/ECS/Utils/ComponentTypeManager.ts b/packages/core/src/ECS/Utils/ComponentTypeManager.ts index 37c70051..bc80cf63 100644 --- a/packages/core/src/ECS/Utils/ComponentTypeManager.ts +++ b/packages/core/src/ECS/Utils/ComponentTypeManager.ts @@ -1,6 +1,6 @@ -import { Component } from '../Component'; import { Bits } from './Bits'; import { getComponentTypeName } from '../Decorators'; +import { ComponentType } from "../../Types"; /** * 组件类型管理器 @@ -29,7 +29,7 @@ export class ComponentTypeManager { * @param componentType 组件类型构造函数 * @returns 组件类型ID */ - public getTypeId(componentType: new (...args: unknown[]) => T): number { + public getTypeId(componentType: ComponentType): number { let typeId = this._componentTypes.get(componentType); if (typeId === undefined) { @@ -55,7 +55,7 @@ export class ComponentTypeManager { * @param componentTypes 组件类型构造函数数组 * @returns Bits对象 */ - public createBits(...componentTypes: (new (...args: unknown[]) => Component)[]): Bits { + public createBits(...componentTypes: ComponentType[]): Bits { const bits = new Bits(); for (const componentType of componentTypes) { @@ -71,11 +71,11 @@ export class ComponentTypeManager { * @param components 组件数组 * @returns Bits对象 */ - public getEntityBits(components: Component[]): Bits { + public getEntityBits(components: ComponentType[]): Bits { const bits = new Bits(); for (const component of components) { - const typeId = this.getTypeId(component.constructor as new (...args: unknown[]) => Component); + const typeId = this.getTypeId(component); bits.set(typeId); }