diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index 83fb0a59..4b6a46eb 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -74,6 +74,14 @@ export class SkillView extends CCComp { mLogger.log(this.debugMode, 'SkillView', `[skillView] 碰撞1 [${this.sData.caster.box_group}][${casterName}][${casterEid}]的[${seCol.group}]:[${this.SConf.name}][${this.ent.eid}]碰撞了 [${oCol.group}]:[ ${targetName}][${targetEid}]`); if (oCol.group === seCol.group) return; if (this.pendingDisableCollider) return; + if (this.sData.hit_count >= this.sData.max_hit_count) { + this.close_collider(); + return; + } + this.sData.hit_count++; + if (this.sData.hit_count >= this.sData.max_hit_count) { + this.close_collider(); + } // 不是 HeroViewComp,直接忽略 if (!targetView) return; // 🔥 方案A:防御性检查 - 在获取model前强制检查ent是否存在 @@ -116,11 +124,6 @@ export class SkillView extends CCComp { if (!target.ent) return; if (!this.sData) return; if (!this.SConf) return; - // 检查技能是否应该销毁 - if ( this.sData.hit_count >= this.sData.max_hit_count ) { - this.close_collider() - return - } // 安全获取名称,防止实体销毁导致的空指针异常 const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? "未知施法者"; const targetName = target.ent.get(HeroAttrsComp)?.hero_name ?? "未知目标"; @@ -135,12 +138,6 @@ export class SkillView extends CCComp { this.sData.ext_dmg, this.sData.dmg_ratio, ); - - // 更新技能命中次数 - this.sData.hit_count++ - if (this.sData.hit_count >= this.sData.max_hit_count) { - this.close_collider(); - } if ( (this.SConf.DTType != DTType.range) && (this.SConf.EType != EType.animationEnd) &&