From 13e1075f541a7fe632c299149bc4906f3a973598 Mon Sep 17 00:00:00 2001 From: dgflash Date: Mon, 26 Aug 2024 13:41:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96GameComponent=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/module/common/GameComponent.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/module/common/GameComponent.ts b/assets/module/common/GameComponent.ts index 2b34f9d..8137f86 100644 --- a/assets/module/common/GameComponent.ts +++ b/assets/module/common/GameComponent.ts @@ -370,7 +370,7 @@ export class GameComponent extends Component { for (const name of args) { var func = self[name]; if (func) - this.on(name, self[name], this); + this.on(name, func, this); else console.error(`名为【${name}】的全局事方法不存在`); } From 947b44b93b1e8e8ca0ffaf4f50ea2d351072f9df Mon Sep 17 00:00:00 2001 From: dgflash Date: Mon, 26 Aug 2024 16:41:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?ECSEntity.removeChild=E6=B7=BB=E5=8A=A0isDe?= =?UTF-8?q?stroy=E6=98=AF=E5=90=A6=E9=87=8A=E6=94=BE=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/libs/ecs/ECSEntity.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/libs/ecs/ECSEntity.ts b/assets/libs/ecs/ECSEntity.ts index 3b1a22c..2879d61 100644 --- a/assets/libs/ecs/ECSEntity.ts +++ b/assets/libs/ecs/ECSEntity.ts @@ -96,13 +96,15 @@ export class ECSEntity { /** * 移除子实体 - * @param entity 被移除的实体对象 + * @param entity 被移除的实体对象 + * @param isDestroy 被移除的实体是否释放,默认为释放 * @returns */ - removeChild(entity: ECSEntity) { + removeChild(entity: ECSEntity, isDestroy = true) { if (this.children == null) return; this.children.delete(entity.eid); + if (isDestroy) entity.destroy(); if (this.children.size == 0) { this._children = null;