fix(碰撞处理): 增加防御性检查并优化英雄死亡时的碰撞体处理

在SkillView中添加对目标实体是否存在的检查,避免访问已销毁实体
在HeroViewComp中死亡时禁用碰撞体,防止"尸体"参与后续碰撞
This commit is contained in:
walkpan
2026-01-02 15:08:30 +08:00
parent f3039eb47b
commit ed728bd1b9
2 changed files with 12 additions and 0 deletions

View File

@@ -375,6 +375,13 @@ export class HeroViewComp extends CCComp {
this.debugWarn("[HeroViewComp] realDead called but model is null, skipping");
return;
}
// 🔥 方案B治理性措施 - 在销毁实体前先禁用碰撞体,从源头减少"尸体"参与碰撞
const collider = this.getComponent(Collider2D);
if (collider) {
collider.enabled = false;
}
if(this.model.fac === FacSet.HERO){
// 英雄死亡:延迟触发死亡事件
oops.message.dispatchEvent(GameEvent.HeroDead, {