From df29a0a928d927cf39641cb9918b9782396c3dcb Mon Sep 17 00:00:00 2001 From: dgflash Date: Tue, 12 Nov 2024 11:30:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ECSEntity=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E5=BC=BA=E9=94=99=E8=AF=AF=E4=BD=BF=E7=94=A8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E7=B2=BE=E5=87=86=E7=9A=84=E6=8A=A5=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/libs/ecs/ECSEntity.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/assets/libs/ecs/ECSEntity.ts b/assets/libs/ecs/ECSEntity.ts index 2e95918..a790a90 100644 --- a/assets/libs/ecs/ECSEntity.ts +++ b/assets/libs/ecs/ECSEntity.ts @@ -126,14 +126,14 @@ export class ECSEntity { if (typeof ctor === 'function') { let compTid = ctor.tid; if (ctor.tid === -1) { - throw Error('组件未注册!'); + throw Error(`【${this.name}】实体【${ctor.compName}】组件未注册`); } if (this.compTid2Ctor.has(compTid)) { // 判断是否有该组件,如果有则先移除 if (isReAdd) { this.remove(ctor); } else { - console.log(`已经存在组件:${ctor.compName}`); + console.log(`【${this.name}】实体【${ctor.compName}】组件已存在`); // @ts-ignore return this[ctor.compName] as T; } @@ -165,12 +165,8 @@ export class ECSEntity { let compTid = tmpCtor.tid; // console.assert(compTid !== -1 || !compTid, '组件未注册!'); // console.assert(this.compTid2Ctor.has(compTid), '已存在该组件!'); - if (compTid === -1 || compTid == null) { - throw Error('组件未注册'); - } - if (this.compTid2Ctor.has(compTid)) { - throw Error('已经存在该组件'); - } + if (compTid === -1 || compTid == null) throw Error(`【${this.name}】实体【${tmpCtor.name}】组件未注册`); + if (this.compTid2Ctor.has(compTid)) throw Error(`【${this.name}】实体【${tmpCtor.name}】组件已经存在`); this.mask.set(compTid); //@ts-ignore