fix(ecs): add entity field to COMPONENT_ADDED event (#396)

Fix missing entity field in COMPONENT_ADDED event payload that caused
ECSRoom's @NetworkEntity auto-broadcast to fail with 'Cannot read
properties of undefined'
This commit is contained in:
YHH
2025-12-30 16:57:11 +08:00
committed by GitHub
parent d9969d0b08
commit 04b08f3f07
2 changed files with 8 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
---
"@esengine/ecs-framework": patch
---
fix(ecs): COMPONENT_ADDED 事件添加 entity 字段
修复 `ECSEventType.COMPONENT_ADDED` 事件缺少 `entity` 字段的问题,导致 ECSRoom 的 `@NetworkEntity` 自动广播功能报错。

View File

@@ -478,6 +478,7 @@ export class Entity {
this.scene.eventSystem.emitSync(ECSEventType.COMPONENT_ADDED, { this.scene.eventSystem.emitSync(ECSEventType.COMPONENT_ADDED, {
timestamp: Date.now(), timestamp: Date.now(),
source: 'Entity', source: 'Entity',
entity: this,
entityId: this.id, entityId: this.id,
entityName: this.name, entityName: this.name,
entityTag: this.tag?.toString(), entityTag: this.tag?.toString(),