Skip to content

Commit 5652948

Browse files
committed
refactor(core): 简化实体删除时的移除钩子调用
详细的提交内容: - 调整 `triggerRemoveHooksForEntityDeletion` 的函数签名,移除未使用的 `HooksContext` 参 数。 - 更新 `World` 在删除实体时的调用方式,直接传入实体 ID、已移除组件和旧 Archetype。 - 该改动用于清理冗余参数,减少删除流程中的上下文创建与传递,保持实体删除路径更简洁。 - 影响范围:`src/core/world-hooks.ts`、`src/core/world.ts` 中的实体删除与生命周期钩子相关逻辑。 - 其他需要说明的重要信息:此次变更不影响对外 API 的核心能力,仅是内部实现层面的重构。
1 parent 5e72c8c commit 5652948

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

src/core/world-hooks.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export function triggerLifecycleHooks(
7474
* is being completely removed.
7575
*/
7676
export function triggerRemoveHooksForEntityDeletion(
77-
_ctx: HooksContext,
7877
entityId: EntityId,
7978
removedComponents: Map<EntityId<any>, any>,
8079
oldArchetype: Archetype,

src/core/world.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class World {
270270
this.entityToArchetype.delete(cur);
271271

272272
// Trigger lifecycle hooks for removed components (fast path for entity deletion)
273-
triggerRemoveHooksForEntityDeletion(this.createHooksContext(), cur, removedComponents, archetype);
273+
triggerRemoveHooksForEntityDeletion(cur, removedComponents, archetype);
274274

275275
this.cleanupArchetypesReferencingEntity(cur);
276276
this.entityIdManager.deallocate(cur);

0 commit comments

Comments
 (0)