fix(技能): 修复瞬时技能碰撞检测关闭时机
移除基于 pendingClose 的延迟关闭逻辑,改为在攻击帧中立即调度关闭碰撞检测。 这避免了同一帧内对同一目标造成多次伤害的问题,并简化了时间类型技能的处理逻辑。
This commit is contained in:
@@ -105,8 +105,12 @@ export class SkillView extends CCComp {
|
||||
this.attackFrameCount++;
|
||||
if (this.enable_collider_safely()) {
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`);
|
||||
this.scheduleOnce(() => {
|
||||
if (!this.node || !this.node.isValid || this.isDisposing) return;
|
||||
this.close_collider();
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧关闭碰撞检测`);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
}
|
||||
//伤害应用
|
||||
apply_damage(target:HeroViewComp,is_range:boolean=false){
|
||||
@@ -120,13 +124,6 @@ export class SkillView extends CCComp {
|
||||
this.close_collider()
|
||||
return
|
||||
}
|
||||
// 对于非持续碰撞类型的技能,在造成伤害后立即关闭碰撞检测
|
||||
// 这样可以避免同一帧内的重复伤害
|
||||
if(this.SConf.EType !== EType.collision && this.collider) {
|
||||
this.close_collider();
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf.name}] 伤害后关闭碰撞检测`);
|
||||
}
|
||||
|
||||
// 安全获取名称,防止实体销毁导致的空指针异常
|
||||
const casterName = this.sData.caster?.ent?.get(HeroAttrsComp)?.hero_name ?? "未知施法者";
|
||||
const targetName = target.ent.get(HeroAttrsComp)?.hero_name ?? "未知目标";
|
||||
|
||||
Reference in New Issue
Block a user