fix(ecs): scene unload kills entities that were already killed and recycled

Đang mở Phù hợp với người mới
#480 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
game-dev

Hướng nghiên cứu

Bắt đầu với modules/ecs/src/scene/ecs-scene.ts, đặc biệt là _track và vòng lặp dỡ tải ở các dòng 77–110. Theo dõi cách các entity được theo dõi được ghi nhận và cách killEntity cập nhật registry; issue đề xuất xóa các entity đã bị kill khỏi _entities và byId. Hoàn tất khi việc dỡ tải sau khi một entity bị kill và id của nó được dùng lại không kill entity mới, không hủy các component cũ hai lần và không thêm id chết trùng lặp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug modules:ecs
Which package is this bug report for?

ecs

Issue description

The tracked registry overrides spawnEntity, addComponent and addSystem, but not killEntity. If gameplay kills a scene entity and its id is reused by a later spawn, unloading the scene kills the new, unrelated owner of that id and calls destroy() on components that were already destroyed. It also pushes a duplicate dead id (see the double-kill issue).

Where:

Evidence:

for (const { entity, components } of this._entities.splice(0)) {
  ...destroy.call(component);
  registry.killEntity(entity);
}

Suggested fix: Override killEntity in _track so that it drops the entity from _entities / byId.

Found during a code audit of main at be72076.

Code sample

No response

Versions
  • Engine main at be72076
  • pnpm 12.0.0, Node.js 26, Bun 1.3.14
Issue priority

High (immediate attention needed)

I have tested this issue on a development release

be72076

Ngôn ngữ chính
TypeScript
Star
7
Fork
2
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NanoForge-dev/Engine

Tất cả issue của NanoForge-dev/Engine

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.