fix(hero): 调整英雄死亡事件处理顺序
修复英雄死亡事件处理顺序问题,将阵营判断提前以避免潜在逻辑错误。同时保持碰撞体禁用逻辑不变。
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a29f50fa-c2f5-4516-b108-ac1ae313c0c3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -415,18 +415,18 @@ export class HeroViewComp extends CCComp {
|
||||
this.debugWarn("[HeroViewComp] realDead called but model is null, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.model.fac === FacSet.HERO){
|
||||
// 英雄死亡:延迟触发死亡事件
|
||||
// 🔥 只有主角死亡才触发游戏结束判定
|
||||
if (this.model.is_master) return
|
||||
}
|
||||
// 🔥 方案B:治理性措施 - 在销毁实体前先禁用碰撞体,从源头减少"尸体"参与碰撞
|
||||
const collider = this.getComponent(Collider2D);
|
||||
if (collider) {
|
||||
collider.enabled = false;
|
||||
}
|
||||
|
||||
if(this.model.fac === FacSet.HERO){
|
||||
// 英雄死亡:延迟触发死亡事件
|
||||
// 🔥 只有主角死亡才触发游戏结束判定
|
||||
if (this.model.is_master) return
|
||||
}
|
||||
|
||||
// 根据阵营触发不同事件
|
||||
if(this.model.fac === FacSet.MON){
|
||||
oops.message.dispatchEvent(GameEvent.MonDead, {
|
||||
|
||||
Reference in New Issue
Block a user