From 5d1609111ccf8a25a5959b7c48cf9964c012ea42 Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Fri, 20 Aug 2021 19:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B3=9B=E5=9E=8B=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/bin/framework.d.ts | 2 +- source/src/ECS/Component.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/bin/framework.d.ts b/source/bin/framework.d.ts index d34149b9..e1cadaa6 100644 --- a/source/bin/framework.d.ts +++ b/source/bin/framework.d.ts @@ -206,7 +206,7 @@ declare module es { setEnabled(isEnabled: boolean): this; setUpdateOrder(updateOrder: number): this; addComponent(component: T): T; - getComponent(type: new (...args: any[]) => Component): Component; + getComponent(type: new (...args: any[]) => T): T; getComponents(typeName: any, componentList?: any[]): any[]; hasComponent(type: new (...args: any[]) => Component): boolean; removeComponent(component?: Component): void; diff --git a/source/src/ECS/Component.ts b/source/src/ECS/Component.ts index 97408c38..c63e78b1 100644 --- a/source/src/ECS/Component.ts +++ b/source/src/ECS/Component.ts @@ -119,12 +119,12 @@ module es { return this; } - public addComponent(component: T) { - return this.entity.addComponent(component); + public addComponent(component: T): T { + return this.entity.addComponent(component); } - public getComponent(type: new (...args: any[])=>Component) { - return this.entity.getComponent(type); + public getComponent(type: new (...args: any[])=>T): T { + return this.entity.getComponent(type); } public getComponents(typeName: any, componentList?: any[]) {