mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-09-03 04:03:46 +08:00
修复发布模式下类名混淆导致addBusinesss属性绑定失败的问题
This commit is contained in:
@@ -296,12 +296,22 @@ export abstract class CCEntity extends ecs.Entity {
|
||||
this.businesss.delete(cls);
|
||||
|
||||
// 清理实体上的业务逻辑组件引用
|
||||
delete (this as any)[cls.name];
|
||||
this.deleteBusinessRef(business);
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/** 删除实体上指向指定 business 实例的属性引用 */
|
||||
private deleteBusinessRef(business: CCBusiness<CCEntity>) {
|
||||
for (const key of Object.keys(this)) {
|
||||
if ((this as any)[key] === business) {
|
||||
delete (this as any)[key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
// 1. 先销毁所有子实体,避免内存泄漏
|
||||
if (this.singletons) {
|
||||
@@ -317,10 +327,10 @@ export abstract class CCEntity extends ecs.Entity {
|
||||
|
||||
// 2. 再销毁所有业务组件
|
||||
if (this.businesss) {
|
||||
this.businesss.forEach((business, cls) => {
|
||||
this.businesss.forEach((business) => {
|
||||
business.destroy();
|
||||
// 清理实体上的业务逻辑组件引用
|
||||
delete (this as any)[cls.name];
|
||||
this.deleteBusinessRef(business);
|
||||
});
|
||||
this.businesss.clear();
|
||||
this.businesss = null!;
|
||||
|
||||
Reference in New Issue
Block a user