From 5634b49fee1176b0f2a3bffd55d7aaa04edcec60 Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 16 Mar 2026 09:10:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8A=80=E8=83=BD):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=9E=AC=E6=97=B6=E6=8A=80=E8=83=BD=E7=A2=B0=E6=92=9E=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=85=B3=E9=97=AD=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除基于 pendingClose 的延迟关闭逻辑,改为在攻击帧中立即调度关闭碰撞检测。 这避免了同一帧内对同一目标造成多次伤害的问题,并简化了时间类型技能的处理逻辑。 --- assets/script/game/skill/STimeComp.ts | 9 +-------- assets/script/game/skill/SkillView.ts | 13 +++++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/assets/script/game/skill/STimeComp.ts b/assets/script/game/skill/STimeComp.ts index 01d36249..356a568e 100644 --- a/assets/script/game/skill/STimeComp.ts +++ b/assets/script/game/skill/STimeComp.ts @@ -9,7 +9,6 @@ export class StimeDataComp extends ecs.Comp { elapsedTime: number = 0; hitInterval: number = 0; hitElapsed: number = 0; - pendingClose: boolean = false; reset() { this.s_uuid = 0; @@ -17,7 +16,6 @@ export class StimeDataComp extends ecs.Comp { this.elapsedTime = 0; this.hitInterval = 0; this.hitElapsed = 0; - this.pendingClose = false; } } @@ -35,10 +33,6 @@ export class STimeSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (!timeComp || !skillView) return; const conf = SkillSet[timeComp.s_uuid]; if (!conf || conf.EType !== EType.timeEnd) return; - if (timeComp.pendingClose) { - skillView.close_collider(); - timeComp.pendingClose = false; - } if (timeComp.totalTime <= 0) { skillView.close_collider(); entity.destroy(); @@ -46,10 +40,9 @@ export class STimeSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate } timeComp.elapsedTime += this.dt; timeComp.hitElapsed += this.dt; - if (timeComp.hitInterval > 0 && timeComp.hitElapsed >= timeComp.hitInterval && !timeComp.pendingClose) { + if (timeComp.hitInterval > 0 && timeComp.hitElapsed >= timeComp.hitInterval) { timeComp.hitElapsed -= timeComp.hitInterval; skillView.atk(null); - timeComp.pendingClose = true; } if (timeComp.elapsedTime >= timeComp.totalTime) { skillView.close_collider(); diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index 6e342272..80331197 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -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 ?? "未知目标";